data0.verify_dataset
Functions
|
Verify that the given xarray dataset is valid. |
|
Verify that the given variable is in the given xarray dataset. |
|
Return standard coordinate name for given fuzzy match. |
Module Contents
- data0.verify_dataset.verify_dataset(xr_dataset, check_time=True, shift_lons=False, **kwargs)
Verify that the given xarray dataset is valid.
Check to make sure the given dataset is of the expected type and contains the expected coordinates.
- Parameters:
xr_dataset (xarray.Dataset or xarray.DataArray) – The xarray data to verify.
check_time (bool, optional) – If True, verify that the dataset has a ‘time’ coordinate.
shift_lons (bool, optional) – If True, shift the longitude values based on the PM_centered kwarg.
**kwargs (keyword arguments) – Additional keyword arguments to pass to shift_lon_arr().
- Returns:
xr_dataset – The verified xarray dataset.
- Return type:
xarray.Dataset or xarray.DataArray
- data0.verify_dataset.verify_var(xr_dataset, var)
Verify that the given variable is in the given xarray dataset.
- Parameters:
xr_dataset (xarray.Dataset or xarray.DataArray) – The xarray data to verify.
var (str) – The variable name to verify.
- Returns:
True if the variable is in the dataset, otherwise raises a ValueError.
- Return type:
bool
- data0.verify_dataset.fuzzy_coord_match(coord)
Return standard coordinate name for given fuzzy match.
Take in a coordinate name which may be a variation of standard coordinate names (e.g., ‘lat’, ‘latitude’, ‘Latitude’) and returns the standard coordinate name (‘lat’, ‘lon’, ‘time’) for latitude, longitude, and time. Also returns the dummy ‘number’ coordinate from ERA5 data.
- Parameters:
coord (str) – The coordinate name to match.
- Returns:
matched_coord – The standard coordinate name that matches the input coordinate.
- Return type:
str
Examples
>>> fuzzy_coord_match('lat') 'lat' >>> fuzzy_coord_match('latitude') 'lat' >>> fuzzy_coord_match('Latitude') 'lat'