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
2 changes: 1 addition & 1 deletion src/GMT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ using .Laszip
grdsample(Glix, inc=0.5)
grdtrend(Glix, model=3)
grdtrack(Glix, [1 1])
coast(R=:g, proj=:guess, W=(level=1, pen=(2, :green)))
coast(R=:g, proj=:guess, W=(level=1, pen=(2, :green)), savefig=tempname()*".ps")
#gridit(rand(10,3), preproc=true, I=0.1);
#earthregions("PT", Vd=2);
#violin(rand(50), fmt=:ps);
Expand Down
14 changes: 9 additions & 5 deletions src/gmtreadwrite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,16 @@ to read a jpg image with the bands reversed

I = gmtread("image.jpg", band=[2,1,0]);
"""
function gmtread(_fname::String; kwargs...)
function gmtread(fname::String; kwargs...)
d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
gmtread(fname, d)
end
function gmtread(fname::String, d::Dict{Symbol, Any})

endswith(_fname, ".xlsx") && return read_xls(_fname; kwargs...) # Excel extension
endswith(fname, ".xlsx") && return read_xls(_fname; kwargs...) # Excel extension

fname::String = _fname # Because args signatures seam to worth shit in body.
d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
#fname::String = _fname # Because args signatures seam to worth shit in body.
#d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
cmd::String, opt_R::String = parse_R(d, "")
cmd, opt_i = parse_i(d, cmd)
cmd, opt_h = parse_h(d, cmd)
Expand Down Expand Up @@ -194,7 +198,7 @@ function gmtread(_fname::String; kwargs...)
elseif (opt_T == "obj") # Means we got a .obj file. Read it and leave
return read_obj(fname)
elseif (opt_T == "las") # Means we got a .laz or .las file. Read it and leave
o_las = lazread(fname; kwargs...)
o_las = lazread(fname; d...)
return getproperty(o_las, Symbol(o_las.stored))
end
else
Expand Down
17 changes: 10 additions & 7 deletions src/grd2kml.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@ Parameters

To see the full documentation type: ``@? grd2kml``
"""
function grd2kml(cmd0::String="", arg1=nothing; kwargs...)

arg2 = nothing; arg3 = nothing; # for CPT and/or illum
grd2kml(cmd0::String; kwargs...) = grd2kml_helper(cmd0, nothing; kwargs...)
grd2kml(arg1; kwargs...) = grd2kml_helper("", arg1; kwargs...)
function grd2kml_helper(cmd0::String, arg1; kwargs...)
d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
grd2kml_helper(cmd0, arg1, d)
end

# ---------------------------------------------------------------------------------------------------
function grd2kml_helper(cmd0::String, arg1, d::Dict{Symbol, Any})

arg2 = nothing; arg3 = nothing; # for CPT and/or illum
cmd, = parse_common_opts(d, "", [:V_params :f :n])
cmd = parse_these_opts(cmd, d, [[:A :mode], [:E :url], [:F :filter], [:H :subpixel :sub_pixel],
[:L :tilesize :tile_size], [:N :prefix], [:Q :nan_t :nan_alpha], [:S :extra_layers :extralayers], [:T :title], [:W :contours]])
Expand All @@ -62,7 +68,4 @@ function grd2kml(cmd0::String="", arg1=nothing; kwargs...)
cmd, N_used, arg1, arg2, = get_cpt_set_R(d, cmd0, cmd, " ", got_fname, arg1, arg2)
cmd, arg1, arg2, arg3 = common_shade(d, cmd, arg1, arg2, arg3, nothing, "grd2kml")
common_grd(d, "grd2kml " * cmd, arg1, arg2, arg3) # Finish build cmd and run it
end

# ---------------------------------------------------------------------------------------------------
grd2kml(arg1; kw...) = grd2kml("", arg1; kw...)
end
10 changes: 5 additions & 5 deletions src/grdclip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ Clip the range of grid values. will set values < low to below and/or values > hi
You can also specify one or more intervals where all values should be set to ``between``,
or replace individual values.

