Bases: object
An N-dimensional data array with units and masked values.
Indexing
A data array is indexable in a similar way to numpy array
>>> d.shape
(12, 19, 73, 96)
>>> d[...].shape
(12, 19, 73, 96)
>>> d[slice(0, 12), 10:0:-2, :, :].shape
(12, 5, 73, 96)
There are two important extensions to the numpy indexing functionality:
Size 1 dimensions are never removed.
An integer index i takes the i-th element but does not reduce the rank of the output array by one:
>>> d.shape
(12, 19, 73, 96)
>>> d[0, ...].shape
(1, 19, 73, 96)
>>> d[:, 3, slice(10, 0, -2), 95].shape
(12, 1, 5, 1)
When advanced indexing is used on more than one dimension, the advanced indices work independently.
When more than one dimension’s slice is a 1-d boolean sequence or 1-d sequence of integers, then these indices work independently along each dimension (similar to the way vector subscripts work in Fortran), rather than by their elements:
>>> d.shape
(12, 19, 73, 96)
>>> d[0, :, [0,1], [0,1,2]].shape
(1, 19, 2, 3)
Miscellaneous
Data objects are picklable.
Data objects are hashable, but that, since Data objects are mutable, their hash values may change if created at different times.
Initialization
Parameters : |
|
---|
Examples
>>> d = cf.Data(5)
>>> d = cf.Data([1,2,3], units='K')
>>> import numpy
>>> d = cf.Data(numpy.arange(10).reshape(2,5), units=cf.Units('m/s'), _FillValue=-999)
>>> d = cf.Data(('f', 'l', 'y'))
array | A numpy array copy the data array. |
dtype | The numpy data type of the data array. |
_FillValue | The _FillValue CF attribute. |
first_datum | The first element of the data array. |
hardmask | Whether the mask is hard (True) or soft (False). |
ismasked | True if the data array has any masked values. |
isscalar | True if the data array is a 0-d scalar array. |
last_datum | The last element of the data array. |
mask | The boolean missing data 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 the data array. |
Partition matrix attributes
dimensions | |
directions | |
partitions | |
pmdimensions | |
pmndim | Number of dimensions in the partition matrix. |
pmshape | List of the partition matrix’s dimension sizes. |
pmsize | Number of partitions in the partition matrix. |
all | Test whether all data array elements evaluate to True. |
any | Test whether any data array elements evaluate to True. |
binary_mask | Return a binary missing data mask of the data array. |
chunk | Partition the data array |
clip | Clip (limit) the values in the data array in place. |
conform_args | Return a dictionary of arguments for the partitions’ |
copy | Return a deep copy. |
cos | Take the trigonometric cosine of the data array in place. |
dump | Return a string containing a full description of the instance. |
equals | True if two data arrays are logically equal, False otherwise. |
expand_dims | Expand the shape of the data array in place. |
flat | Return a flat iterator over elements of the data array. |
flip | Flip dimensions of the data array in place. |
func | Apply an element-wise array operation to the data array in place. |
iterindices | Return an iterator over indices of the data array. |
new_dimension_identifier | Return a dimension name not being used by the data array. |
override_units | Override the data array units in place. |
save_to_disk | Put the data array on disk. |
setitem | write me! |
setmask | Set selected elements of the data array’s mask in place. |
sin | Take the trigonometric sine of the data array in place. |
squeeze | Remove size 1 dimensions from the data in place. |
to_disk | Store the data array on disk in place. |
to_memory | Store each partition’s data in memory in place if the master array is smaller than the chunk size. |
transpose | Permute the dimensions of the data array in place. |
Partition matrix methods
add_partitions | Add partition boundaries. |
change_dimension_names | Change the dimension names. |
chunk | Partition the data array |
conform_args | Return a dictionary of arguments for the partitions’ |
expand_partition_dims | Expand the shape of the partition matrix in place. |
new_dimension_identifier | Return a dimension name not being used by the data array. |
partition_boundaries | |
save_to_disk | Put the data array on disk. |
to_disk | Store the data array on disk in place. |
to_memory | Store each partition’s data in memory in place if the master array is smaller than the chunk size. |
Arithmetic and comparison operations are defined on a field as element-wise array operations which yield a new cf.Data object or, for augmented arithmetic assignments, modify the master data array in-place.
Comparison operators
__lt__ | The rich comparison operator < |
__le__ | The rich comparison operator <= |
__eq__ | The rich comparison operator == |
__ne__ | The rich comparison operator != |
__gt__ | The rich comparison operator > |
__ge__ | The rich comparison operator >= |
Binary arithmetic operators
__add__ | The binary arithmetic operation + |
__sub__ | The binary arithmetic operation - |
__mul__ | The binary arithmetic operation * |
__div__ | The binary arithmetic operation / |
__truediv__ | The binary arithmetic operation / (true division) |
__floordiv__ | The binary arithmetic operation // |
__pow__ | The binary arithmetic operations ** and pow |
__and__ | The binary arithmetic operation & |
__or__ | The binary arithmetic operation | |
__xor__ | The binary arithmetic operation ^ |
Binary arithmetic operators with reflected (swapped) operands
__radd__ | The binary arithmetic operation + with reflected operands |
__rsub__ | The binary arithmetic operation - with reflected operands |
__rmul__ | The binary arithmetic operation * with reflected operands |
__rdiv__ | The binary arithmetic operation / with reflected operands |
__rtruediv__ | The binary arithmetic operation / (true division) with reflected operands |
__rfloordiv__ | The binary arithmetic operation // with reflected operands |
__rpow__ | The binary arithmetic operations ** and pow with reflected operands |
__rand__ | The binary arithmetic operation & with reflected operands |
__ror__ | The binary arithmetic operation | with reflected operands |
__rxor__ | The binary arithmetic operation ^ with reflected operands |
Augmented arithmetic assignments
__iadd__ | The augmented arithmetic assignment += |
__isub__ | The augmented arithmetic assignment -= |
__imul__ | The augmented arithmetic assignment *= |
__idiv__ | The augmented arithmetic assignment /= |
__itruediv__ | The augmented arithmetic assignment /= (true division) |
__ifloordiv__ | The augmented arithmetic assignment //= |
__ipow__ | The augmented arithmetic assignment **= |
__iand__ | The augmented arithmetic assignment &= |
__ior__ | The augmented arithmetic assignment |= |
__ixor__ | The augmented arithmetic assignment ^= |
Unary arithmetic operators
__neg__ | The unary arithmetic operation - |
__pos__ | The unary arithmetic operation + |
__abs__ | The unary arithmetic operation abs |
__invert__ | The unary arithmetic operation ~ |