# Using GrADS Station Data

This section describes some of the GrADS commands and functions that are available for analyzing and displaying station data. Please refer to the companion section About Station Data for information on the structure of station data files, how to create them, and how to instruct GrADS to interpret them properly.

Here are some quick links for skipping through this section:

- Operating on Station Data
- Plotting Station Models
- Drawing Arbitrary Cross Sections

## Operating on Station Data

Currently, station data operations and display are supported for three distinct dimension environments:

- X, Y varying (horizontal X, Y plot)
- Z varying (vertical profile)
- T varying (time series)

Operations may be done on station data as with gridded data. Operations between grids and station data are not supported.

Operations between station data are defined as being the operation performed on data points that have exactly the same varying dimension values.

For example, if T is the only varying dimension, the expression:

  `display ts-ds`

  would result in a time series of station data reports being retrieved for two separate variables. Then, for station reports having exactly the same time, the operation is performed. Note that duplicates are ignored, with the operation being performed between the first occurrences encountered.

  When both X and Y are both fixed dimensions, the variable specification may include a station identifier, which specifies a local override for both lat and lon.

  The syntax for this would be:

  `varname(stid=ident)`

  The station identifiers are case insensitive.

  Some functions do not support station data types. These are:

  `hdivg hcurl vint maskout ave aave tloop`

  When X and Y are varying, station data values are displayed as numbers centred at their locations. If two expressions are supplied on the `display` command (ie, `display` ts;ds) then two values are displayed, above and below the station location. The display is controlled by the following `set` commands:

  `set ccolor color
  set dignum digits
  set digsiz size
  set stid on|off
  `

  The `set stid` command controls whether the station identifier is displayed with each value.

  ## Plotting Station Models

  GrADs will plot station models from station data. This is enabled by:

  `set gxout` model

  The appropriate display command is:

  `display u;v;t;d;slp;delta;cld;wx;vis`

  where:

  `u` and `v` are the wind components. A wind barb will be drawn using these values. If either is missing, the station model will not be plotted at all.

  `t, d, slp`, and `delta` are plotted numerically around the station model

  `cld` is the value of the symbol desired at the center of the station model. Values `1` to `9` are assumed to be the marker types (ie, circle, square, crosshair, etc). Values `20` to `25` are assumed to be cloudiness values:

  `20` -clear
  `21` -scattered `22` -broken
  `23` -overcast
  `24` -obscured
  `25` -missing (M plotted)

  `wx` is the value of the `wx` symbol (see `draw wxsym`) to be plotted in the `wx` location.

  `vis` is the visibility as a real number. It will be plotted as a whole number and a fraction.

  When any of these items are missing (other than `u` and `v`), the model is plotted without that element. To represent a globally missing value, enter a constant in the `display` command. For example, if the `delta` were always missing, use:

  `display u;v;t;d;slp;0.0;cld`

  The station models respond to the usual set commands such as `set digsiz`, `set dignum`, `set cthick`, `set ccolor`.

  In addition, there is:

  `set stnopts`

  which will cause the model to plot the number in the slp location as a three digit number, with only the last three digits of the whole number plotted. This allows the standard 3 digit sea level pressure to be plotted by enabling `dig3` and plotting slp*10.

  ## Drawing Arbitrary Cross Sections

  Drawing arbitrary vertical cross sections based on a collection of station data profiles involves transforming station data (scattered observations) into gridded data so as to take advantage of the GrADS grid display and analysis features.

  The first step is to form a collection of 1-D data (Z or T varying). The `collect` command saves station data profiles or time series in memory as a set. The 1-D data may be either real station data or gridded data converted to station data using `gr2stn`.

  The second stop is to convert the collection of station data into a grid for display or analysis purposes. This is accomplished by the new function `coll2gr`.

  `coll2gr` does not yet support time slices; currently, it will only work when the collection of stations is a collection of vertical profiles.

  `coll2gr` produces an output grid that varies in X and Z; the dimension environment used when `coll2gr` is invoked must also be X and Z varying. The X axis of the output grid will contain the equally spaced station profiles and will span the range of the current X dimension environment. The Z axis of the output grid will span the range of the current Z dimension environment and will have either the specified number of levels or a union of the levels. Data points outside of the range of levels will be used for interpolating to within the range if appropriate.

  The X axis of the output grid from `coll2gr` is artificial in terms of the world coordinates -- it doesn't really represent longitudes. A way to completely control the labelling of the display output is provided:

  `set xlabs lab1 | lab2 | lab3 ...
  set ylabs lab1 | lab2 | lab3 ...
  `

  Each label string may include blanks. The labels will be plotted equally spaced along the indicated axis. Spacing can be modified by adding blank strings:

  `set xlabs | | | | lab1 | ...
  `

  Here is a sample script written by M. Fiorino that uses these features:

  `*********************************************************************
  * The following lines will display an arbitrary X section
  * from one specified point to another.
  *
  * lon1 is the westernmost longitude point
  * lon2 is the easternmost longitude point
  * lat1 is the latitude that corresponds to lon1
  * lat2 is the latitude that corresponds to lon2
  *
  * The loop is used to interpolate between points in
  * the arbitrary cross section. This code will plot
  * any cross section as long as you specify the points.
  * My code plots cross sections of PV after I calculated
  * PV on 11 pressure surfaces. I have another script
  * that plots cross sections of potential temperature, and
  * the code is very similar to this, except theta is substituted
  * for PV.
  *
  * Many thanks to Brian Doty at COLA for his help with this code.
  *
  ********************************************************************
  'open pv.ctl'
  'set grads off'
  'set zlog on'
  'set x 1'
  'set y 1'
  'set lev 1000 100'
  lon1 = -95.0
  lon2 = -90.0
  lat1 = 55.0
  lat2 = 15.0
  lon = lon1
  'collect 1 free'
  while (lon <= lon2)
  lat = lat1 + (lat2-lat1)*(lon-lon1) / (lon2-lon1)
  'collect 1 gr2stn(pv,'lon','lat')'
  lon = lon + 1
  endwhile
  'set x 14 16'
  'set xaxis 'lon1' 'lon2
  'set clab on'
  'set gxout shaded'
  'set clevs 0 .5 15'
  'set ccols 0 0 7 0'
  'd coll2gr(1,-u)'
  'set gxout contour'
  'set cint .5'
  'd coll2gr(1,-u)'
  `