access_nri_intake.source.utils
#
Shared utilities for writing Intake-ESM builders and their parsers
Module Contents#
Functions#
|
Get start date, end date and frequency of a xarray dataset. Stolen and adapted from the |
|
Parse an ACCESS model filename and return a file id and any time information |
|
Get Intake-ESM datastore entry info from an ACCESS netcdf file |
- exception access_nri_intake.source.utils.EmptyFileError#
Bases:
Exception
Common base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- add_note()#
Exception.add_note(note) – add a note to the exception
- with_traceback()#
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- 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
- time_dim: str
The name of the time dimension
- access_nri_intake.source.utils.parse_access_filename(filename)#
Parse an ACCESS model filename and return a file id and any time information
- Parameters:
- filename: str
The filename to parse with the extension removed
- Returns:
- file_id: str
The file id constructed by redacting time information and replacing non-python characters with underscores
- timestamp: str
A string of the redacted time information (e.g. “1990-01”)
- frequency: str
The frequency of the file if available in the filename
- access_nri_intake.source.utils.parse_access_ncfile(file, time_dim='time')#
Get Intake-ESM datastore entry info from an ACCESS netcdf file
- Parameters:
- file: str
The path to the netcdf file
- time_dim: str
The name of the time dimension
- Returns: