# grdbarb

Plot wind barb field from two component grids

## Synopsis

grdbarb compx.nc compy.nc -J parameters [ -A ] [ -B[p|s]parameters ] [ -C cpt ] [ -G fill ] [ -I[x]dx[/dy] ] [ -N ] [ -Q parameters ] [ -R region ] [ -T ] [ -U[stamp] ] [ -W pen ] [ -X[a|c|f|r][xshift] ] [ -Y[a|c|f|r][yshift] ] [ -Z ] [ -f flags ] [ -p flags ] [ -t transp ]

Note: No space is allowed between the option flag and the associated arguments.

## Description

grdbarb reads two 2-D grid files which represents the x- and y-components of a wind field and produces a wind field plot by drawing wind barbs with orientation and barbs according to the information in the files. Alternatively, polar coordinate r, theta grids may be given instead.

## Required Arguments

compx.nc

  Contains the x-components of the wind field. (See Grid File Formats).

compy.nc

  Contains the y-components of the wind field. (See Grid File Formats).

-J parameters

  Specify the projection. (See full description) (See cookbook summary) (See projections table).

## Optional Arguments

-A

  The grid files contain polar (speed, theta) wind components instead of Cartesian (u, v) components [Default is (u, v)].

-B[p|s]parameters

  Set map boundary frame and axes attributes. (See full description) (See cookbook information).

