Timeutils module

pygeode.timeutils.conform_values(taxis1, taxis2)[source]

Given two time axes, return new axes such that their values are comparable.

pygeode.timeutils.date_diff(taxis, dt1, dt2, units=None)[source]

Returns time interval between two dates. A time axis must be given to specify the calendar. If no units are specified the units of the given time axis are used.

pygeode.timeutils.delta(taxis, units=None, allow_multiple=False)[source]

Returns the interval between values of a given time axis. If non-unique intervals are found an exception is raised. The units can be specified; if none are given the units of the given time axis are used.

pygeode.timeutils.jointimeaxes(var, yaxis='year', daxis='day')[source]

Convert a variable with a 2D time axis into one with a 1D time axis.

pygeode.timeutils.modify(taxis, resolution=None, exclude=[], include=[], uniquify=False)[source]

Modifies the auxiliary arrays associated with a time axis.

Parameters
taxistime axis instance

Time axis to modify

resolution{None, ‘year’, ‘month’, ‘day’, ‘hour’, ‘minute’, ‘second’}, optional

Finest division to retain.

excludelist of strings, optional

List of arrays to remove

includelist of strings, optional

Explicit list of arrays to include

Returns
taxistime axis instance

Modified time axis

pygeode.timeutils.reltime(taxis, startdate=None, units=None)[source]

Returns time axis values relative to a given reference date. The units can be be specified, if none are given the units of the given time axis are used.

pygeode.timeutils.removeleapyears(data, omitdoy_leap=[60], omitdoy_noleap=[], new_axis_type=<class 'pygeode.timeaxis.ModelTime365'>)[source]

Removes leap day(s) from data on a standard calendar. Casts variable with a StandardTime time axis onto a time axis with a uniform year length by removing days from leap years.

Parameters
dataVar

The variable to modify. Should have a Time axis.

omitdoy_leaplist, optional [ [60] ]

A list of days of the year (e.g. 1 is 1 January, 60 is 29 February) to remove from leap years.

omitdoy_noleaplist, optional [ [] ]

A list of days of the year (e.g. 1 is 1 January, 60 is 1 March) to remove from non-leap years. Can be empty.

new_axis_typeCalendarTime, optional

Time axis class to use instead. Default is ModelTime365. Should expect a year length consistent with the lists passed to omitdoy_leap and omitdoy_noleap

Returns
New Var object with modified time axis and specified days removed
from leap year.
pygeode.timeutils.splittimeaxis(var, iaxis='time')[source]

Convert a variable with a 1D time axis into one with a 2D time axis.

pygeode.timeutils.wrapdate(taxis, dt, allfields=False)[source]

Returns a modified date dictionary such that all fields lie within standard values.