cf.FieldList

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

Bases: cf.field.Field, list

An ordered sequence of fields.

Each element of a field list is a cf.Field object.

A field list supports the python list-like operations (such as indexing and methods like append), but not the python list arithmetic and comparison behaviours. Any field list arithmetic and comparison operation is applied independently to each field element, so all of the operators defined for a field are allowed.

Initialization

Parameters:
fields: (sequence of) cf.Field, optional

Create a new field list with these fields.

Examples:
>>> fl = cf.FieldList()
>>> len(fl)
0
>>> f
<CF Field: air_temperature() 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

Domain operations

Domain axes

autocyclic For each field, set axes to be cyclic if they meet conditions.

Subspacing

subspace Return a new object which will get or set a subspace of the field.

Mathematical functions

Trigonometry

cos For each field, take the trigonometric cosine of the data array.
sin For each field, take the trigonometric sine of the data array.
tan Take the trigonometric tangent of the data array.

Exponents and logarithms

exp For each field, the exponential of the data array.
log For each field, the logarithm of the data array.

Rounding

ceil For each field, the ceiling of the data array.
floor For each field, floor the data array.
rint For each field, round data array.
trunc For each field, truncate the data array.

Statistics

collapse For each field, collapse axes of the field.

Miscellaneous mathematical functions

clip Clip (limit) the values in the data array in place.

Data array operations

Data array mask

binary_mask For each field, a field of the binary (0 and 1) mask of the data array.
mask For each field, a field of the mask of the data array.

Order and number of dimensions

expand_dims For each field, insert a size 1 axis into the data array.
squeeze For each field, remove size 1 axes from the data array.
transpose For each field, permute the axes of the data array.
unsqueeze For each field, insert size 1 axes into the data array.

Rearranging elements

anchor For each field, roll a cyclic axis so that the given value lies in the first coordinate cell.
flip For each field, flip (reverse the direction of) axes of the field.
roll For each field, roll the field along a cyclic axis.

Regridding operations

regrids For each field, returns the field regridded onto a new latitude-longitude grid.

Logic functions

Comparison

equals True if two field lists are equal, False otherwise.
equivalent True if two field lists are equivalent, False otherwise
equivalent_data Return True if two fields have equivalent data arrays.
equivalent_domain Return True if two fields have equivalent data domains.

Miscellaneous

binary_mask For each field, a field of the binary (0 and 1) mask of the data array.
chunk Partition the data array.
close For each field, close all files referenced by the field.
cf.FieldList.concatenate Join a sequence of fields together.
convert_reference_time Convert reference time data values to have new units.
copy Return a deep copy.
datum Return an element of the data array as a standard Python scalar.
dump For each field, print or return a string containing a description of the field.
fill_value Return the data array missing data value.
identity Return the identity.
insert_data
mask_invalid For each field, mask the array where invalid values occur (NaN or inf).
match
name Return a name.
override_units For each field, override the units.
override_calendar For each field, override the calendar of date-time units.
cf.FieldList.promote
remove_data
select For each field, return the field if it satisfies the given conditions.
weights For each field, return weights for the data array values.
where For each field, set data array elements depending on a condition.

List-like operations

These methods provide functionality similar to that of a built-in list.

append L.append(object) – append object to end
count L.count(value) – return number of occurrences of value
extend L.extend(iterable) – extend list by appending elements from the iterable
index L.index(value, [start, [stop]]) – return first index of value.
insert L.insert(index, object) – insert object before index
pop Raises IndexError if list is empty or index is out of range.
reverse L.reverse() – reverse IN PLACE
sort L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE;
__contains__ Called to implement membership test operators.
__getitem__ Called to implement evaluation of f[index]
__len__
__setitem__ x.__setitem__(i, y) <==> x[i]=y

Arithmetic and comparison operations

Any arithmetic, bitwise or comparison operation is applied independently to each field element of the field list

In particular, the built-in list arithmetic and comparison operator behaviours do not apply. For example, adding 2 to a field list will add 2 to the data array of each of its fields, but the + operator will concatenate two built-in lists.

Comparison operators

__lt__ The rich comparison operator <
__le__ The rich comparison operator <=
__eq__ The rich comparison operator ==
__ne__ The rich comparison operator !=
__gt__ The rich comparison operator >
__ge__ The rich comparison operator >=

Binary arithmetic operators

__add__ The binary arithmetic operation +
__sub__ The binary arithmetic operation -
__mul__ The binary arithmetic operation *
__div__ The binary arithmetic operation /
__truediv__ The binary arithmetic operation / (true division)
__floordiv__ The binary arithmetic operation //
__pow__ The binary arithmetic operations ** and pow
__mod__ The binary arithmetic operation %

Binary arithmetic operators with reflected (swapped) operands

__radd__ The binary arithmetic operation + with reflected operands
__rsub__ The binary arithmetic operation - with reflected operands
__rmul__ The binary arithmetic operation * with reflected operands
__rdiv__ The binary arithmetic operation / with reflected operands
__rtruediv__ The binary arithmetic operation / (true division) with reflected
__rfloordiv__ The binary arithmetic operation // with reflected operands
__rpow__ The binary arithmetic operations ** and pow with reflected
__rmod__ The binary arithmetic operation % with reflected operands

Augmented arithmetic assignments

__iadd__ The augmented arithmetic assignment +=
__isub__ The augmented arithmetic assignment -=
__imul__ The augmented arithmetic assignment *=
__idiv__ The augmented arithmetic assignment /=
__itruediv__ The augmented arithmetic assignment /= (true division)
__ifloordiv__ The augmented arithmetic assignment //=
__ipow__ The augmented arithmetic assignment **=
__imod__ The binary arithmetic operation %=

Unary arithmetic operators

__neg__ The unary arithmetic operation -
__pos__ The unary arithmetic operation +
__abs__ The unary arithmetic operation abs

Binary bitwise operators

__and__ The binary bitwise operation &
__or__ The binary bitwise operation |
__xor__ The binary bitwise operation ^
__lshift__ The binary bitwise operation <<
__rshift__ The binary bitwise operation >>

Binary bitwise operators with reflected (swapped) operands

__rand__ The binary bitwise operation & with reflected operands
__ror__ The binary bitwise operation | with reflected operands
__rxor__ The binary bitwise operation ^ with reflected operands
__rlshift__ The binary bitwise operation << with reflected operands
__rrshift__ The binary bitwise operation >> with reflected operands

Augmented bitwise assignments

__iand__ The augmented bitwise assignment &=
__ior__ The augmented bitwise assignment |=
__ixor__ The augmented bitwise assignment ^=
__ilshift__ The augmented bitwise assignment <<=
__irshift__ The augmented bitwise assignment >>=

Unary bitwise operators

__invert__ The unary bitwise operation ~

Special methods

__deepcopy__ Called by the copy.deepcopy standard library function.
__repr__ Called by the repr built-in function.
__str__ Called by the str built-in function.