cf.TimeDuration.bounds¶

TimeDuration.
bounds
(dt, direction=True)[source]¶ Return a time interval containing a datetime.
The interval spans the time duration and starts and ends at datetimes consistent with the time duration’s offset.
The offset of the time duration is used to modify the bounds.
New in version 1.2.3.
 Parameters
 dt: datetimelike
The datetime to be contained by the interval. dt may be any datetimelike object, such as
cf.Datetime
,datetime.datetime
,netCDF4.netcdftime.datetime
, etc. Parameter example:
To find bounds around 1999161 in the Gregorian calendar you could use
dt=cf.dt(1999, 1, 16)
ordt=datetime.datetime(1999, 1, 16)
(Seecf.dt
for details).
 direction:
bool
, optional If
False
then the bounds are decreasing. By default the bounds are increasing. Note thatt.bounds(dt, direction=False)
is equivalent tot.bounds(dt)[::1]
.
 Returns
tuple
The two bounds.
Examples:
TODO
>>> t = cf.M() >>> t.bounds(cf.dt(2000, 1, 1)) (cftime.DatetimeGregorian(20000101 00:00:00), cftime.DatetimeGregorian(20000201 00:00:00))
>>> t = cf.M(1) >>> t.bounds(cf.dt(2000, 3, 1)) (cftime.DatetimeGregorian(20000301 00:00:00), cftime.DatetimeGregorian(20000401 00:00:00))
>>> t = cf.M(1, day=15) >>> t.bounds(cf.dt(2000, 3, 1)) (cftime.DatetimeGregorian(20000215 00:00:00), cftime.DatetimeGregorian(20000315 00:00:00))
>>> t = cf.M(2, day=15) >>> t.bounds(cf.dt(2000, 3, 1), direction=False) (cftime.DatetimeGregorian(20000315 00:00:00), cftime.DatetimeGregorian(20000115 00:00:00))