cf.FieldList


class cf.FieldList(fields=None)[source]

Bases: list, cfdm.abstract.container.Container

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 assessed 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.

Selecting

select_by_construct

Select field constructs by metadata constructs.

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

Select field constructs by the number of domain axis constructs.

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.

Comparison

equals

Whether two field lists are the same.

Miscellaneous

close

Close all files referenced by each field construct.

concatenate

Join the sequence of fields together.

copy

Return a deep copy.

List-like operations

These methods provide functionality identical to that of a Python list, with one exception:

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__

Called by the str built-in function.

Special methods

__call__

Alias for cf.FieldList.select_by_identity.

__deepcopy__

Called by the copy.deepcopy standard library function.

Deprecated

Methods

select1

Deprecated at version 3.0.0.

set_equals

Deprecated at version 3.0.0.