cf.Field

class cf.Field(properties={}, domain=None, data=None, attributes={}, flags=None, ancillary_variables=None, dimensions=None, finalize=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 coordinates and cell measures (which themselves contain data arrays and properties to describe them) and transforms to further describe existing coordinates or to describe how new coordinates may be computed.

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. Values are deep copied.

data : Data, optional

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

domain : Domain, optional

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

attributes : dict, optional

Provide the new field with attributes from the dictionary’s key/value pairs. Values are deep copied.

flags : Flags, optional

Provide the new field with self-describing flag values in a cf.Flags object. The flags are deep copied.

ancillary_variables : AncillaryVariables, optional

Provide the new field with ancillary variable fields in a cf.AncillaryVariables object. The ancillary variables are deep copied.

dimensions : sequence of str, optional

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

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

If the field’s domain has any of the data array’s dimensions, then their sizes must correspond to those of the field’s data array.

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 CellMethods object containing the CF cell methods of the data array.
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.
_FillValue The _FillValue CF property.
first_datum The first element 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.
last_datum The last element of the data 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 Units object containing the units of the data array.
varray A numpy array view of the data array.

Field attributes

ancillary_variables An AncillaryVariables object containing CF ancillary data.
domain The Domain object containing the coordinate system (domain).
Flags A Flags object containing self-describing CF flag values.
id A definitive identity for the variable.
properties A dictionary of the CF properties.
subspace Return a new object which in turn may return a subspace of the field.

Field methods

binary_mask Return a binary missing data mask of the data array.
chunk Partition the field in place for LAMA functionality.
clip Clip (limit) the values in the data array in place.
close Close all files referenced by the field.
coord Return a coordinate of the domain.
copy Return a deep copy.
cos Take the trigonometric cosine of the data array in place.
delprop Delete a CF property.
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.
expand_dims Expand the shape of the data array in place.
finalize Finalize a newly created field.
flip Flip dimensions of the data array and domain in place.
getprop Get a CF property.
hasprop Return True if the variable has a CF property.
identity Return the variable’s identity.
indices Return the indices to the data array which correspond to coordinate values.
insert_data Insert a new data array into the field in place, preserving internal consistency.
match Determine whether or not a field matches the given conditions.
name Return a name for the variable.
override_units Override the data array units in place.
remove_data Remove the fields’s data array in-place, preserving internal consistency.
select Return the field if it matches the given conditions.
setitem Set selected elements of the data array in place.
setmask Set selected elements of the data array’s mask in place.
setprop Set a CF property.
sin Take the trigonometric sine of the data in place.
squeeze Remove size 1 dimensions from the field’s data array in place.
transpose Permute the dimensions of the data array in place.
unsqueeze Insert size 1 dimensions from the field’s domain into its data array in place.

Field arithmetic and comparison operations

See the section on arithmetic and comparison operations.

Table Of Contents

Previous topic

cf.VariableList.subspace

Next topic

cf.Field.add_offset

This Page