# Using Preprojected Grids

Polar Stereo Preprojected Data
Lambert Conformal Preprojected Data
NMC Eta model
NMC high accuracy polar stereo for SSM/I data
CSU RAMS Oblique Polar Stereo Grids
Pitfalls when using preprojected data

Preprojected data are data already on a map projection. GrADS supports four types of preprojected data:

1. N polar stereo (NMC model projection);
2. S polar stereo (NMC model projection) ;
3. Lambert Conformal (originally for Navy NORAPS model);
4. NMC eta model (unstaggered).
5. More precise N and S polar stereo (hi res SSM/I data)
6. Colorado State University RAMS model (oblique polar stereo; beta)
   When preprojected grids are opened in GrADS, bilinear interpolation constants are calculated and all date are displayed on an internal GrADS lat/lon grid defined by the `xdef` and `ydef` card in the data description or `.ctl` file (that's why it takes longer to "open" a preprojected grid data set).

   It is very important to point out that the internal GrADS grid can be any grid as it is completely independent of the preprojected data grid. Thus, there is nothing stopping you displaying preprojected data on a very high res lon/lat grid (again, defined in the `.ctl` by `xdef` and `ydef`). In fact, you could create and open multiple .ctl files with different resolutions and/or regions which pointed to the same preprojected data file.

   When you do a `display` (i.e., get a grid of data), the preprojected data are bilinearly interpolated to the GrADS internal lat/lon grid. For preprojected scalar fields (e.g., 500 mb heights), the display is adequate and the precision of the interpolation can be controlled by `xdef` and `ydef` to define a higher spatial resolution grid.

   The big virtue of this approach is that all built in GrADS analytic functions (e.g., `aave`, `hcurl`...) continue to work even though the data were not originally on a lon/lat grid. The downside is that you are not looking directly at your data on a geographic map. However, one could always define a .ctl file which simply opened the data file as i,j data and displayed without the map (`set mpdraw` `off`). So, in my opinion, this compromise is not that limiting even if as a modeller you wanted to look at the grid--you just don't get the map background.

   `Preprojected vector fields` are a little trickier, depending on whether the vector is defined relative to the data grid or relative to the Earth. For example, NMC polar stereo grids use winds relative to the data grid and thus must be rotated to the internal GrADS lat/lon grid (again defined in the `.ctl` file by the `xdef` and `ydef` cards).

   The only potential problem with working with preprojected data is defining the projection for GrADS. This is accomplished using a `pdef` card in the data descriptor `.ctl` file.

Polar Stereographic Preprojected Data

Preprojected data on polar stereographic projections (N and S) is defined as at NMC. For the NCEP model GRIB data distributed via anon ftp from ftp.ncep.noaa.gov, the `pdef` card is:

`pdef isize jsize projtype ipole jpole lonref gridinc
pdef 53 45 nps 27 49 -105 190.5`

where,

`ipole` and `jpole` are the (i,j) of the pole referenced from the lower left corner at (1,1) and `gridinc` is the dx in km.

Lambert Conformal Preprojected Data

The Lambert Conformal projection (lcc) was implemented for use with data from the U.S. Navy's limited area model NORAPS. Thus, to work with your lcc data you must express your grid in the context of the Navy lcc grid.

A typical NORAPS Lambert-Conformal grid is described below, including the C code which sets up the internal interpolation.

The`pdef record for a typical NORAPS Lambert-Conformal grid might be:``
pdef 103 69 lcc 30 -88 51.5 34.5 20 40 -88 90000 90000
`

where,

`103` = #pts in x
`69` = #pts in y
`lcc` = Lambert-Conformal
`30` = lat of ref point
`88` = lon of ref point (E is positive, W is negative)
`51.5` = i of ref point
`34.5` = j of ref point
`20` = S true lat
`40` = N true lat
`88` = standard lon
`90000` = dx in M
`90000` = dy in M

NMC Eta model (unstaggered grids)

The NMC eta model "native" grid is awkward to work with because the variables are on staggered (e.g., the grid for winds is not the same as the grid for mass points) and non rectangular (number of points in i is not constant with j) grids. Because any contouring of irregularly gridded data involves interpolation at some point, NMC creates "unstaggered" eta model fields for practical application programs such as GrADS. In the unstaggered grids all variables are placed on a common and rectangular grid (the mass points).

Wind rotation has also been added so that vector data will be properly displayed.

The pdef card for a typical eta model grid is:

`pdef 181 136 eta.u -97.0 41.0 0.38888888 0.37037037`

`181` = #pts in x
`136` = #pts in y
`eta.u` = eta grid, unstaggered
`-97.0` = lon of ref point (E is positive in GrADS, W is negative) [deg]
`41.0` = lat of ref point [deg]
`0.3888` = dlon [deg]
`0.37037` = dlat [deg]

NMC high accuracy polar stereo for SSM/I data

The polar stereo projection used by the original NMC models is not very precise because it assumes the earth is round (eccentricity = 0). While this approximation was reasonable for coarse resolution NWP models, it is inadequate to work with higher resolution data such as SSM/I.

Wind rotation has not been implemented!!! Use only for scalar fields.

`pdef ni nj pse slat slon polei polej dx dy sgn`

`ni` = # points in x
`nj` = # points in y
`slat` = absolute value of the standard latitude
`slon` = absolute value of the standard longitude
`pse` = polar stereo, "eccentric"
`polei` = x index position of the pole (where (0,0) is the index of the first point vice the more typical (1,1) )
`polej` = y index position of the pole (where (0,0) is the index of the first point vice the more typical (1,1) )
`dx` = delta x in km
`dy` = delta y in km
`sgn` = 1 for N polar stereo and -1 for S polar stereo

Source code in GrADS for the lon,lat -> i,j mapping:

Oblique Polar Stereo Grids

The CSU RAMS model uses an oblique polar stereo projection. Wind rotation has not been implemented!!! Use only for scalar fields.

`pdef 26 16 ops 40.0 -100.0 90000.0 90000.0 14.0 9.0 180000.0 180000.0`

`26` = #pts in x
`16` = #pts in y
`ops` = oblique polar stereo
`40.0` = lat of ref point (14.0, 9.0)
`-100.0` = lon of ref point (14.0, 9.0 (E is positive in GrADS, W is negative)
`90000.0` = xref offset [m]
`90000.0` = yref offset [m]
`14.0` = i of ref point
`9.0` = j of ref point
`180000.0` = dx [m]
`180000.0` = dy [m]

Pitfalls when using preprojected data

There are a few gotchas with using preprojected data:

1. the units in the variable definition for the `u` and `v` components must be `33` and `34` (the GRIB standard) respectively, e.g.,

   `u 15 33` u component of the wind at 15 pressure levels
   `v 15 34` v component of the wind at 15 pressure levels

2. wind rotation is handled for polar stereo (N and S) preprojected data, but not for Lambert Conformal, as the Navy rotates the winds relative to earth.
3. the `eta.u` and `ops` projection are still experimental...

## GrADS Display Projections

Now that you hopefully understand GrADS data grids, it is time to discuss display projections. Graphics in GrADS are calculated relative to the internal GrADS data grid `i,j` space, transformed to the display device coordinates (e.g., the screen) and then displayed. That is, the i,j of the graphic element is converted to `lat/lon` and then to `x,y` on the screen via a map projection.

GrADS currently supports four `display projections`:

- lat/lon (or spherical);
- N polar stereo (`set mproj` `nps`);
- S polar stereo (`set mproj` `sps`);
- the Robinson projection (set lon -180 180, set lat -90 90, set mproj robinson).

As you can probably appreciate, the i,j-to-lon/lat-to-screen x,y for `lon/lat` displays is very simple and is considerably more complicated for N and S `polar stereo` projections.

In principle, a Lambert Conformal display projection could be implemented. It just takes work and a simple user interface for setting up that display projection. Actually, the user interface (i.e., "set" calls) is the most difficult problem...

## Summary and Plans

GrADS handles map projections in two different ways. The first is preprojected data where the fields are already on a projection (e.g., Lambert Conformal). It is fairly straightforward to implement other preprojected data projections and we will be fully implementing the NMC eta grid both staggered and unstaggered, "thinned" gaussian grids and the CSU RAMS oblique polar stereo projection. The second is in how i,j graphics (calculated in "grid" space) are displayed on a map background. Currently, only a few basic projections (lon/lat, polar stereo and robinson) are supported, but perhaps the development group will tackle this problem.