cfdm.Data¶
-
class
cfdm.
Data
(array=None, units=None, calendar=None, fill_value=None, source=None, copy=True, dtype=None, mask=None, _use_array=True, **kwargs)[source]¶ Bases:
cfdm.mixin.container.Container
,cfdm.mixin.netcdf.NetCDFHDF5
,cfdm.core.data.data.Data
An orthogonal multidimensional array with masking and units.
New in version (cfdm): 1.7.0
Initialisation
- Parameters
- array: data_like, optional
The array of values.
A data_like object is any object that can be converted to a
Data
object, i.e.numpy
array_like objects,Data
objects, and cfdm instances that containData
objects.Ignored if the source parameter is set.
- Parameter example:
array=[34.6]
- Parameter example:
array=[[1, 2], [3, 4]]
- Parameter example:
array=numpy.ma.arange(10).reshape(2, 1, 5)
- units:
str
, optional The physical units of the data. Ignored if the source parameter is set.
The units may also be set after initialisation with the
set_units
method.- Parameter example:
units='km hr-1'
- Parameter example:
units='days since 2018-12-01'
- calendar:
str
, optional The calendar for reference time units. Ignored if the source parameter is set.
The calendar may also be set after initialisation with the
set_calendar
method.- Parameter example:
calendar='360_day'
- fill_value: optional
The fill value of the data. By default, or if set to
None
, thenumpy
fill value appropriate to the array’s data type will be used (seenumpy.ma.default_fill_value
). Ignored if the source parameter is set.The fill value may also be set after initialisation with the
set_fill_value
method.- Parameter example:
fill_value=-999.
- dtype: data-type, optional
The desired data-type for the data. By default the data-type will be inferred form the array parameter.
The data-type may also be set after initialisation with the
dtype
attribute.- Parameter example:
dtype=float
- Parameter example:
dtype='float32'
- Parameter example:
dtype=numpy.dtype('i2')
- mask: data_like, optional
Apply this mask to the data given by the array parameter. By default, or if mask is
None
, no mask is applied. May be any data_like object that broadcasts to array. Masking will be carried out where mask elements evaluate toTrue
.A data_like object is any object that can be converted to a
Data
object, i.e.numpy
array_like objects,Data
objects, and cfdm instances that containData
objects.This mask will applied in addition to any mask already defined by the array parameter.
- source: optional
Initialise the array, units, calendar and fill value from those of source.
Note that if source is a
Data
instance thencfdm.Data(source=source)
is equivalent tosource.copy()
.- copy:
bool
, optional If False then do not deep copy input parameters prior to initialisation. By default arguments are deep copied.
- kwargs: ignored
Not used. Present to facilitate subclassing.
Inspection¶
Attributes
Return an independent numpy array containing the data. |
|
Data-type of the data elements. |
|
Number of data dimensions. |
|
Tuple of data dimension sizes. |
|
Number of elements in the data. |
Units¶
Delete the units. |
|
Return the units. |
|
Whether units have been set. |
|
Set the units. |
|
Delete the calendar. |
|
Return the calendar. |
|
Whether a calendar has been set. |
|
Set the calendar. |
Data creation routines¶
Ones and zeros¶
Create a new data array without initialising the elements. |
From existing data¶
Return a deep copy. |
Data manipulation routines¶
Changing data shape¶
Flatten axes of the data. |
Transpose-like operations¶
Permute the axes of the data array. |
Changing number of dimensions¶
Expand the shape of the data array. |
|
Remove size 1 axes from the data. |
Adding and removing elements¶
The unique elements of the data. |
Date-time support¶
Delete the calendar. |
|
Return the calendar. |
|
Whether a calendar has been set. |
|
Set the calendar. |
Attributes
Returns an independent numpy array of datetimes. |
|
Returns an independent numpy array with datetimes as strings. |
Indexing routines¶
Single value selection¶
Return the first element of the data as a scalar. |
|
Return the second element of the data as a scalar. |
|
Return the last element of the data as a scalar. |
Logic functions¶
Truth value testing¶
Test whether any data array elements evaluate to True. |
Comparison¶
Whether two data arrays are the same. |
Mask support¶
Apply masking. |
|
Replace masked elements with the fill value. |
|
Delete the fill value. |
|
Return the missing data value. |
|
Whether a fill value has been set. |
|
Set the missing data value. |
Attributes
The Boolean missing data mask of the data array. |
Mathematical functions¶
Sums, products, differences¶
Return the sum of an array or the sum along axes. |
Set routines¶
Making proper sets¶
The unique elements of the data. |
Sorting, searching, and counting¶
Statistics¶
Order statistics¶
Return the maximum of an array or the maximum along axes. |
|
Return the minimum of an array or minimum along axes. |
|
Alias for |
|
Alias for |
Sums¶
Return the sum of an array or the sum along axes. |
Compression by convention¶
Returns the dimensions that are compressed in the array. |
|
Returns the compressed dimension’s array position. |
|
Returns the type of compression applied to the array. |
|
Return the count variable for a compressed array. |
|
Return the index variable for a compressed array. |
|
Return the list variable for a compressed array. |
|
Uncompress the underlying array. |
Attributes
Returns an independent numpy array of the compressed data. |
Miscellaneous¶
Return the commands that would create the data object. |
|
Return the name of the file containing the data array. |
|
Return the underlying array object. |
Performance¶
Clear the HDF5 chunksizes for the data. |
|
Return the HDF5 chunksizes for the data. |
|
Set the HDF5 chunksizes for the data. |
|
Bring data on disk into memory and retain it there. |
Special¶
The numpy array interface. |
|
Called by the |
|
Return a subspace of the data defined by indices. |
|
Called by the |
|
Called when an iterator is required. |
|
Called by the |
|
Assign to data elements defined by indices. |
|
Called by the |
Docstring substitutions¶
Methods
Return the special docstring substitutions. |
|
Returns the substitutions that apply to methods of the class. |
|
Returns the class {{package}} substitutions package depth. |
|
Returns method names excluded in the class substitutions. |