unifhy.TimeDomain.from_field
- classmethod TimeDomain.from_field(field)
Instantiate a
TimeDomain
from temporal dimension coordinate of acf.Field
.- Parameters
- field:
cf.Field
The field object that will be used to initialise a
TimeDomain
instance. This field must feature a ‘time’ construct with bounds, and this construct must feature ‘units’ and ‘calendar’ properties.
- field:
- Returns
Examples
>>> import cf >>> f = cf.Field() >>> d = f.set_construct( ... cf.DimensionCoordinate( ... properties={'standard_name': 'time', ... 'units': 'days since 1970-01-01', ... 'calendar': 'gregorian', ... 'axis': 'T'}, ... data=cf.Data([0, 1, 2, 3]), ... bounds=cf.Bounds(data=cf.Data([[0, 1], [1, 2], ... [2, 3], [3, 4]])) ... ), ... axes=f.set_construct(cf.DomainAxis(size=4)) ... ) >>> td = TimeDomain.from_field(f) >>> print(td) TimeDomain( time (4,): [1970-01-01 00:00:00, ..., 1970-01-04 00:00:00] gregorian bounds (4, 2): [[1970-01-01 00:00:00, ..., 1970-01-05 00:00:00]] gregorian calendar: gregorian units: days since 1970-01-01 period: 4 days, 0:00:00 timedelta: 1 day, 0:00:00 )