gs_Coordinate
- class gspy.src.classes.data.xarray_gs.Coordinate.Coordinate(xarray_obj)
Accessor to xarray.DataArray to define a Coordinate.
Checks necessary metadata to satisfy the CF convention, and allows use with GIS software. Handles both arbitrary coordinates and standard coordinates defined as x, y, z, or t used within NetCDF files. Standard coordinates have extra checks on the metadata.
See also
Coordinate.from_dict
For instantiation
Coordinate.from_values
For instantiation
- static check_is_projected(name, is_projected)
Checks for a projected standard coordinate x or y
- Parameters:
name (str) – Name of the coordinate
is_projected (bool) – Is the coordinate projected or not
- Returns:
out
- Return type:
str
- static check_standard_coordinates(name, **kwargs)
If this is a standard coordinate do some extra checks on metadata.
- Parameters:
axis (int, optional) – Axis this Coordinate belongs to .
positive (str, optional) – “up” or “down”. Only used if name == ‘z’.
datum (str, optional) – Datum. Only used if name == ‘z’ or ‘t’.
- classmethod from_dict(name, is_projected=False, is_dimension=False, **kwargs)
Specifically generates a coordinate/dimension from a dict.
Automatically checks/generates required Coordinate metadata and bounds. If the coordinate is a “standard coordinate” i.e. (‘x’, ‘y’, ‘z’, ‘t’), extra checks on metadata are performed.
- Parameters:
name (str) – The name of the coordinate to attach
is_projected (bool) – If the coordinate is projected, the standard_name metadata entry needs to change
is_dimension (bool) – If the coordinate is a coordinate-dimension defines its dims as itself
centers (array_like, optional) –
Explicit definition of Coordinate center values. Used for non-uniformly distanced center values.
Has shape (size of dimension, ) defining the center values of each “cell”
increment (scalar, optional) – Increment of the Coordinate centers. Only used if centers is None.
length (int, optional) – Size of the Coordinate centers. Only used if centers is None.
origin (scalar, optional) – Lower limit of the Coordinate centers. Only used if centers is None.
See also
DataArray.DataArray.from_values
For GS standard metadata keywords
Coordinate.check_standard_coordinates
For extra keywords when name in (‘x’, ‘y’, ‘z’, ‘t’)
Example
>>> depth_dict = {"standard_name": "depth", >>> "long_name": "Depth below earth's surface DTM", >>> "units": "m", >>> "null_value": "not_defined", >>> "centers" : [2.5, 7.5, 20.0]} >>> Coordinate.from_dict('depth', **depth_dict)
- classmethod from_values(name, values, is_projected=False, is_dimension=False, **kwargs)
Generate a Coordinate from an array of values.
- Parameters:
name (str) – The name of the coordinate to attach
is_projected (bool) – If the coordinate is projected, the standard_name metadata entry needs to change
is_dimension (bool) – If the coordinate is a coordinate-dimension defines its dims as itself.
centers (array_like, optional) – Explicit definition of Coordinate center values. Used for non-uniformly distanced center values. Has shape (size of dimension, ) defining the center values of each “cell”
increment (scalar, optional) – Increment of the Coordinate centers. Only used if centers is None.
length (int, optional) – Size of the Coordinate centers. Only used if centers is None.
origin (scalar, optional) – Lower limit of the Coordinate centers. Only used if centers is None.
See also
DataArray.DataArray.from_values
For GS convention metadata keywords
Coordinate.check_standard_coordinates
For extra keywords when creating a standard coordinate
Example
>>> depth_dict = {"standard_name": "depth", >>> "long_name": "Depth below earth's surface DTM", >>> "units": "m", >>> "null_value": "not_defined", >>> "centers" : [2.5, 7.5, 20.0]} >>> Coordinate.from_dict('depth', np.r_[2.5, 7.5, 20.0], **depth_dict)