cf.Field.has_construct

Field.has_construct(*identity, **filter_kwargs)[source]

Whether a metadata construct exists.

New in version 3.4.0.

Parameters
identity, filter_kwargs: optional

Select the unique construct returned by f.construct(*identity, **filter_kwargs). See construct for details.

Returns
bool

True if the construct exists, otherwise False.

Examples:

>>> f = cf.example_field(0)
>>> print(f)
Field: specific_humidity (ncvar%q)
----------------------------------
Data            : specific_humidity(latitude(5), longitude(8)) 1
Cell methods    : area: mean
Dimension coords: latitude(5) = [-75.0, ..., 75.0] degrees_north
                : longitude(8) = [22.5, ..., 337.5] degrees_east
                : time(1) = [2019-01-01 00:00:00]
>>> f.has_construct('T')
True
>>> f.has_construct('longitude')
True
>>> f.has_construct('Z')
False