Skip to content

Commit f767fab

Browse files
committed
Two more examples.
1 parent b411608 commit f767fab

File tree

8 files changed

+165
-14
lines changed

8 files changed

+165
-14
lines changed

documentation/common_opts/common_opts.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,10 @@ In case the central meridian is an optional parameter and it is being omitted, t
373373
range given by the *limits* option is used. The default standard parallel is the equator.
374374

375375
For linear (Cartesian) projections one can use *proj=:linear* but the simplest is just to omit the projection
376-
setting, which will default to a fig with of 14 cm. To set other fig dimensions, use the *figsize* specification
376+
setting, which will default to a fig with of 15 cm. To set other fig dimensions, use the *figsize* specification
377377
with *figsize=(width, height)* (both numeric or string) or just *figsize=width* and the *height* is computed
378378
automatically from the fig limits aspect ratio. We can also specify the scale separately: *e.g.* *figscale=x*,
379-
*figscale=1:xxxx*. As mentioned, when no size is provided a default width value of 14 cm is assumed.
379+
*figscale=1:xxxx*. As mentioned, when no size is provided a default width value of 15 cm is assumed.
380380

381381
For logarithm and power axes use `logx`, `logy` or `loglog` to take log10 of values before scaling, and `powx`
382382
and/or `powy` to to raise values to _power_ before scaling.

gallery.md

+22
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@
2626
~~~</a>~~~
2727
@@
2828

29+
@@box
30+
~~~<a class="boxlink" href="ex03/">~~~
31+
@@title (3) Spectral estimation @@
32+
@@box-content
33+
~~~
34+
<img src="/gallery/tillelogo_ex03.jpg">
35+
~~~
36+
@@
37+
~~~</a>~~~
38+
@@
39+
2940
@@box
3041
~~~<a class="boxlink" href="ex04/">~~~
3142
@@title (4) A 3-D perspective mesh plot @@
@@ -422,4 +433,15 @@
422433
~~~</a>~~~
423434
@@
424435

436+
@@box
437+
~~~<a class="boxlink" href="ex48/">~~~
438+
@@title (48) Line networks @@
439+
@@box-content
440+
~~~
441+
<img src="/gallery/tillelogo_ex48.jpg">
442+
~~~
443+
@@
444+
~~~</a>~~~
445+
@@
446+
425447
@@

