Climatology

Docstrings for the Climatology class

Objects

Climatology()
Climatology.make_climatology()
Climatology._get_date_ranges()
Climatology.multiyear_averages()

Climatology class

Climatology()

class Climatology(Coast):
A Python class containing methods for lazily creating climatologies of
NEMO data (or any xarray datasets) and writing to file. Also for resampling
methods.
Climatology.make_climatology()
@staticmethod
def Climatology.make_climatology(ds, output_frequency, monthly_weights=False, time_var_name=time, time_dim_name=t_dim, fn_out=None):

Calculates a climatology for all variables in a supplied dataset.
The resulting xarray dataset will NOT be loaded to RAM. Instead,
it is a set of dask operations. To load to RAM use, e.g. .compute().
However, if the original data was large, this may take a long time and
a lot of memory. Make sure you have the available RAM or chunking
and parallel processes are specified correctly.

Otherwise, it is recommended that you access the climatology data
in an indexed way. I.E. compute only at specific parts of the data
are once.

The resulting cliamtology dataset can be written to disk using
.to_netcdf(). Again, this may take a while for larger datasets.

ds :: xarray dataset object from a Coast object.
output_frequency :: any xarray groupby string. i.e:
                'month'
                'season'
time_var_name :: the string name of the time variable in dataset
time_dim_name :: the string name of the time dimension variable in dataset
fn_out :: string defining full output netcdf file path and name.

Climatology._get_date_ranges()
@staticmethod
def Climatology._get_date_ranges(years, month_periods):

Calculates a list of datetime date ranges for a given list of years and a specified start/end month.

Args:
                years (list): A list of years to calculate date ranges for.
                month_periods (list): A list containing tuples of start and end month integers.
                (i.e. [(3,5),(12, 2)] is Mar -> May, Dec -> Feb). Must be in chronological order.

                Returns:
                                date_ranges (list): A list of tuples, each containing a start and end datetime.date object.

Climatology.multiyear_averages()
@classmethod
def Climatology.multiyear_averages(cls, ds, month_periods, time_var=time, time_dim=t_dim):

Calculate multiyear means for all Data variables in a dataset between a given start and end month.

Args:
                ds (xr.Dataset): xarray dataset containing data.
                month_periods (list): A list containing tuples of start and end month integers.
                (i.e. [(3,5),(12, 2)] is Mar -> May, Dec -> Feb). Must be in chronological order.
                The seasons module can be used for convenience (e.g. seasons.WINTER, seasons.ALL etc. )
                time_var (str): String representing the time variable name within the dataset.
                time_dim (str): String representing the time dimension name within the dataset.
returns:
                ds_mean (xr.Dataset): A new dataset containing mean averages for each data variable across all years and
                date periods. Indexed by the multi-index 'year_period' (i.e. (2000, 'Dec-Feb')).


Last modified November 23, 2022: Updated docstrings from coast repo. (9daee18)