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_datafunction returns True then callingarraywill 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
arraycauses all delayed operations to be computed. The returnednumpyarray is a deep copy of that returned by createdcompute.See also
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