Grid

class ESMF.Grid(*args, **kwargs)
__del__()

Release the memory associated with a Grid.

Required Arguments:

None

Optional Arguments:

None

Returns:

None
__init__(*args, **kwargs)

Create a logically rectangular Grid object and optionally allocate space for coordinates at a specified stagger location. A grid can be created in-memory or from file, there are two sets of argument for these methods, outlined below.

Grid in memory:

Required arguments for creating a Grid in memory:

max_index: a numpy array which specifies the maximum
index of each dimension of the Grid.

type: np.array

shape: [number of dimensions, 1]

Optional arguments for creating a grid in memory:

num_peri_dims: the number of periodic dimensions (0 or 1).

coord_sys: the coordinates system for the Grid.

Argument values are:

CoordSys.CART

(default) CoordSys.SPH_DEG

CoordSys.SPH_RAD

coord_typekind: the type of the Grid coordinates.

Argument values are:

TypeKind.I4

TypeKind.I8

TypeKind.R4

(default) TypeKind.R8

Grid from file:

Required arguments for creating a Grid from file:

filename: the name of NetCDF file containing the Grid.

filetype: the input file type of the Grid.

Argument values are:

FileFormat.SCRIP

FileFormat.GRIDSPEC

Optional arguments for creating a Grid from file:

is_sphere: Set to True for a spherical grid, or False for
regional. Defaults to True.
add_corner_stagger: Set to True to use the information in the
grid file to add the corner stagger to the Grid. The coordinates for the corner stagger are required for conservative regridding. If not specified, defaults to False.
add_user_area: Set to True to read in the cell area from the Grid
file; otherwise, ESMF will calculate it. Defaults to False.
add_mask: Set to True to generate the mask using the missing_value
attribute defined in ‘varname’. This argument is only supported with filetype FileFormat.GRIDSPEC. Defaults to False.
varname: If add_mask is True, provide a variable name stored in
the grid file and the mask will be generated using the missing value of the data value of this variable. The first two dimensions of the variable has to be the longitude and the latitude dimension and the mask is derived from the first 2D values of this variable even if this data is a 3D, or 4D array. This argument is only supported with filetype FileFormat.GRIDSPEC. Defaults to the empty string.
coord_names: A two-element array containing the longitude and
latitude variable names in a GRIDSPEC file if there are multiple coordinates defined in the file. This argument is only supported with filetype FileFormat.GRIDSPEC. Defaults to None.

The following optional arguments apply to a Grid created either from file or in memory.

staggerloc: the stagger location of the coordinate data.

Argument values are:

2D:

(default) StaggerLoc.CENTER

StaggerLoc.EDGE1

StaggerLoc.EDGE2

StaggerLoc.CORNER

3D:

(default) StaggerLoc.CENTER_VCENTER

StaggerLoc.EDGE1_VCENTER

StaggerLoc.EDGE2_VCENTER

StaggerLoc.CORNER_VCENTER

StaggerLoc.CENTER_VFACE

StaggerLoc.EDGE1_VFACE

StaggerLoc.EDGE2_VFACE

StaggerLoc.CORNER_VFACE

Returns:

Grid
add_coords(staggerloc=None, coord_dim=None, from_file=False)

Add coordinates to a Grid at the specified stagger location.

Required Arguments:

None

Optional Arguments:

staggerloc: the stagger location of the coordinate data.

Argument values are:

2D:

(default) StaggerLoc.CENTER

StaggerLoc.EDGE1

StaggerLoc.EDGE2

StaggerLoc.CORNER

3D:

(default) StaggerLoc.CENTER_VCENTER

StaggerLoc.EDGE1_VCENTER

StaggerLoc.EDGE2_VCENTER

StaggerLoc.CORNER_VCENTER

StaggerLoc.CENTER_VFACE

StaggerLoc.EDGE1_VFACE

StaggerLoc.EDGE2_VFACE

coord_dim: the dimension number of the coordinates to
return (coordinates will not be returned if coord_dim is not specified and staggerlocs is a list with more than one element).

Returns:

None
add_item(item, staggerloc=None, from_file=False)

Allocate space for a Grid item (mask or areas) at a specified stagger location.

Required Arguments:

item: the Grid item to allocate.

Argument values are:

GridItem.AREA

GridItem.MASK

Optional Arguments:

staggerloc: the stagger location of the coordinate data.

Argument values are:

2D:

(default) StaggerLoc.CENTER

StaggerLoc.EDGE1

StaggerLoc.EDGE2

StaggerLoc.CORNER

3D:

(default) StaggerLoc.CENTER_VCENTER

StaggerLoc.EDGE1_VCENTER

StaggerLoc.EDGE2_VCENTER

StaggerLoc.CORNER_VCENTER

StaggerLoc.CENTER_VFACE

StaggerLoc.EDGE1_VFACE

StaggerLoc.EDGE2_VFACE

Returns:

None
get_coords(coord_dim, staggerloc=None)

Return a numpy array of coordinates at a specified stagger location. The returned array is NOT a copy, it is directly aliased to the underlying memory allocated by ESMF.

Required Arguments:

coord_dim: the dimension number of the coordinates to return:
e.g. [x, y, z] = (0, 1, 2), or [lat, lon] = (0, 1)

Optional Arguments:

staggerloc: the stagger location of the coordinate data.

Argument values are:

2D:

(default) StaggerLoc.CENTER

StaggerLoc.EDGE1

StaggerLoc.EDGE2

StaggerLoc.CORNER

3D:

(default) StaggerLoc.CENTER_VCENTER

StaggerLoc.EDGE1_VCENTER

StaggerLoc.EDGE2_VCENTER

StaggerLoc.CORNER_VCENTER

StaggerLoc.CENTER_VFACE

StaggerLoc.EDGE1_VFACE

StaggerLoc.EDGE2_VFACE

Returns:

None
get_item(item, staggerloc=None)

Return a numpy array for a Grid item at a specified stagger location. The returned array is NOT a copy, it is directly aliased to the underlying memory allocated by ESMF.

Required Arguments:

item: the Grid item to allocate.

Argument values are:

GridItem.AREA

GridItem.MASK

Optional Arguments:

staggerloc: the stagger location of the coordinate data.

Argument values are:

2D:

(default) StaggerLoc.CENTER

StaggerLoc.EDGE1

StaggerLoc.EDGE2

StaggerLoc.CORNER

3D:

(default) StaggerLoc.CENTER_VCENTER

StaggerLoc.EDGE1_VCENTER

StaggerLoc.EDGE2_VCENTER

StaggerLoc.CORNER_VCENTER

StaggerLoc.CENTER_VFACE

StaggerLoc.EDGE1_VFACE

StaggerLoc.EDGE2_VFACE

Returns:

None

This Page