Bases: cf.space.CfList
A modified list for variables (any object which is subclass of Variable, such as a space, coordinate, etc.) supporting element-wise attribute retrieval and subsetting by phenomena criteria.
When requesting a non-private attribute that the cf list does not have, and the _elements_atts attribute is True, instead of raising an AttributeError a cf list is returned containing the values of the attribute from each of the elements, with a value of None if an element does not have the attribute. The setting of an attribute is as usual, i.e. it is set on the object itself rather that the object’s elements.
Parameters: | sequence (iterable) – Optional. Initialize new list from sequence’s items. |
---|
Overloaded operators
Refer to CfList.
Attributes
Refer to CfList.
Method | Description |
---|---|
append() | As for a built-in list. |
copy() | Create a deep copy. |
count() | As for a built-in list but using numerically tolerant equality. |
dump() | Return a string containing a full description of the each of the list’s elements. |
equals() | Determine whether two lists are congruent element-wise. |
extend() | As for a built-in list. |
extract() | Select list elements which match phenomena criteria. |
index() | As for a built-in list but using numerically tolerant equality. |
insert() | As for a built-in list. |
pop() | As for a built-in list. |
properties() | Return a set of writable, public attributes. |
remove() | As for a built-in list. |
reverse() | As for a built-in list. |
sort() | As for a built-in list. |
Create a deep copy of the list. Equivalent to calling copy.deepcopy on the list.
Returns: | A deep copy of the list. |
---|
Returns: | The number of occurrences of value using numerically tolerant equality. |
---|
Return a string containing a full description of each variable in the list, utilizing each variable’s dump() method.
Parameters: |
|
---|---|
Returns: | A string containing the descriptions of each variable in the list. |
See also
Return True if two instances are congruent in that each pair of their elements are equal.
Equality of numbers is to within a tolerance. Refer to cf for details.
Parameters: |
|
---|---|
Returns: | True if the two objects are congruent, False otherwise. |
Return a subset of a list of variables by selecting only the variables which match conditions on their phenomena.
A variable’s phenomena are its attributes and, if it has any, its size 1 coordinates.
A phenomenon and its conditions are specified with **kwargs parameters.
A variable in the list matches the conditions if and only if it contains all of the specified phenomena and they pass all of their given criteria. A variable always matches no criteria (kwargs={})
A match for a variable is determined by passing the criteria to the variable’s extract() method.
Unless the exact keyword is True, the phenomena identified in different variable elements may vary. For example, the keyword ‘unit’ could identify the ‘units’ phenomenon in one variable and ‘unitary’ in another.
By default, the returned list of variables is a shallow copy of part of the original list (in the same way that a standard slice is). To return a list whose elements are deep copies, set the deep parameter to True.
Parameters: |
|
---|---|
Returns: | A list of variables |
Examples
>>> s
[<CF Space: pressure(30, 24)>,
<CF Space: u_compnt_of_wind(19, 29, 24)>
>>> s.units
['hPa', 'm s-1']
>>> s.extract(units = 'm s-1')
[<CF Space: u_compnt_of_wind(19, 29, 24)>]
>>> t = s.extract(uni = 'm\s*s-1')
>>> t
[<CF Space: u_compnt_of_wind(19, 29, 24)>]
>>> t[0] is s[1]
True
>>> t = s.extract(uni = 'm\s*s-1', deep=True)
>>> t[0] is s[1]
False
Refer to cf.Variable.extract() for more examples.
Returns: | The first index of value using numerically tolerant equality. Restrict the search to the slice start:stop. If stop is None then the slice is :obj:`start:`cf. |
---|
L.insert(index, object) – insert object before index
Return a set of writable, public attribute names, excluding methods.
An attribute created by assigning directly to the __dict__ dictionary (as opposed to using setattr()) will not appear in this set.
Parameters: | nc (bool) – If False then exclude attributes whose names begin “nc”. |
---|---|
Returns: | A set of attribute names. |