cf.Field¶
-
class
cf.
Field
(properties=None, source=None, copy=True, _use_data=True)[source]¶ Bases:
cf.mixin.propertiesdata.PropertiesData
,cfdm.field.Field
A field construct of the CF data model.
The field construct is central to the CF data model, and includes all the other constructs. A field corresponds to a CF-netCDF data variable with all of its metadata. All CF-netCDF elements are mapped to a field construct or some element of the CF field construct. The field construct contains all the data and metadata which can be extracted from the file using the CF conventions.
The field construct consists of a data array and the definition of its domain (that describes the locations of each cell of the data array), field ancillary constructs containing metadata defined over the same domain, and cell method constructs to describe how the cell values represent the variation of the physical quantity within the cells of the domain. The domain is defined collectively by the following constructs of the CF data model: domain axis, dimension coordinate, auxiliary coordinate, cell measure, coordinate reference and domain ancillary constructs.
The field construct also has optional properties to describe aspects of the data that are independent of the domain. These correspond to some netCDF attributes of variables (e.g. units, long_name and standard_name), and some netCDF global file attributes (e.g. history and institution).
NetCDF interface
The netCDF variable name of the construct may be accessed with the
nc_set_variable
,nc_get_variable
,nc_del_variable
andnc_has_variable
methods.The selection of properties to be written as netCDF global attributes may be accessed with the
nc_global_attributes
,nc_clear_global_attributes
andnc_set_global_attribute
methods.Initialization
- Parameters
- properties:
dict
, optional Set descriptive properties. The dictionary keys are property names, with corresponding values. Ignored if the source parameter is set.
- Parameter example:
properties={'standard_name': 'air_temperature'}
Properties may also be set after initialisation with the
set_properties
andset_property
methods.- source: optional
Initialize the properties, data and metadata constructs from those of source.
- copy:
bool
, optional If False then do not deep copy input parameters prior to initialization. By default arguments are deep copied.
- properties:
Inspection¶
Methods
A full description of the field construct. |
|
Return the canonical identity. |
|
Return all possible identities. |
Attributes
Return a description of the construct type. |
|
A canonical identity. |
Selection¶
Methods
Whether or not the construct identity satisfies conditions. |
|
Whether or not the data has a given dimensionality. |
|
Whether or not the netCDF variable name satisfies conditions. |
|
Whether or not properties satisfy conditions. |
|
Whether or not the number of domain axis constructs satisfies conditions. |
|
Whether or not the construct has given units. |
|
Whether or not there are particular metadata constructs. |
Properties¶
Methods
Remove a property. |
|
Get a CF property. |
|
Whether a property has been set. |
|
Set a property. |
|
Return all properties. |
|
Remove all properties. |
|
Set properties. |
Attributes
The add_offset CF property. |
|
The calendar CF property. |
|
Return cell method constructs. |
|
The comment CF property. |
|
The Conventions CF property. |
|
The _FillValue CF property. |
|
The flag_masks CF property. |
|
The flag_meanings CF property. |
|
The flag_values CF property. |
|
The history CF property. |
|
The institution CF property. |
|
The leap_month CF property. |
|
The leap_year CF property. |
|
The long_name CF property. |
|
The missing_value CF property. |
|
The month_lengths CF property. |
|
The references CF property. |
|
The scale_factor CF property. |
|
The source CF property. |
|
The standard_error_multiplier CF property. |
|
The standard_name CF property. |
|
The title CF property. |
|
The units CF property. |
|
The valid_max CF property. |
|
The valid_min CF property. |
|
The valid_range CF property. |
Units¶
Override the units. |
|
Override the calendar of date-time units. |
The |
Data¶
Methods
Remove the data. |
|
Return the data. |
|
Whether a data has been set. |
|
Set the field construct data. |
|
Remove the keys of the domain axis constructs spanned by the data of the field or of a metadata construct. |
|
Return the keys of the domain axis constructs spanned by the data of a metadata construct. |
|
Whether the domain axis constructs spanned by the data of the field or of a metadata construct have been set. |
|
Set the domain axis constructs spanned by the data of the field or of a metadata construct. |
Attributes
A numpy array deep copy of the data array. |
|
The |
|
An independent numpy array of date-time objects. |
|
Return an element of the data array as a standard Python scalar. |
|
The |
|
The number of dimensions in the data array. |
|
A tuple of the data array’s dimension sizes. |
|
The number of elements in the data array. |
|
A numpy array view of the data array. |
Rearranging elements
Roll a cyclic axis so that the given value lies in the first coordinate cell. |
|
Flatten axes of the field. |
|
Flip (reverse the direction of) axes of the field. |
|
Insert a size 1 axis into the data array. |
|
Roll the field along a cyclic axis. |
|
Remove size 1 axes from the data. |
|
Interchange two axes of the data. |
|
Permute the axes of the data array. |
|
Insert size 1 axes into the data array. |
Data array mask
Count the non-masked elements of the data. |
|
Count the masked elements of the data. |
|
Return the data array missing data value. |
A binary (0 and 1) missing data mask of the data array. |
|
Whether the mask is hard (True) or soft (False). |
|
The mask of the data array. |
|
Mask the array where invalid values occur. |
Changing data values
Called to implement assignment to x[indices]=value |
|
Create indices that define a subspace of the field construct. |
|
Mask the array where invalid values occur. |
|
Create a subspace of the field construct. |
|
Assign to data elements depending on a condition. |
Miscellaneous data operations¶
Methods
Partition the data array. |
|
Close all files referenced by the field. |
|
Set the cyclicity of an axis. |
|
Return the names of any files containing parts of the data array. |
Metadata constructs¶
Methods
Select a metadata construct by its identity. |
|
Select the key of a metadata construct by its identity. |
|
Remove a metadata construct. |
|
Return a metadata construct. |
|
Whather a metadata construct exisits. |
|
Set a metadata construct. |
|
Replace a metadata construct. |
|
Remove the keys of the domain axis constructs spanned by the data of the field or of a metadata construct. |
|
Return the keys of the domain axis constructs spanned by the data of a metadata construct. |
|
Whether the domain axis constructs spanned by the data of the field or of a metadata construct have been set. |
|
Set the domain axis constructs spanned by the data of the field or of a metadata construct. |
|
Return an auxiliary coordinate construct, or its key. |
|
Select a cell measure construct by its identity. |
|
Select a cell method construct by its identity. |
|
Return a dimension coordinate construct, or its key. |
|
Return a coordinate reference construct, or its key. |
|
Return a dimension coordinate construct, or its key. |
|
Return a domain ancillary construct, or its key. |
|
Return a domain axis construct, or its key. |
|
Return the key of the domain axis construct that is spanned by 1-d coordinate constructs. |
|
Return the position in the data of a domain axis construct. |
|
Return a field ancillary construct, or its key. |
Attributes
Return the metdata constructs. |
|
Return auxiliary coordinate constructs. |
|
Return cell measure constructs. |
|
Return cell method constructs. |
|
Return dimension and auxiliary coordinate constructs. |
|
Return coordinate reference constructs. |
|
Return dimension coordinate constructs. |
|
Return domain ancillary constructs. |
|
Return domain axis constructs. |
|
Return domain axis constructs. |
|
Return field ancillary constructs. |
Miscellaneous¶
Methods
Return a deep copy of the field construct. |
|
Whether two instances are the same. |
|
Compress the field construct. |
|
Convert a metadata construct into a new field construct. |
|
Return the commands that would create the field construct. |
|
Return the radius used for calculating cell areas in spherical polar coordinates. |
|
Uncompress the construct. |
|
Join a sequence of fields together. |
Attributes
A |
|
Whether or not there are cell bounds. |
|
True if the variable is an auxiliary coordinate object. |
|
True if the variable is a dimension coordinate object. |
|
True if the variable is a cell measure object. |
|
The number of axes in the domain. |
|
|
|
Always False. |
|
Always False. |
|
Always False. |
NetCDF¶
Methods
Remove the netCDF variable name. |
|
Return the netCDF variable name. |
|
Whether the netCDF variable name has been set. |
|
Set the netCDF variable name. |
|
Return the selection of properties to be written as netCDF global attributes. |
|
Remove the selection of properties to be written as netCDF global attributes. |
|
Select a property to be written as a netCDF global attribute. |
|
Set properties to be written as netCDF global attributes. |
|
A report of problems encountered whilst reading the field construct from a dataset. |
Domain axes¶
Set dimensions to be cyclic. |
|
Return domain axis constructs. |
|
|
|
Alias of |
|
Return the canonical name for an axis. |
|
Return the size of a domain axis construct. |
|
Set the cyclicity of an axis. |
|
Return the domain axes for the data array dimensions. |
|
Returns True if the given axis is cyclic. |
|
Return the axes of a domain item of the field. |
|
Return the axes of items of the field. |
|
Return the period of an axis. |
Subspacing¶
Return a subspace of the field construct defined by indices. |
|
Create a subspace of the field construct. |
|
Create indices that define a subspace of the field construct. |
Mathematical operations¶
Trigonometrical and hyperbolic functions
Take the inverse hyperbolic sine of the data element-wise. |
|
Take the trigonometric inverse tangent of the data element-wise. |
|
Take the trigonometric cosine of the data, element-wise. |
|
Take the hyperbolic cosine of the data array in place. |
|
The trigonometric sine of the data, element-wise. |
|
Take the hyperbolic sine of the data array in place. |
|
The trigonometric tangent of the data, element-wise. |
|
Take the hyperbolic tangent of the data array. |
Rounding and truncation
The ceiling of the data, element-wise. |
|
Limit the values in the data. |
|
Floor the data array, element-wise. |
|
Round the data to the nearest integer, element-wise. |
|
Round the data to the given number of decimals. |
|
Truncate the data, element-wise. |
Statistical collapses
Collapse axes of the field. |
|
Return a field containing horizontal cell areas. |
|
The maximum of the data array. |
|
The unweighted mean the data array. |
|
The unweighted average of the maximum and minimum of the data array. |
|
The minimum of the data array. |
|
The absolute difference between the maximum and minimum of the data array. |
|
The number of non-missing data elements in the data array. |
|
The sum of the data array. |
|
The unweighted sample standard deviation of the data array. |
|
The unweighted sample variance of the data array. |
|
Return weights for the data array values. |
Exponential and logarithmic functions
The exponential of the data, element-wise. |
|
The logarithm of the data array. |
Derivatives
Return the derivative along the specified axis. |
Convolution filters
Return the field convolved along the given axis with the specified filter. |
Cumulative sums
Return the field cumulatively summed along the given axis. |
Binning operations
Collapse the data values that lie in N-dimensional bins. |
|
Return the indices of the bins to which each value belongs. |
|
Compute percentiles of the data along the specified axes. |
Data array operations¶
Adding and removing elements
The unique elements of the data. |
Miscellaneous data array operations
Partition the data array. |
|
True if the data array is scalar. |
Regridding operations¶
Return the field with the specified Cartesian axes regridded onto a new grid. |
|
Return the field regridded onto a new latitude-longitude grid. |
Date-time operations¶
The day of each date-time data array element. |
|
An independent numpy array of date-time objects. |
|
The hour of each date-time data array element. |
|
The minute of each date-time data array element. |
|
The month of each date-time data array element. |
|
The second of each date-time data array element. |
|
The year of each date-time data array element. |
Convert reference time data values to have new units. |
Logic functions¶
Truth value testing
Test whether all data elements evaluate to True. |
|
Test whether any data elements evaluate to True. |
Comparison
Test whether all data are element-wise equal to other, broadcastable data. |
|
Whether two instances are the same. |
|
True if two fields are equivalent, False otherwise. |
|
|
|
|
Set operations
The unique elements of the data. |
Aliases¶
Methods
Alias for |
|
Alias for |
|
Alias of |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
Attributes
Alias for |
Arithmetic and comparison operations¶
Arithmetic, bitwise and comparison operations are defined on a field construct as element-wise operations on its data which yield a new field construct or, for augmented assignments, modify the field construct’s data in-place.
Relational operators
The rich comparison operator |
|
The rich comparison operator |
|
The rich comparison operator |
|
The rich comparison operator |
|
The rich comparison operator |
|
The rich comparison operator |
Binary arithmetic operators
The binary arithmetic operation |
|
The binary arithmetic operation |
|
The binary arithmetic operation |
|
The binary arithmetic operation |
|
The binary arithmetic operation |
|
The binary arithmetic operation |
|
The binary arithmetic operations |
|
The binary arithmetic operation |
Binary arithmetic operators with reflected (swapped) operands
The binary arithmetic operation |
|
The binary arithmetic operation |
|
The binary arithmetic operation |
|
The binary arithmetic operation |
|
The binary arithmetic operation |
|
The binary arithmetic operation |
|
The binary arithmetic operations |
|
The binary arithmetic operation |
Augmented arithmetic assignments
The augmented arithmetic assignment |
|
The augmented arithmetic assignment |
|
The augmented arithmetic assignment |
|
The augmented arithmetic assignment |
|
The augmented arithmetic assignment |
|
The augmented arithmetic assignment |
|
The augmented arithmetic assignment |
|
The binary arithmetic operation |
Unary arithmetic operators
The unary arithmetic operation |
|
The unary arithmetic operation |
|
The unary arithmetic operation |
Binary bitwise operators
The binary bitwise operation |
|
The binary bitwise operation |
|
The binary bitwise operation |
|
The binary bitwise operation |
|
The binary bitwise operation |
Binary bitwise operators with reflected (swapped) operands
The binary bitwise operation |
|
The binary bitwise operation |
|
The binary bitwise operation |
|
The binary bitwise operation |
|
The binary bitwise operation |
Augmented bitwise assignments
The augmented bitwise assignment |
|
The augmented bitwise assignment |
|
The augmented bitwise assignment |
|
The augmented bitwise assignment |
|
The augmented bitwise assignment |
Unary bitwise operators
The unary bitwise operation |
Special¶
Methods
Called by the |
|
Return a subspace of the field construct defined by indices. |
|
Called by the |
|
Called by the |