cf.FieldList.select_by_construct¶
-
FieldList.select_by_construct(*identities, OR=False, **conditions)[source]¶ Select elements by their metadata constructs.
To find the inverse of the selection, use a list comprehension with the
match_by_constructmethod of the construct elements. For example, to select all constructs that do not have a “latitude” metadata construct:>>> gl = cf.FieldList( ... f for f in fl if not f.match_by_construct('latitude') ... )
Note
The API changed at version 3.1.0
New in version 3.0.0.
- Parameters
- identities: optional
Identify metadata constructs that have an identity, defined by their
identitiesmethods, that matches any of the given values.If no identities nor conditions (see the conditions parameter) are provided then all constructs are selected.
A value may be any object that can match via the
==operator, or are.Patternobject that matches via itssearchmethod.Note that in the output of a
dumpmethod orprintcall, a construct is always described by an identity that will select it.If a cell method construct identity is given (such as
'method:mean') then it will only be compared with the most recently applied cell method operation.Alternatively, one or more cell method constructs may be identified in a single string with a CF-netCDF cell methods-like syntax for describing both the collapse dimensions, the collapse method, and any cell method construct qualifiers. If N cell methods are described in this way then they will collectively identify the N most recently applied cell method operations. For example,
'T: maximum within years T: mean over years'will be compared with the most two most recently applied cell method operations.- 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:
'domainancillary2', 'longitude'- Parameter example:
'area: mean T: maximum'- Parameter example:
'grid_latitude', 'area: mean T: maximum'
- conditions: optional
Identify the metadata constructs that have any of the given identities or construct keys, and whose data satisfy conditions.
A construct identity or construct key (defined in the same way as by the identities parameter) is given as a keyword name and a condition on its data is given as the keyword value.
The condition is satisfied if any of its data values equals the value provided.
If no conditions nor identities (see the identities parameter) are provided then all list elements are selected.
- Parameter example:
longitude=180.0- Parameter example:
time=cf.dt('1959-12-16')- Parameter example:
latitude=cf.ge(0)- Parameter example:
latitude=cf.ge(0), air_pressure=500- Parameter example:
**{'latitude': cf.ge(0), 'long_name=soil_level': 4}
- OR:
bool, optional If True then return
Trueif at least one metadata construct matches at least one of the criteria given by the identities or conditions arguments. By defaultTrueis only returned if the field constructs matches each of the given criteria.- mode: deprecated at version 3.1.0
Use the OR parameter instead.
constructs: deprecated at version 3.1.0
- Returns
boolThe matching field constructs.
Examples
TODO