BritishNationalGrid

class unifhy.BritishNationalGrid(projection_y_coordinate, projection_x_coordinate, projection_y_coordinate_bounds, projection_x_coordinate_bounds)

Bases: unifhy.space.Grid

This class characterises the spatial dimension for a Component as a regular grid on a cartesian domain whose coordinates are northings and eastings covering Great Britain and Northern Ireland (EPSG:27700).

Instantiation

Parameters
projection_y_coordinate: one-dimensional array-like object

The array of northing coordinates in metres defining a spatial dimension of the domain. May be any type that can be cast to a numpy.ndarray. Must contain numerical values. Coordinates must be ordered positively.

Parameter example:

projection_y_coordinate=[12500, 13500, 14500]

Parameter example:

projection_y_coordinate=numpy.arange(12500, 15500, 1000)
projection_x_coordinate: one-dimensional array-like object

The array of easting coordinates in metres defining a spatial dimension of the domain. May be any type that can be cast to a numpy.ndarray. Must contain numerical values. Coordinates must be ordered positively.

Parameter example:

projection_x_coordinate=(80500, 81500, 82500, 83500)

Parameter example:

projection_x_coordinate=numpy.arange(80500, 84500, 1000)
projection_y_coordinate_bounds: two-dimensional array-like object

The array of northing coordinate bounds in metres 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 projection_y_coordinate and the second dimension equal to 2. Must contain numerical values.

Parameter example:

projection_y_coordinate_bounds=[
    [12e3, 13e3], [13e3, 14e3], [14e3, 15e3]
]

Parameter example:

projection_y_coordinate_bounds=numpy.column_stack(
    (numpy.arange(12000, 15000, 1000),
     numpy.arange(13000, 16000, 1000))
)
projection_x_coordinate_bounds: two-dimensional array-like object

The array of easting coordinate bounds in metres 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 projection_x_coordinate and the second dimension equal to 2. Must contain numerical values.

Parameter example:

projection_x_coordinate_bounds=((80e3, 81e3), (81e3, 82e3),
                                (82e3, 83e3), (83e3, 84e3))

Parameter example:

projection_x_coordinate_bounds=numpy.column_stack(
    (numpy.arange(80000, 84000, 1000),
     numpy.arange(81000, 85000, 1000))
)

Examples

Instantiating a 2D grid:

>>> import numpy
>>> sd = BritishNationalGrid(
...     projection_y_coordinate=[12500, 13500, 14500],
...     projection_x_coordinate=(80500, 81500, 82500, 83500),
...     projection_y_coordinate_bounds=numpy.column_stack(
...         (numpy.arange(12000, 15000, 1000),
...          numpy.arange(13000, 16000, 1000))
...     ),
...     projection_x_coordinate_bounds=numpy.column_stack(
...         (numpy.arange(80000, 84000, 1000),
...          numpy.arange(81000, 85000, 1000))
...     )
... )
>>> print(sd)
BritishNationalGrid(
    shape {Y, X}: (3, 4)
    Y, projection_y_coordinate (3,): [12500, 13500, 14500] m
    X, projection_x_coordinate (4,): [80500, ..., 83500] m
    Y_bounds (3, 2): [[12000, ..., 15000]] m
    X_bounds (4, 2): [[80000, ..., 84000]] m
)

Methods

Construction

from_extent_and_resolution

Instantiate a BritishNationalGrid from the extent and the resolution of northing, easting coordinates.

from_field

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

Comparison

is_space_equal_to

Compare equality between the BritishNationalGrid 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 SpaceDomain in square metres given as a cf.Field and returned as a numpy.ndarray.