cf.Constructs.filter_by_ncvar

Constructs.filter_by_ncvar(*ncvars, todict=False, cached=None)[source]

Select domain axis constructs by netCDF variable name.

New in version (cfdm): 1.7.0

Parameters
ncvars: optional

Select constructs that have a netCDF variable name, defined by their nc_get_variable methods, that match any of the given values.

If no netCDF variable names are provided then all constructs that do or could have a netCDF variable name are selected.

A value may be any object that can match via the == operator, or a re.Pattern object that matches via its search method.

todict: bool, optional

If True then return a dictionary of constructs keyed by their construct identifiers, instead of a Constructs object. This is a faster option.

New in version (cfdm): 1.8.9.0

cached: optional

If any value other than None then return cached without selecting any constructs.

New in version (cfdm): 1.8.9.0

Returns
Constructs or dict or cached

The selected constructs, or a cached valued.

Examples

Select the constructs with netCDF variable name ‘time’:

>>> d = c.filter_by_ncvar('time')

Select the constructs with netCDF variable name ‘time’ or ‘lat’:

>>> d = c.filter_by_ncvar('time', 'lat')