gs_DataArray
- class gspy.src.classes.data.xarray_gs.DataArray.DataArray(xarray_obj)
Accessor for xarray.DataArray.
See also
DataArray.from_values
for instantiation
- classmethod add_bounds_to_coordinate_dimension(coordinate, name, bounds=None, **kwargs)
For an existing DataArray, compute its bounds and attach them.
Automatically modifies any attached metadata keys.
- Parameters:
coordinate (xarray.DataArray) – Existing DataArray inside an xarray.Dataset
name (str) – Used purely for error messages.
bounds (array_like, optional) –
Has shape (size of dimension, 2) defining the bounds of each “cell” in the coordinate
if not present, bounds are computed. Otherwise assign them.
- Return type:
xarray.DataArray
- static catch_nan(values, name, **kwargs)
Replace NaNs with the defined null_value in the metadata.
- Parameters:
values (array_like) – Values to check
name (str) – Name of the variable being checked
null_value (str, optional) – Number that represents unusable data. default is ‘not_defined’
- Return type:
array_like
- Raises:
If there are NaNs in the values, and no defined null_value in the kwargs, notify the user. –
- static check_metadata(name, **kwargs)
Check the metadata provided and ensure GS standard compliance, i.e. at least long_name, standard_name, and units.
- Parameters:
name (str) – Name of the variable
long_name (str, optional) – CF convention long name
null_value (int or float, optional) – Number that represents unusable data. default is ‘not_defined’
standard_name (str, optional) – CF convention standard name
units (str, optional) – units of the coordinate
- Raises:
Exception – If required metadata is missing.
- classmethod from_values(name, values, **kwargs)
Generates an xarray.DataArray using an array of values
Wraps around the xarray.DataArray instantiator and checks for Nans and adds CF convention metadata entries like valid_range, grid_mapping.
- Parameters:
name (str) – Name of the DataArray.
values (array_like) – Values to assign to the DataArray.
coords (dict, optional) – Dictionary of DataArrays along each dimension of this variable
dtype (dtype, optional) – Coerce values into this dtype.
dimensions (list of str) – names of this variables dimesions
grid_mapping (str, optional) – Name of the grid_mapping. Default is ‘spatial_ref’ and refers to any attached spatial_ref class, handled by gspy
long_name (str, optional) – CF convention long name
null_value (int or float, optional) – Number that represents unusable data. default is ‘not_defined’
standard_name (str, optional) – CF convention standard name
units (str, optional) – units of the coordinate
- Return type:
xarray.DataArray
- property label
- static valid_range(values, name, **kwargs)
Generate a valid range for some values
- Parameters:
values (array_like) – numerical array
name (str) – name of the variable
null_value (scalar, optional) – Representation of unusable data values
dtype (dtype, optional) – Coerce the min, max to this dtype default is values.dtype.
- Returns:
[nanmin(values), nanmax(values)]
- Return type:
array_like