gallery/ex03.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# (3) Spectral estimation and xy-plots
2+
3+
In this example we will show how to use the GMT programs \myreflink{fitcircle}, \myreflink{project},
4+
\myreflink{sample1d}, \myreflink{spectrum1d}, and \myreflink{plot}. Suppose you have (lon, lat, gravity)
5+
along a satellite track in a file called ``sat.xyg``, and (lon, lat, gravity) along a ship track in a
6+
file called ``ship.xyg``. You want to make a cross-spectral analysis of these data. First, you will
7+
have to get the two data sets into equidistantly sampled time-series form. To do this, it will be
8+
convenient to project these along the great circle that best fits the sat track. We must use
9+
\myreflink{fitcircle} to find this great circle and choose the L2 estimates of best pole. We project
10+
the data using \myreflink{project} to find out what their ranges are in the projected coordinate.
11+
The script computes the common range. We can then resample the projected data, and carry out the
12+
cross-spectral calculations, assuming that the ship is the input and the satellite is the output data.
13+
The final plot example_03.ps shows the ship and sat power in one diagram and the coherency on another
14+
diagram, both on the same page, with an auto-generated legend. Thus, the complete automated script reads:
15+
16+
The final illustration shows that the ship gravity anomalies have more power than altimetry derived gravity
17+
for short wavelengths and that the coherency between the two signals improves dramatically for wavelengths > 20 km.
18+
19+
\begin{examplefig}{}
20+
```julia
21+
using GMT
22+
GMT.resetGMT() # hide
23+
24+
# First, we use "fitcircle" to find the parameters of a great circle
25+
# most closely fitting the x,y points in "sat_03.txt":
26+
cpos = fitcircle("@sat_03.txt", norm=2, coordinates=:mean, par=(IO_COL_SEPARATOR="/",))
27+
ppos = fitcircle("@sat_03.txt", norm=2, coordinates=:north, par=(IO_COL_SEPARATOR="/",))
28+
29+
# Now we use "project" to project the data in both sat_03.txt and ship_03.txt
30+
# into data.pg, where g is the same and p is the oblique longitude around
31+
# the great circle. We use "km" to get the p distance in kilometers, and "sort"
32+
# to sort the output into increasing p values.
33+
sat_pg = project("@sat_03.txt", origin=cpos, pole=ppos, sort=true, outvars=:pz, km=true)
34+
ship_pg = project("@ship_03.txt", origin=cpos, pole=ppos, sort=true, outvars=:pz, km=true)
35+
36+
# Get the common extrema values rounded to 1 km
37+
bounds = round.([max(sat_pg.bbox[1], ship_pg.bbox[1]) min(sat_pg.bbox[2], ship_pg.bbox[2])], digits=0)
38+
39+
samp_x = collect(bounds[1]:bounds[2])
40+
# Now we can resample the gmt projected satellite data:
41+
samp_sat_pg = sample1d(sat_pg, range=samp_x)
42+
43+
# For reasons above, we use filter1d to pre-treat the ship data. We also need to sample
44+
# it because of the gaps > 1 km we found. So we use filter1d | sample1d. We also
45+
# use the "ends" on filter1d to use the data all the way out to bounds :
46+
D = filter1d(ship_pg, filter=:m1, range=@sprintf("%g/%g/1", bounds...), ends=true)
47+
samp_ship_pg = sample1d(D, range=samp_x)
48+
49+
# Now to do the cross-spectra, assuming that the ship is the input and the sat is the output
50+
# data, we do this:
51+
D = spectrum1d([samp_ship_pg[:,2] samp_sat_pg[:,2]], size=256, sample_dist=1, wavelength=true, outputs=(:xpower, :ypower, :coherence))
52+
53+
# Time to plot spectra
54+
subplot(grid=(2,1), margins="0.3c", col_axes=(bott=true, label="Wavelength (km)"),
55+
autolabel=(anchor=:TR, offset="8p"), title="Ship and Satellite Gravity",
56+
panel_size=10, frame=(axes="WeSn", bg="240/255/240"), Vd=1)
57+
gmtset(FONT_TAG="18p,Helvetica-Bold",)
58+
59+
subplot(:set, panel=(1,1), autolabel="Input Power")
60+
plot(D[:Wavelength, :Xpower, :σ_Xpow], proj=:loglog, flip_axes=:x, xaxis=(annot=1, ticks=3, scale=:pow),
61+
yaxis=(annot=1, ticks=3, scale=:pow, label="Power (mGal@+2@+km)"), fill="red", marker=:Triangle,
62+
ms="5p", region=(1,1000,0.1,10000), error_bars=(y=true, pen=0.5), legend="Ship")
63+
64+
plot(D[:Wavelength, :Ypower, :σ_Ypow], fill="blue", marker=:circ, ms="5p",
65+
error_bars=(y=true, pen=0.5), legend="Satellite")
66+
67+
legend(pos=(anchor="BL", offset=0.5), box="+gwhite+pthicker", par=(FONT_ANNOT_PRIMARY="14p,Helvetica-Bold",))
68+
subplot(:set, panel=(2,1), autolabel="Coherency@+2@+")
69+
70+
plot(D[:Wavelength, :Coher, :σ_Coher], region=(1,1000,0,1), proj=:logx, flip_axes=:x,
71+
xaxis=(annot=1, ticks=3, scale=:pow, label="Wavelength (km)"),
72+
yaxis=(annot=0.25, ticks=0.05, label="Coherency@+2@+"), marker=:circ, ms="5p",
73+
fill=:purple, error_bars=(y=true, pen=0.5))
74+
subplot(:show)
75+
```
76+
\end{examplefig}

gallery/ex33.md

+6-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ resetGMT() # hide
1313
makecpt(cmap=:rainbow, range=(-5000,-2000))
1414
G = grdcut("@earth_relief_01m", region=(-118,-107,-49,-42))
1515
grdimage(G, shade=(angle=15, norm="e0.75"), proj=:merc)
16-
resetGMT() # Need to find a fix for this. It lets the API in a geog mode
16+
#resetGMT() # Need to find a fix for this. It lets the API in a geog mode
1717

