cf.FieldList.select_by_identity¶
-
FieldList.
select_by_identity
(*identities)[source]¶ Select field constructs by identity.
To find the inverse of the selection, use a list comprehension with
match_by_identity
method of the field constucts. For example, to select all field constructs whose identity is not'air_temperature'
:>>> gl = cf.FieldList(f for f in fl if not f.match_by_identity('air_temperature'))
New in version 3.0.0.
See also
select
,select_by_units
,select_by_construct
,select_by_naxes
,select_by_rank
,select_by_property
,cf.Field.match_by_identity
- identities: optional
Select field constructs. By default all field constructs are selected. May be one or more of:
- The identity of a field construct.
A construct identity is specified by a string (e.g.
'air_temperature'
,'long_name=Air Temperature', ``'ncvar%tas'
, etc.); or a compiled regular expression (e.g.re.compile('^air_')
) that selects the relevant constructs whose identities match viare.search
.Each construct has a number of identities, and is selected if any of them match any of those provided. A construct’s identities are those returned by its
identities
method. In the following example, the constructx
has five identities:>>> x.identities() ['air_temperature', 'long_name=Air Temperature', 'foo=bar', 'standard_name=air_temperature', 'ncvar%tas']
Note that in the output of a
print
call ordump
method, a construct is always described by one of its identities, and so this description may always be used as an identities argument.
Returns: FieldList
The matching field constructs.
Examples:
>>> fl [<CF Field: specific_humidity(latitude(73), longitude(96)) 1>, <CF Field: air_temperature(time(12), latitude(64), longitude(128)) K>] >>> fl('air_temperature') [<CF Field: air_temperature(time(12), latitude(64), longitude(128)) K>]