With Ferret as the backend, we can visualize or list data in its native form. Or, we can pre-define a few output rectilinear grids, and pre-compute a mapping function to take a particular curvilinear grid and map it to that output grid. Computing the mapping functions is slow, and so we do this as a separate step ahead of time.
Note that creating a map file is useful even if you don't want to regrid the data to a rectililinear grid. See the section Creating and congfiguring a map file for better zooming, below.
Here is a Ferret script to define a rectilinear grid and compute the mapping function to regrid a curvilinear grid to it. These capabilities are discussed in the Ferret documentation; see CURV_TO_RECT_MAP and CURV_TO_RECT
! Define a 2-degree by 2-degree rectilinear grid.
! Map a curvilinear grid to this output grid, and save the
! mapping function.
! Open the dataset with curvilinear coordinates. Say it's called polar_curvilinear.nc
! And say that the curvilinear longitude and latitude coordinate variables are
! geolon and geolat
let lonin = geolon
let latin = geolat
! Define output grid and a variable on the output grid
! /modulo tells Ferret that longitudes wrap around the earth
def axis/x=2:360:2/modulo/units=degrees xax
def axis/y=-80:90:2/units=degrees yax
! This is a dummy variable, on theXY rectilinear grid
! defined by coordinate axes xax and yax.
let lonlatout = y[gy=yax] + x[gx=xax]
! Compute and save the mapping function as variable MAP
let map = curv_to_rect_map ( lonin,latin,lonlatout, 4)
We could make another map file, say map_5deg_polar.nc with a mapping to a 5- by 5- degree rectilinear grid.
Now, in the xml for the dataset polar_curvilinear.nc, we can add configuration to let the end user choose to map the output onto one of these grids.
As in the last section, put ferret properties pointing to the curvilinear coordinate variables. Add to that a property called <curv_coord_mapvar> pointing to the name of the mapping variable. Here, that is "map". Also add any number of <curvi_coord_map2file> properties with the mapping-file names and locations.
Include the <ui> element so that the constraint is available to regrid curvilinear to rectilinear data.
<curvi_coord_lon>GEOLON</curvi_coord_lon> <!-- curv. coords -->
<curvi_coord_lat>GEOLAT</curvi_coord_lat> <!-- curv. coords -->
<curvi_coord_mapvar>map</curvi_coord_mapvar> <!-- mapping function -->
<curvi_coord_map2file>map_2deg_polar.nc</curvi_coord_map2file> <!-- mapping function -->
<curvi_coord_map5file>map_5deg_polar.nc</curvi_coord_map5file> <!-- mapping function -->
The example file Regrid_Curv_Rect.xml contains the information to set up the regridding constraint, which lets the user choose whether to do the regridding, and if several map files are available, which one to use.