From f127dab1feb4a041572b8cc3a62f825f3e28c352 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Mon, 30 Dec 2024 01:39:21 +0000 Subject: [PATCH] Revert many of the args to kwargs move. Shit happened under the hood. (#1624) --- src/common_options.jl | 58 +++++++++++++++++++++---------------------- src/drawing.jl | 2 +- src/geodesy/psvelo.jl | 2 +- src/gmtbegin.jl | 2 +- src/grdcontour.jl | 2 +- src/grdimage.jl | 2 +- src/grdvector.jl | 2 +- src/grdview.jl | 2 +- src/gridit.jl | 2 +- src/imshow.jl | 2 +- src/plot.jl | 2 +- src/psbasemap.jl | 2 +- src/psclip.jl | 2 +- src/pscontour.jl | 2 +- src/pshistogram.jl | 2 +- src/psimage.jl | 2 +- src/pslegend.jl | 2 +- src/psmask.jl | 16 ++++-------- src/psrose.jl | 2 +- src/psscale.jl | 2 +- src/pssolar.jl | 2 +- src/pstext.jl | 2 +- src/pswiggle.jl | 2 +- src/psxy.jl | 2 +- src/seis/psmeca.jl | 4 +-- src/subplot.jl | 2 +- test/test_PSs.jl | 2 +- 27 files changed, 60 insertions(+), 66 deletions(-) diff --git a/src/common_options.jl b/src/common_options.jl index 02fb136851..6faaa94e40 100644 --- a/src/common_options.jl +++ b/src/common_options.jl @@ -151,7 +151,7 @@ function leave_paper_mode() end # --------------------------------------------------------------------------------------------------- -parse_RIr(d::Dict, cmd::String, O::Bool=false; del::Bool=true) = parse_R(d, cmd, O=O, del=del, RIr=true) +parse_RIr(d::Dict, cmd::String, O::Bool=false, del::Bool=true) = parse_R(d, cmd, O=O, del=del, RIr=true) function parse_R(d::Dict, cmd::String; O::Bool=false, del::Bool=true, RIr::Bool=false, noGlobalR::Bool=false)::Tuple{String, String} # Build the option -R string. Make it simply -R if overlay mode (-O) and no new -R is fished here # The RIr option is to assign also the -I and -r when R was given a GMTgrid|image value. This is a @@ -163,7 +163,7 @@ function parse_R(d::Dict, cmd::String; O::Bool=false, del::Bool=true, RIr::Bool= val, symb = find_in_dict(d, [:R :region :limits :region_llur :limits_llur :limits_diag :region_diag], del) (val === nothing && IamModern[1] && !RIr) && return cmd, "" - opt_R = build_opt_R(val, symb=symb) + opt_R = build_opt_R(val, symb) opt_R = merge_R_and_xyzlims(d, opt_R) # Let a -R be partially changed by the use of optional xyzlim @@ -272,8 +272,8 @@ function merge_R_and_xyzlims(d::Dict, opt_R::String)::String end # --------------------------------------------------------------------------------------------------- -build_opt_R(val::Symbol; symb::Symbol=Symbol())::String = build_opt_R(string(val), symb=symb) -function build_opt_R(r::String; symb::Symbol=Symbol())::String +build_opt_R(val::Symbol, symb::Symbol=Symbol())::String = build_opt_R(string(val), symb) +function build_opt_R(r::String, symb::Symbol=Symbol())::String if (r == "global") R = " -Rd" elseif (r == "global360") R = " -Rg" elseif (r == "same") R = " -R" @@ -282,7 +282,7 @@ function build_opt_R(r::String; symb::Symbol=Symbol())::String R end -function build_opt_R(val; symb::Symbol=Symbol())::String # Generic function that deals with all but NamedTuple args +function build_opt_R(val, symb::Symbol=Symbol())::String # Generic function that deals with all but NamedTuple args R::String = "" if ((isvector(val) || isa(val, Tuple)) && (length(val) == 4 || length(val) == 6)) if (symb ∈ (:region_llur, :limits_llur, :limits_diag, :region_diag)) @@ -303,7 +303,7 @@ function build_opt_R(val; symb::Symbol=Symbol())::String # Generic function tha end # --------------------------------------------------------------------------------------------------- -function build_opt_R(arg::NamedTuple; symb::Symbol=Symbol())::String +function build_opt_R(arg::NamedTuple, symb::Symbol=Symbol())::String # Option -R can also be diabolicly complicated. Try to addres it. Stil misses the Time part. BB::String = "" d = nt2dict(arg) # Convert to Dict @@ -403,7 +403,7 @@ function opt_R2num(opt_R::String)::Vector{Float64} end # --------------------------------------------------------------------------------------------------- -function parse_JZ(d::Dict, cmd::String; del::Bool=true, O::Bool=false, is3D::Bool=false)::Tuple{String,String} +function parse_JZ(d::Dict, cmd::String, del::Bool=true; O::Bool=false, is3D::Bool=false)::Tuple{String,String} symbs = [:JZ :Jz :zsize :zscale] (SHOW_KWARGS[1]) && return (print_kwarg_opts(symbs, "String | Number"), "") opt_J::String = ""; seek_JZ = true @@ -498,7 +498,7 @@ function parse_J(d::Dict, cmd::String; default::String="", map::Bool=true, O::Bo end (opt_J == "") && (opt_J = " -JX") # If only the projection but no size, try to get it from the kwargs. - if ((s = helper_append_figsize(d, opt_J, O, del=del)) != "") # Takes care of both fig scales and fig sizes + if ((s = helper_append_figsize(d, opt_J, O, del)) != "") # Takes care of both fig scales and fig sizes opt_J = s elseif (default != "" && opt_J == " -JX") opt_J = IamSubplot[1] ? " -JX?" : (default != "guess" ? default : opt_J) # -JX was a working default @@ -521,7 +521,7 @@ function parse_J(d::Dict, cmd::String; default::String="", map::Bool=true, O::Bo end end else # For when a new size is entered in a middle of a script - if ((s = helper_append_figsize(d, opt_J, O, del=del)) != "") + if ((s = helper_append_figsize(d, opt_J, O, del)) != "") if (opt_J == " -J") (CTRL.pocket_J[1] != s) && # Composed funs (ex: fill_between) would trigger this warning println("SEVERE WARNING: When appending a new fig with a different size you SHOULD set the `projection`. \n\tAdding `projection=:linear` at your own risk."); @@ -588,7 +588,7 @@ function fish_size_from_J(opt_J; onlylinear::Bool=true, opt_R::String="") return nothing end -function get_figsize(; opt_R::String="", opt_J::String="") +function get_figsize(opt_R::String="", opt_J::String="") # Compute the current fig dimensions in paper coords using the know -R -J (opt_R == "" || opt_R == " -R") && (opt_R = CTRL.pocket_R[1]) (opt_J == "" || opt_J == " -J") && (opt_J = CTRL.pocket_J[1]) @@ -597,7 +597,7 @@ function get_figsize(; opt_R::String="", opt_J::String="") return Dwh[1], Dwh[2] # Width, Height end -function helper_append_figsize(d::Dict, opt_J::String, O::Bool; del::Bool=true)::String +function helper_append_figsize(d::Dict, opt_J::String, O::Bool, del::Bool=true)::String val_, symb = find_in_dict(d, [:figscale :fig_scale :scale :figsize :fig_size], del) (val_ === nothing && is_in_dict(d, [:flipaxes :flip_axes]) === nothing) && return "" val::String = arg2str(val_) @@ -609,18 +609,18 @@ function helper_append_figsize(d::Dict, opt_J::String, O::Bool; del::Bool=true): if (opt_J == " -JX") val = check_flipaxes(d, val) opt_J::String = isletter(val[1]) ? " -J" * val : " -Jx" * val # FRAGILE - else opt_J = append_figsize(d, opt_J, width=val, scale=true) + else opt_J = append_figsize(d, opt_J, val, true) end else # A fig SIZE request (haskey(d, :units)) && (val *= d[:units][1]::String) if (occursin("+proj", opt_J)) opt_J *= "+width=" * val - else opt_J = append_figsize(d, opt_J, width=val) + else opt_J = append_figsize(d, opt_J, val) end end return opt_J end -function append_figsize(d::Dict, opt_J::String; width::String="", scale::Bool=false)::String +function append_figsize(d::Dict, opt_J::String, width::String="", scale::Bool=false)::String # Appending either a fig width or fig scale depending on what projection. # Sometimes we need to separate with a '/' others not. If WIDTH == "" we # use the DEF_FIG_SIZE, otherwise use WIDTH that can be a size or a scale. @@ -697,7 +697,7 @@ end # ---------------------------------------------------------------------------------------------------- """ - w, h = plot_GI_size(GI; proj="", region="") + w, h = plot_GI_size(GI, proj="", region="") Compute the plot width and height in cm given the the region `region` and projection `proj`. Note that here the `region` and `proj` options, if provided, must be the full " -R...." and " -J..." strings and @@ -707,7 +707,7 @@ value is not particularly important because the main idea here is to be able to Returns a tuple of Float64 with the width, height in cm. """ -function plot_GI_size(GI::GItype; opt_J="", opt_R="") +function plot_GI_size(GI::GItype, opt_J="", opt_R="") got_J = (opt_J != "") (opt_R == "") && (opt_R = @sprintf(" -R%.10g/%.10g/%.10g/%.10g", GI.range[1:4]...)) (opt_J == "") && (opt_J = (GI.geog > 0) ? guess_proj(GI.range[1:2], GI.range[3:4]) : " -JX") @@ -1309,11 +1309,11 @@ end # --------------------------------------------------------------------------------------------------- title(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset) -subtitle(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset, tipo="s") -xlabel(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset, tipo="x") -ylabel(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset, tipo="y") -zlabel(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset, tipo="z") -function titles_e_comp(str::AbstractString, fnt, offset; tipo::String="")::Tuple{String, String} +subtitle(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset, "s") +xlabel(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset, "x") +ylabel(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset, "y") +zlabel(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset, "z") +function titles_e_comp(str::AbstractString, fnt, offset, tipo::String="")::Tuple{String, String} f::String = (fnt !== nothing) ? font(fnt) : "" o::String = (offset != 0) ? string(offset) : "" (str == "") && return str, "" @@ -1371,7 +1371,7 @@ function guess_WESN(d::Dict, cmd::String)::String end # --------------------------------------------------------------------------------------------------- -function parse_BJR(d::Dict, cmd::String, caller::String, O::Bool; defaultJ::String="", del::Bool=true) +function parse_BJR(d::Dict, cmd::String, caller::String, O::Bool, defaultJ::String="", del::Bool=true) # Join these three in one function. CALLER is non-empty when module is called by plot() cmd, opt_R = parse_R(d, cmd, O=O, del=del) cmd, opt_J = parse_J(d, cmd, default=defaultJ, map=true, O=O, del=del) @@ -1511,16 +1511,16 @@ function parse_c(d::Dict, cmd::String)::Tuple{String, String} end # --------------------------------------------------------------------------------------------------- -function parse_d(d::Dict, cmd::String; symbs::VMs=[:d :nodata]) +function parse_d(d::Dict, cmd::String, symbs::VMs=[:d :nodata]) (SHOW_KWARGS[1]) && return (print_kwarg_opts(symbs, "$(symbs[2])=val"),"") parse_helper(cmd, d, [:d :nodata], " -d") end -parse_di(d::Dict, cmd::String) = parse_d(d, cmd, symbs=[:di :nodata_in]) -parse_do(d::Dict, cmd::String) = parse_d(d, cmd, symbs=[:do :nodata_out]) +parse_di(d::Dict, cmd::String) = parse_d(d, cmd, [:di :nodata_in]) +parse_do(d::Dict, cmd::String) = parse_d(d, cmd, [:do :nodata_out]) parse_e(d::Dict, cmd::String) = parse_helper(cmd, d, [:e :pattern :find], " -e") parse_g(d::Dict, cmd::String) = parse_helper(cmd, d, [:g :gap], " -g") parse_h(d::Dict, cmd::String) = parse_helper(cmd, d, [:h :header], " -h") -parse_i(d::Dict, cmd::String) = parse_helper(cmd, d, [:i :incols :incol], " -i", sep=',') +parse_i(d::Dict, cmd::String) = parse_helper(cmd, d, [:i :incols :incol], " -i", ',') parse_j(d::Dict, cmd::String) = parse_helper(cmd, d, [:j :metric :spherical :spherical_dist], " -j") # --------------------------------------------------------------------------------- @@ -1565,7 +1565,7 @@ function parse_n(d::Dict, cmd::String, gmtcompat::Bool=false) end # --------------------------------------------------------------------------------- -parse_o(d::Dict, cmd::String) = parse_helper(cmd, d, [:o :outcols :outcol], " -o", sep=',') +parse_o(d::Dict, cmd::String) = parse_helper(cmd, d, [:o :outcols :outcol], " -o", ',') parse_p(d::Dict, cmd::String) = parse_helper(cmd, d, [:p :view :perspective], " -p") # --------------------------------------------------------------------------------- @@ -1650,7 +1650,7 @@ function parse_append(d::Dict, cmd::String)::String end # --------------------------------------------------------------------------------------------------- -function parse_helper(cmd::String, d::Dict, symbs::VMs, opt::String; sep='/')::Tuple{String, String} +function parse_helper(cmd::String, d::Dict, symbs::VMs, opt::String, sep='/')::Tuple{String, String} # Helper function to the parse_?() global options. (SHOW_KWARGS[1]) && return (print_kwarg_opts(symbs, "(Common option not yet expanded)"),"") opt_val::String = "" @@ -1759,7 +1759,7 @@ end parse_G(d::Dict, cmd::String) = parse_helper(cmd, d, [:G :save :write :outgrid :outfile], " -G") # --------------------------------------------------------------------------------------------------- -function parse_I(d::Dict, cmd::String, symbs, opt::String, del::Bool)::String +function parse_I(d::Dict, cmd::String, symbs, opt::String, del::Bool=true)::String # Parse the quasi-global -I option. But arguments can be strings, arrays, tuples or NamedTuples # At the end we must recreate this syntax: xinc[unit][+e|n][/yinc[unit][+e|n]] or get_that_string(arg)::String = string(arg)::String # Function barrier. Shuting up JET, etc. diff --git a/src/drawing.jl b/src/drawing.jl index fe8e9563a6..fe0116dc05 100644 --- a/src/drawing.jl +++ b/src/drawing.jl @@ -97,7 +97,7 @@ function helper_shapes(x, y, cmd; Vd=0, kw...) end CTRLshapes.points[1] = true else - _cmd, opt_B, opt_J, opt_R = GMT.parse_BJR(d, "", "", false, defaultJ=" ") + _cmd, opt_B, opt_J, opt_R = GMT.parse_BJR(d, "", "", false, " ") (opt_R == "") && (opt_R = " -R0/21/0/29") (opt_J == " ") && (opt_J = " -Jx1") end diff --git a/src/geodesy/psvelo.jl b/src/geodesy/psvelo.jl index 91a23912d9..36c2f3c42c 100644 --- a/src/geodesy/psvelo.jl +++ b/src/geodesy/psvelo.jl @@ -15,7 +15,7 @@ function velo(cmd0::String="", arg1=nothing; first=true, kwargs...) d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode - cmd, _, _, opt_R = parse_BJR(d, "", "", O, defaultJ=" -JX12cd/0d") + cmd, _, _, opt_R = parse_BJR(d, "", "", O, " -JX12cd/0d") cmd, = parse_common_opts(d, cmd, [:UVXY :di :e :p :t :params]; first=first) if ((val = find_in_dict(d, [:A :arrow])[1]) !== nothing) diff --git a/src/gmtbegin.jl b/src/gmtbegin.jl index b3b7ac56cf..2b46236ed6 100644 --- a/src/gmtbegin.jl +++ b/src/gmtbegin.jl @@ -226,7 +226,7 @@ function helper1_inset_nested(d; iscoast=false, isplot=false, imgdims=tuple()) # All inset_nested methods start with this. Also sets some defaults. fig_opt_R, fig_opt_J = CTRL.pocket_R[1], CTRL.pocket_J[1] # Main fig region and proj. Need these to cheat the modern session bak = CTRL.limits[7:end] # Backup these because parse_R will change them - _, opt_B::String, opt_J::String, opt_R::String = parse_BJR(d, "", "", false, defaultJ=" ") + _, opt_B::String, opt_J::String, opt_R::String = parse_BJR(d, "", "", false, " ") CTRL.limits[7:end] = bak # and we don't want that change to be stored islinear = (opt_J == "" || opt_J[4] == 'X' || opt_J[4] == 'x'); fname = hack_modern_session(fig_opt_R, fig_opt_J) # Start a modern session and return the full name of the gmt_0.ps- file diff --git a/src/grdcontour.jl b/src/grdcontour.jl index 157832cdd8..84e7245b75 100644 --- a/src/grdcontour.jl +++ b/src/grdcontour.jl @@ -77,7 +77,7 @@ function _grdcontour_helper(cmd0::String, arg1, O::Bool, K::Bool, d::Dict) arg2, arg3 = nothing, nothing dict_auto_add!(d) # The ternary module may send options via another channel - cmd::String, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, defaultJ=" -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") + cmd::String, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, " -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") cmd, = parse_common_opts(d, cmd, [:UVXY :margin :params :bo :c :e :f :h :p :t]; first=!O) cmd = parse_these_opts(cmd, d, [[:D :dump], [:F :force], [:L :range], [:Q :cut], [:S :smooth]]) cmd = parse_contour_AGTW(d::Dict, cmd::String)[1] diff --git a/src/grdimage.jl b/src/grdimage.jl index d0fb952af8..47aefe31ac 100644 --- a/src/grdimage.jl +++ b/src/grdimage.jl @@ -71,7 +71,7 @@ function _grdimage(cmd0::String, arg1, arg2, arg3, O::Bool, K::Bool, d::Dict) has_opt_B = (is_in_dict(d, [:B :frame :axis :axes]) !== nothing) (is_in_dict(d, [:A :img_out :image_out]) !== nothing) && (d[:B] = "none") # When -A is used, -B is forbiden - cmd::String, opt_B::String, opt_J::String, opt_R::String = parse_BJR(d, "", "", O, defaultJ=" -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") + cmd::String, opt_B::String, opt_J::String, opt_R::String = parse_BJR(d, "", "", O, " -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") (startswith(opt_J, " -JX") && !contains(opt_J, "/")) && (cmd = replace(cmd, opt_J => opt_J * "/0")) # When sub-regions (!has_opt_B && isa(arg1, GMTimage) && (isimgsize(arg1) || CTRL.limits[1:4] == zeros(4)) && opt_B == DEF_FIG_AXES_BAK) && (cmd = replace(cmd, opt_B => "")) # Dont plot axes for plain images if that was not required diff --git a/src/grdvector.jl b/src/grdvector.jl index b26ad4166b..ff74ef3082 100644 --- a/src/grdvector.jl +++ b/src/grdvector.jl @@ -79,7 +79,7 @@ function grdvector(arg1, arg2; first=true, kwargs...) (inverse=("i", nothing, 1), length=("l", arg2str, 1), scale=("",arg2str,2), scale_at_lat="+c", refsize="+s")) opt_R = (contains(cmd, "-R") && !contains(cmd, " -R ")) ? "" : @sprintf(" -R%.4g/%.14g/%.14g/%.14g", info[1:4]...) - w,h = get_figsize(opt_R=opt_R, opt_J=opt_J) + w,h = get_figsize(opt_R, opt_J) max_extrema = max(abs(info[5]), abs(info[6]), abs(info2[5]), abs(info2[6])) # The max of the absolute extremas as = 1.05 * max_extrema * sqrt((n_rows*n_cols) / (w*h)) # Autoscale (approx). Idealy it should be max magnitude. diff --git a/src/grdview.jl b/src/grdview.jl index de6a5ba296..c7b782f3af 100644 --- a/src/grdview.jl +++ b/src/grdview.jl @@ -66,7 +66,7 @@ function grdview_helper(cmd0::String, arg1, O::Bool, K::Bool, d::Dict) common_insert_R!(d, O, cmd0, arg1; is3D=true) # Set -R in 'd' out of grid/images (with coords) if limits was not used have_opt_B = (find_in_dict(d, [:B :frame :axis :axes], false)[1] !== nothing) - cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "grdview", O, defaultJ=" -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") + cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "grdview", O, " -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") (startswith(opt_J, " -JX") && !contains(opt_J, "/")) && (cmd = replace(cmd, opt_J => opt_J * "/0")) # When sub-regions (!have_opt_B && isa(arg1, GMTimage) && (isimgsize(arg1) || CTRL.limits[1:4] == zeros(4)) && opt_B == DEF_FIG_AXES_BAK) && (cmd = replace(cmd, opt_B => "")) # Dont plot axes for plain images if that was not required diff --git a/src/gridit.jl b/src/gridit.jl index fb0d4dacec..52df910b7b 100644 --- a/src/gridit.jl +++ b/src/gridit.jl @@ -94,7 +94,7 @@ gridit(arg1::MatGDsGd; method::StrSymb="surface", proj="", epsg=0, kw...) = function seek_auto_RI(d::Dict{Symbol,Any}, fname::String, arg1::Union{Nothing, MatGDsGd}) # Check if -R -I was provided and if not make a wild guess of them. IamModern[1] && return d # No sniffs in modern - opt_RI, opt_R = parse_RIr(d, "", false, del=false) + opt_RI, opt_R = parse_RIr(d, "", false, false) opt_I = (opt_RI != opt_R) ? split(opt_RI)[1] : "" # opt_RI has -I first than -R have_R, have_I = (opt_R != ""), (opt_RI != opt_R) diff --git a/src/imshow.jl b/src/imshow.jl index 22659af579..ce6f9b3ac8 100644 --- a/src/imshow.jl +++ b/src/imshow.jl @@ -152,7 +152,7 @@ function imshow(arg1::GItype; kw...) (arg1.geog > 0 && is_in_dict(d, [:J :proj :projection]) === nothing) && (d[:J] = "guess") opt_J = parse_J(d, "", default="", map=true, O=false, del=false)[2] (startswith(opt_J, " -JX") && !contains(opt_J, '/')) && (opt_J *= "/0") # We always want axis equal - w, h = plot_GI_size(arg1, opt_J=opt_J) # Compute the plot Width,Height given the arg1 limits and proj + w, h = plot_GI_size(arg1, opt_J) # Compute the plot Width,Height given the arg1 limits and proj aspect = h / w _w = 15 / nc; _h = _w * aspect diff --git a/src/plot.jl b/src/plot.jl index 9bbefefab3..0289d8357d 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -991,7 +991,7 @@ function arrows(cmd0::String="", arg1=nothing; first=true, kwargs...) # TYPEVEC = 0, ==> u,v = theta,rho. TYPEVEC = 1, ==> u,v = u,v. TYPEVEC = 2, ==> u,v = x2,y2 typevec = (find_in_dict(d, [:uv])[1] !== nothing) ? 1 : (find_in_dict(d, [:endpt :endpoint])[1] !== nothing) ? 2 : 0 d, arg1 = helper_vecBug(d, arg1, first, haveR, haveVarFill, typevec) # Deal with GMT nasty bug - _common_plot_xyz(cmd0, mat2ds(arg1), "", first==1, true, false, d) + common_plot_xyz(cmd0, mat2ds(arg1), "", first, false; d...) end arrows!(cmd0::String="", arg1=nothing; kw...) = arrows(cmd0, arg1; first=false, kw...) diff --git a/src/psbasemap.jl b/src/psbasemap.jl index ad79359081..059466fb4c 100644 --- a/src/psbasemap.jl +++ b/src/psbasemap.jl @@ -50,7 +50,7 @@ function basemap(; first=true, kwargs...) d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode - cmd, = parse_BJR(d, "", "", O, defaultJ=" -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") + cmd, = parse_BJR(d, "", "", O, " -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") cmd, = parse_JZ(d, cmd) cmd, = parse_common_opts(d, cmd, [:F :UVXY :bo :c :f :p :t :params :margin]; first=first) cmd = parse_these_opts(cmd, d, [[:A :polygon]]) diff --git a/src/psclip.jl b/src/psclip.jl index 55f780f23f..7835c3c678 100644 --- a/src/psclip.jl +++ b/src/psclip.jl @@ -41,7 +41,7 @@ function clip_helper(cmd0::String, arg1; first=true, kwargs...) d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode - cmd, _, _, opt_R = parse_BJR(d, "", "", O, defaultJ=" -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") + cmd, _, _, opt_R = parse_BJR(d, "", "", O, " -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") cmd, = parse_common_opts(d, cmd, [:UVXY :JZ :c :e :f :g :p :t :yx :params]; first=first) cmd = parse_these_opts(cmd, d, [[:A :steps :straightlines], [:C :endclip], [:N :invert], [:T :clipregion :clip_limits]]) cmd *= add_opt_pen(d, [:W :pen], opt="W") diff --git a/src/pscontour.jl b/src/pscontour.jl index a5154f8ce7..9b8b109f9a 100644 --- a/src/pscontour.jl +++ b/src/pscontour.jl @@ -85,7 +85,7 @@ function contour_helper(cmd0::String, arg1; first=true, kwargs...) d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode dict_auto_add!(d) # The ternary module may send options via another channel - cmd, _, _, opt_R = parse_BJR(d, "", "", O, defaultJ=" -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") + cmd, _, _, opt_R = parse_BJR(d, "", "", O, " -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") cmd, = parse_common_opts(d, cmd, [:UVXY :bo :c :d :do :e :p :t :params :margin]; first=first) cmd = parse_these_opts(cmd, d, [[:D :dump], [:I :fill :colorize], [:N :no_clip], [:Q :cut], [:S :skip]]) cmd *= add_opt_pen(d, [:L :mesh], opt="L") diff --git a/src/pshistogram.jl b/src/pshistogram.jl index 7cfd28289b..f2e28b233b 100644 --- a/src/pshistogram.jl +++ b/src/pshistogram.jl @@ -113,7 +113,7 @@ function histogram_helper(cmd0::String, arg1; first=true, kwargs...) return gmt(gmt_proggy * cmd, arg1) end - cmd, opt_B, opt_J, opt_R ::String= parse_BJR(d, cmd, "histogram", O, defaultJ=" -JX14c/14c") + cmd, opt_B, opt_J, opt_R ::String= parse_BJR(d, cmd, "histogram", O, " -JX14c/14c") cmd = parse_JZ(d, cmd)[1] cmd = parse_common_opts(d, cmd, [:UVXY :JZ :c :e :f :p :t :w :params :margin]; first=first)[1] cmd = parse_these_opts(cmd, d, [[:A :horizontal], [:F :center], [:Q :cumulative], [:S :stairs]]) diff --git a/src/psimage.jl b/src/psimage.jl index 3eb7c31547..903e1af7b2 100644 --- a/src/psimage.jl +++ b/src/psimage.jl @@ -49,7 +49,7 @@ function image_helper(cmd0::String, arg1; first=true, kwargs...) d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode - cmd = parse_BJR(d, "", "", O, defaultJ=" -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0")[1] + cmd = parse_BJR(d, "", "", O, " -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0")[1] cmd = parse_common_opts(d, cmd, [:F :UVXY :JZ :c :p :t :params :margin]; first=first)[1] cmd = parse_these_opts(cmd, d, [[:I :invert], [:M :monochrome]]) ((val = find_in_dict(d, [:G :bitcolor :bit_color])[1]) !== nothing && isa(val, String)) && (cmd *= string(" -G", val)) diff --git a/src/pslegend.jl b/src/pslegend.jl index f5e5aa5473..f1b612aa19 100644 --- a/src/pslegend.jl +++ b/src/pslegend.jl @@ -71,7 +71,7 @@ function legend(cmd0::String="", arg1=nothing; first::Bool=true, kwargs...) end def_J = " -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0" - cmd, _, _, opt_R = parse_BJR(d, "", "", O, defaultJ=def_J) + cmd, _, _, opt_R = parse_BJR(d, "", "", O, def_J) cmd, arg1, opt_R, = read_data(d, cmd0, cmd, arg1, opt_R) # If called from classic without input it hangs here. # Trouble here is that 'legend' may be called from modern mode (inside gmtbegin()), case in which so far we want to diff --git a/src/psmask.jl b/src/psmask.jl index 98e0b5e1cd..b1e688806c 100644 --- a/src/psmask.jl +++ b/src/psmask.jl @@ -60,19 +60,13 @@ Parameters To see the full documentation type: ``@? mask`` """ -mask(cmd0::String; kwargs...) = mask_helper(cmd0, nothing; kwargs...) -mask(arg1; kwargs...) = mask_helper("", arg1; kwargs...) -mask!(cmd0::String; kwargs...) = mask_helper(cmd0, nothing; first=false, kwargs...) -mask!(arg1; kwargs...) = mask_helper("", arg1; first=false, kwargs...) - -# --------------------------------------------------------------------------------------------------- -function mask_helper(cmd0::String, arg1; first=true, kwargs...) +function mask(cmd0::String="", arg1=nothing; first=true, kwargs...) gmt_proggy = (IamModern[1]) ? "mask " : "psmask " d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode - cmd, _, _, opt_R = parse_BJR(d, "", "", O, defaultJ=" -JX12c/12c") + cmd, _, _, opt_R = parse_BJR(d, "", "", O, " -JX12c/12c") cmd, = parse_common_opts(d, cmd, [:I :UVXY :JZ :c :e :p :r :t :w :params]; first=first) cmd = parse_these_opts(cmd, d, [[:C :endclip :end_clip_path], [:D :dump], [:L :nodegrid], [:N :invert :inverse], [:Q :cut :cut_number], [:S :search_radius], [:T :tiles]]) @@ -90,9 +84,9 @@ function mask_helper(cmd0::String, arg1; first=true, kwargs...) end # --------------------------------------------------------------------------------------------------- -#mask!(cmd0::String="", arg1=nothing; kw...) = mask(cmd0, arg1; first=false, kw...) -#mask(arg1; kw...) = mask("", arg1; first=true, kw...) -#mask!(arg1; kw...) = mask("", arg1; first=false, kw...) +mask!(cmd0::String="", arg1=nothing; kw...) = mask(cmd0, arg1; first=false, kw...) +mask(arg1; kw...) = mask("", arg1; first=true, kw...) +mask!(arg1; kw...) = mask("", arg1; first=false, kw...) # --------------------------------------------------------------------------------------------------- # This method has nothing to do with psmask, but can be seen as an extension to it. diff --git a/src/psrose.jl b/src/psrose.jl index 4588a66863..c2420bc88d 100644 --- a/src/psrose.jl +++ b/src/psrose.jl @@ -95,7 +95,7 @@ function rose_helper(cmd0::String, arg1; first=true, kwargs...) return gmt("psrose " * cmd, arg1) end - cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, defaultJ=" -JX12c") + cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, " -JX12c") cmd, = parse_common_opts(d, cmd, [:UVXY :c :e :p :t :w :margin :params]; first=first) cmd = parse_these_opts(cmd, d, [[:D :shift], [:F :no_scale], [:L :labels], [:M :vector_params], [:N :vonmises], [:Q :alpha], [:S :norm :normalize], [:T :orientation], [:Z :scale]]) diff --git a/src/psscale.jl b/src/psscale.jl index 225738242e..8322b2e35c 100644 --- a/src/psscale.jl +++ b/src/psscale.jl @@ -56,7 +56,7 @@ function colorbar(arg1::Union{Nothing, GMTcpt}=nothing; first=true, kwargs...) parse_paper(d) # See if user asked to temporarily pass into paper mode coordinates - cmd = parse_BJR(d, "", "", O, defaultJ="")[1] + cmd = parse_BJR(d, "", "", O, "")[1] opt_B = (!contains(cmd, " -B") && !IamModern[1]) ? DEF_FIG_AXES[1] : "" cmd = parse_JZ(d, cmd; O=O, is3D=(CTRL.pocket_J[3] != ""))[1] # We can't use parse_J(d)[1] cmd = parse_common_opts(d, cmd, [:F :UVXY :params :margin :c :p :t]; first=first)[1] diff --git a/src/pssolar.jl b/src/pssolar.jl index 67c5c1e745..26c7f6e791 100644 --- a/src/pssolar.jl +++ b/src/pssolar.jl @@ -46,7 +46,7 @@ function solar(cmd0::String="", arg1=nothing; first=true, kwargs...) def_J = (isempty(d)) ? " -JG0/0/14c" : " -JX14cd/0d" (isempty(d)) && (d[:coast] = true; d[:T] = :d; d[:G] = "navy@75"; d[:show] = true) - cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, defaultJ=def_J) + cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, def_J) cmd, = parse_common_opts(d, cmd, [:bo :c :h :o :p :t :UVXY :params]; first=first) cmd = parse_these_opts(cmd, d, [[:C :format], [:M :dump], [:N :invert]]) diff --git a/src/pstext.jl b/src/pstext.jl index be5d940b41..0bad26ed07 100644 --- a/src/pstext.jl +++ b/src/pstext.jl @@ -98,7 +98,7 @@ function _text(cmd0::String, arg1, O::Bool, K::Bool, d::Dict) cmd0 = "" end - cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, defaultJ=" -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") + cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, " -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0") _is3D = (isa(arg1, GDtype) && getsize(arg1)[2] == 3) # But this does not check the reading file path cmd, = parse_common_opts(d, cmd, [:a :e :f :p :t :w :JZ :UVXY :margin :params]; first=first, is3D=_is3D) cmd = parse_these_opts(cmd, d, [[:A :azimuths :azimuth :azim], [:M :paragraph], [:N :no_clip :noclip], diff --git a/src/pswiggle.jl b/src/pswiggle.jl index ed252f1770..7797dfb7b3 100644 --- a/src/pswiggle.jl +++ b/src/pswiggle.jl @@ -71,7 +71,7 @@ function wiggle_helper(cmd0::String, arg1; first=true, kw...) d, K, O = init_module(first, kw...) # Also checks if the user wants ONLY the HELP mode - cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, defaultJ=" -JX12c/0") + cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, " -JX12c/0") cmd, = parse_common_opts(d, cmd, [:c :e :f :g :p :t :w :F :UVXY :margin :params]; first=first) cmd = parse_these_opts(cmd, d, [[:A :azimuth], [:C :center], [:I :fixed_azim], [:S], [:Z :ampscale :amp_scale]]) diff --git a/src/psxy.jl b/src/psxy.jl index e6259b5ffc..528449d91d 100644 --- a/src/psxy.jl +++ b/src/psxy.jl @@ -63,7 +63,7 @@ function _common_plot_xyz(cmd0::String, arg1, caller::String, O::Bool, K::Bool, (isa(arg1, GMTdataset) && size(arg1,2) > 1 && !isempty(arg1.colnames)) && (CTRL.XYlabels[1] = arg1.colnames[1]; CTRL.XYlabels[2] = arg1.colnames[2]) isa(arg1, Vector{<:GMTdataset}) && !isempty(arg1[1].colnames) && (CTRL.XYlabels[1] = arg1[1].colnames[1]; CTRL.XYlabels[2] = arg1[1].colnames[2]) if (is_ternary) cmd, opt_J = parse_J(d, cmd, default=def_J) - else cmd, opt_B, opt_J, opt_R = parse_BJR(d, cmd, caller, O, defaultJ=def_J) + else cmd, opt_B, opt_J, opt_R = parse_BJR(d, cmd, caller, O, def_J) end # Current parse_B does not add a default -Baz when 3D AND -J has a projection. More or less fix that. if (is3D && opt_B != "" && !contains(opt_B, " -Bz")) diff --git a/src/seis/psmeca.jl b/src/seis/psmeca.jl index af4fcaae1f..f41ed07832 100644 --- a/src/seis/psmeca.jl +++ b/src/seis/psmeca.jl @@ -123,13 +123,13 @@ function common_mecas(cmd0, arg1, d, proggy, first, K, O) N_args = (arg1 === nothing) ? 0 : 1 if (occursin("meca", proggy)) - cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, defaultJ=" -JX12cd/0d") + cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, " -JX12cd/0d") cmd, = parse_common_opts(d, cmd, [:UVXY :c :di :e :p :t :params]; first=first) (haskey(d, :A) || haskey(d, :offset) && GMTver <= v"6.4.0" && isa(arg1, GDtype)) && @warn("Due to a GMT bug (fixed in GMT > 6.4.0) plotting with offsets works only when data is in a disk file.") cmd = parse_these_opts(cmd, d, [[:A :offset], [:D :depth_limits]]) else - cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, defaultJ=" -JX14c/10c") + cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, " -JX14c/10c") cmd, = parse_common_opts(d, cmd, [:UVXY :c :di :e :p :t :params]; first=first) cmd_ = add_opt(d, "", "Aa", [:Aa :cross_ll_pts], (lon1="", lat1="", lon2="", lat2="", dip="", width="", dmin="", dmax="", frame="_+f")) if (cmd_ == "") diff --git a/src/subplot.jl b/src/subplot.jl index 20aa377cd4..5a3e7f72d3 100644 --- a/src/subplot.jl +++ b/src/subplot.jl @@ -45,7 +45,7 @@ function subplot(fim=nothing; stop=false, kwargs...) # In case :title exists we must use and delete it to avoid double parsing cmd = ((val = find_in_dict(d, [:T :title])[1]) !== nothing) ? " -T\"" * val * "\"" : "" val_grid = find_in_dict(d, [:grid])[1] # Must fish this one right now because parse_B also looks for (another) :grid - cmd, = parse_BJR(d, cmd, "", false, defaultJ=" ") + cmd, = parse_BJR(d, cmd, "", false, " ") cmd, = parse_common_opts(d, cmd, [:V_params], first=true) cmd = parse_these_opts(cmd, d, [[:M :margin :margins]]) cmd = add_opt(d, cmd, "A", [:A :autolabel], diff --git a/test/test_PSs.jl b/test/test_PSs.jl index 20150af236..c40968a471 100644 --- a/test/test_PSs.jl +++ b/test/test_PSs.jl @@ -157,7 +157,7 @@ println(" PSMASK") D = gmtmath("-T-90/90/10 -N2/1 0"); mask(D, G=:yellow, I="30m", R="-75/75/-90/90", J="Q0/7i", S="4d", T=true, B="xafg180 yafg10") mask!(D, G=:yellow, I="30m", R="-75/75/-90/90", J="Q0/7i", S="4d", T=true, Vd=dbg2) -mask!(D, G=:yellow, I="30m", R="-75/75/-90/90", J="Q0/7i", S="4d", T=true, Vd=dbg2) +mask!("", D, G=:yellow, I="30m", R="-75/75/-90/90", J="Q0/7i", S="4d", T=true, Vd=dbg2) D = coast(DCW=:HR, dump=true); I = gmtread("@earth_day_05m", region=D, V=:q); mask(I, D);