Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
joa-quim committed Mar 3, 2024
2 parents a053321 + c889481 commit 09d27ad
Show file tree
Hide file tree
Showing 21 changed files with 767 additions and 116 deletions.
4 changes: 2 additions & 2 deletions doc/rst/source/greenspline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Synopsis

**gmt greenspline** [ *table* ]
|-G|\ *grdfile*
[ |-A|\ *gradfile*\ **+f**\|\ **0**\|\ **1**\|\ **2**\|\ **3**\|\ **4**\|\ **5** ]
[ |-A|\ *gradfile*\ **+f**\ **0**\|\ **1**\|\ **2**\|\ **3**\|\ **4**\|\ **5** ]
[ |-C|\ [[**n**\|\ **r**\|\ **v**]\ *value*\ [%]][**+c**][**+f**\ *file*][**+i**][**+n**] ]
[ |SYN_OPT-D3| ]
[ |-E|\ [*misfitfile*][**+r**\ *reportfile*] ]
Expand Down Expand Up @@ -131,7 +131,7 @@ Optional Arguments

.. _-A:

**-A**\ *gradfile*\ **+f**\|\ **0**\|\ **1**\|\ **2**\|\ **3**\|\ **4**\|\ **5**
**-A**\ *gradfile*\ **+f**\ **0**\|\ **1**\|\ **2**\|\ **3**\|\ **4**\|\ **5**
The solution will partly be constrained by surface gradients
:math:`\mathbf{v} = v \hat{\mathbf{n}}`, where :math:`v` is the gradient
magnitude and :math:`\hat{\mathbf{n}}` its unit vector direction.
Expand Down
26 changes: 12 additions & 14 deletions src/longopt/grdcut_inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,27 @@ static struct GMT_KEYWORD_DICTIONARY module_kw[] = {
short_directives, long_directives,
short_modifiers, long_modifiers,
transproc_mask */
{ 0, 'D', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'F', "",
"", "",
{ 0, 'D', "dryrun",
"", "",
"t", "trailer",
GMT_TP_STANDARD },
{ 0, 'G', "",
"", "",
{ 0, 'E', "extract|colslice|rowslice",
"x,y", "x,y",
"", "",
GMT_TP_STANDARD },
{ 0, 'N', "",
"", "",
{ 0, 'F', "clip",
"", "",
"c,i", "crop,invert",
GMT_TP_STANDARD },
{ 0, 'S', "",
"", "",
GMT_G_OUTGRID_KW,
{ 0, 'N', "extend", "", "", "", "", GMT_TP_STANDARD },
{ 0, 'S', "circ_subregion",
"", "",
"n", "set_nan",
GMT_TP_STANDARD },
{ 0, 'Z', "",
"", "",
{ 0, 'Z', "zrange",
"", "",
"n,N,r", "exclude_nan,include_nan,strip_nan_rowcols",
GMT_TP_STANDARD },
{ 0, '\0', "", "", "", "", "", 0 } /* End of list marked with empty option and strings */
};
Expand Down
67 changes: 23 additions & 44 deletions src/longopt/greenspline_inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,62 +25,41 @@ static struct GMT_KEYWORD_DICTIONARY module_kw[] = {
short_directives, long_directives,
short_modifiers, long_modifiers,
transproc_mask */
{ 0, 'A', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'C', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'D', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'E', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'G', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'I', "",
"", "",
{ 0, 'A', "gradient",
"", "",
"f", "format",
GMT_TP_STANDARD },
{ 0, 'L', "",
"", "",
"", "",
{ 0, 'C', "approx_fit|approximate",
"n,r,v", "largest,ratio,variance",
"c,f,i,n", "cumulative,file,incremental,no_surface",
GMT_TP_STANDARD },
{ 0, 'M', "",
"", "",
{ 0, 'D', "metadata|mode",
"", "",
"c,d,n,o,r,s,t,v,x,y,z",
"cpt|cmap,dname,invalid,offset,remark,scale,title,varname,xname,yname,zname",
GMT_TP_STANDARD },
{ 0, 'N', "",
"", "",
{ 0, 'E', "misfit",
"", "",
"r", "report",
GMT_TP_STANDARD },
{ 0, 'Q', "",
"", "",
GMT_G_OUTGRID_KW,
{ 0, 'I', "inc|increment|spacing", "", "", "", "", GMT_TP_STANDARD },
{ 0, 'L', "detrend|leave_trend",
"t,r", "leastsquares,residuals",
"", "",
GMT_TP_STANDARD },
{ 0, 'S', "",
"", "",
"", "",
{ 0, 'N', "nodes", "", "", "", "", GMT_TP_STANDARD },
{ 0, 'Q', "derivative|dir_derivative|vector", "", "", "", "", GMT_TP_STANDARD },
{ 0, 'S', "splines",
"c,l,p,q,r,t", "min_scurvature,linear,min_pcurvature,ctensionA,rtension,ctensionB",
"e,n", "error,npoints",
GMT_TP_STANDARD },
{ 0, 'T', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'W', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'Z', "",
"", "",
{ 0, 'T', "maskgrid|mask", "", "", "", "", GMT_TP_STANDARD },
{ 0, 'W', "uncertainties",
"w", "weights",
"", "",
GMT_TP_STANDARD },
{ 0, 'Z', "distmode|mode", "", "", "", "", GMT_TP_STANDARD },
{ 0, '\0', "", "", "", "", "", 0 } /* End of list marked with empty option and strings */
};
#endif /* !GREENSPLINE_INC_H */
43 changes: 9 additions & 34 deletions src/longopt/sphdistance_inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,17 @@ static struct GMT_KEYWORD_DICTIONARY module_kw[] = {
short_directives, long_directives,
short_modifiers, long_modifiers,
transproc_mask */
{ 0, 'A', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'C', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'D', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'E', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'G', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'I', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'L', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'N', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'Q', "",
"", "",
{ 0, 'C', "save_mem|single_form", "", "", "", "", GMT_TP_STANDARD },
{ 0, 'D', "duplicates|skipdup", "", "", "", "", GMT_TP_STANDARD },
{ 0, 'E', "quantity",
"d,n,z", "distance,polygon,zvalue",
"", "",
GMT_TP_STANDARD },
GMT_G_OUTGRID_KW,
GMT_I_INCREMENT_KW,
{ 0, 'L', "unit|dist_unit", "", "", "", "", GMT_TP_STANDARD },
{ 0, 'N', "nodes|node_table", "", "", "", "", GMT_TP_STANDARD },
{ 0, 'Q', "voronoi", "", "", "", "", GMT_TP_STANDARD },
{ 0, '\0', "", "", "", "", "", 0 } /* End of list marked with empty option and strings */
};
#endif /* !SPHDISTANCE_INC_H */
29 changes: 7 additions & 22 deletions src/longopt/sphinterpolate_inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,15 @@ static struct GMT_KEYWORD_DICTIONARY module_kw[] = {
short_directives, long_directives,
short_modifiers, long_modifiers,
transproc_mask */
{ 0, 'D', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'G', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'I', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'Q', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'T', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'Z', "",
"", "",
{ 0, 'D', "skipdup", "", "", "", "", GMT_TP_STANDARD },
GMT_G_OUTGRID_KW,
GMT_I_INCREMENT_KW,
{ 0, 'Q', "tension",
"g,l,p,s", "global,local,piecewise,smooth",
"", "",
GMT_TP_STANDARD },
{ 0, 'T', "vartension|var_tension", "", "", "", "", GMT_TP_STANDARD },
{ 0, 'Z', "scale", "", "", "", "", GMT_TP_STANDARD },
{ 0, '\0', "", "", "", "", "", 0 } /* End of list marked with empty option and strings */
};
#endif /* !SPHINTERPOLATE_INC_H */
36 changes: 36 additions & 0 deletions test/grdcut/grdcut-l2s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
#
# Test grdcut longopts translation.

m=grdcut
l2s='--l2stranstest'
a=$m-l2s-a.txt
b=$m-l2s-b.txt
rm -f $a $b ; touch $b

cat << EOF > $a
--l2stranstest -D+t
--l2stranstest -Ex50 -Ey10
--l2stranstest -F+i+c
--l2stranstest -G/some/file.grd=nf+d2+n-99
--l2stranstest -G/other/file.grd=nf+o6+s1.5
--l2stranstest -N-999
--l2stranstest -S100/20/5+n
--l2stranstest -Z1000/2000+n
--l2stranstest -Z1000/2000+N
--l2stranstest -Z1000/2000+r
EOF

# module-specific longopts
gmt $m $l2s --dryrun+trailer >> $b
gmt $m $l2s --extract=x:50 --extract=y:10 >> $b
gmt $m $l2s --clip+invert+crop >> $b
gmt $m $l2s --outgrid=/some/file.grd=nf+divide:2+nan:-99 >> $b
gmt $m $l2s --outgrid=/other/file.grd=nf+offset:6+scale:1.5 >> $b
gmt $m $l2s --extend=-999 >> $b
gmt $m $l2s --circ_subregion=100/20/5+set_nan >> $b
gmt $m $l2s --zrange=1000/2000+exclude_nan >> $b
gmt $m $l2s --zrange=1000/2000+include_nan >> $b
gmt $m $l2s --zrange=1000/2000+strip_nan_rowcols >> $b

diff $a $b --strip-trailing-cr > fail
48 changes: 48 additions & 0 deletions test/grdfft/grdfft-l2s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
#
# Test grdfft longopts translation.

m=grdfft
l2s='--l2stranstest'
a=$m-l2s-a.txt
b=$m-l2s-b.txt
rm -f $a $b ; touch $b

cat << EOF > $a
--l2stranstest -A90 -A10
--l2stranstest -C12 -C-8
--l2stranstest -D5 -D
--l2stranstest -Er+n
--l2stranstest -Ex+wk -Ey
--l2stranstest -Fr1/2/3/4 -Fx10/20 -Fy4/8/1
--l2stranstest -G/some/file.grd=nf+d2+n-99
--l2stranstest -G/other/file.grd=nf+o6+s1.5
--l2stranstest -I4 -Ig
--l2stranstest -N10/20+d -Na+a
--l2stranstest -Nf+a+e
--l2stranstest -Nm+h+m
--l2stranstest -Nr+l+n
--l2stranstest -Ns+v+wfft+z
--l2stranstest -Q
--l2stranstest -S5 -Sd
EOF

# module-specific longopts
gmt $m $l2s --azimuth=90 --azim=10 >> $b
gmt $m $l2s --upward=12 --upward=-8 >> $b
gmt $m $l2s --differentiate=5 --dfdz >> $b
gmt $m $l2s --power_spectrum=radial+normalize >> $b
gmt $m $l2s --power_spectrum=x+wavelength:k --power_spectrum=y >> $b
gmt $m $l2s --filter=isotropic:1/2/3/4 --filter=x:10/20 --filter=y:4/8/1 >> $b
gmt $m $l2s --outgrid=/some/file.grd=nf+divide:2+nan:-99 >> $b
gmt $m $l2s --outgrid=/other/file.grd=nf+offset:6+scale:1.5 >> $b
gmt $m $l2s --integrate=4 --integrate=gravity >> $b
gmt $m $l2s --dimensions=10/20+detrend --inquire=accurate+remove_mean >> $b
gmt $m $l2s --dimensions=actual+remove_mean+edge_point >> $b
gmt $m $l2s --dimensions=low_memory+remove_mid+edge_mirror >> $b
gmt $m $l2s --dimensions=rapid+leave_alone+no_extend >> $b
gmt $m $l2s --dimensions=show+verbose+suffix:fft+complex >> $b
gmt $m $l2s --no_wavenum_ops >> $b
gmt $m $l2s --scale=5 --scale=deflection >> $b

diff $a $b --strip-trailing-cr > fail
56 changes: 56 additions & 0 deletions test/greenspline/greenspline-l2s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
#
# Test greenspline longopts translation.

m=greenspline
l2s='--l2stranstest'
a=$m-l2s-a.txt
b=$m-l2s-b.txt
rm -f $a $b ; touch $b

cat << EOF > $a
--l2stranstest -A/some/file+f0
--l2stranstest -Cn10+c+f/some/file
--l2stranstest -Cr6+i
--l2stranstest -Cv0.5+n
--l2stranstest -D+cmycpt -D+cmycpt
--l2stranstest -D+dbaddata+n-999+o5
--l2stranstest -D"+rsilly comment+s2+tBig News"
--l2stranstest -D+vDataset+xMrX+yMsY+zZeebo
--l2stranstest -E/some/file+r/report/file
--l2stranstest -G/some/file.grd
--l2stranstest -I4 -I2/3 -I1/2/3
--l2stranstest -L -Lt -Lr
--l2stranstest -N/node/file
--l2stranstest -Q -Q12 -Q4/5/6
--l2stranstest -Sc -Sl+e0.1
--l2stranstest -Sp -Sq200+n20
--l2stranstest -Sr200/10 -St500/3
--l2stranstest -T/this/mask.grd -T/that/mask.grd
--l2stranstest -W -Ww
--l2stranstest -Z3 -Z5
EOF

# module-specific longopts
gmt $m $l2s --gradient=/some/file+format:0 >> $b
gmt $m $l2s --approx_fit=largest:10+cumulative+file:/some/file >> $b
gmt $m $l2s --approx_fit=ratio:6+incremental >> $b
gmt $m $l2s --approximate=variance:0.5+no_surface >> $b
gmt $m $l2s --metadata+cpt:mycpt --ncdata+cmap:mycpt >> $b
gmt $m $l2s --metadata+dname:baddata+invalid:-999+offset:5 >> $b
gmt $m $l2s --metadata+remark:'silly comment'+scale:2+title:'Big News' >> $b
gmt $m $l2s --metadata+varname:Dataset+xname:MrX+yname:MsY+zname:Zeebo >> $b
gmt $m $l2s --misfit=/some/file+report:/report/file >> $b
gmt $m $l2s --outgrid=/some/file.grd >> $b
gmt $m $l2s --inc=4 --increment=2/3 --spacing=1/2/3 >> $b
gmt $m $l2s --leave_trend --detrend=leastsquares --detrend=residuals >> $b
gmt $m $l2s --nodes=/node/file >> $b
gmt $m $l2s --derivative --dir_derivative=12 --vector=4/5/6 >> $b
gmt $m $l2s --splines=min_scurvature --splines=linear+error:0.1 >> $b
gmt $m $l2s --splines=min_pcurvature --splines=ctensionA:200+npoints:20 >> $b
gmt $m $l2s --splines=rtension:200/10 --splines=ctensionB:500/3 >> $b
gmt $m $l2s --maskgrid=/this/mask.grd --mask=/that/mask.grd >> $b
gmt $m $l2s --uncertainties --uncertainties=weights >> $b
gmt $m $l2s --distmode=3 --mode=5 >> $b

diff $a $b --strip-trailing-cr > fail

0 comments on commit 09d27ad

Please sign in to comment.