-
Notifications
You must be signed in to change notification settings - Fork 0
/
diag.trajectory.drifters.locate.jl
38 lines (31 loc) · 1.16 KB
/
diag.trajectory.drifters.locate.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#=
= Identify and count the location of all observations in the input file,
= where locations are defined at the resolution of a grid (for subsequent
= collocation) - RD April 2016.
=#
using My
if (argc = length(ARGS)) != 1
print("\nUsage: jjj $(basename(@__FILE__)) buoydata_1993_2014_drogON.asc.nonmdt\n")
exit(1)
end
lats = collect( -79.875:0.25:79.875) # then define the collocation grid
lons = collect(-179.875:0.25:179.875) # and initialize the count
subs = Set(Array(Tuple{Int64, Int64}, 0))
numb = zeros(length(lons), length(lats))
fpa = My.ouvre(ARGS[1], "r")
fpb = My.ouvre(ARGS[1] * ".locate", "w")
for line in readlines(fpa) # identify and count the collocations
vals = split(line)
indlat = findin(lats, float(vals[2]))[1]
indlon = findin(lons, float(vals[3]))[1]
push!(subs, (indlat, indlon))
numb[indlon,indlat] += 1.0
end
for loc in subs
(indlat, indlon) = loc
line = @sprintf("%8.3f %8.3f %8.0f\n", lats[indlat], lons[indlon], numb[indlon,indlat])
write(fpb, line)
end
close(fpa)
close(fpb)
exit(0)