LatLonGrid
- class unifhy.LatLonGrid(latitude, longitude, latitude_bounds, longitude_bounds)
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 aligned with the North pole (EPSG:4326).Instantiation
- Parameters
- latitude: one-dimensional array-like object
The array of latitude coordinates in degrees North 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 from South to North. Coordinates must be regularly spaced.Parameter example:
latitude=[15, 45, 75]
Parameter example:
latitude=numpy.arange(-89.5, 90.5, 1)
- longitude: one-dimensional array-like object
The array of longitude coordinates in degrees East 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 from West to East. Coordinates must be regularly spaced.Parameter example:
longitude=(-150, -90, -30, 30, 90, 150)
Parameter example:
longitude=numpy.arange(-179.5, 180.5, 1)
- latitude_bounds: two-dimensional array-like object
The array of latitude coordinate bounds in degrees North 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 latitude and the second dimension equal to 2. Must contain numerical values.Parameter example:
latitude_bounds=[[0, 30], [30, 60], [60, 90]]
Parameter example:
latitude_bounds=numpy.column_stack( (numpy.arange(-90, 90, 1), numpy.arange(-89, 91, 1)) )
- longitude_bounds: two-dimensional array-like object
The array of longitude coordinate bounds in degrees East 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 longitude and the second dimension equal to 2. Must contain numerical values.Parameter example:
longitude_bounds=((-180, -120), (-120, -60), (-60, 0) (0, 60), (60, 120), (120, 180))
Parameter example:
longitude_bounds=numpy.column_stack( (numpy.arange(-180, 180, 1), numpy.arange(-179, 181, 1)) )
Examples
Instantiating grid using lists:
>>> import numpy >>> sd = LatLonGrid( ... latitude=[15, 45, 75], ... longitude=[30, 90, 150], ... latitude_bounds=[[0, 30], [30, 60], [60, 90]], ... longitude_bounds=[[0, 60], [60, 120], [120, 180]] ... ) >>> print(sd) LatLonGrid( shape {Y, X}: (3, 3) Y, latitude (3,): [15, 45, 75] degrees_north X, longitude (3,): [30, 90, 150] degrees_east Y_bounds (3, 2): [[0, ..., 90]] degrees_north X_bounds (3, 2): [[0, ..., 180]] degrees_east )
Trying to instantiate grid with latitudes from North to South:
>>> sd = LatLonGrid( ... latitude=[75, 45, 15], ... longitude=[30, 90, 150], ... latitude_bounds=[[90, 60], [60, 30], [30, 0]], ... longitude_bounds=[[0, 60], [60, 120], [120, 180]] ... ) Traceback (most recent call last): ... RuntimeError: latitude dimension not directed positively
Trying to instantiate grid with latitude cells of varying width:
>>> sd = LatLonGrid( ... latitude=[15, 45, 75], ... longitude=[30, 90, 150], ... latitude_bounds=[[10, 20], [20, 70], [70, 80]], ... longitude_bounds=[[0, 60], [60, 120], [120, 180]] ... ) Traceback (most recent call last): ... RuntimeError: latitude bounds space gap not constant across region
Methods
Construction
Instantiate a |
|
Instantiate a |
Comparison
Compare equality between the |
|
Compare equality in region spanned between the grid and another instance of |
|
Determine whether the horizontal cell bounds of the grid are overlapping with the cell bounds of another instance of |
Utility
Move the given values from their current location in the |
Attributes
Return the size of the |
|
Return the name of the properties to use to get access to the axes defined for the |
|
Return the X-axis of the |
|
Return the Y-axis of the |
|
Return the bounds of the X-axis of the |
|
Return the bounds of the Y-axis of the |
|
Return the name of the X-axis of the |
|
Return the name of the Y-axis of the |
|
The land-sea mask for the |
|
The information necessary to move any variable laterally (i.e. |
|
The horizontal area for the grid cells of the |