Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/geodesy/psvelo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ See full GMT docs at [`velo`]($(GMTdoc)supplements/seis/velo.html)
velo(mat2ds([0. -8 0 0 4 6 0.5; -8 5 3 3 0 0 0.5], ["4x6", "3x3"]), pen=(0.6,:red), fill_wedges=:green, outlines=true, Se="0.2/0.39/18", arrow="0.3c+p1p+e+gred", region=(-15,10,-10,10), show=1)
```
"""
function velo(cmd0::String="", arg1=nothing; first=true, kwargs...)
velo!(cmd0::String="", arg1=nothing; kw...) = velo(cmd0, arg1; first=false, kw...)
velo(arg1; kw...) = velo("", arg1; first=true, kw...)
velo!(arg1; kw...) = velo("", arg1; first=false, kw...)
function velo(cmd0::String="", arg1=nothing; first=true, kw...)
d, K, O = init_module(first, kw...) # Also checks if the user wants ONLY the HELP mode
velo(cmd0, arg1, O, K, d)
end
function velo(cmd0::String, arg1, O::Bool, K::Bool, d::Dict{Symbol, Any})

proggy = (IamModern[]) ? "velo " : "psvelo "

d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode

cmd, _, _, opt_R = parse_BJR(d, "", "", O, " -JX15cd/0d")
cmd, = parse_common_opts(d, cmd, [:UVXY :di :e :p :t :params]; first=first)
cmd, = parse_common_opts(d, cmd, [:UVXY :di :e :p :t :params]; first=!O)

if ((val = find_in_dict(d, [:A :arrow :arrows])[1]) !== nothing)
cmd = (isa(val, String)) ? cmd * " -A" * val : cmd * " -A" * vector_attrib(val)
Expand Down Expand Up @@ -44,10 +49,5 @@ function velo(cmd0::String="", arg1=nothing; first=true, kwargs...)
prep_and_call_finish_PS_module(d, cmd, "", K, O, true, arg1)
end

# ---------------------------------------------------------------------------------------------------
velo!(cmd0::String="", arg1=nothing; kw...) = velo(cmd0, arg1; first=false, kw...)
velo(arg1; kw...) = velo("", arg1; first=true, kw...)
velo!(arg1; kw...) = velo("", arg1; first=false, kw...)

const psvelo = velo # Alias
const psvelo! = velo! # Alias
16 changes: 8 additions & 8 deletions src/gmtlogo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ Parameters

- Example, make a GMT Julia logo with circles of 1 cm: logo(GMTjulia=1, show=true)
"""
function logo(cmd0::String=""; first=true, kwargs...)

d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode
logo!(cmd0::String=""; first=false, kw...) = logo(cmd0; first=first, kw...)
function logo(cmd0::String=""; first=true, kw...)
d, K, O = init_module(first, kw...) # Also checks if the user wants ONLY the HELP mode
logo(cmd0, O, K, d)
end
function logo(cmd0::String, O::Bool, K::Bool, d::Dict{Symbol, Any})

cmd, = parse_R(d, "", O=O)
cmd, = parse_J(d, cmd, default=" -Jx1", map=true, O=O)
cmd, = parse_common_opts(d, cmd, [:UVXY :params]; first=first)
cmd, = parse_common_opts(d, cmd, [:UVXY :params]; first=!O)

cmd = parse_type_anchor(d, cmd, [:D :pos :position],
(map=("g", arg2str, 1), outside=("J", nothing, 1), inside=("j", nothing, 1), norm=("n", arg2str, 1), paper=("x", arg2str, 1), anchor=("", arg2str, 2), width="+w", size="+w", justify="+j", offset=("+o", arg2str)), 'g')
Expand Down Expand Up @@ -78,9 +81,6 @@ function logo(cmd0::String=""; first=true, kwargs...)
end
end

# ---------------------------------------------------------------------------------------------------
logo!(cmd0::String=""; first=false, kw...) = logo(cmd0; first=first, kw...)

# -------------------------------------------------------------------------
function jlogo(L::Float64=5.0)
# Create the Julia "Terminator" 3 colored circles triangle
Expand All @@ -97,4 +97,4 @@ function jlogo(L::Float64=5.0)
end

const gmtlogo = logo # Alias
const gmtlogo! = logo!
const gmtlogo! = logo!
35 changes: 21 additions & 14 deletions src/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,12 @@ Example:
fill_between([theta y1], [theta y2], white=true, legend="Sinc1,Sinc2", show=1)
"""
fill_between(fname::String; first::Bool=true, kw...) = fill_between(gmtread(fname); first=first, kw...)
function fill_between(arg1, arg2=nothing; first=true, kwargs...)
fill_between!(arg1, arg2=nothing; kw...) = fill_between(arg1, arg2; first=false, kw...)
function fill_between(arg1, arg2=nothing; first=true, kw...)
d = init_module(false, kw...)[1]
fill_between(arg1, arg2, first, d)
end
function fill_between(arg1, arg2, first::Bool, d::Dict{Symbol, Any})

function find_the_pos(x, x_int)
len_x = length(x)
Expand All @@ -714,7 +719,6 @@ function fill_between(arg1, arg2=nothing; first=true, kwargs...)
return legs
end

d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
fc = helper_ds_fill(d) # Got fill colors?
if (!isempty(fc))
!any(contains.(fc, "@")) && (fc .*= "@60") # If no transparency provided default to 60%
Expand Down Expand Up @@ -863,8 +867,6 @@ function fill_between(arg1, arg2=nothing; first=true, kwargs...)
=#
end

fill_between!(arg1, arg2=nothing; kw...) = fill_between(arg1, arg2; first=false, kw...)

# ------------------------------------------------------------------------------------------------------
"""
stairs(cmd0::String="", arg1=nothing; step=:post, kwargs...)
Expand Down Expand Up @@ -1532,9 +1534,12 @@ const vspan! = vband!
const hspan = hband
const hspan! = hband!

function helper_hvband(mat::Matrix{<:Real}, tipo="v"; width=false, height=false, percent=false, first=true, kwargs...)
function helper_hvband(mat::Matrix{<:Real}, tipo="v"; width=false, height=false, percent=false, first=true, kw...)
d, _, O = init_module(first, kw...)
helper_hvband(mat, tipo, width, height, percent, O, d)
end
function helper_hvband(mat::Matrix{<:Real}, tipo, width, height, percent, O::Bool, d::Dict{Symbol, Any})
# This is the main function for the hband and vband functions.
d, _, O = init_module(first, kwargs...)
cmd, = parse_R(d, "", O=O, del=false)
all(CTRL.limits .== 0.) && error("Need to know the axes limits in a numeric form.")
cmd, = parse_J(d, cmd, default="", map=true, O=O, del=false)
Expand Down Expand Up @@ -1576,7 +1581,7 @@ function helper_hvband(mat::Matrix{<:Real}, tipo="v"; width=false, height=false,

d[:S] = bB # Add -Sb|B, otherwise headers are not scanned.
got_pattern && (d[:G] = "p1") # Patterns fck the session. Use this to inform gmt() that session must be recreated
common_plot_xyz("", D, "", first, false, d)
common_plot_xyz("", D, "", !O, false, d)
end

# ------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1668,11 +1673,17 @@ Other than the above options, the `kwargs` input accepts still the following opt
- `clockwise`: - Set it to `true` to indicate that positive axes directions be clock-wise
[Default lets the a, b, c axes be positive in a counter-clockwise direction].
"""
function ternary(cmd0::String="", arg1=nothing; first::Bool=true, image::Bool=false, kwargs...)
# A wrapper for psternary
ternary!(cmd0::String="", arg1=nothing; kw...) = ternary(cmd0, arg1; first=false, kw...)
ternary(arg1; kw...) = ternary("", arg1; first=true, kw...)
ternary!(arg1; kw...) = ternary("", arg1; first=false, kw...)
function ternary(cmd0::String="", arg1=nothing; first::Bool=true, image::Bool=false, kw...)
(cmd0 == "" && arg1 === nothing) && (arg1 = [0.0 0.0 0.0]) # No data in, just a kind of ternary basemap
(cmd0 != "") && (arg1 = gmtread(cmd0))
d = init_module(first, kwargs...)[1]
d = init_module(first, kw...)[1]
ternary(arg1, first, image, d)
end
function ternary(arg1, first::Bool, image::Bool, d::Dict{Symbol, Any})
# A wrapper for psternary
opt_J::String = parse_J(d, "", default=" -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0", map=true, O=false, del=false)[2]
opt_R::String = parse_R(d, "")[1]
d[:R] = (opt_R == "") ? "0/100/0/100/0/100" : opt_R[4:end]
Expand Down Expand Up @@ -1768,10 +1779,6 @@ function dict_auto_add!(d::Dict)
end
end

ternary!(cmd0::String="", arg1=nothing; kw...) = ternary(cmd0, arg1; first=false, kw...)
ternary(arg1; kw...) = ternary("", arg1; first=true, kw...)
ternary!(arg1; kw...) = ternary("", arg1; first=false, kw...)
ternary(kw...) = ternary("", nothing; first=true, kw...)
const psternary = ternary # Aliases
const psternary! = ternary! # Aliases

Expand Down
20 changes: 10 additions & 10 deletions src/pslegend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,19 @@ Parameters

To see the full documentation type: ``@? legend``
"""
function legend(cmd0::String="", arg1=nothing; first::Bool=true, kwargs...)
legend!(cmd0::String="", arg1=nothing; kw...) = legend(cmd0, arg1; first=false, kw...)
legend(arg1; kw...) = legend("", arg1; first=true, kw...)
legend!(arg1; kw...) = legend("", arg1; first=false, kw...)
function legend(cmd0::String="", arg1=nothing; first::Bool=true, kw...)
d, K, O = init_module(first, kw...) # Also checks if the user wants ONLY the HELP mode
legend(cmd0, arg1, O, K, d)
end
function legend(cmd0::String, arg1, O::Bool, K::Bool, d::Dict{Symbol, Any})

gmt_proggy = (IamModern[]) ? "legend " : "pslegend "

d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode

if (cmd0 == "" && arg1 === nothing && !IamModern[])
first && error("Need input data or file for legend")
!O && error("Need input data or file for legend")
# Here we have a bit of a convoluted case. This section is for the case where 'legend' is called without
# input data and relies on the data stored in previous commands by using the 'legend' keyword. That is,
# we use the keyword option 'position', 'fontsize', etc args as kwargs to 'legend'. As said, convoluted.
Expand Down Expand Up @@ -79,7 +84,7 @@ function legend(cmd0::String="", arg1=nothing; first::Bool=true, kwargs...)
# where the default is 8 pts. This allows for the user to set options 'fontsize' or 'font' to override the defaults.
((fnt = get_legend_font(d, IamModern[] ? 0 : 8; modern=IamModern[])) != "") && (cmd *= " --FONT_ANNOT_PRIMARY=" * fnt)

cmd, = parse_common_opts(d, cmd, [:F :c :p :q :t :JZ :UVXY :params]; first=first)
cmd, = parse_common_opts(d, cmd, [:F :c :p :q :t :JZ :UVXY :params]; first=!O)

opt_D = parse_type_anchor(d, "", [:D :pos :position],
(map=("g", arg2str, 1), outside=("J", arg2str, 1), inside=("j", arg2str, 1), norm=("n", arg2str, 1), paper=("x", arg2str, 1), anchor=("", arg2str, 2), width=("+w", arg2str), justify="+j", spacing="+l", offset=("+o", arg2str)), 'j')
Expand Down Expand Up @@ -244,10 +249,5 @@ function mk_legend(; kwargs...)
leg
end

# ---------------------------------------------------------------------------------------------------
legend!(cmd0::String="", arg1=nothing; kw...) = legend(cmd0, arg1; first=false, kw...)
legend(arg1; kw...) = legend("", arg1; first=true, kw...)
legend!(arg1; kw...) = legend("", arg1; first=false, kw...)

const pslegend = legend # Alias
const pslegend! = legend! # Alias
18 changes: 9 additions & 9 deletions src/psmask.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ Parameters

To see the full documentation type: ``@? mask``
"""
function mask(cmd0::String="", arg1=nothing; first=true, kwargs...)
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...)
function mask(cmd0::String="", arg1=nothing; first=true, kw...)
d, K, O = init_module(first, kw...) # Also checks if the user wants ONLY the HELP mode
mask(cmd0, arg1, O, K, d)
end
function mask(cmd0::String, arg1, O::Bool, K::Bool, d::Dict{Symbol, Any})

gmt_proggy = (IamModern[]) ? "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, " -JX15c/15c")
cmd, = parse_common_opts(d, cmd, [:I :UVXY :JZ :c :e :p :r :t :w :params]; first=first)
cmd, = parse_common_opts(d, cmd, [:I :UVXY :JZ :c :e :p :r :t :w :params]; first=!O)
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]])

Expand All @@ -92,11 +97,6 @@ function mask(cmd0::String="", arg1=nothing; first=true, kwargs...)
prep_and_call_finish_PS_module(d, cmd, "", K, O, true, arg1)
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...)

# ---------------------------------------------------------------------------------------------------
# This method has nothing to do with psmask, but can be seen as an extension to it.
function mask(GI::GItype, D::GDtype; touches=false, inverse::Bool=false)
Expand Down
18 changes: 10 additions & 8 deletions src/psrose.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,23 @@ Parameters

To see the full documentation type: ``@? rose``
"""
rose(cmd0::String; kwargs...) = rose_helper(cmd0, nothing; kwargs...)
rose(arg1; kwargs...) = rose_helper("", arg1; kwargs...)
rose!(cmd0::String; kwargs...) = rose_helper(cmd0, nothing; first=false, kwargs...)
rose!(arg1; kwargs...) = rose_helper("", arg1; first=false, kwargs...)
rose(cmd0::String; kw...) = rose_helper(cmd0, nothing; kw...)
rose(arg1; kw...) = rose_helper("", arg1; kw...)
rose!(cmd0::String; kw...) = rose_helper(cmd0, nothing; first=false, kw...)
rose!(arg1; kw...) = rose_helper("", arg1; first=false, kw...)

# ---------------------------------------------------------------------------------------------------
function rose_helper(cmd0::String, arg1; first=true, kwargs...)
function rose_helper(cmd0::String, arg1; first=true, kw...)
d, K, O = init_module(first, kw...) # Also checks if the user wants ONLY the HELP mode
rose_helper(cmd0, arg1, O, K, d)
end
function rose_helper(cmd0::String, arg1, O::Bool, K::Bool, d::Dict{Symbol, Any})

gmt_proggy = (IamModern[]) ? "rose " : "psrose "

arg2 = nothing # May be needed if GMTcpt type is sent in via C
N_args = (arg1 === nothing) ? 0 : 1

d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode

# If inquire, no plotting so do it and return
cmd = add_opt(d, "", "I", [:I :inquire])
if (cmd != "")
Expand All @@ -96,7 +98,7 @@ function rose_helper(cmd0::String, arg1; first=true, kwargs...)
end

cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, " -JX15c")
cmd, = parse_common_opts(d, cmd, [:UVXY :c :e :p :t :w :margin :params]; first=first)
cmd, = parse_common_opts(d, cmd, [:UVXY :c :e :p :t :w :margin :params]; first=!O)
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]])
cmd = add_opt(d, cmd, "A", [:A :sector :sectors], (width="", rose="_+r"))
Expand Down
14 changes: 8 additions & 6 deletions src/pssolar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@ Parameters

To see the full documentation type: ``@? solar``
"""
function solar(cmd0::String="", arg1=nothing; first=true, kwargs...)
solar!(cmd0::String="", arg1=nothing; kw...) = solar(cmd0, arg1; first=false, kw...)
function solar(cmd0::String="", arg1=nothing; first=true, kw...)
d, K, O = init_module(first, kw...) # Also checks if the user wants ONLY the HELP mode
solar(cmd0, arg1, O, K, d)
end
function solar(cmd0::String, arg1, O::Bool, K::Bool, d::Dict{Symbol, Any})

gmt_proggy = (IamModern[]) ? "solar " : "pssolar "
d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode

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_J, = parse_BJR(d, "", "", O, def_J)
cmd, = parse_common_opts(d, cmd, [:bo :c :h :o :p :t :UVXY :params]; first=first)
cmd, = parse_common_opts(d, cmd, [:bo :c :h :o :p :t :UVXY :params]; first=!O)
cmd = parse_these_opts(cmd, d, [[:C :format], [:M :dump], [:N :invert]])

cmd = add_opt_fill(cmd, d, [:G :fill], 'G')
Expand All @@ -69,7 +73,5 @@ function solar(cmd0::String="", arg1=nothing; first=true, kwargs...)
end

# ---------------------------------------------------------------------------------------------------
solar!(cmd0::String="", arg1=nothing; kw...) = solar(cmd0, arg1; first=false, kw...)

const pssolar = solar # Alias
const pssolar! = solar! # Alias
const pssolar! = solar! # Alias
8 changes: 5 additions & 3 deletions src/pswiggle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ const pswiggle! = wiggle! # Alias

# ---------------------------------------------------------------------------------------------------
function wiggle_helper(cmd0::String, arg1; first=true, kw...)
gmt_proggy = (IamModern[]) ? "wiggle " : "pswiggle "

d, K, O = init_module(first, kw...) # Also checks if the user wants ONLY the HELP mode
wiggle_helper(cmd0, arg1, O, K, d)
end
function wiggle_helper(cmd0::String, arg1, O::Bool, K::Bool, d::Dict{Symbol, Any})
gmt_proggy = (IamModern[]) ? "wiggle " : "pswiggle "

cmd, opt_B, opt_J, opt_R = parse_BJR(d, "", "", O, " -JX15c/0")
cmd, = parse_common_opts(d, cmd, [:c :e :f :g :p :t :w :F :UVXY :margin :params]; first=first)
cmd, = parse_common_opts(d, cmd, [:c :e :f :g :p :t :w :F :UVXY :margin :params]; first=!O)
cmd = parse_these_opts(cmd, d, [[:A :azimuth], [:C :center], [:I :fixed_azim], [:S], [:Z :ampscale :amp_scale]])

# If file name sent in, read it and compute a tight -R if this was not provided
Expand Down
8 changes: 5 additions & 3 deletions src/seis/gmtisf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ Parameters

This module can also be called via `gmtread`. _I.,e._ `gmtread("file.isf", opts...)_
"""
function gmtisf(cmd0::String; kwargs...)::GMTdataset{Float64,2}

d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
function gmtisf(cmd0::String; kw...)::GMTdataset{Float64,2}
d = init_module(false, kw...)[1]
gmtisf(cmd0, d)
end
function gmtisf(cmd0::String, d::Dict{Symbol, Any})::GMTdataset{Float64,2}

cmd = parse_common_opts(d, "", [:R :V_params :yx])[1]
cmd = parse_these_opts(cmd, d, [[:F :focal], [:D :date], [:N :notime]])
Expand Down
Loading
Loading