cf.Domain.match_by_ncvar

Domain.match_by_ncvar(*ncvars)[source]

Whether or not the netCDF variable name satisfies conditions.

New in version 3.0.0.

Parameters
ncvars: optional

Define one or more conditions on the netCDF variable name.

A netCDF variable name is specified by a string (e.g. 'lat'), etc.); a Query object (e.g. cf.eq('lon')); or a compiled regular expression (e.g. re.compile('^t')) that is compared with the construct’s netCDF variable name via re.search.

The condition is satisfied if the netCDF variable name, as returned by the nc_get_variable method, exists and equals the condition value.

Returns
bool

Whether or not at least one of the conditions are met.

Examples

>>> f.nc_get_variable()
'time'
>>> f.match_by_ncvar('time')
True
>>> f.match_by_ncvar('t', 'time')
True
>>> f.match_by_ncvar('t')
False
>>> f.match_by_ncvar()
True
>>> import re
>>> f.match_by_ncvar(re.compile('^t'))
True