cf.climatology_cells

cf.climatology_cells(years=True, months=True, days=(1, ), hours=(1, 3, 6), minutes=(), seconds=(), days_instantaneous=False, hours_instantaneous=True, minutes_instantaneous=True, seconds_instantaneous=True)[source]

Return a climatological cells dictionary for cf.aggregate.

Returns a dictionary of temporal frequency conditions that can be passed to the cells parameter of cf.aggregate, and which may be suitable for separating time axis aggregations into the commonly used temporal frequencies typically created by climate models.

The temporal frequency conditions are configurable via parameters, and further customisation may be applied by manually adding conditions to, or removing them from, the returned dictionary.

New in version 3.15.2.

See also

cf.aggregate

Parameters
years: bool, optional

If True, the default, then include a condition for cell sizes of 1 calendar year.

months: bool, optional

If True, the default, then include a condition for cell sizes of 1 calendar month.

days: sequence of numbers, optional

Include a condition for a cell size for each number of days in the sequence. May be an empty sequence. By default the sequence is (1,).

hours: sequence of numbers, optional

Include a condition for a cell size for each number of hours in the sequence. May be an empty sequence. By default the sequence is (1, 3, 6).

minutes: sequence of numbers, optional

Include a condition for a cell size for each number of minutes in the sequence. May be an empty sequence. By default the sequence is ().

seconds: sequence of numbers, optional

Include a condition for a cell size for each number of seconds in the sequence. May be an empty sequence. By default the sequence is ().

days_instantaneous: bool, optional

If True, then also include conditions for cell coordinate spacings with the values given by the days parameter. By default such conditions are not included.

hours_instantaneous: bool, optional

If True, the default, then also include conditions for cell coordinate spacings with the values given by the hours parameter.

minutes_instantaneous: bool, optional

If True then also include conditions for cell coordinate spacings with the values given by the minutes parameter. By default such conditions are not included.

seconds_instantaneous: bool, optional

If True then also include conditions for cell coordinate spacings with the values given by the seconds parameter. By default such conditions are not included.

Returns
dict

A dictionary in the format expected by the cells parameter of the cf.aggregate function. The dictionary has a single key of 'T'.

Examples

>>> cf.climatology_cells()
{'T': [{'cellsize': <CF Query: (isclose 1 hour)>},
  {'cellsize': <CF Query: (isclose 0 hour)>,
   'spacing': <CF Query: (isclose 1 hour)>},
  {'cellsize': <CF Query: (isclose 3 hour)>},
  {'cellsize': <CF Query: (isclose 0 hour)>,
   'spacing': <CF Query: (isclose 3 hour)>},
  {'cellsize': <CF Query: (isclose 6 hour)>},
  {'cellsize': <CF Query: (isclose 0 hour)>,
   'spacing': <CF Query: (isclose 6 hour)>},
  {'cellsize': <CF Query: (isclose 1 day)>},
  {'cellsize': <CF TimeDuration: P1M (Y-M-01 00:00:00)>},
  {'cellsize': <CF TimeDuration: P1Y (Y-01-01 00:00:00)>}]}

Configure the output:

>>> cells = cf.climatology_cells(
...     years=False,
...     hours=(12, 3),
...     days=(),
...     hours_instantaneous=False
... )
>>> cells
{'T': [{'cellsize': <CF Query: (isclose 3 hour)>},
  {'cellsize': <CF Query: (isclose 12 hour)>},
  {'cellsize': <CF TimeDuration: P1M (Y-M-01 00:00:00)>}]}

Add a condition for decadal data:

>>> cells['T'].append({'cellsize': cf.wi(3600, 3660, 'day')})
>>> cells
{'T': [{'cellsize': <CF Query: (isclose 3 hour)>},
  {'cellsize': <CF Query: (isclose 12 hour)>},
  {'cellsize': <CF TimeDuration: P1M (Y-M-01 00:00:00)>},
  {'cellsize': <CF Query: (wi [3600, 3660] day)>}]}