cfdm.Constructs.filter_by_identity¶
-
Constructs.filter_by_identity(*identities)[source]¶ Select metadata constructs by identity.
Calling a
Constructsinstance selects metadata constructs by identity and is an alias for thefilter_by_identitymethod.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,unfilterParameters: 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
identitiesmethod. In the following example, the constructxhas four identities:>>> x.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 in the output of a
printcall ordumpmethod, a construct is always described by one of its identities, and so this description may always be used as an identities argument.Returns: ConstructsThe 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')