See full GMT docs at [`grdclip`]($(GMTdoc)grdclip.html)

Parameters
----------

Expand Down Expand Up @@ -50,11 +48,13 @@ Parameters
"""
grdclip(cmd0::String; kwargs...) = grdclip_helper(cmd0, nothing; kwargs...)
grdclip(arg1; kwargs...) = grdclip_helper("", arg1; kwargs...)

# ---------------------------------------------------------------------------------------------------
function grdclip_helper(cmd0::String, arg1; kwargs...)

d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
grdclip_helper(cmd0, arg1, d)
end

# ---------------------------------------------------------------------------------------------------
function grdclip_helper(cmd0::String, arg1, d::Dict{Symbol, Any})

cmd, = parse_common_opts(d, "", [:G :R :V_params])
cmd = add_opt(d, cmd, "S", [:S])
Expand Down
7 changes: 5 additions & 2 deletions src/grdcut.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ To see the full documentation type: ``@? grdcut``
grdcut(cmd0::String; kwargs...) = grdcut_helper(cmd0, nothing; kwargs...)
grdcut(arg1; kwargs...) = grdcut_helper("", arg1; kwargs...)
grdcut(; kwargs...) = grdcut_helper("", nothing; kwargs...) # To allow grdcut(data=..., ...)
function grdcut_helper(cmd0::String, arg1; kwargs...)
d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
grdcut_helper(cmd0, arg1, d)
end

# ---------------------------------------------------------------------------------------------------
function grdcut_helper(cmd0::String, arg1; kwargs...)::Union{Nothing, GMTgrid, GMTimage, String}
function grdcut_helper(cmd0::String, arg1, d::Dict{Symbol, Any})::Union{Nothing, GMTgrid, GMTimage, String}

arg2 = nothing
d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
cmd::String, opt_R::String = parse_R(d, "")
cmd, = parse_common_opts(d, cmd, [:V_params :f])
opt_J, = parse_J(d, "")
Expand Down
10 changes: 5 additions & 5 deletions src/grdfilter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
Filter a grid file in the time domain using one of the selected convolution or non-convolution
isotropic or rectangular filters and compute distances using Cartesian or Spherical geometries.

See full GMT docs at [`grdfilter`]($(GMTdoc)grdfilter.html)

Parameters
----------

Expand Down Expand Up @@ -34,13 +32,15 @@ To see the full documentation type: ``@? grdfilter``
"""
grdfilter(cmd0::String; kwargs...) = grdfilter_helper(cmd0, nothing; kwargs...)
grdfilter(arg1; kwargs...) = grdfilter_helper("", arg1; kwargs...)
function grdfilter_helper(cmd0::String, arg1; kwargs...)
d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
grdfilter_helper(cmd0, arg1, d)
end

# ---------------------------------------------------------------------------------------------------
function grdfilter_helper(cmd0::String, arg1; kwargs...)
function grdfilter_helper(cmd0::String, arg1, d::Dict{Symbol, Any})

d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
cmd, = parse_common_opts(d, "", [:G :RIr :V_params :f])
cmd = parse_these_opts(cmd, d, [[:D :distflag :distance], [:F :filter], [:N :nans], [:T :toggle]])

common_grd(d, cmd0, cmd, "grdfilter ", arg1) # Finish build cmd and run it
end
21 changes: 14 additions & 7 deletions src/grdimage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,21 @@ Parameters

