Skip to content

Commit

Permalink
Merge pull request #211 from GenericMappingTools/docstuff
Browse files Browse the repository at this point in the history
Docs fixes.
  • Loading branch information
joa-quim authored Apr 9, 2019
2 parents f8b9400 + 943697a commit 83dbc4a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ makedocs(
"bar3.md",
"coast.md",
"grdcontour.md",
"grdimage.md",
"lines.md",
"scatter.md",
"scatter3.md",
Expand Down
24 changes: 22 additions & 2 deletions docs/src/common_opts.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,26 @@ See [GMT Map Projections](@ref) for a list of projection examples
# perspective

- **p** **|** **view** **|** **perspective** : *view=(azim, elev)*\
Selects perspective view and sets the azimuth and elevation of the viewpoint (180,90). When **view** is used in consort with **Jz** or **JZ**, a third value can be appended which indicates at which z-level all 2D material, like the plot frame, is plotted (in perspective). [Default is at the bottom of the z-axis].
Selects perspective view and sets the azimuth and elevation of the viewpoint (180,90). When **view**
is used in consort with **Jz** or **JZ**, a third value can be appended which indicates at which
z-level all 2D material, like the plot frame, is plotted (in perspective). [Default is at the bottom
of the z-axis].

[`-p GMT doc`](https://www.generic-mapping-tools.org/gmt/latest/gmt.html#p-full)
[`-p GMT doc`](https://www.generic-mapping-tools.org/gmt/latest/gmt.html#p-full)

# interp

- **n** **|** *interp* **|** *interpol* : *interp="[b|c|l|n][+a][+bBC][+c][+tthreshold]"*\

Select grid interpolation mode by adding b for B-spline smoothing, c for bicubic interpolation,
l for bilinear interpolation, or n for nearest-neighbor value (for example to plot categorical data).
Optionally, append +a to switch off antialiasing (where supported). Append +bBC to override the boundary
conditions used, adding g for geographic, p for periodic, or n for natural boundary conditions. For the
latter two you may append x or y to specify just one direction, otherwise both are assumed. Append +c
to clip the interpolated grid to input z-min/max [Default may exceed limits]. Append +tthreshold to
control how close to nodes with NaNs the interpolation will go. A threshold of 1.0 requires all (4 or 16)
nodes involved in interpolation to be non-NaN. 0.5 will interpolate about half way from a non-NaN value;
0.1 will go about 90% of the way, etc. [Default is bicubic interpolation with antialiasing and a threshold
of 0.5, using geographic (if grid is known to be geographic) or natural boundary conditions].

[`-n GMT doc`](https://www.generic-mapping-tools.org/gmt/latest/gmt.html#n-full)
1 change: 1 addition & 0 deletions src/common_options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ function add_opt_module(d::Dict, symbs)
nt = (val..., Vd=:cmd)
if (symbs[k] == :coast) r = coast!(; nt...)
elseif (symbs[k] == :colorbar) r = colorbar!(; nt...)
elseif (symbs[k] == :basemap) r = basemap!(; nt...)
end
elseif (isa(val, Number) && (val != 0)) # Allow setting coast=true || colorbar=true
if (symbs[k] == :coast) r = coast!(W=0.5, Vd=:cmd)
Expand Down
10 changes: 5 additions & 5 deletions src/grdimage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Parameters
- **G** : -- Str or Int --
[`-G`](http://gmt.soest.hawaii.edu/doc/latest/grdimage.html#g)
- **I** : **shade** : **intensity** : **intensfile** : -- Str or GMTgrid --
- **I** : **shade** : **intensity** : -- Str or GMTgrid --
Gives the name of a grid file or GMTgrid with intensities in the (-1,+1) range,
or a grdgradient shading flags.
Expand Down Expand Up @@ -79,7 +79,7 @@ function grdimage(cmd0::String="", arg1=[], arg2=[], arg3=[]; first=true, kwargs
end

cpt_opt_T = ""
if (opt_R == "" && isa(arg1, GMTgrid)) # GMT bug. -R is not stored in gmt.history
if (opt_R == "" && isa(arg1, GMTgrid)) # GMT bug, -R will not be stored in gmt.history
cmd *= @sprintf(" -R%f/%f/%f/%f", arg1.range[1], arg1.range[2], arg1.range[3], arg1.range[4])
cpt_opt_T = @sprintf(" -T%f/%f/128+n", arg1.range[5], arg1.range[6])
elseif (opt_R == "" && cmd0 != "")
Expand All @@ -89,11 +89,11 @@ function grdimage(cmd0::String="", arg1=[], arg2=[], arg3=[]; first=true, kwargs
end

N_used = got_fname == 0 ? 1 : 0 # To know whether a cpt will go to arg1 or arg2
if (isempty_(arg3) && !occursin("-D", cmd)) # This lieves out the case when the r,g,b were sent as a text.
if (isempty_(arg3) && !occursin("-D", cmd)) # But this lieves out the case when the r,g,b were sent as a text.
cmd, arg1, arg2, = add_opt_cpt(d, cmd, [:C :color :cmap], 'C', N_used, arg1, arg2, true, true, cpt_opt_T)
end

if ((val = find_in_dict(d, [:I :shade :intensity :intensfile])[1]) !== nothing)
if ((val = find_in_dict(d, [:I :shade :intensity])[1]) !== nothing)
if (!isa(val, GMTgrid)) # Uff, simple. Either a file name or a -A type modifier
if (isa(val, String) || isa(val, Symbol)) cmd *= " -I" * arg2str(val)
else
Expand All @@ -113,7 +113,7 @@ function grdimage(cmd0::String="", arg1=[], arg2=[], arg3=[]; first=true, kwargs
if (isa(arg1, GMTimage) && !occursin("-D", cmd)) cmd *= " -D" end # GMT bug. It says not need but it is.
cmd = "grdimage " * cmd # In any case we need this
if (!occursin("-A", cmd)) # -A means that we are requesting the image directly
cmd, K = finish_PS_nested(d, cmd, output, K, O, [:coast :colorbar])
cmd, K = finish_PS_nested(d, cmd, output, K, O, [:coast :colorbar :basemap])
end
return finish_PS_module(d, cmd, "", output, fname_ext, opt_T, K, arg1, arg2, arg3, arg4)
end
Expand Down
2 changes: 1 addition & 1 deletion src/pscoast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function coast(cmd0::String=""; clip=nothing, first=true, kwargs...)
if (!occursin("-D",cmd)) cmd *= " -Da" end # Then pick automatic

cmd = finish_PS(d, cmd, output, K, O)
return finish_PS_module(d, "pscoast " * cmd, "", output, fname_ext, opt_T, K)
return finish_PS_module(d, "pscoast " * cmd, "", output, fname_ext, opt_T, K)
end

# ---------------------------------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ end

if (got_it) # Otherwise go straight to end

GMT.GMT_Get_Version();

# -------------------- Test common_options ----------------------------------------
@test GMT.parse_R("", Dict(:xlim => (1,2), :ylim => (3,4), :zlim => (5,6)))[1] == " -R1/2/3/4/5/6"
G1 = gmt("grdmath -R-2/2/-2/2 -I0.5 X Y MUL");
Expand Down Expand Up @@ -286,6 +288,7 @@ if (got_it) # Otherwise go straight to end
# GRDCLIP
G2=grdclip(G,above="5/6", low=[2 2], between=[3 4 4.5]); # Use G of previous test
@test_throws ErrorException("Wrong number of elements in S option") G2=grdclip(G,above="5/6", low=[2], between=[3 4 4.5]);
@test_throws ErrorException("OPT_S: argument must be a string or a two elements array.") G2=grdclip(G,above=5, low=[2 2]);

# GRDCONTOUR
G = gmt("grdmath -R-15/15/-15/15 -I0.3 X Y HYPOT DUP 2 MUL PI MUL 8 DIV COS EXCH NEG 10 DIV EXP MUL =");
Expand Down Expand Up @@ -574,6 +577,8 @@ if (got_it) # Otherwise go straight to end
@test startswith(coast(R=:g, W=(2,:green), Vd=:cmd), "pscoast -Rg -JX12cd/0 -Baf -BWSen -W2,green")
r = coast(R=:g, N=((level=1,pen=(2,:green)), (level=3,pen=(4,:blue, "--"))), Vd=:cmd);
@test startswith(r, "pscoast -Rg -JX12cd/0 -Baf -BWSen -N1/2,green -N3/4,blue,--")
r = coast(proj=:Mercator, DCW=((country="GB,IT,FR", fill=:blue, pen=(0.25,:red)), (country="ES,PT,GR", fill=:yellow)), Vd=:cmd);
@test startswith(r, "pscoast -JM12c -Baf -BWSen -EGB,IT,FR+gblue+p0.25,red -EES,PT,GR+gyellow -Da")

# PSCONTOUR
x,y,z=GMT.peaks(grid=false);
Expand All @@ -591,6 +596,7 @@ if (got_it) # Otherwise go straight to end
C = makecpt(T="-200/1000/100", C="rainbow");
colorbar(C=C, D="x8c/1c+w12c/0.5c+jTC+h", B="xaf+l\"topography\" y+lkm", fmt="ps", par=(MAP_FRAME_WIDTH=0.2,))
colorbar!("", C=C, D="x8c/1c+w12c/0.5c+jTC+h", B="xaf+l\"topography\" y+lkm", Vd=:cmd)
colorbar!(C=C, D="x8c/1c+w12c/0.5c+jTC+h", B="xaf+l\"topography\" y+lkm", Vd=:cmd)

# PSHISTOGRAM
histogram(randn(1000),W=0.1,center=true,B=:a,N=0, x_offset=1, y_offset=1, stamp=[], t=50)
Expand Down

0 comments on commit 83dbc4a

Please sign in to comment.