1818
# Select two points along the ridge
1919
ridge_pts = [-111.6 -43.0; -113.3 -47.5];
@@ -23,19 +23,15 @@ plot!(ridge_pts, region=G, symbol=(symb=:circle, size=0.25), fill=:blue, pen=(2,
2323

2424
# Generate cross-profiles 400 km long, spaced 10 km, samped every 2km
2525
# and stack these using the median, write stacked profile
26-
table = grdtrack(G, ridge_pts, equidistant="400k/2k/10k+v", stack="m+sstack.txt")
26+
table, stack = grdtrack(G, ridge_pts, equidistant="400k/2k/10k+v", stack="m+s")
2727
plot!(table, pen=0.5)
2828

2929
# Show upper/lower values encountered as an envelope
30-
env1 = gmtconvert("stack.txt", outcols="0,5")
31-
env2 = gmtconvert("stack.txt", outcols="0,6", reverse=true, suppress=true)
32-
env = [env1.data; env2.data]; # Concat the two matrices
33-
plot!(env, region=(-200,200,-3500,-2000), frame=(axes=:WSne, annot=:auto, ticks=:auto),
34-
xaxis=(grid=1000, label="Distance from ridge (km)"), ylabel="Depth (m)", proj=:linear,
35-
figsize=(15,7.5), fill=:lightgray, yshift=16)
36-
plot!("stack.txt", pen=3)
30+
plot!(stack[:,[1,2,6,7]], region=(-200,200,-3500,-2000), frame=(axes=:WSne, annot=:auto, ticks=:auto),
31+
xaxis=(grid=1000, label="Distance from ridge (km)"), ylabel="Depth (m)",
32+
figsize=(15,7.5), fill=:lightgray, close=(envelope=true,), yshift=16)
33+
plot!(stack, pen=3)
3734
text!(mat2ds([0 -2000], "MEDIAN STACKED PROFILE"), fill=:white, font=14, justify=:TC,
3835
offset=(away=true, shift=0.25), show=true)
39-
rm("stack.txt")
4036
```
4137
\end{examplefig}

gallery/ex46.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ using GMT
1010
resetGMT() # hide
1111

1212
coast(limits=:global, frame=(annot=:a,ticks=:a,grid=:a), proj=:EckertVI,
13-
area=5000, shore=0.5, borders=(type=1, pen=(0.5,:gray)), water=[175 210 255],
14-
par=(:MAP_FRAME_TYPE, :plain), figsize=16)
13+
area=5000, shore=0.5, borders=(type=1, pen=(0.5,:gray)), water=[175 210 255])
1514
solar!(terminators=(term=:d, date="2016-02-09T16:00:00"), fill="navy@95")
1615
solar!(terminators=(term=:c, date="2016-02-09T16:00:00"), fill="navy@85")
1716
solar!(terminators=(term=:n, date="2016-02-09T16:00:00"), fill="navy@80")

gallery/ex48.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# (48) Line networks, map embellishments, and curved titles
2+
3+
In this example we show how the module \myreflink{plot} can be used to create a network of lines based
4+
on a file with just the nodes (the siz airports). We also demonstrate how the lines can be shortened by
5+
(a) a given measure (here 250 km) and then (b) the length of the added vector heads. The airspace closest
6+
to each airport is identified as spherical Voronoi cells by \myreflink{sphtriangulate} and filled with
7+
transparent coloring, allowing us to see the seafloor texture beneath. Finally, we add six local spiderweb
8+
azimuth/distance gridlines and set a curved plot title.
9+
10+
\begin{examplefig}{}
11+
```julia
12+
using GMT
13+
resetGMT() # hide
14+
15+
loc = [-157.858 21.307 61 300
16+
-149.558 -17.552 -120 120
17+
139.692 35.689 56 170
18+
-70.669 -33.449 215 322
19+
151.207 -33.867 -10 145
20+
-118.244 34.052 142 306]
21+
par = [["HNL" "BC" "1.5"];
22+
["PPT" "TC" "1.5"];
23+
["HND" "RB" "0.75"];
24+
["SCL" "TL" "0.6"];
25+
["SYD" "TR" "2.2"];
26+
["LAX" "BL" "2.0"]]
27+
28+
makecpt(cmap=:lightgray, range="-12000,12000")
29+
grdimage("@earth_relief_10m", region=:global360, shade=(azim=45, norm="t2"),
30+
proj=(name=:ortho, center=(205,-10)), figsize=18)
31+
near_area = sphtriangulate(loc, voronoi=:v)
32+
t_cpt = makecpt(cmap=:categorical, range=(0,6,1))
33+
plot!(near_area, close=true, cmap=t_cpt, alpha=65)
34+
35+
# Make a 15 degrees by 250 km spiderweb grid around each airport
36+
plot!(loc, marker=(Web=true, size=("2000k","250k"), arc="250k", radial=15), pen=0.5, fill="white@40")
37+
coast!(land=:black, area=500, frame=(annot=:auto, ticks=:auto, grid=:auto))
38+
39+
# Then place custom labels.
40+
for k = 1:size(loc,1)
41+
text!(loc[k:k,1:2], txt=par[k,1], offset=(corners=true, shift=par[k,3], line=(0.5,:white)),
42+
font=16, justify=par[k,2], noclip=true)
43+
text!(loc[k:k,1:2], text=par[k,1], offset=(corners=true, shift=par[k,3], line=0.25), font=16,
44+
justify=par[k,2], noclip=true, fill=:white, pen=0.25)
45+
end
46+
47+
# Plot trimmed lines and overlay airport locations
48+
lines!(loc, connection=:network, pen=(lw=1.5, arrow=(len=0.5,fill=:red,shape=0.5,pen=0.5), offset="250k"))
49+
plot!(loc, symbol="E-500", fill=:orange, ml=0.25)
50+
51+
# Make an arc of radius 12 cm from 45 to 135 degrees around map center and use it to place text
52+
path = [cosd.(45:135) sind.(45:135)] .* 12
53+
# Move up 8 cm so origin is at the map center
54+
lines!(path, region=(-9.0,9.0,0,15), proj=:linear, figscale=1.0, decorated=(quoted=true, n_labels=1,
55+
const_label="IMPORTANT PACIFIC AIRPORTS", font=32, curved=true),
56+
pen=(:faint,:white), noclip=true, yshift=8, show=true)
57+
```
58+
\end{examplefig}

gallery/tillelogo_ex03.jpg

28.8 KB
Loading

gallery/tillelogo_ex48.jpg

69.2 KB
Loading

0 commit comments

Comments
 (0)