cf.Field

class cf.Field(properties={}, attributes={}, data=None, domain=None, flags=None, ancillary_variables=None, axes=None, finalize=True, copy=True)[source]

Bases: cf.variable.Variable

A field construct according to the CF data model.

A field is a container for a data array and metadata comprising properties to describe the physical nature of the data and a coordinate system (called a domain) which describes the positions of each element of the data array.

The field’s domain may contain dimensions and auxiliary coordinate and cell measure objects (which themselves contain data arrays and properties to describe them) and transform objects.

All components of a field are optional.

Miscellaneous

Field objects are picklable.

Initialization

Parameters :
properties : dict, optional

Provide the new field with CF properties from the dictionary’s key/value pairs.

data : cf.Data, optional

Provide the new field with an N-dimensional data array in a cf.Data object.

domain : cf.Domain, optional

Provide the new field with a coordinate system in a cf.Domain object. By default an empty domain is created.

attributes : dict, optional

Provide the new field with attributes from the dictionary’s key/value pairs.

flags : cf.Flags, optional

Provide the new field with self-describing flag values in a cf.Flags object.

ancillary_variables : cf.AncillaryVariables, optional

Provide the new field with ancillary variable fields in a cf.AncillaryVariables object.

axes : sequence of str, optional

A list of domain axis identifiers ('dimN'), stating the axess, in order, of field’s data array. By default these axis identifiers will be the sequence of consecutive axis identifiers 'dim0' up to 'dimM', where M is the number of axes of the data array, or an empty sequence if the data array is a scalar.

If the field’s domain already defines any of these axes, then their identifiers and sizes must correspond to those of the field’s data array. Otherwise, new axes will be created in the field’s domain.

copy : bool, optional

If False then do not deep copy arguments prior to initialization. By default arguments are deep copied.

finalize : bool, optional

If False then do not finalize the field with its finalize method. By default the field is finalized.

Field CF Properties

add_offset The add_offset CF property.
calendar The calendar CF property.
cell_methods The cf.CellMethods object containing the CF cell methods of the data
comment The comment CF property.
Conventions The Conventions CF property.
_FillValue The _FillValue CF property.
flag_masks The flag_masks CF property.
flag_meanings The flag_meanings CF property.
flag_values The flag_values CF property.
history The history CF property.
institution The institution CF property.
leap_month The leap_month CF property.
leap_year The leap_year CF property.
long_name The long_name CF property.
missing_value The missing_value CF property.
month_lengths The month_lengths CF property.
references The references CF property.
scale_factor The scale_factor CF property.
source The source CF property.
standard_error_multiplier The standard_error_multiplier CF property.
standard_name The standard_name CF property.
title The title CF property.
units The units CF property.
valid_max The valid_max CF property.
valid_min The valid_min CF property.
valid_range The valid_range CF property.

Field data attributes

array A numpy array deep copy of the data array.
data The cf.Data object containing the data array.
dtype The numpy data type of the data array.
hardmask Whether the mask is hard (True) or soft (False).
isscalar True if and only if the data array is a scalar array.
mask A field containing the mask of the data array.
ndim Number of dimensions in the data array.
shape Tuple of the data array’s dimension sizes.
size Number of elements in the data array.
Units The cf.Units object containing the units of the data array.
unsafe_array
varray A numpy array view of the data array.

Field attributes

ancillary_variables A cf.AncillaryVariables object containing CF ancillary data.
domain The cf.Domain object containing the field’s domain.
Flags A cf.Flags object containing self-describing CF flag values.
properties A dictionary of the CF properties.
subspace Return a new object which will get or set a subspace of the field.

Field methods

asdatetime Change the internal representation of data array elements from numeric reference times to datatime-like objects.
asreftime Change the internal representation of data array elements from datatime-like objects to numeric reference times.
aux Return an auxiliary coordinate object of the domain, or its domain identifier.
auxs Return auxiliary coordinate objects of the domain.
axes Return domain axis identifiers from the field.
binary_mask Return a binary (0 and 1) missing data mask of the data array.
chunk Partition the data array.
clip Clip (limit) the values in the data array in place.
close Close all files referenced by the field.
cm Return a cell measure object of the domain, or its domain identifier.
cms Return cell measure objects of the domain.
coord Return a dimension or auxiliary coordinate object of the domain, or its domain identifier.
coords Return dimension and auxiliary coordinate objects of the domain.
copy Return a deep copy.
cos Take the trigonometric cosine of the data array in place.
data_axes Return the axes of the field’s data array.
datum Return an element of the data array as a standard Python scalar.
delattr Delete a named attribute.
delprop Delete a CF property.
dim Return a dimension coordinate object of the domain, or its domain identifier.
dims Return dimension coordinate objects of the domain.
dump Return a string containing a description of the field.
equals True if two fields are logically equal, False otherwise.
equivalent True if and only if two fields are logically equivalent.
equivalent_data Equivelence is defined as both fields having the same data arrays after accounting for different but equivalent units, size one dimensions, different dimension directions and different dimension orders.
equivalent_domain
expand_dims Insert a size 1 axis into the data array.
fill_value Return the data array missing data value.
finalize Finalize a newly created field.
flip Flip axes of the field in place.
getattr Get a named attribute.
getprop Get a CF property.
hasprop Return True if a CF property exists, otherise False.
identity Return the variable’s identity.
indices Return the data array indices which correspond to one dimensional coordinate object values.
insert_aux Insert an auxiliary coordinate object into the domain in place.
insert_axis Insert an axis into the domain in place.
insert_cm Insert an cell measure object into the domain in place.
insert_data Insert a new data array into the field in place.
insert_dim Insert a dimension coordinate object into the domain in place.
insert_transform Insert a transform object into the domain in place.
item Return a domain, or its domain identifier, from the field.
item_axes Return the axes of a domain item of the field.
items Return domain items from the field.
iter Return a single element iterable for the output of a method (with arguments).
match Test whether or not the field satisfies the given conditions.
method Return the results of a callable method (with arguments) applied to the field.
name Return a name for the variable.
override_units Override the data array units in place.
remove_axes Remove and return axes from the field.
remove_axis Remove and return an axis from the field.
remove_data Remove and return the data array of the field.
remove_item Remove and return a domain item from the field.
remove_items Remove and return domain items from the domain.
select Return the field if it satisfies the given conditions.
setattr Set a named attribute.
setdata Set data array elements depending on a condition.
setprop Set a CF property.
sin Take the trigonometric sine of the data array in place.
sort Sort of the field in place.
squeeze Remove size 1 axes from the data array.
subspace Return a new object which will get or set a subspace of the field.
transform Return a transform object of the domain, or its domain identifier.
transforms Return transforms of the domain.
transpose Permute the dimensions of the data array in place.
unsqueeze Insert size 1 axes into the data array of the field.

Field arithmetic and comparison operations

See the section on arithmetic and comparison operations.

Field special methods

Standard library functions

__deepcopy__ Used if copy.deepcopy is called on the variable.
__hash__ x.__hash__() <==> hash(x)

Container customization

__len__
__getitem__ x.__getitem__(index) <==> x[index]
__contains__ Membership test operators

String representations

__repr__
__str__