RotatedLatLonGrid

class unifhy.RotatedLatLonGrid(grid_latitude, grid_longitude, grid_latitude_bounds, grid_longitude_bounds, grid_north_pole_latitude, grid_north_pole_longitude, north_pole_grid_longitude=0.0)

Bases: unifhy.space.Grid

This class characterises the spatial dimension for a Component as a regular grid on a spherical domain whose coordinates are latitudes and longitudes, and whose rotation axis is not aligned with the North pole. Its ellipsoid and datum are those of WGS 84 (see EPSG:4326).

Instantiation

Parameters
grid_latitude: one-dimensional array-like object

The array of latitude coordinates in degrees defining a spatial dimension of the domain. May be any type that can be cast to a numpy.ndarray. Must contain numerical values.

Parameter example:

grid_latitude=[0.88, 0.44, 0., -0.44, -0.88]
grid_longitude: one-dimensional array-like object

The array of longitude coordinates in degrees defining a spatial dimension of the domain. May be any type that can be cast to a numpy.ndarray. Must contain numerical values.

Parameter example:

grid_longitude=[-2.5, -2.06, -1.62, -1.18]
grid_latitude_bounds: two-dimensional array-like object

The array of latitude coordinate bounds in degrees defining the extent of the grid cell around the coordinate. May be any type that can be cast to a numpy.ndarray. Must be two dimensional with the first dimension equal to the size of grid_latitude and the second dimension equal to 2. Must contain numerical values.

Parameter example:

grid_latitude_bounds=[[1.1, 0.66], [0.66, 0.22],
                      [0.22, -0.22], [-0.22, -0.66],
                      [-0.66, -1.1]]
grid_longitude_bounds: two-dimensional array-like object

The array of longitude coordinate bounds in degrees defining the extent of the grid cell around the coordinate. May be any type that can be cast to a numpy.ndarray. Must be two dimensional with the first dimension equal to the size of grid_longitude and the second dimension equal to 2. Must contain numerical values.

Parameter example:

grid_longitude_bounds=[[-2.72, -2.28], [-2.28, -1.84],
                       [-1.84, -1.4], [-1.4, -0.96]]
grid_north_pole_latitude: int or float

The true latitude (i.e. in EPSG:4326) of the north pole of the rotated grid in degrees North. This parameter is required to project the rotated grid into a true latitude-longitude coordinate system.

grid_north_pole_longitude: int or float

The true longitude (i.e. in EPSG:4326) of the north pole of the rotated grid in degrees East. This parameter is required to project the rotated grid into a true latitude-longitude coordinate system.

north_pole_grid_longitude: int or float, optional

The longitude of the true north pole (i.e. in EPSG:4326) in the rotated grid in degrees. This parameter is optional to project the rotated grid into a true latitude-longitude coordinate system. If not provided, set to default value 0.

Examples

Instantiate 2D grid using lists:

>>> sd = RotatedLatLonGrid(
...     grid_latitude=[-0.88, -0.44, 0., 0.44, 0.88],
...     grid_longitude=[-2.5, -2.06, -1.62, -1.18],
...     grid_latitude_bounds=[[-1.1, -0.66], [-0.66, -0.22], [-0.22, 0.22],
...                           [0.22, 0.66], [0.66, 1.1]],
...     grid_longitude_bounds=[[-2.72, -2.28], [-2.28, -1.84],
...                            [-1.84, -1.4], [-1.4, -0.96]],
...     grid_north_pole_latitude=38.0,
...     grid_north_pole_longitude=190.0,
... )
>>> print(sd)
RotatedLatLonGrid(
    shape {Y, X}: (5, 4)
    Y, grid_latitude (5,): [-0.88, ..., 0.88] degrees
    X, grid_longitude (4,): [-2.5, ..., -1.18] degrees
    Y_bounds (5, 2): [[-1.1, ..., 1.1]] degrees
    X_bounds (4, 2): [[-2.72, ..., -0.96]] degrees
)

Methods

Construction

from_extent_and_resolution

Instantiate a RotatedLatLonGrid from the extent and the resolution of grid_latitude and grid_longitude coordinates (and optional altitude coordinates).

from_field

Instantiate a RotatedLatLonGrid from spatial dimension coordinates of a cf.Field.

Comparison

is_space_equal_to

Compare equality between the RotatedLatLonGrid and the spatial (X, Y, and Z) dimension coordinate in a cf.Field.

spans_same_region_as

Compare equality in region spanned between the RotatedLatLonGrid and another instance of RotatedLatLonGrid.

is_matched_in

Determine whether the horizontal cell bounds of the grid are overlapping with the cell bounds of another instance of Grid.

Utility

route

Move the given values from their current location in the Grid to their downstream/downslope location according to the flow_direction property of Grid.

Attributes

shape

Return the size of the Grid dimension axes as a tuple.

axes

Return the name of the properties to use to get access to the axes defined for the Grid instance as a tuple.

X

Return the X-axis of the Grid instance as a cf.Data instance.

Y

Return the Y-axis of the Grid instance as a cf.Data instance.

X_bounds

Return the bounds of the X-axis of the Grid instance as a cf.Data instance.

Y_bounds

Return the bounds of the Y-axis of the Grid instance as a cf.Data instance.

X_name

Return the name of the X-axis of the Grid instance as a str.

Y_name

Return the name of the Y-axis of the Grid instance as a str.

land_sea_mask

The land-sea mask for the Grid of boolean/binary values (i.e.

flow_direction

The information necessary to move any variable laterally (i.e.

cell_area

The horizontal area for the grid cells of the Grid in square metres given as a cf.Field and returned as a numpy.ndarray.