cfdm.Data.array

Data.array

A numpy array copy of the data.

In-place changes to the returned numpy array do not affect the underlying Dask array.

The returned numpy array has the same mask hardness and fill values as the data.

Note

If the cfdm.persist_data function returns True then calling array will persist the underlying lazy Dask array into an equivalent chunked Dask array, but now with the results fully computed and cached memory.

Compare with compute.

Performance

array causes all delayed operations to be computed. The returned numpy array is a deep copy of that returned by created compute.

Examples

>>> d = cfdm.Data([1, 2, 3.0], 'km')
>>> a = d.array
>>> isinstance(a, numpy.ndarray)
True
>>> print(a)
[ 1.  2.  3.]
>>> d[0] = -99
>>> print(a[0])
1.0
>>> a[0] = 88
>>> print(d[0])
-99.0 km
>>> d = cfdm.Data('2000-12-1', units='days since 1999-12-1')
>>> print(d.array)
366
>>> print(d.datetime_array)
2000-12-01 00:00:00