cfdm.core.data.abstract.Array¶
-
class
cfdm.core.data.abstract.
Array
(**kwargs)[source]¶ Bases:
cfdm.core.abstract.container.Container
Abstract base class for a container of an array.
The form of the array is arbitrary and is defined by the initialization parameters of a subclass of Array.
See cfdm.core.NumpyArray for an example implementation.
Initialization
Parameters: - kwargs: optional
Named parameters and their values that define the array.
-
__init__
(**kwargs)[source]¶ Initialization
Parameters: - kwargs: optional
Named parameters and their values that define the array.
Methods
__init__
(**kwargs)Initialization copy
()Return a deep copy of the array. get_array
()Return an independent numpy array containing the data. Array.next
Attributes
dtype
Data-type of the data elements. ndim
Number of array dimensions shape
Tuple of array dimension sizes. size
Number of elements in the array. -
copy
()[source]¶ Return a deep copy of the array.
a.copy() is equivalent to ``copy.deepcopy(a)
.Copy-on-write is employed. Therefore, after copying, care must be taken when making in-place modifications to attributes of either the original or the new copy.
Returns: - out:
The deep copy.
Examples: >>> b = a.copy()
-
get_array
()[source]¶ Return an independent numpy array containing the data.
Returns: - out: numpy.ndarray
An independent numpy array of the data.
Examples: >>> n = a.get_array() >>> isinstance(n, numpy.ndarray) True
-
dtype
¶ Data-type of the data elements.
Examples: >>> a.dtype dtype('float64') >>> print(type(a.dtype)) <type 'numpy.dtype'>
-
ndim
¶ Number of array dimensions
Examples: >>> a.shape (73, 96) >>> a.ndim 2 >>> a.size 7008
>>> a.shape (1, 1, 1) >>> a.ndim 3 >>> a.size 1
>>> a.shape () >>> a.ndim 0 >>> a.size 1
-
shape
¶ Tuple of array dimension sizes.
Examples: >>> a.shape (73, 96) >>> a.ndim 2 >>> a.size 7008
>>> a.shape (1, 1, 1) >>> a.ndim 3 >>> a.size 1
>>> a.shape () >>> a.ndim 0 >>> a.size 1
-
size
¶ Number of elements in the array.
Examples: >>> a.shape (73, 96) >>> a.size 7008 >>> a.ndim 2
>>> a.shape (1, 1, 1) >>> a.ndim 3 >>> a.size 1
>>> a.shape () >>> a.ndim 0 >>> a.size 1