cfdm.Constructs.filter_by_identity¶
-
Constructs.
filter_by_identity
(*identities)[source]¶ Select metadata constructs by identity.
New in version 1.7.0.
See also
filter_by_axis
,filter_by_data
,filter_by_key
,filter_by_measure
,filter_by_method
,filter_by_naxes
,filter_by_ncdim
,filter_by_ncvar
,filter_by_property
,filter_by_type
,filters_applied
,inverse_filter
,unfilter
Parameters: identities: optional
Select constructs that have any of the given identities.
An identity is specified by a string (e.g.
'latitude'
,'long_name=time'
, etc.); or a compiled regular expression (e.g.re.compile('^atmosphere')
), for which all constructs whose identities match (viare.search
) are selected.If no identities are provided then all constructs are selected.
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 constructc
has four identities:>>> c.identities() ['time', 'long_name=Time', 'foo=bar', 'ncvar%T']
In addition, each construct also has an identity based its construct key (e.g.
'key%dimensioncoordinate2'
)Note that the identifiers of metadata constructs in the output of a
print
ordump
call are always one of its identities, and so may always be used as an identities argument.Returns: Constructs
The selected constructs and their construct keys.
Examples:
Select constructs that have a “standard_name” property of ‘latitude’:
>>> d = c.filter_by_identity('latitude')
Select constructs that have a “long_name” property of ‘Height’:
>>> d = c.filter_by_identity('long_name=Height')
Select constructs that have a “standard_name” property of ‘latitude’ or a “foo” property of ‘bar’:
>>> d = c.filter_by_identity('latitude', 'foo=bar')
Select constructs that have a netCDF variable name of ‘time’:
>>> d = c.filter_by_identity('ncvar%time')