cf.Variable.match

Variable.match(prop={}, attr={})[source]

Determine whether or not a variable satisfies conditions.

Conditions may be specified on the variable’s attributes and CF properties.

Parameters :
prop : dict, optional

Dictionary for which each key/value pair is a CF property name and a condition for the property to be tested against. If the value is a sequence of conditions then the attribute matches if at least one of the conditions is passed.

In general, a condition may be any object and it is passed if the attribute is equal to the object, with the following exception:

  • If the property is string-valued, then the condition may be a regular expression pattern recognised by the re module and the condition is passed if the property matches the regular expression. Special characters for the start and end of the string are assumed and need not be included. For example, '.*wind' is equivalent to '^.*wind$'.
attr : dict, optional

Dictionary for which each key/value pair is an attribute name and a condition for the attribute to be tested against. If the value is a sequence of conditions then the attribute matches if at least one of the conditions is passed.

In general, a condition behaves as for prop, with the following exception:

  • For the Units attribute, the condition is passed if the attribute is equivalent (rather than equal) to the object. (Note that this behaviour does not apply to the units attribute.)
Returns :
out : bool

Whether or not the variable matches the given criteria.

Examples

Previous topic

cf.Variable.insert_data

Next topic

cf.Variable.name

This Page