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 coordinate reference 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 axes, 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 an axis of the data array already exists in the domain then the it must have the same size as the domain axis. If it does not exist in the domain then a new axis will be created.

By default the axes will either be those defined for the data array by the domain or, if these do not exist, the domain axis identifiers whose sizes unambiguously match the data array.

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 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 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.
rank The number of axes in the domain of the field.
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 to within numerical tolerance.
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.
axes_sizes Return the size a of a domain axis.
axis Return a domain axis identifier.
axis_name Return the canonical name for an axis.
axis_size Return the size a of a domain axis.
binary_mask Return a binary (0 and 1) missing data mask of the data array.
ceil Return the ceiling 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.
collapse Collapse axes of the field.
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 domain axes identifiers 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 Return True if two fields have equivalent data arrays.
equivalent_domain Return True if two fields have equivalent data domains.
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.
floor Return the floor of the data array.
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 Create data array indices based on domain metadata.
insert_aux Insert an auxiliary coordinate object into the domain in place.
insert_axis Insert an axis 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_measure Insert an cell measure object into the domain in place.
insert_ref Insert a coordinate reference object into the domain in place.
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.
items_axes Return the axes of domain items of 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).
max The maximum of the data array.
mean The unweighted mean the data array.
match Test whether or not the field satisfies the given conditions.
measure Return a cf.CellMeasure object of the domain, or its domain identifier.
measures Return cell measure objects of the domain.
method Return the results of a callable method (with arguments) applied to the field.
mid_range The unweighted average of the maximum and minimum of the data array.
min The minimum of the data array.
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.
range The absolute difference between the maximum and minimum of the data array.
ref Return a coordinate reference object of the domain, or its domain identifier.
refs Return coordinate references of the domain.
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.
rint Round elements of the data array to the nearest integer.
roll Roll the field along a cyclic axis.
sample_size The number of non-missing data elements in the data array.
sd The unweighted sample standard deviation of the data array.
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.
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.
sum The sum of the data array.
transpose Permute the axes of the data array in place.
trunc Return the truncated values of the data array.
unsqueeze Insert size 1 axes into the data array of the field.
var The unweighted sample variance of the data array.
weights Return weights for the data array values.
where Set data array elements depending on a condition.

Field class methods

concatenate Join a sequence of fields together.

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

Next topic

cf.Field.add_offset

This Page