cf.Constructs.filter_by_identity¶
-
Constructs.filter_by_identity(*identities, todict=False, cached=None, _config={})[source]¶ Select metadata constructs by identity.
Calling a
Constructsinstance is an alias forfilter_by_identity.New in version (cfdm): 1.7.0
See also
filter,filters_applied,inverse_filter,clear_filters_applied,unfilter- Parameters
- identities: optional
Select constructs that have an identity, defined by their
identitiesmethods, that matches any of the given values.
A metadata construct identity.
- A construct has a number of string-valued identities
defined by its
identitiesmethod, 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 are.Patternobject that matches one of a construct’s identities viare.search.Note that in the output of a
dumpmethod orprintcall, a metadata construct is always described by one of its identities, and so this description may always be used as an identity value.
The key of a metadata construct
- Parameter example:
identity='latitude'- todict:
bool, optional If True then return a dictionary of constructs keyed by their construct identifiers, instead of a
Constructsobject. This is a faster option.New in version (cfdm): 1.8.9.0
- cached: optional
If any value other than
Nonethen return cached without selecting any constructs.New in version (cfdm): 1.8.9.0
- _config: optional
Additional parameters for configuring the application of a construct’s
identitiesmethod.New in version (cfdm): 1.8.9.0
- Returns
Constructsordictor cachedThe selected constructs, or a cached valued.
Examples
Select constructs that have a
standard_nameproperty of ‘latitude’:>>> d = c.filter_by_identity('latitude')
Select constructs that have a
long_nameproperty of ‘Height’:>>> d = c.filter_by_identity('long_name=Height')
Select constructs that have a
standard_nameproperty 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')