cf.TimeDuration.bounds¶
-
TimeDuration.
bounds
(dt, direction=True)[source]¶ Return a time interval containing a date-time.
The interval spans the time duration and starts and ends at date-times consistent with the time duration’s offset.
New in version 1.2.3.
Parameters: - dt: date-time-like
The date-time to be contained by the interval. dt may be any date-time-like object, such as
cf.Datetime
,datetime.datetime
,netCDF4.netcdftime.datetime
, etc.- Parameter example:
To find bounds around 1999-16-1 in the Gregorian calendar you could use
dt=cf.dt(1999, 1, 16)
ordt=datetime.datetime(1999, 1, 16)
(Seecf.dt
for details).
- calendar:
str
, optional Define the CF calendar for the input date-time and output time interval. By default the calendar of the input date-time is used. If calendar is set, then the calendar of the input date-time is overridden.
- Parameter example:
To set a calendar without leap years:
calendar='noleap'
.
- 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: (
cf.Datetime
,cf.Datetime
) TODOExamples:
TODO
>>> t = cf.M() >>> t.bounds(cf.dt(2000, 1, 1)) (<CF Datetime: 2000-1-1 00:00:00>, <CF Datetime: 2000-2-1 00:00:00>) TODO >>> t.bounds(cf.dt(2000, 1, 1)) (<CF Datetime: 2000-1-1 00:00:00>, <CF Datetime: 2000-2-1 00:00:00>)
>>> t = cf.M(1) >>> t.bounds(cf.dt(2000, 3, 1)) (<CF Datetime: 2000-03-01 00:00:00>, <CF Datetime: 2000-04-01 00:00:00>)
>>> t = cf.M(1, day=15) >>> t.bounds(cf.dt(2000, 3, 1)) (<CF Datetime: 2000-02-15 00:00:00>, <CF Datetime: 2000-03-15 00:00:00>)
>>> t = cf.M(2, day=15) >>> t.bounds(cf.dt(2000, 3, 1), direction=False) (<CF Datetime: 2000-03-15 00:00:00>, <CF Datetime: 2000-01-15 00:00:00>)