cf.FieldList¶
-
class
cf.
FieldList
(fields=None)[source]¶ Bases:
list
An ordered sequence of fields.
Each element of a field list is a field construct.
A field list supports the python list-like operations (such as indexing and methods like
append
).>>> fl = cf.FieldList() >>> len(fl) 0 >>> f <CF Field: air_temperaturetime(12), latitude(73), longitude(96) K> >>> fl = cf.FieldList(f) >>> len(fl) 1 >>> fl = cf.FieldList([f, f]) >>> len(fl) 2 >>> fl = cf.FieldList(cf.FieldList([f] * 3)) >>> len(fl) 3 >>> len(fl + fl) 6
These methods provide functionality similar to that of a built-in list. The main difference is that when a field element needs to be assesed for equality its
equals
method is used, rather than the==
operator.Initialization
Parameters: - fields: (sequence of)
Field
, optional Create a new field list with these fields.
- fields: (sequence of)
Selecting¶
select_by_construct |
TODO |
select_by_identity |
Select field constructs by identity. |
select_by_naxes |
Select field constructs by property. |
select_by_ncvar |
Select field constructs by netCDF variable name. |
select_by_property |
Select field constructs by property. |
select_by_rank |
TODO |
select_by_units |
Select field constructs by units. |
select |
Alias of cf.FieldList.select_by_identity . |
select_field |
Select a unique field construct by its identity. |
__call__ |
Alias for cf.FieldList.select_by_identity . |
Miscellaneous¶
close |
Close all files referenced by each field. |
concatenate |
Join the sequence of fields together. |
copy |
Return a deep copy. |
Aliases¶
select |
Alias of cf.FieldList.select_by_identity . |
__call__ |
Alias for cf.FieldList.select_by_identity . |
List-like operations¶
These methods provide functionality identical to that of a Python
list
, with one exception:
- When a field construct element needs to be assesed for equality, its
equals
method is used, rather than the==
operator. This affects thecount
,index
,remove
,__contains__
,__eq__
and__ne__
methods.
For example
>>> fl.count(x)
is equivalent to
>>> sum(f.equals(x) for f in fl)
append |
Append object to the end of the list. |
clear |
Remove all items from list. |
count |
Return number of occurrences of value |
extend |
Extend list by appending elements from the iterable. |
index |
Return first index of value. |
insert |
Insert object before index. |
pop |
Remove and return item at index (default last). |
remove |
Remove first occurrence of value. |
reverse |
Reverse IN PLACE. |
sort |
Sort of the field list in place. |
__add__ |
The binary arithmetic operation + |
__contains__ |
Called to implement membership test operators. |
__eq__ |
The rich comparison operator == |
__ge__ |
Return self>=value. |
__getitem__ |
Called to implement evaluation of f[index] |
__getslice__ |
Called to implement evaluation of f[i:j] |
__gt__ |
Return self>value. |
__iter__ |
Implement iter(self). |
__iadd__ |
Implement self+=value. |
__imul__ |
Implement self*=value. |
__le__ |
Return self<=value. |
__len__ |
Return len(self). |
__lt__ |
Return self<value. |
__mul__ |
The binary arithmetic operation * |
__ne__ |
The rich comparison operator != |
__repr__ |
Called by the repr built-in function. |
__rmul__ |
Return value*self. |
__setitem__ |
Set self[key] to value. |
__str__ |
Return str(self). |
Special methods¶
__call__ |
Alias for cf.FieldList.select_by_identity . |
__deepcopy__ |
Called by the copy.deepcopy standard library function. |