cf.FieldList.select_by_naxes

FieldList.select_by_naxes(*naxes)[source]

Select field constructs by property.

To find the inverse of the selection, use a list comprehension with match_by_naxes method of the construct elements. For example, to select all constructs which do not have 3-dimensional data:

>>> gl = cf.FieldList(
...     f for f in fl if not f.match_by_naxes(3)
... )

New in version 3.0.0.

Parameters
naxes: int, optional

Select field constructs whose data spans a particular number of domain axis constructs.

A number of domain axis constructs is given by an int.

If no numbers are provided then all field constructs are selected.

Returns
FieldList

The matching field constructs.

Examples

>>> f = cf.read("file.nc")
>>> f
[<CF Field: specific_humidity(latitude(5), longitude(8)) 1>,
 <CF Field: air_temperature(atmosphere_hybrid_height_coordinate(1), grid_latitude(10), grid_longitude(9)) K>]
>>> f.select_by_naxes()
[<CF Field: specific_humidity(latitude(5), longitude(8)) 1>,
<CF Field: air_temperature(atmosphere_hybrid_height_coordinate(1), grid_latitude(10), grid_longitude(9)) K>]
>>> f.select_by_naxes(1)
[]
>>> f.select_by_naxes(2)
[<CF Field: specific_humidity(latitude(5), longitude(8)) 1>]
>>> f.select_by_naxes(3)
[<CF Field: air_temperature(atmosphere_hybrid_height_coordinate(1), grid_latitude(10), grid_longitude(9)) K>]