improver.spotdata.build_spotdata_cube module¶
Functions to create spotdata cubes.
-
improver.spotdata.build_spotdata_cube.build_spotdata_cube(data, name, units, altitude, latitude, longitude, wmo_id, scalar_coords=None, neighbour_methods=None, neighbour_methods_dim=1, grid_attributes=None, grid_attributes_dim=2)[source]¶ Function to build a spotdata cube with expected dimension and auxiliary coordinate structure.
It can be used to create spot data cubes. In this case the data is the spot data values at each site, and the coordinates that describe each site.
It can also be used to create cubes which describe the grid points that are used to extract each site from a gridded field, for different selection method. The selection methods are specified by the neighbour_methods coordinate. The grid_attribute coordinate encapsulates information required to extract data, for example the x/y indices that identify the grid point neighbour.
Examples
For a cube containing diagnostic values:
air_temperature / (K) (index: 5) Dimension coordinates: time - index x Auxiliary coordinates: forecast_period - altitude x latitude x longitude x utc_offset x wmo_site x Scalar coordinates: forecast_reference_time: 2018-07-13 09:00:00 height: 1.5 m
Or for a cube identifying grid point neighbours:
ukvx_grid_neighbour / (1) (spot_index: 100; neighbour_selection_method: 3; grid_attribute: 3) Dimension coordinates: spot_index x - - neighbour_selection_method - x - grid_attribute - - x Auxiliary coordinates: altitude x - - latitude x - - longitude x - - wmo_ids x - - neighbour_selection_method_name - x - grid_attribute_key - - x
where the neighbour_selection dimension coordinate is necessarily numeric, but the string names of the methods can be found in the associated neighbour_selection_method_name auxiliary coordinate, e.g.:
AuxCoord(array(['nearest', 'nearest_land', 'nearest_land_minimumdz', 'bilinear'], dtype='<U22'), standard_name=None, units=Unit('1'), long_name='neighbour_selection_method_name')
The grid attribute coordinate contains the information necessary for extracting and adjusting diagnostic data from a gridded field. The names of the elements of this coordinate can be found in the grid_attribute_key auxiliary coordinate, e.g.:
AuxCoord(array(['x_index', 'y_index', 'vertical_displacement'], dtype='<U22'), standard_name=None, units=Unit('1'), long_name='grid_attribute_key')
- Parameters
data (float or numpy.ndarray) – Float spot data or array of data points from several sites. The spot index should be the first dimension if the array is multi-dimensional (see optional additional dimensions below).
name (str) – Cube name (eg ‘air_temperature’)
units (str) – Cube units (eg ‘K’)
altitude (float or numpy.ndarray) – Float or 1d array of site altitudes in metres
latitude (float or numpy.ndarray) – Float or 1d array of site latitudes in degrees
longitude (float or numpy.ndarray) – Float or 1d array of site longitudes in degrees
wmo_id (str or list) – String or list of site 5-digit WMO identifiers
scalar_coords (list) – Optional list of iris.coords.AuxCoord instances
neighbour_methods (list) – Optional list of neighbour method names, e.g. ‘nearest’
neighbour_methods_dim (int) – Data dimension to match the neighbour method list
grid_attributes (list) – Optional list of grid attribute names, e.g. x-index, y-index
grid_attributes_dim (int) – Data dimension to match the grid attributes list