Skip to content

Commit

Permalink
Fix typos, minor bugs and clean up -F for plot and gmtconnect (#8082)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulWessel authored Nov 26, 2023
1 parent 57ca5d9 commit 49b7ac4
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 48 deletions.
39 changes: 22 additions & 17 deletions doc/rst/source/gmtconvert.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Synopsis
[ |-C|\ [**+l**\ *min*][**+u**\ *max*][**+i**]]
[ |-D|\ [*template*\ [**+o**\ *orig*]] ]
[ |-E|\ [**f**\|\ **l**\|\ **m**\|\ **M**\ *stride*] ]
[ |-F|\ [**c**\|\ **n**\|\ **p**\|\ **v**][**a**\|\ **t**\|\ **s**\|\ **r**\|\ *refpoint*] ]
[ |-F|\ [**c**\|\ **n**\|\ **p**\|\ **v**][**a**\|\ **r**\|\ **s**\|\ **t**\|\ *refpoint*] ]
[ |-I|\ [**tsr**] ]
[ |-L| ]
[ |-N|\ *col*\ [**+a**\|\ **d**] ]
Expand Down Expand Up @@ -120,25 +120,30 @@ Optional Arguments

.. _-F:

**-F**\ [**c**\|\ **n**\|\ **p**\|\ **v**][**a**\|\ **t**\|\ **s**\|\ **r**\|\ *refpoint*]
**-F**\ [**c**\|\ **n**\|\ **p**\|\ **v**][**a**\|\ **r**\|\ **s**\|\ **t**\|\ *refpoint*]
Alter the way points are connected (by specifying a *scheme*) and data are grouped (by specifying a *method*).
Append one of four line connection schemes:
**c**\ : Form continuous line segments for each group [Default].
**p**\ : Form line segments from a reference point reset for each group.
**n**\ : Form networks of line segments between all points in each group.
**v**\ : Form vector line segments suitable for :doc:`plot` **-Sv+s**.

- **c**\ : Form continuous line segments for each group [Default].
- **n**\ : Form networks of line segments between all points in each group.
- **p**\ : Form line segments from a reference point reset for each group.
- **v**\ : Form vector line segments suitable for :doc:`plot` **-Sv+s**.

Optionally, append the one of four segmentation methods to define the group:
**a**\ : Ignore all segment headers, i.e., let all points belong to a single group,
and set group reference point to the very first point of the first file.
**t**\ : Consider all data in each table to be a single separate group and
reset the group reference point to the first point of each group.
**s**\ : Segment headers are honored so each segment is a group; the group
reference point is reset to the first point of each incoming segment [Default].
**r**\ : Same as **s**, but the group reference point is reset after
each record to the previous point (this method is only available with the **-Fp** scheme).
Instead of the codes **a**\|\ **f**\|\ **s**\|\ **r** you may append
the coordinates of a *refpoint* which will serve as a fixed external
reference point for all groups.

- **a**\ : Ignore all segment headers, i.e., let all points belong to a single group,
and set group reference point to the very first point of the first file.
- **r**\ : Segment headers are honored so each segment is a group; the group
reference point is reset after each record to the previous point (this method
is only available with the **-Fp** scheme).
- **s**\ : Same as **r**, but the group reference point is reset to the first
point of each incoming segment [Default].
- **t**\ : Consider all data in each table to be a single separate group and
reset the group reference point to the first point of each group.

Instead of the codes **a**\|\ **r**\|\ **s**\|\ **t** you may append the
*lon/lat* (or *x/y*) coordinates of a *refpoint*, which will serve as a fixed
external reference point for all groups.

.. figure:: /_images/GMT_segmentize.*
:width: 600 px
Expand Down
39 changes: 22 additions & 17 deletions doc/rst/source/plot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Synopsis
[ |-C|\ *cpt* ]
[ |-D|\ *dx*/*dy* ]
[ |-E|\ [**x**\|\ **y**\|\ **X**\|\ **Y**][**+a**\|\ **A**][**+cl**\|\ **f**][**+n**][**+w**\ *width*\ [/*cap*]][**+p**\ *pen*] ]
[ |-F|\ [**c**\|\ **n**\|\ **r**][**a**\|\ **f**\|\ **s**\|\ **r**\|\ *refpoint*] ]
[ |-F|\ [**c**\|\ **n**\|\ **p**][**a**\|\ **s**\|\ **t**\|\ **r**\|\ *refpoint*] ]
[ |-G|\ *fill*\|\ **+z** ]
[ |-H|\ [*scale*] ]
[ |-I|\ [*intens*] ]
Expand Down Expand Up @@ -161,24 +161,29 @@ Optional Arguments

.. _-F:

**-F**\ [**c**\|\ **n**\|\ **p**][**a**\|\ **f**\|\ **s**\|\ **r**\|\ *refpoint*]
**-F**\ [**c**\|\ **n**\|\ **p**][**a**\|\ **r**\|\ **s**\|\ **t**\|\ *refpoint*]
Alter the way points are connected (by specifying a *scheme*) and data are grouped (by specifying a *method*).
Append one of three line connection schemes:
**c**\ : Draw continuous line segments for each group [Default].
**p**\ : Draw line segments from a reference point reset for each group.
**n**\ : Draw networks of line segments between all points in each group.

- **c**\ : Form continuous line segments for each group [Default].
- **n**\ : Form networks of line segments between all points in each group.
- **p**\ : Form line segments from a reference point reset for each group.

Optionally, append the one of four segmentation methods to define the group:
**a**\ : Ignore all segment headers, i.e., let all points belong to a single group,
and set group reference point to the very first point of the first file.
**f**\ : Consider all data in each file to be a single separate group and
reset the group reference point to the first point of each group.
**s**\ : Segment headers are honored so each segment is a group; the group
reference point is reset to the first point of each incoming segment [Default].
**r**\ : Same as **s**, but the group reference point is reset after
each record to the previous point (this method is only available with the **-Fp** scheme).
Instead of the codes **a**\|\ **f**\|\ **s**\|\ **r** you may append
the coordinates of a *refpoint* which will serve as a fixed external
reference point for all groups.

- **a**\ : Ignore all segment headers, i.e., let all points belong to a single group,
and set group reference point to the very first point of the first file.
- **r**\ : Segment headers are honored so each segment is a group; the group
reference point is reset after each record to the previous point (this method
is only available with the **-Fp** scheme).
- **s**\ : Same as **r**, but the group reference point is reset to the first
point of each incoming segment [Default].
- **t**\ : Consider all data in each table to be a single separate group and
reset the group reference point to the first point of each group.

Instead of the codes **a**\|\ **r**\|\ **s**\|\ **t** you may append the
*lon/lat* (or *x/y*) coordinates of a *refpoint*, which will serve as a fixed
external reference point for all groups.

.. figure:: /_images/GMT_segmentize.*
:width: 600 px
Expand All @@ -187,7 +192,7 @@ Optional Arguments
Use the |-F| option to create various networks between input point. Dashed lines
indicate input ordering for the two tables, while solid lines are the resulting
network connections. Top left is original input, while the next five reflect the results
of directives **ra**, **rf**, **rs**, **r**\ 10/35 and **na**.
of directives **ra**, **rt**, **rs**, **r**\ 10/35 and **na**.

.. _-G:

Expand Down
21 changes: 12 additions & 9 deletions src/gmt_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -9058,18 +9058,19 @@ void gmt_segmentize_syntax (struct GMT_CTRL *GMT, char option, unsigned int mode
struct GMTAPI_CTRL *API = GMT->parent;
char *verb[2] = {"Form", "Draw"}, *count[2] = {"four", "three"};
char *syntax = (mode) ? GMT_SEGMENTIZE3 : GMT_SEGMENTIZE4;
char *module = (GMT->current.setting.run_mode == GMT_MODERN) ? "plot" : "psxy";
GMT_Usage (API, 1, "\n-%c%s", option, syntax);
GMT_Usage (API, -2, "Alter the way points are connected and the data are segmented. "
"Append one of %s line connection schemes: ", count[mode]);
GMT_Usage (API, 3, "c: %s continuous line segments for each group [Default].", verb[mode]);
GMT_Usage (API, 3, "p: %s line segments from a reference point reset for each group.", verb[mode]);
GMT_Usage (API, 3, "n: %s networks of line segments between all points in each group.", verb[mode]);
if (mode == 0) GMT_Usage (API, 3, "v: Form vector line segments suitable for psxy -Sv|=<size>+s");
GMT_Usage (API, 3, "p: %s line segments from a reference point reset for each group.", verb[mode]);
if (mode == 0) GMT_Usage (API, 3, "v: Form vector line segments suitable for the %s -Sv|=<size>+s option", module);
GMT_Usage (API, 2, "Optionally, append one of five ways to define a \"group\":");
GMT_Usage (API, 3, "a: Data set is considered a single group; reference point is first point in the group.");
GMT_Usage (API, 3, "f: Each file is a separate group; reference point is reset to first point in the group.");
GMT_Usage (API, 3, "s: Each segment is a group; reference point is reset to first point in the group [Default].");
GMT_Usage (API, 3, "r: Each segment is a group, but reference point is reset to each point in the group.");
GMT_Usage (API, 3, "s: Each segment is a group; reference point is reset to first point in the group [Default].");
GMT_Usage (API, 3, "t: Each table is a separate group; reference point is reset to first point in the group.");
GMT_Usage (API, 3, "Alternatively, append a fixed external reference point instead.");
}

Expand Down Expand Up @@ -10170,7 +10171,7 @@ int gmt_parse_model (struct GMT_CTRL *GMT, char option, char *in_arg, unsigned i
unsigned int gmt_parse_segmentize (struct GMT_CTRL *GMT, char option, char *in_arg, unsigned int mode, struct GMT_SEGMENTIZE *S) {
/* Parse segmentizing options in gmt convert (mode == 0) or psxy (mode == 1).
* Syntax is given below (assuming option = -F here):
* -F<scheme><method: i.e., -F[c|n|p[<origin>|v][a|t|s|r] or -Fp<origin>
* -F<scheme><method: i.e., -F[c|n|p[<origin>|v][a|r|s|t] or -Fp<origin>
* where <scheme> is c = continuous [Default], n = network, r = reference point, and v = vectors.
* and impact is a = all tables, t = per table, s = per segment [Default], r = per record.
* Four different segmentizing schemes:
Expand All @@ -10191,8 +10192,8 @@ unsigned int gmt_parse_segmentize (struct GMT_CTRL *GMT, char option, char *in_a
* given as a, f, s and if so we pick the first point in the dataset, or first point in each
* file, or the first point in each segment to update the actual reference point.
* 4) -Fv: Vectorize. Here, consecutive points are turned into vector segments such as used
* by psxy -Sv+s or external applications. Again, appending a|t|s controls if we should
* honor the segment headers [Default is -Fvs if -Fv is given]. Only a|t|s is allowed.
* by gmt plot -Sv+s or external applications. Again, appending a|s|t controls if we should
* honor the segment headers [Default is -Fvs if -Fv is given]. Only a|t|s is allowed in plot.
*/

unsigned int k, errors = 0;
Expand Down Expand Up @@ -10228,8 +10229,10 @@ unsigned int gmt_parse_segmentize (struct GMT_CTRL *GMT, char option, char *in_a
GMT_Report (GMT->parent, GMT_MSG_ERROR, "Option -%c: Only -Fp may accept refpoint = r\n", option);
errors++;
}
if (mode == 1 && S->method == SEGM_VECTOR) /* Only available for gmtconvert */
if (mode == 1 && S->method == SEGM_VECTOR) { /* Only available for gmtconvert */
GMT_Report (GMT->parent, GMT_MSG_ERROR, "Option -%c: Method v is only available in gmt select\n", option);
errors++;
}
return (errors);
}

Expand Down Expand Up @@ -14327,7 +14330,7 @@ void gmt_end (struct GMT_CTRL *GMT) {
fflush (GMT->session.std[GMT_OUT]); /* Make sure output buffer is flushed */

gmtlib_free_ogr (GMT, &(GMT->current.io.OGR), 1); /* Free up the GMT/OGR structure, if used */
gmtlib_free_tmp_arrays (GMT); /* Free emp memory for vector io or processing */
gmtlib_free_tmp_arrays (GMT); /* Free temp memory for vector io or processing */
gmtinit_free_user_media (GMT);
/* Terminate PSL machinery (if used) */
PSL_endsession (GMT->PSL);
Expand Down
4 changes: 2 additions & 2 deletions src/gmt_synopsis.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@

/* Argument for segmentation option */

#define GMT_SEGMENTIZE3 "[c|n|p][a|t|s|r|<refpoint>]"
#define GMT_SEGMENTIZE4 "[c|n|p|v][a|t|s|r|<refpoint>]"
#define GMT_SEGMENTIZE3 "[c|n|p][a|r|s|t|<refpoint>]"
#define GMT_SEGMENTIZE4 "[c|n|p|v][a|r|s|t|<refpoint>]"

/* Argument to *contour programs */

Expand Down
2 changes: 1 addition & 1 deletion src/gmtconvert.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct GMTCONVERT_CTRL {
bool end;
int mode; /* -3, -1, -1, 0, or increment stride */
} E;
struct GMTCONVERT_F { /* -F<mode> */
struct GMTCONVERT_F { /* -F[c|n|p|v][a|r|s|t|<refpoint>] */
bool active;
struct GMT_SEGMENTIZE S;
} F;
Expand Down
4 changes: 2 additions & 2 deletions src/psxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct PSXY_CTRL {
double cap; /* Width of error bar cap or whisker [7p] */
struct GMT_PEN pen;
} E;
struct PSXY_F { /* -F<mode> */
struct PSXY_F { /* -F[c|n|p][a|r|s|t|<refpoint>] */
bool active;
struct GMT_SEGMENTIZE S;
} F;
Expand Down Expand Up @@ -934,7 +934,7 @@ static int parse (struct GMT_CTRL *GMT, struct PSXY_CTRL *Ctrl, struct GMT_OPTIO
break;
case 'F':
n_errors += gmt_M_repeated_module_option (API, Ctrl->F.active);
n_errors += gmt_parse_segmentize (GMT, opt->option, opt->arg, 0, &(Ctrl->F.S));
n_errors += gmt_parse_segmentize (GMT, opt->option, opt->arg, 1, &(Ctrl->F.S));
break;
case 'G': /* Set fill for symbols or polygon */
n_errors += gmt_M_repeated_module_option (API, Ctrl->G.active);
Expand Down

0 comments on commit 49b7ac4

Please sign in to comment.