cfdm.Data.__array__

Data.__array__(*dtype)[source]

The numpy array interface.

New in version (cfdm): 1.7.0

Parameters
dtype: optional

Typecode or data-type to which the array is cast.

Returns
numpy.ndarray

An independent numpy array of the data.

Examples

>>> d = cfdm.Data([1, 2, 3])
>>> a = numpy.array(d)
>>> print(type(a))
<class 'numpy.ndarray'>
>>> a[0] = -99
>>> d
<Data(3): [1, 2, 3]>
>>> b = numpy.array(d, float)
>>> print(b)
[1. 2. 3.]