cf.Constructs.filter_by_ncvar

Constructs.filter_by_ncvar(*ncvars)[source]

Select domain axis constructs by netCDF variable name.

New in version 1.7.0.

Parameters:
ncvars: optional

Select constructs that have any of the given netCDF variable names.

A netCDF variable name is specified by a string (e.g. 'time'); or a compiled regular expression (e.g. re.compile('^lat')), for which all constructs whose netCDF variable names match (via re.search) are selected.

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

Returns:
Constructs

The selected constructs and their construct keys.

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')