hydro.core¶
Core operations on a CCHDO CF/netCDF file.
Attributes¶
Functions¶
|
|
|
Remove a parameter and/or its ancillary variables from a dataset. |
|
Add a new parameter, and optionally some ancillary associated variables to a dataset. |
|
|
|
|
|
|
Create an empty CF Dataset with the minimum required contents. |
Module Contents¶
- hydro.core.dataarray_factory(param, ctype='data', N_PROF=0, N_LEVELS=0, strlen=0)[source]¶
- Parameters:
param (cchdo.params.WHPName)
- Return type:
- hydro.core.remove_param(ds, param, *, delete_param=False, delete_flag=False, delete_error=False, delete_ancillary=False, require_empty=True)[source]¶
Remove a parameter and/or its ancillary variables from a dataset.
Since this function is rather destructive, by default, it is basically a no-op, you must make a choice when calling to delete the parameter or ancillary variable.
- Parameters:
ds (xarray.Dataset) – The dataset to remove a param from.
param (cchdo.params.WHPName | str) – A string or
WHPName
instance of a parameter, strings are in the form"param [unit]"
or"param"
if unitless, e.g."OXYGEN [UMOL/KG]"
or"EXPOCODE"
delete_param (bool) – If True, delete this parameter and all associated ancillary variables. Defaults to False.
delete_flag (bool) – If True, delete this parameters flag, Defaults to False.
delete_error (bool) – If True, delete this parameters error variable. Defaults to False.
delete_ancillary – Currently a no-op.
require_empty (bool) – If True, require that all the variables that will be deleted contain exclusively fill values, defualts to True
- Returns:
A new dataset with the requested variables removed, will return a new dataset even if the results of calling this function are no-op
- Return type:
- hydro.core.add_param(ds, param, *, with_flag=False, with_error=False, with_ancillary=None)[source]¶
Add a new parameter, and optionally some ancillary associated variables to a dataset.
This function is idempotent and will not overwrite any existing data or parameters. To add a flag or error parameter to an existing parameter is done by setting the with_flag or with_error arguments to True.
- Parameters:
ds (xarray.Dataset) – Dataset to add a param to
param (cchdo.params.WHPName | str) – A string or
WHPName
instance of a parameter, strings are in the form"param [unit]"
or"param"
if unitless, e.g."OXYGEN [UMOL/KG]"
or"EXPOCODE"
with_flag (bool) – If True, also add a quality flag variable, defaults to False
with_error (bool) – If True, also add an error variable if one is defined for this parent parameter, defaults to False
with_ancillary – Currently a no-op, hopefully will be used to add ancillary variable for things like analytical temperature
- Returns:
A new dataset with the requested variables added, will return a new dataset even if the results of calling this function are no-op
- Return type:
- hydro.core.add_profile_level(ds, idx, levels)[source]¶
- Parameters:
ds (xarray.Dataset)
- Return type:
- hydro.core.add_level(ds, n_levels=1)[source]¶
- Parameters:
ds (xarray.Dataset)
- Return type:
- hydro.core.add_profile(ds, expocode, station, cast, time, latitude, longitude, profile_type)[source]¶
- Parameters:
ds (xarray.Dataset)
expocode (numpy.typing.ArrayLike)
station (numpy.typing.ArrayLike)
cast (numpy.typing.ArrayLike)
time (numpy.typing.ArrayLike)
latitude (numpy.typing.ArrayLike)
longitude (numpy.typing.ArrayLike)
profile_type (numpy.typing.ArrayLike)
- Return type: