cf.FieldList.select

FieldList.select(match=None, items=None, rank=None, ndim=None, exact=False, match_and=True, inverse=False)[source]

For each field, return the field if it satisfies the given conditions.

The conditions are defined in the same manner as for cf.Field.match, which tests whether or not a field matches the given criteria.

If the field does not satisfy the conditions then an empty cf.FieldList object is returned.

Note that f.select(**kwargs) is equivalent to FieldList(g for g in f if g.match(**kwargs))

See also

match

Parameters:
match : optional

Set conditions on the field’s CF property and attribute values. See the match parameter of cf.Field.match for details.

items : dict, optional

A dictionary which identifies domain items of the field (dimension coordinate, auxiliary coordinate, cell measure or coordinate reference objects) with corresponding tests on their elements. See the items parameter of cf.Field.match for details.

rank : int or cf.Query, optional

Specify a condition on the number of axes in the field’s domain. See cf.Field.match for details.

ndim : optional

Specify a condition on the number of axes in the field’s data array. See cf.Field.match for details.

exact : bool, optional

The exact parameter applies to the interpretation of string values of the match parameter and of keys of the items parameter. See the exact parameter of cf.Field.match for details.

match_and : bool, optional

By default match_and is True and the field matches if it satisfies the conditions specified by each test parameter (match, items, rank and ndim). If match_and is False then the field will match if it satisfies at least one test parameter’s condition. See the match_and parameter of cf.Field.match for details.

inverse : bool, optional

If True then return the field matches if it does not satisfy the given conditions. See the inverse parameter of cf.Field.match for details.

Returns:
out : cf.Field or cf.FieldList

If a single field matches the given conditions then it is returned, otherwise a field list of the matching fields is returned.

Examples:

Select the field if has exactly four domain axes:

>>> f.select(rank=4)

See cf.Field.match for further examples.