To see the full documentation type: ``@? grdimage``
"""
function grdimage(cmd0::String="", arg1=nothing, arg2=nothing, arg3=nothing; first=true, kwargs...)
grdimage(arg1, arg2=nothing, arg3=nothing; kw...) = grdimage_helper("", arg1, arg2, arg3; first=true, kw...)
grdimage(cmd0::String="", arg1=nothing, arg2=nothing, arg3=nothing; kw...) =
grdimage_helper(cmd0, arg1, arg2, arg3; first=true, kw...)
grdimage!(cmd0::String="", arg1=nothing, arg2=nothing, arg3=nothing; kw...) =
grdimage_helper(cmd0, arg1, arg2, arg3; first=false, kw...)
grdimage!(arg1, arg2=nothing, arg3=nothing; kw...) = grdimage_helper("", arg1, arg2, arg3; first=false, kw...)
function grdimage_helper(cmd0::String, arg1=nothing, arg2=nothing, arg3=nothing; first=true, kwargs...)
d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode
(cmd0 != "" && arg1 === nothing && haskey(d, :inset)) && (arg1 = gmtread(cmd0); cmd0 = "")
grdimage_helper(cmd0, arg1, arg2, arg3, K, O, d)
end

# ---------------------------------------------------------------------------------------------------
#function grdimage(cmd0::String="", arg1=nothing, arg2=nothing, arg3=nothing; first=true, kwargs...)
function grdimage_helper(cmd0::String, arg1, arg2, arg3, K::Bool, O::Bool, d::Dict{Symbol, Any})

common_insert_R!(d, O, cmd0, arg1) # Set -R in 'd' out of grid/images (with coords) if limits was not used

Expand Down Expand Up @@ -74,6 +86,7 @@ function grdimage(cmd0::String="", arg1=nothing, arg2=nothing, arg3=nothing; fir

_grdimage(cmd0, arg1, arg2, arg3, O, K, d)
end

function _grdimage(cmd0::String, arg1, arg2, arg3, O::Bool, K::Bool, d::Dict)

arg4 = nothing # For the r,g,b + intensity case
Expand Down Expand Up @@ -217,9 +230,3 @@ function common_shade(d::Dict, cmd::String, arg1, arg2, arg3, arg4, prog)
return cmd, arg1, arg2, arg3, arg4
end

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

grdimage(arg1, arg2=nothing, arg3=nothing; kw...) = grdimage("", arg1, arg2, arg3; first=true, kw...)
grdimage!(arg1, arg2=nothing, arg3=nothing; kw...) = grdimage("", arg1, arg2, arg3; first=false, kw...)
7 changes: 5 additions & 2 deletions src/grdproject.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ To see the full documentation type: ``@? grdproject``
"""
grdproject(cmd0::String; kwargs...) = grdproject_helper(cmd0, nothing; kwargs...)
grdproject(arg1; kwargs...) = grdproject_helper("", arg1; kwargs...)
function grdproject_helper(cmd0::String, arg1; kwargs...)
d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
grdproject_helper(cmd0, arg1, d)
end

# ---------------------------------------------------------------------------------------------------
function grdproject_helper(cmd0::String, arg1; kwargs...)
function grdproject_helper(cmd0::String, arg1, d::Dict{Symbol, Any})

d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode
cmd::String = parse_n(d, "", true)[1] # Here we keep the GMT default to Antialiasing
cmd = parse_common_opts(d, cmd, [:G :R :V_params :r])[1]
if ((val = find_in_dict(d, [:J :proj :projection], false)[1]) !== nothing) # Here we don't want any default value
Expand Down
28 changes: 15 additions & 13 deletions src/grdvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ Takes two 2-D grid files which represents the x- and y-components of a vector fi
a vector field plot by drawing vectors with orientation and length according to the information
in the files. Alternatively, polar coordinate r, theta grids may be given instead.

See full GMT docs at [`grdvector`]($(GMTdoc)grdvector.html)

Parameters
----------

Expand Down Expand Up @@ -55,9 +53,22 @@ Parameters

