cf.Field

class cf.Field(properties={}, attributes={}, data=None, domain=None, flags=None, ancillary_variables=None, axes=None, auto_cyclic=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.

auto_cyclic : bool, optional

If False then do not auto-detect cyclic axes. By default cyclic axes are auto-detected with the setcyclic method.

copy : bool, optional

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

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 attributes

ancillary_variables A cf.AncillaryVariables object containing CF ancillary data.
array A numpy array deep copy of the data array.
attributes A dictionary of the attributes which are not CF properties.
data The cf.Data object containing the data array.
day The day of each data array element.
domain The cf.Domain object containing the field’s domain.
dtarray An independent numpy array of date-time objects.
dtvarray A numpy array view the data array converted to date-time objects.
dtype The numpy data type of the data array.
Flags A cf.Flags object containing self-describing CF flag values.
hardmask Whether the mask is hard (True) or soft (False).
hour The hour of each data array element.
isscalar True if and only if the data array is a scalar array.
mask A field containing the mask of the data array.
minute The minute of each data array element.
month The month of each data array element.
ndim Number of dimensions in the data array.
properties A dictionary of the CF properties.
second The second of each data array element.
shape Tuple of the data array’s dimension sizes.
size Number of elements in the data array.
subspace Return a new object which will get or set a subspace of the field.
unique The unique elements of the array.
Units The cf.Units object containing the units of the data array.
varray A numpy array view of the data array.
year The year of each data array element.

Field methods

allclose Returns True if two broadcastable fields have have equal array values
anchor Roll a cyclic axis so that the given value lies in the first coordinate cell.
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.
collapse Collapse axes by statistical calculations.
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.
cyclic Set the cyclicity of an axis.
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.
flip Flip (reverse the direction of) axes of the field.
getattr Get a named attribute.
getprop Get a CF property.
hasattr Return whether an attribute exists.
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 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.
cf.Field.isclose
iscyclic Whether or not a particular axis is cyclic.
item Return an item, 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).
mask_invalid Mask the array where invalid values occur (NaNs or infs).
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.
period Return the period of a potentially cyclic axis.
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.
roll Roll the field along a cylcic axis.
select Return the field if it satisfies the given conditions.
setattr Set a named attribute.
setcyclic Set axes to be cyclic if they meet conditions.
setdata Set data array elements depending on a condition.
setprop Set a CF property.
sin Take the trigonometric sine of the data array.
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 axes of the data array in place.
unsqueeze Insert size 1 axes into the data array of the field.
weights
Parameters:

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.

Container customization

__len__ The built-in function len
__getitem__ x.__getitem__(index) <==> x[index]
__contains__ Membership test operator in

String representations

__repr__ The built-in function repr
__str__ The built-in function str

Table Of Contents

Previous topic

cf.Variable.transpose

Next topic

cf.Field.add_offset

This Page