Skip to content

Commit dcecb43

Browse files
authored
Fix CoreBoxes and rework the funcurve() function. (#1872)
1 parent f51b213 commit dcecb43

13 files changed

Lines changed: 76 additions & 50 deletions

File tree

src/GMT.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,10 @@ export
179179

180180
add2PSfile, append2fig, isoutlier, linearfitxy, regiongeog, streamlines, peaks, polygonlevels, randinpolygon, polyfit, polyval,
181181

182-
ablines, ablines!, biplot, biplot!, density, density!, boxplot, boxplot!, cornerplot, cornerplot!, cubeplot, cubeplot!, ecdfplot, ecdfplot!,
183-
fill_between, fill_between!, marginalhist, marginalhist!, parallelplot, parallelplot!, piechart, piechart!, plotlinefit, plotlinefit!,
184-
qqplot, qqplot!, qqnorm, qqnorm!, remotegrid, sealand, squeeze, terramar, violin, violin!, viz, vizpdf, windbarbs, whereami,
182+
ablines, ablines!, biplot, biplot!, density, density!, boxplot, boxplot!, cornerplot, cornerplot!, cubeplot, cubeplot!,
183+
ecdfplot, ecdfplot!, fill_between, fill_between!, funcurve, marginalhist, marginalhist!, parallelplot, parallelplot!,
184+
piechart, piechart!, plotlinefit, plotlinefit!, qqplot, qqplot!, qqnorm, qqnorm!, remotegrid, sealand, squeeze, terramar,
185+
violin, violin!, viz, vizpdf, windbarbs, whereami,
185186

186187
maregrams, pastplates, seismicity, ecmwf, era5time, era5vars, listecmwfvars, meteostat, weather, wmsinfo, wmstest, wmsread,
187188

src/extras/anaglyph.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ function anaglyph(G::GMTgrid; vscale=1, sscale=2, view3d=false, zsize=4, azim=19
5454
m_scale = -vscale / 50 # Amp factor
5555

5656
function gra(G, scale)
57-
azim,elev = 0.0, 30.0
58-
s = [sind(azim) * cosd(elev); cosd(azim) * cosd(elev); sind(elev)]
57+
_azim,elev = 0.0, 30.0
58+
s = [sind(_azim) * cosd(elev); cosd(_azim) * cosd(elev); sind(elev)]
5959
data = zeros(Float32, size(G))
6060
@inbounds Threads.@threads for c = 2:size(G,1)-1
6161
@inbounds for r = 2:size(G,2)-1

src/extras/weather.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ function ecmwf_fc(; filename="", levlist="", kw...)
319319
function which_name(d::Dict, thisvar::String, name::String, filename::AbstractString, EXT::String)::String
320320
# Select which name to use for saving the file. NAME is the composed (long) name. The others are user choices.
321321
(filename != "") && return filename # This one takes priority
322-
fname_prefix::String = ((val = find_in_dict(d, [:prefix], false)[1]) !== nothing) ? string(val)::String * "_$(thisvar)$(EXT)" : ""
322+
fname_prefix::String = ((_val = find_in_dict(d, [:prefix], false)[1]) !== nothing) ? string(_val)::String * "_$(thisvar)$(EXT)" : ""
323323
return (fname_prefix != "") ? fname_prefix : name # 'fname_prefix' takes priority if exists.
324324
end
325325

src/filter1d.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ function filter1d_helper(cmd0::String, arg1; kwargs...)
6767
r = common_grd(d, cmd0, cmd, "filter1d ", arg1) # Finish build cmd and run it
6868
if (isa(arg1, GDtype)) # Keep the attribs if they existed in arg1
6969
isa(arg1, GMTdataset) && !isempty(arg1.attrib) && (r.attrib = arg1.attrib)
70-
isa(arg1, Vector) && !isempty(arg1[1].attrib) && [r[k].attrib = arg1[1].attrib for k = 1:length(arg1)]
70+
if (isa(arg1, Vector) && !isempty(arg1[1].attrib))
71+
for k = 1:length(arg1) r[k].attrib = arg1[1].attrib end
72+
end
7173
end
7274
return r
7375
end

src/gadm.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ function gadm(country, subregions...; children::Bool=false, names::Bool=false, c
7979

8080
function _getlayer(plevel)
8181
# Get layer of the desired `level` from the `data`.
82-
nlayers = Gdal.nlayer(data)
83-
for l = 0:nlayers - 1
82+
_nlayers = Gdal.nlayer(data)
83+
for l = 0:_nlayers - 1
8484
layer = Gdal.getlayer(data, l)
8585
lname = Gdal.getname(layer)
8686
llevel = last(split(lname, "_"))
8787
string(plevel) == llevel && return layer, lname
8888
end
89-
error("Asked data for a level ($(plevel+1)) that is lower than lowest data level ($(nlayers))")
89+
error("Asked data for a level ($(plevel+1)) that is lower than lowest data level ($(_nlayers))")
9090
end
9191

9292
function _get_attrib(feature)

src/linefit.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ function _plotlinefit(D::GMTdataset, first::Bool, grp::Bool, d::Dict{Symbol,Any}
227227

228228
function do_ribs(d, symbs, def_color::String)
229229
do_rib, rib_cor = false, ""
230-
if ((val = find_in_dict(d, symbs)[1]) !== nothing) # Either 'true' or ribbon color
231-
rib_cor = (val == 1) ? def_color : string(val)::String
230+
if ((_val = find_in_dict(d, symbs)[1]) !== nothing) # Either 'true' or ribbon color
231+
rib_cor = (_val == 1) ? def_color : string(_val)::String
232232
do_rib = (rib_cor != "")
233233
end
234234
return do_rib, rib_cor

src/maregrams.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ function maregrams(; list=false, code="", name="", days=2, starttime::String="",
7171
(n_lines <= 0) && (println("This station has no data or a file tranfer error occured."); return GMTdataset())
7272

7373
mat = Matrix{Float64}(undef, n_lines, 2)
74-
n = -2
7574
var_in_mareg = ["prs(m)"]
7675
open(file, "r") do io
76+
n = -2
77+
local ind
7778
for line in eachline(io)
7879
if ((n += 1) <= 0) # To jump the first two (header) lines
7980
(n == -1) && continue # Header line with station name
@@ -123,14 +124,18 @@ function read_maregrams(fname=TESTSDIR * "/assets/maregs_online.csv")
123124
names = Vector{String}(undef, 378)
124125
codes = Vector{String}(undef, 378)
125126
countries = Vector{String}(undef, 378)
126-
n = -1
127+
#fid = open(fname)
128+
#iter = eachline(fid)
129+
#for line in iter
127130
open(fname, "r") do io
131+
n = -1
128132
for line in eachline(io)
129133
x, y, name, code, country = split(line, ",")
130134
((n += 1) == 0) && continue # The header line
131135
mat[n, 1], mat[n, 2] = parse(Float64, x), parse(Float64, y)
132136
names[n], codes[n], countries[n] = name, code, country
133137
end
134138
end
139+
#close(fid)
135140
Dict(:pos => mat, :name => names, :code => codes, :country => countries)
136141
end

src/potential/gravprisms.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ function gravprisms(cmd0::String="", arg1::GDtype=GMTdataset(); kwargs...)
6464
d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
6565

6666
function fish_grids(d, Gs, cmd, symbs, opt, N)
67-
if ((val = find_in_dict(d, symbs)[1]) !== nothing)
68-
if (isa(val, Real) || isa(val, String))
69-
cmd *= string(" -", opt, val)::String
67+
if ((_val = find_in_dict(d, symbs)[1]) !== nothing)
68+
if (isa(_val, Real) || isa(_val, String))
69+
cmd *= string(" -", opt, _val)::String
7070
else
71-
isa(val, GMTgrid) ? (Gs[N+=1] = val; cmd *= " -D") : error("Invalid type $(typeof(val)) for option $opt")
71+
isa(_val, GMTgrid) ? (Gs[N+=1] = _val; cmd *= " -D") : error("Invalid type $(typeof(_val)) for option $opt")
7272
end
7373
end
7474
return cmd, N

src/proj_utils.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,12 @@ function invgeod(lonlat1::Matrix{<:Real}, lonlat2::Matrix{<:Real}; proj::String=
167167
az2 += 180; (az2 > 180) && (az2 -= 360)
168168
else
169169
az1 .+= 180; az2 .+= 180
170-
[(az1[k] > 180) && (az1[k] -= 360) for k = 1:lastindex(az1)]
171-
[(az2[k] > 180) && (az2[k] -= 360) for k = 1:lastindex(az2)]
170+
@inbounds for k = 1:lastindex(az1)
171+
(az1[k] > 180) && (az1[k] -= 360)
172+
end
173+
@inbounds for k = 1:lastindex(az2)
174+
(az2[k] > 180) && (az2[k] -= 360)
175+
end
172176
end
173177
end
174178
return size(d,1) == 1 ? (d[1], az1[1], az2[1]) : (d, az1, az2)
@@ -493,8 +497,8 @@ function geodesic_long(lonlat1::VMr, lonlat2::VMr; step=0.0, np=180, proj::Strin
493497
(step != 0) && (np = round(Int, dtot / step) + 1) # Takes precedence over 'np' because that one has a default value.
494498

495499
function get_mindist(az)
496-
D = geod(lonlat1, az, linspace(0,dtot,360), proj=proj, epsg=epsg)[1]
497-
gmtwrite(_name, D);
500+
_D = geod(lonlat1, az, linspace(0,dtot,360), proj=proj, epsg=epsg)[1]
501+
gmtwrite(_name, _D);
498502
gmt("mapproject -L$_name", [lonlat2[1] lonlat2[2]]) # Find closest point to B in the passing by geodesic.
499503
end
500504

src/psxy.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ function parse_opt_S(d::Dict, arg1, is3D::Bool=false)
946946
elseif (isa(val, Tuple) && isa(val[1], Function) && isa(val[2], VMr)) # ~useless size=(fun, [2,20]) but no col size
947947
val2::Tuple = val
948948
sc = _scale(eltype(val2[2]) <: Integer)
949-
arg1 = hcat(arg1, funcurve(val2[1], vec(Float64.(val2[2] .* sc)), size(arg1,1)))
949+
arg1 = hcat(arg1, funcurve(val2[1], vec(Float64.(val2[2] .* sc)), size(arg1,1))[2])
950950
end
951951
elseif (string(val)::String != "indata") # WTF is "indata"?
952952
marca *= arg2str(val)::String

0 commit comments

Comments
 (0)