Skip to content

Commit 5736dbc

Browse files
authored
Improve windbarb docs, synopsis and usage for -Q and parsing of -Q (#8314)
* Improve docs for -Q and parsing of -Q THe -Q option now lists the modifiers, and +z only allowed in psbarb. THe docs shows -Q modifiers under the -Q option and not a separate section. * polish rst docs * Pollish * Constant -Q arg string added * Update grdbarb.rst * Update barb.rst
1 parent 634e898 commit 5736dbc

File tree

7 files changed

+68
-62
lines changed

7 files changed

+68
-62
lines changed

doc/rst/source/supplements/windbarbs/barb.rst

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Synopsis
2323
[ |-G|\ *fill* ]
2424
[ |-I|\ *intens* ]
2525
[ |-N| ]
26-
[ |-Q|\ *parameters* ]
26+
[ |-Q|\ *length*\ [**+a**\ *angle*][**+g**\ -\|\ *fill*][**+jb**\|\ **c**\|\ **e**][**+p**\ -\|\ *pen*][**+s**\ *scale*][**+w**\ *width*][**+z**] ]
2727
[ |SYN_OPT-U| ]
2828
[ |SYN_OPT-V| ]
2929
[ |-W|\ [*pen*][*attr*] ]
@@ -56,7 +56,6 @@ interpret the third and fourth columns of the input data as barb length and
5656
width, respectively.
5757
Select a fill with |-G|. If |-G| is set, |-W| will control
5858
whether the outline is drawn or not.
59-
The PostScript code is written to standard output.
6059

6160
Required Arguments
6261
------------------
@@ -132,9 +131,24 @@ Optional Arguments
132131

133132
.. _-Q:
134133

135-
**-Q**\ *parameters*
134+
**-Q**\ *length*\ [**+a**\ *angle*][**+g**\ -\|\ *fill*][**+jb**\|\ **c**\|\ **e**][**+p**\ -\|\ *pen*][**+s**\ *scale*][**+w**\ *width*][**+z**]
136135
Modify wind barb parameters. Append wind barb *length* [Default is 0.5c].
137-
See `Wind Barb Attributes`_ for specifying additional attributes.
136+
Several modifiers may be appended to specify the placement of barbs, their shapes, and the
137+
justification of the wind barb. Below, left and right refers to the
138+
side of the wind barb line when viewed from the start point to the
139+
end point of the segment. Chose among these modifiers:
140+
141+
- **+a** - Set the angle of the wind barb [120].
142+
- **+g** - Turn off *fill* (if -) or set the wind
143+
barb fill [Default fill is used, which may be no fill].
144+
- **+p** - Sets the wind barb pen attributes. If *pen* has a
145+
leading - then the outline is not drawn [Default pen is used, and
146+
outline is drawn].
147+
- **+j** - Determines how the input *x*,\ *y* point relates to the
148+
wind barb. Choose from **b**\ eginning [default], **e**\ nd, or **c**\ enter.
149+
- **+s** - Set the wind speed which corresponds to a long barb [default 5].
150+
- **+w** - Set the *width* of wind barbs.
151+
- **+z** - Input (u,v) wind components instead of (azimuth,speed).
138152

139153
.. |Add_-U| replace:: |Add_-U_links|
140154
.. include:: ../../explain_-U.rst_
@@ -188,9 +202,6 @@ Optional Arguments
188202

189203
.. include:: ../../explain_help.rst_
190204

191-
.. include:: explain_windbarbs.rst_
192-
**+z** to input (u,v) wind components instead of (azimuth,speed)
193-
194205
.. module_common_ends
195206
196207
Examples

doc/rst/source/supplements/windbarbs/explain_windbarbs.rst_

Lines changed: 0 additions & 24 deletions
This file was deleted.

doc/rst/source/supplements/windbarbs/grdbarb.rst

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Synopsis
2323
[ |-G|\ *fill* ]
2424
[ |-I|\ [**x**]\ *dx*\ [/*dy*] ]
2525
[ |-N| ]
26-
[ |-Q|\ *parameters* ]
26+
[ |-Q|\ *length*\ [**+a**\ *angle*][**+g**\ -\|\ *fill*][**+jb**\|\ **c**\|\ **e**][**+p**\ -\|\ *pen*][**+s**\ *scale*][**+w**\ *width*] ]
2727
[ |SYN_OPT-R| ]
2828
[ |-T| ]
2929
[ |SYN_OPT-U| ]
@@ -112,10 +112,24 @@ Optional Arguments
112112

113113
.. _-Q:
114114

115-
**-Q**\ *parameters*
115+
**-Q**\ *length*\ [**+a**\ *angle*][**+g**\ -\|\ *fill*][**+jb**\|\ **c**\|\ **e**][**+p**\ -\|\ *pen*][**+s**\ *scale*][**+w**\ *width*]
116116
Modify wind barb parameters. Append wind barb *length* [Default is 0.5c].
117-
See `Wind Barb Attributes`_ for specifying additional attributes.
118-
117+
Several modifiers may be appended to specify the placement of barbs, their shapes, and the
118+
justification of the wind barb. Below, left and right refers to the
119+
side of the wind barb line when viewed from the start point to the
120+
end point of the segment. Chose among these modifiers:
121+
122+
- **+a** - Set the angle of the wind barb [120].
123+
- **+g** - Turn off *fill* (if -) or set the wind
124+
barb fill [Default fill is used, which may be no fill].
125+
- **+p** - Sets the wind barb pen attributes. If *pen* has a
126+
leading - then the outline is not drawn [Default pen is used, and
127+
outline is drawn].
128+
- **+j** - Determines how the input *x*,\ *y* point relates to the
129+
wind barb. Choose from **b**\ eginning [default], **e**\ nd, or **c**\ enter.
130+
- **+s** - Set the wind speed which corresponds to a long barb [default 5].
131+
- **+w** - Set the *width* of wind barbs.
132+
119133
.. _-R:
120134

121135
.. |Add_-Rgeo| replace:: |Add_-R_auto_table|
@@ -167,8 +181,6 @@ Optional Arguments
167181

168182
.. include:: ../../explain_grd_inout.rst_
169183

170-
.. include:: explain_windbarbs.rst_
171-
172184

173185
Examples
174186
--------
@@ -191,4 +203,4 @@ See Also
191203
--------
192204

193205
:doc:`gmt </gmt>`, :doc:`gmtcolors </gmtcolors>`,
194-
:doc:`grdvector </grdvector>`, :doc:`psbarb`
206+
:doc:`grdvector </grdvector>`, :doc:`barb`

src/windbarbs/grdbarb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ GMT_LOCAL int usage (struct GMTAPI_CTRL *API, int level) {
100100
const char *name = gmt_show_name_and_purpose (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_PURPOSE);
101101
if (level == GMT_MODULE_PURPOSE) return (GMT_NOERROR);
102102
GMT_Usage (API, 0, "usage: %s <gridx> <gridy> %s [-A] [%s] [-C[<cpt>]] [-G<fill>] [-I[x]<dx>/<dy>] "
103-
"%s[-N] %s%s[-Q<params>] [%s] [-T] [%s] [%s] [-W<pen>] [%s] [%s] [-Z] "
104-
"%s [%s] [%s] [%s] [%s]\n", name, GMT_J_OPT, GMT_B_OPT, API->K_OPT, API->O_OPT, API->P_OPT,
103+
"%s[-N] %s%s[-Q%s] [%s] [-T] [%s] [%s] [-W<pen>] [%s] [%s] [-Z] "
104+
"%s [%s] [%s] [%s] [%s]\n", name, GMT_J_OPT, GMT_B_OPT, API->K_OPT, API->O_OPT, API->P_OPT, GMT_BARG_PARAMS,
105105
GMT_Rgeo_OPT, GMT_U_OPT, GMT_V_OPT, GMT_X_OPT, GMT_Y_OPT, API->c_OPT, GMT_f_OPT, GMT_p_OPT, GMT_t_OPT, GMT_PAR_OPT);
106106

107107
if (level == GMT_SYNOPSIS) return (GMT_MODULE_SYNOPSIS);
@@ -197,7 +197,7 @@ GMT_LOCAL int parse (struct GMT_CTRL *GMT, struct GRDBARB_CTRL *Ctrl, struct GMT
197197
Ctrl->N.active = true;
198198
break;
199199
case 'Q': /* Set wind barb parameters */
200-
n_errors += gmt_parse_barb (GMT, opt->arg, &Ctrl->Q.B);
200+
n_errors += gmt_parse_barb (GMT, opt->arg, &Ctrl->Q.B, 0);
201201
break;
202202
case 'T': /* Rescale Cartesian angles */
203203
Ctrl->T.active = true;

src/windbarbs/psbarb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ GMT_LOCAL int usage (struct GMTAPI_CTRL *API, int level) {
112112
const char *name = gmt_show_name_and_purpose (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_PURPOSE);
113113
if (level == GMT_MODULE_PURPOSE) return (GMT_NOERROR);
114114
GMT_Usage (API, 0, "usage: %s [<table>] %s %s [%s] [-C<cpt>] [-D<dx>/<dy>] [-G<fill>|+z] "
115-
"[-I[<intens>]] %s [-N[c|r]] %s%s [-Q[<params>]] [%s] [%s] [-W[<pen>][<attr>]] [%s] [%s] "
115+
"[-I[<intens>]] %s [-N[c|r]] %s%s [-Q[%s[+z]] [%s] [%s] [-W[<pen>][<attr>]] [%s] [%s] "
116116
"[-Z<value>|<file>[+t|T]] [%s] [%s] %s[%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s]\n",
117-
name, GMT_J_OPT, GMT_Rgeoz_OPT, GMT_B_OPT, API->K_OPT, API->O_OPT, API->P_OPT,
117+
name, GMT_J_OPT, GMT_Rgeoz_OPT, GMT_B_OPT, API->K_OPT, API->O_OPT, API->P_OPT, GMT_BARG_PARAMS,
118118
GMT_U_OPT, GMT_V_OPT, GMT_X_OPT, GMT_Y_OPT, GMT_a_OPT, GMT_bi_OPT, API->c_OPT,
119119
GMT_di_OPT, GMT_e_OPT, GMT_f_OPT, GMT_g_OPT, GMT_h_OPT, GMT_i_OPT, GMT_l_OPT, GMT_p_OPT, GMT_q_OPT, GMT_tv_OPT,
120120
GMT_w_OPT, GMT_colon_OPT, GMT_PAR_OPT);
@@ -242,7 +242,7 @@ GMT_LOCAL int parse (struct GMT_CTRL *GMT, struct PSBARB_CTRL *Ctrl, struct GMT_
242242
}
243243
break;
244244
case 'Q': /* Set wind barb parameters */
245-
n_errors += gmt_parse_barb (GMT, opt->arg, &Ctrl->Q.B);
245+
n_errors += gmt_parse_barb (GMT, opt->arg, &Ctrl->Q.B, 1);
246246
break;
247247
case 'T': /* Skip all input files */
248248
Ctrl->T.active = true;

src/windbarbs/windbarb.c

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ void gmt_barb_syntax (struct GMT_CTRL *GMT, char option, char *string, unsigned
4444
* 1 = Accepts +z (not mathangle)
4545
*/
4646
struct GMTAPI_CTRL *API = GMT->parent;
47-
GMT_Usage (API, 1, "\n-%c<params>", option);
47+
GMT_Usage (API, 1, "\n-%c%s[+z]", option, GMT_BARG_PARAMS);
4848
GMT_Usage (API, -2, "%s Append length of wind barbs, with optional modifiers:", string);
49-
GMT_Usage (API, 3, "+a<angle> to set angle of wind barb [120]");
50-
GMT_Usage (API, 3, "+g<fill> to set fill or use - to turn off fill [default fill].");
51-
GMT_Usage (API, 3, "+j<just> to justify wind barb at (b)eginning [default], (e)nd, or (c)enter.");
52-
GMT_Usage (API, 3, "+p[-][<pen>] to set pen attributes, prepend - to turn off outlines [default pen and outline].");
53-
GMT_Usage (API, 3, "+s[scale] to set the wind speed which corresponds to a long wind barb [default 5]");
54-
GMT_Usage (API, 3, "+w[width] to set the width of wind barbs");
55-
if (mode & 1) GMT_Usage (API, 3, "+z if (u,v) wind components are given instead of (azimuth,speed) on input.");
49+
GMT_Usage (API, 3, "+a Append angle of wind barb [120]");
50+
GMT_Usage (API, 3, "+g Set fill or use - to turn off fill [default fill].");
51+
GMT_Usage (API, 3, "+j Append b|c|e to justify wind barb at (b)eginning [default], (e)nd, or (c)enter.");
52+
GMT_Usage (API, 3, "+p Set pen attributes, or prepend - to turn off outlines [default pen and outline].");
53+
GMT_Usage (API, 3, "+s Set the wind speed scale which corresponds to a long wind barb [default 5]");
54+
GMT_Usage (API, 3, "+w Set the width of wind barbs");
55+
if (mode & 1) GMT_Usage (API, 3, "+z Wind components (u,v) are given instead of (azimuth,speed) on input.");
5656
}
5757

5858
int gmt_draw_barb (struct GMT_CTRL *GMT, double x0, double y0, double lat, double theta, double spd, struct GMT_BARB_ATTR B, struct GMT_PEN *pen, struct GMT_FILL *fill, unsigned int outline)
@@ -169,7 +169,7 @@ int gmt_init_barb_param (struct GMT_CTRL *GMT, struct GMT_BARB_ATTR *B, bool set
169169
}
170170

171171
/*! Parser for -Q */
172-
GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL *GMT, char *text, struct GMT_BARB_ATTR *B) {
172+
GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL *GMT, char *text, struct GMT_BARB_ATTR *B, unsigned int mode) {
173173

174174
unsigned int pos = 0, k, error = 0;
175175
bool p_opt = false, g_opt = false;
@@ -191,7 +191,7 @@ GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL *GMT, char *text, struct GMT_BA
191191
B->status |= PSL_VEC_FILL;
192192
if (p[1]) {
193193
if (gmt_getfill (GMT, &p[1], &B->fill)) {
194-
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Bad +g<fill> modifier %c\n", &p[1]);
194+
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Option -Q: Bad +g-|<fill> modifier %c\n", &p[1]);
195195
error++;
196196
}
197197
B->status |= PSL_VEC_FILL2;
@@ -203,7 +203,7 @@ GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL *GMT, char *text, struct GMT_BA
203203
case 'c': B->status |= PSL_VEC_JUST_C; break; /* Input (x,y) refers to center point */
204204
case 'e': B->status |= PSL_VEC_JUST_E; break; /* Input (x,y) refers to end point */
205205
default: /* Bad justifier code */
206-
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Bad +j<just> modifier %c\n", p[1]);
206+
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Option -Q: Bad +j<just> modifier %c\n", p[1]);
207207
error++;
208208
break;
209209
}
@@ -218,7 +218,7 @@ GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL *GMT, char *text, struct GMT_BA
218218
}
219219
if (p[j]) { /* Change default pen */
220220
if (gmt_getpen (GMT, &p[j], &B->pen)) {
221-
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Bad +p<pen> modifier %c\n", &p[1]);
221+
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Option -Q: Bad +p-|<pen> modifier %c\n", &p[1]);
222222
error++;
223223
}
224224
B->status |= PSL_VEC_OUTLINE2; /* Flag that a pen specification was given */
@@ -231,10 +231,15 @@ GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL *GMT, char *text, struct GMT_BA
231231
B->width = (float)gmt_M_to_inch (GMT, &p[1]);
232232
break;
233233
case 'z': /* Input (angle,length) are vector components (dx,dy) instead */
234-
B->status |= PSL_VEC_COMPONENTS;
234+
if (mode == 1) /* Only psbarb can take +z */
235+
B->status |= PSL_VEC_COMPONENTS;
236+
else { /* grdbarb does not take -Q+z */
237+
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Option -Q: Bad modifier +z\n");
238+
error++;
239+
}
235240
break;
236241
default:
237-
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Bad modifier +%c\n", p[0]);
242+
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Option -Q: Bad modifier +%c\n", p[0]);
238243
error++;
239244
break;
240245
}
@@ -252,7 +257,7 @@ GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL *GMT, char *text, struct GMT_BA
252257
}
253258

254259
/*! Parser for -Q */
255-
int gmt_parse_barb (struct GMT_CTRL *GMT, char *text, struct GMT_BARB_ATTR *B) {
260+
int gmt_parse_barb (struct GMT_CTRL *GMT, char *text, struct GMT_BARB_ATTR *B, unsigned int mode) {
256261

257262
char txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""}, txt_c[GMT_LEN256] = {""}, txt_d[GMT_LEN256] = {""};
258263
unsigned int error = 0;
@@ -276,13 +281,13 @@ int gmt_parse_barb (struct GMT_CTRL *GMT, char *text, struct GMT_BARB_ATTR *B) {
276281
}
277282
else {
278283
if (text[0] == '+') { /* No size (use default), just attributes */
279-
error += gmt_parse_barb_v5 (GMT, text, B);
284+
error += gmt_parse_barb_v5 (GMT, text, B, mode);
280285
}
281286
else { /* Size, plus possible attributes */
282287
j = sscanf (text, "%[^+]%s", txt_a, txt_b); /* txt_a should be symbols size with any +<modifiers> in txt_b */
283288
if (j == 1) txt_b[0] = 0; /* No modifiers present, set txt_b to empty */
284289
if (j >= 1) B->length = gmt_M_to_inch (GMT, txt_a); /* Length of barb */
285-
error += gmt_parse_barb_v5 (GMT, txt_b, B);
290+
error += gmt_parse_barb_v5 (GMT, txt_b, B, mode);
286291
}
287292
}
288293

src/windbarbs/windbarb.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#ifndef _GMT_WINDBARB_H
1919
#define _GMT_WINDBARB_H
2020

21+
#define GMT_BARG_PARAMS "<length>[+a<angle>][+g[<fill>|-][+jb|c|e][+p[-|<pen>][+s<scale>][+w>width>]"
22+
2123
struct GMT_BARB_ATTR {
2224
/* Container for common attributes for plot attributes of wind barbs */
2325
unsigned int status; /* Bit flags for barb position information (see GMT_enum_vecattr above) */
@@ -33,6 +35,6 @@ struct GMT_BARB_ATTR {
3335
EXTERN_MSC void gmt_barb_syntax (struct GMT_CTRL *GMT, char option, char *string, unsigned int mode);
3436
EXTERN_MSC int gmt_draw_barb (struct GMT_CTRL *GMT, double x0, double y0, double lat, double theta, double spd, struct GMT_BARB_ATTR B, struct GMT_PEN *pen, struct GMT_FILL *fill, unsigned int outline);
3537
EXTERN_MSC int gmt_init_barb_param (struct GMT_CTRL *GMT, struct GMT_BARB_ATTR *B, bool set, bool outline, struct GMT_PEN *pen, bool do_fill, struct GMT_FILL *fill);
36-
EXTERN_MSC int gmt_parse_barb (struct GMT_CTRL *GMT, char *text, struct GMT_BARB_ATTR *B);
38+
EXTERN_MSC int gmt_parse_barb (struct GMT_CTRL *GMT, char *text, struct GMT_BARB_ATTR *B, unsigned int mode);
3739

3840
#endif /* _GMT_WINDBARB_H */

0 commit comments

Comments
 (0)