-C[cpt]

  Use cpt to assign colors based on wind speed. Alternatively, supply the name of a GMT color master dynamic CPT [rainbow] to automatically determine a continuous CPT from the grid’s z-range. If the dynamic CPT has a default range then that range will be imposed instead. Yet another option is to specify -Ccolor1,color2[,color3,…] to build a linear continuous cpt from those colors automatically. In this case color n can be a r/g/b triplet, a color name, or an HTML hexadecimal color (e.g. #aabbcc ).

-G fill

  Sets color or shade for wind barb interiors [Default is no fill].

-I[x]dx[/dy]

  Only plot wind barbs at nodes every x_inc, y_inc apart (must be multiples of original grid spacing). Append m for arc minutes or s for arc seconds. Alternatively, use -Ix to specify the multiples multx[/multy] directly [Default plots every node].

-K (more …)

  Do not finalize the PostScript plot.

-N

  Do NOT clip wind barbs at map boundaries [Default will clip].

-Q parameters

  Modify wind barb parameters. Append wind barb length [Default is 0.5c]. See Wind Barb Attributes for specifying additional attributes.

-R west/east/south/north[/zmin/zmax][+r][+u unit]

> Specify the region of interest. Note: If using modern mode and -R is not provided, the region will be set based on previous plotting commands. If this is the first plotting command in the modern mode levels and -R is not provided, the region will be automatically determined based on the data in table (equivalent to using -Ra). (See full description) (See cookbook information).

> The region may be specified in one of several ways:

> 1. -R west/east/south/north. This is the standard way to specify geographic regions when using map projections where meridians and parallels are rectilinear. The coordinates may be specified in decimal degrees or in [±]dd:mm[:ss.xxx][W|E|S|N] format.

> 2. -R west/south/east/north+r. This form is useful for map projections that are oblique, making meridians and parallels poor choices for map boundaries. Here, we instead specify the lower left corner and upper right corner geographic coordinates, followed by the modifier +r. This form guarantees a rectangular map even though lines of equal longitude and latitude are not straight lines.

> 3. -R g or -R d. These forms can be used to quickly specify the global domain (0/360 for -Rg and -180/+180 for -Rd in longitude, with -90/+90 in latitude).

> 4. -R code1,code2,…[+e|r|R incs]. This indirectly supplies the region by consulting the DCW (Digital Chart of the World) database and derives the bounding regions for one or more countries given by the codes. Simply append one or more comma-separated countries using either the two-character ISO 3166-1 alpha-2 convention (e.g., NO) or the full country name (e.g., Norway). To select a state within a country (if available), append .state (e.g, US.TX), or the full state name (e.g., Texas). To specify a whole continent, spell out the full continent name (e.g., -RAfrica). Finally, append any DCW collection abbreviations or full names for the extent of the collection or named region. All names are case-insensitive. The following modifiers can be appended:

>    > - +r to adjust the region boundaries to be multiples of the steps indicated by inc, xinc/yinc, or winc/einc/sinc/ninc [default is no adjustment]. For example, -R FR+r1 will select the national bounding box of France rounded to nearest integer degree, where inc can be positive to expand the region or negative to shrink the region.

>    > - +R to adjust the region by adding the amounts specified by inc, xinc/yinc, or winc/einc/sinc/ninc [default is no extension], where inc can be positive to expand the region or negative to shrink the region.

>    > - +e to adjust the region boundaries to be multiples of the steps indicated by inc, xinc/yinc, or winc/einc/sinc/ninc, while ensuring that the bounding box is adjusted by at least 0.25 times the increment [default is no adjustment], where inc can be positive to expand the region or negative to shrink the region.

> 5. -R xmin/xmax/ymin/ymax[+u unit] specifies a region in projected units (e.g., UTM meters) where xmin/xmax/ymin/ymax are Cartesian projected coordinates compatible with the chosen projection (-J) and unit is an allowable distance unit [e]; we inversely project to determine the actual rectangular geographic region. For projected regions centered on (0,0) you may use the short-hand -R halfwidth[/halfheight]+u unit, where halfheight defaults to halfwidth if not given. This short-hand requires the +u modifier.

> 6. -R justify lon0/lat0/nx/ny, where justify is a 2-character combination of L|C|R (for left, center, or right) and T|M|B (for top, middle, or bottom) (e.g., BL for lower left). The two character code justify indicates which point on a rectangular region region the lon0/lat0 coordinates refer to and the grid dimensions nx and ny are used with grid spacings given via -I to create the corresponding region. This method can be used when creating grids. For example, -RCM 25/25/50/50 specifies a 50x50 grid centered on 25,25.

> 7. -R gridfile. This will copy the domain settings found for the grid in specified file. Note that depending on the nature of the calling module, this mechanism will also set grid spacing and possibly the grid registration (see Grid registration: The -r option).

> 8. -Ra[uto] or -Re[xact]. Under modern mode, and for plotting modules only, you can automatically determine the region from the data used. You can either get the exact area using -Re [Default if no -R is given] or a slightly larger area sensibly rounded outwards to the next multiple of increments that depend on the data range using -Ra.

-T

  Means the azimuths of Cartesian data sets should be adjusted according to the signs of the scales in the x- and y-directions [Leave alone]. This option can be used to convert vector azimuths in cases when a negative scale is used in one of both directions (e.g., positive down).

-U[label|+c][+j justify][+o dx[/dy]][+t text]

  Draw GMT time stamp logo on plot. (See full description) (See cookbook information).

-V[level]

  Select verbosity level [w]. (See full description) (See cookbook information).

-W pen

  Set pen attributes used for wind barb outlines [Default: width = default, color = black, style = solid].

-X[a|c|f|r][xshift]

  Shift plot origin. (See full description) (See cookbook information).

-Y[a|c|f|r][yshift]

  Shift plot origin. (See full description) (See cookbook information).

-Z

  The theta grid provided contains azimuths rather than directions (implies -A).

-f[i|o]colinfo (more …)

  Specify data types of input and/or output columns.

-p[x|y|z]azim[/elev[/zlevel]][+w lon0/lat0[/z0]][+v x0/y0] (more …)

  Select perspective view.

-t transp[/transp2] (more …)

  Set transparency level(s) in percent.

-^ or just -

  Print a short message about the syntax of the command, then exit (Note: on Windows just use -).

-+ or just +

  Print an extensive usage (help) message, including the explanation of any module-specific option (but not the GMT common options), then exit.

-? or no arguments

  Print a complete usage (help) message, including the explanation of all options, then exit.

--PAR=value

  Temporarily override a GMT default setting; repeatable. See gmt.conf for parameters.

## Grid File Formats

By default GMT writes out grids as single precision floats in a COARDS-complaint netCDF file format. However, GMT is able to produce and read grid files in many other commonly used grid file formats and also facilitates so called “packing” of grids, writing out floating point data as 1- or 2-byte integers. To specify the precision, scale and offset, the user should add the suffix [=ID][+d divisor][+n invalid][+o offset][+s scale], where ID is a two-letter identifier of the grid type and precision, and the scale (or divisor), offset and invalid are the arguments of optional modifiers to be applied to all grid values, Here, invalid is the value used to indicate missing data. In case the ID is not provided, as in +s scale, then a ID=nf is assumed. When reading grids, the format is generally automatically recognized from almost all of those formats that GMT and GDAL combined offer. If not, the same suffix can be added to input grid file names. If reading an image as a grid you can select the band via +b. See grdconvert and Section Grid file format specifications of the GMT Technical Reference for more information regarding GDAL settings.

When reading a netCDF file that contains multiple grids, GMT will read, by default, the first 2-dimensional grid that it can find in that file. To coax GMT into reading another multi-dimensional variable in the grid file, append ?varname to the file name, where varname is the name of the variable. Note that you may need to escape the special meaning of ? in your shell program by putting a backslash in front of it, or by placing the filename and suffix between quotes or double quotes. The ?varname suffix can also be used for output grids to specify a variable name different from the default: “z”. See grdconvert and Sections Modifiers for COARDS-compliant netCDF files and Grid file format specifications of the GMT Technical Reference for more information, particularly on how to read slices of 3-, 4-, or 5-dimensional grids.

When writing a netCDF file, the grid is stored by default with the variable name “z”. To specify another variable name varname, append ?varname to the file name. Note that you may need to escape the special meaning of ? in your shell program by putting a backslash in front of it, or by placing the filename and suffix between quotes or double quotes.

ingrid[=ID|?varname][+b band][+d divisor][+n invalid][+o offset][+s scale]

> Optionally, append =ID for reading a specific file format [Default is =nf] or ?varname for a specific netCDF variable [Default is the first 2-D grid found by GMT]. The following modifiers are supported:

> > - +b - Select a band [Default is 0].

> > - +d - Divide data values by the given divisor [Default is 1].

> > - +n - Replace data values matching invalid with NaN.

> > - +o - Offset data values by the given offset [Default is 0].

> > - +s - Scale data values by the given scale [Default is 1].

> Note: Any offset is added after any scaling.

-G outgrid[=ID][+d divisor][+n invalid][+o offset|a][+s scale|a][:driver[dataType][+c options]]

> Optionally, append =ID for writing a specific file format. The following modifiers are supported:

> > - +d - Divide data values by given divisor [Default is 1].

> > - +n - Replace data values matching invalid with a NaN.

> > - +o - Offset data values by the given offset, or append a for automatic range offset to preserve precision for integer grids [Default is 0].

> > - +s - Scale data values by the given scale, or append a for automatic scaling to preserve precision for integer grids [Default is 1].

> Note: Any offset is added before any scaling. +sa also sets +oa (unless overridden). To write specific formats via GDAL, use =gd and supply driver (and optionally dataType) and/or one or more concatenated GDAL -co options using +c. See the “Writing grids and images” cookbook section for more details.

## Wind Barb Attributes

Several modifiers may be appended to the windbarb-producing options to specify the placement of barbs, their shapes, and the justification of the wind barb. Below, left and right refers to the side of the wind barb line when viewed from the start point to the end point of the segment:

+a angle sets the angle of the wind barb [120].

+g-|fill turns off wind barb fill (if -) or sets the wind barb fill [Default fill is used, which may be no fill].

+p[-][pen] sets the wind barb pen attributes. If pen has a leading - then the outline is not drawn. [Default pen is used, and outline is drawn]

+j just determines how the input x,y point relates to the wind barb. Choose from beginning [default], end, or center.

+s to set the wind speed which corresponds to a long barb [default 5]

+w to set the width of wind barbs

## Examples

Note: Below are some examples of valid syntax for this module. The examples that use remote files (file names starting with `@`) can be cut and pasted into your terminal for testing. Other commands requiring input files are just dummy examples of the types of uses that are common but cannot be run verbatim as written.

Note: Since many GMT plot examples are very short (i.e., one module call between the gmt begin and gmt end commands), we will often present them using the quick modern mode GMT Modern Mode One-line Commands syntax, which simplifies such short scripts.

To draw the wind field given by the files r.nc and theta.nc on a barb plot with 0.1 inch length and centered on the node locations, run:

    gmt grdbarb r.nc theta.nc -Jx5c -A -Q0.1i+jc -png gradient

To plot a geographic data sets given the files comp_x.nc and comp_y.nc, and only plot every 3rd node in either direction, try:

    gmt grdbarb comp_x.nc comp_y.nc -Ix3 -JH0/20c -Q0.1i+jc -png globe

## See Also

gmt, gmtcolors, grdvector, psbarb