To see the full documentation type: ``@? grdvector``
"""
function grdvector(arg1, arg2; first=true, kwargs...)
grdvector(arg1, arg2; kw...) = grdvector_helper(arg1, arg2; first=true, kw...)
grdvector!(arg1, arg2; kw...) = grdvector_helper(arg1, arg2; first=false, kw...)
grdvector(arg1::Matrix{<:Real}, arg2::Matrix{<:Real}; kw...) = grdvector_helper(mat2grid(arg1), mat2grid(arg2); kw...)
grdvector!(arg1::Matrix{<:Real}, arg2::Matrix{<:Real}; kw...) = grdvector_helper(mat2grid(arg1), mat2grid(arg2); first=false, kw...)
grdvector(arg1::Matrix{<:Real}, arg2::Matrix{<:Real}, arg3::Matrix{<:Real}, arg4::Matrix{<:Real}; kw...) =
grdvector_helper(mat2grid(arg3, x=Float64.(arg1[1,:]), y=Float64.(arg2[:,1])), mat2grid(arg4, x=Float64.(arg1[1,:]), y=Float64.(arg2[:,1])); kw...)
grdvector!(arg1::Matrix{<:Real}, arg2::Matrix{<:Real}, arg3::Matrix{<:Real}, arg4::Matrix{<:Real}; kw...) =
grdvector_helper(mat2grid(arg3, x=Float64.(arg1[1,:]), y=Float64.(arg2[:,1])), mat2grid(arg4, x=Float64.(arg1[1,:]), y=Float64.(arg2[:,1])); first=false, kw...)

function grdvector_helper(arg1, arg2; first=true, kwargs...)
d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode
grdvector_helper(arg1, arg2, K, O, d)
end

# ---------------------------------------------------------------------------------------------------
function grdvector_helper(arg1, arg2, K::Bool, O::Bool, d::Dict{Symbol, Any})

# Must call parse_R first to get opt_R that is needed in the get_grdinfo() call.
cmd, opt_R = parse_R(d, "", O=O)
Expand All @@ -72,7 +83,7 @@ function grdvector(arg1, arg2; first=true, kwargs...)
DEF_FIG_AXES_::String = (IamModern[]) ? "" : DEF_FIG_AXES[] # DEF_FIG_AXES is a global const
cmd, opt_B = parse_B(d, cmd, (O ? "" : DEF_FIG_AXES_))

cmd = parse_common_opts(d, cmd, [:UVXY :f :p :t :margin :params]; first=first)[1]
cmd = parse_common_opts(d, cmd, [:UVXY :f :p :t :margin :params]; first=!O)[1]
!(contains(cmd, "-V")) && (cmd *= " -Ve") # Shut up annoying warnings if -S has no units
cmd = parse_these_opts(cmd, d, [[:A :polar], [:N :noclip :no_clip], [:T :sign_scale], [:Z :azimuth]])
opt_S = add_opt(d, "", "S", [:S :vscale :vec_scale],
Expand Down Expand Up @@ -181,14 +192,5 @@ end
get_grdinfo(grd::String, opt_R::String) = gmt_grdinfo_C(opt_R * " " * grd).data
get_grdinfo(grd::GMTgrid, opt_R::String)::Matrix{Float64} = gmt("grdinfo -C" * opt_R, grd).data

# ---------------------------------------------------------------------------------------------------
grdvector!(arg1, arg2; kw...) = grdvector(arg1, arg2; first=false, kw...)
grdvector(arg1::Matrix{<:Real}, arg2::Matrix{<:Real}; kw...) = grdvector(mat2grid(arg1), mat2grid(arg2); kw...)
grdvector!(arg1::Matrix{<:Real}, arg2::Matrix{<:Real}; kw...) = grdvector(mat2grid(arg1), mat2grid(arg2); first=false, kw...)
grdvector(arg1::Matrix{<:Real}, arg2::Matrix{<:Real}, arg3::Matrix{<:Real}, arg4::Matrix{<:Real}; kw...) =
grdvector(mat2grid(arg3, x=Float64.(arg1[1,:]), y=Float64.(arg2[:,1])), mat2grid(arg4, x=Float64.(arg1[1,:]), y=Float64.(arg2[:,1])); kw...)
grdvector!(arg1::Matrix{<:Real}, arg2::Matrix{<:Real}, arg3::Matrix{<:Real}, arg4::Matrix{<:Real}; kw...) =
grdvector(mat2grid(arg3, x=Float64.(arg1[1,:]), y=Float64.(arg2[:,1])), mat2grid(arg4, x=Float64.(arg1[1,:]), y=Float64.(arg2[:,1])); first=false, kw...)

const quiver = grdvector # Aliases
const quiver! = grdvector!
Loading