access_nri_intake.source.utils#
Shared utilities for writing Intake-ESM builders and their parsers
Attributes#
Exceptions#
Common base class for all non-exit exceptions. |
Classes#
Consumes either an xarray dataset or its _indexes attribute, and creates a |
Functions#
|
Get start date, end date and frequency of a xarray dataset. Stolen and adapted from the |
|
Cache xarray open dataset so that multiple opens of the same file can reuse |
Module Contents#
- access_nri_intake.source.utils.FREQUENCY_STATIC = 'fx'#
- access_nri_intake.source.utils.FILENAME_TO_FREQ#
- exception access_nri_intake.source.utils.EmptyFileError#
Bases:
ExceptionCommon base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- class access_nri_intake.source.utils.HashableIndexes(*, ds=None, _indexes=None, drop_indices=None)#
Consumes either an xarray dataset or its _indexes attribute, and creates a hashable representation of the indexes. Can be used to compare datasets & whether they are mergeable based on their indexes, and potentially for labelling grids in a catalog.
- dict#
- xxh#
- keys()#
- access_nri_intake.source.utils.get_timeinfo(ds, filename_frequency, time_dim)#
Get start date, end date and frequency of a xarray dataset. Stolen and adapted from the cosima cookbook, see COSIMA/cosima-cookbook
- Parameters:
- ds: :py:class:`xarray.Dataset`
The dataset to parse the time info from
- filename_frequency: str
Frequency as determined from the filename
- time_dim: str
The name of the time dimension
- Returns:
- start_date: str
The start date of the dataset
- end_date: str
The end date of the dataset
- frequency: str
The frequency of the dataset
- Raises:
- EmptyFileError
If the dataset has a valid unlimited dimension, but no data
- access_nri_intake.source.utils.open_dataset_cached(*args, **kwargs)#
Cache xarray open dataset so that multiple opens of the same file can reuse the returned object. As we don’t currently access the data variable data then we shouldn’t need to worry about xarray’s laziness and the Dataset object should have the needed info even if close()ed.