cf.Field.match_by_identity

Field.match_by_identity(*identities)[source]

Whether or not the construct identity satisfies conditions.

New in version 3.0.0.

Parameters
identities: optional

Define conditions on the construct identities by one or more of

  • A construct identity. TODO

    A construct has a number of string-valued identities

defined by its identities method, and is selected if any of them match the identity parameter. identity may be a string that equals one of a construct’s identities; or a re.Pattern object that matches one of a construct’s identities via re.search.

Note that in the output of a dump method or print call, a metadata construct is always described by one of its identities, and so this description may always be used as an identity value.

Parameter example:

'latitude'

Parameter example:

``’T’

Parameter example:

'long_name=Cell Area'

Parameter example:

'cellmeasure1'

Parameter example:

'measure:area'

Parameter example:

cf.eq('time')'

Parameter example:

re.compile('^lat')

Parameter example:

To match identities of “T”, or any that start with “lat”: 'T', re.compile('^lat')

Returns
bool

Whether or not at least one of the conditions are met.

Examples

>>> f.match_by_identity('time')
>>> f.match_by_identity(re.compile('^air'))
>>> f.match_by_identity('air_pressure', 'air_temperature')
>>> f.match_by_identity('ncvar%t')