momlevel.test_data.time module

time.py - time module for generating test data

momlevel.test_data.time.generate_daily_timeaxis(start_year=1979, nyears=2, calendar='noleap')

Function to generate a daily time axis for testing

Parameters:
  • start_year (int, optional) – Starting year for timeseries, by default 1979

  • nyears (int, optional) – Number of years for test data, by default 2

  • calendar (str, optional) – Valid cftime calendar, by default “noleap”

Returns:

List of cftime datetime objects for specified calendar

Return type:

List[cftime._cftime.Datetime]

momlevel.test_data.time.generate_time_stub(start_year=1981, nyears=5, calendar='noleap', frequency='MS')

Function to generate a dataset with a time coordinate

This function creates a “stub” dataset that can be used a starting point for further test datasets. It returns a cf-time index and related FMS bounds and helper fields. Values for nyears are generated.

Parameters:
  • start_year (int) – Starting year for time coordinate, by default 1981

  • nyears (int) – Number of years of monthly data to generate, by default 5

  • calendar (str) – Cf-time recognized calendar, by default “noleap”

  • frequency (str) – Frequency string compatible with xarray.cftime_range

Returns:

Stub dataset with time coordinate

Return type:

xarray.core.dataset.Dataset