cf.Data.to_dask_array

Data.to_dask_array(apply_mask_hardness=False)[source]

Convert the data to a dask array.

Warning

By default, the mask hardness of the returned dask array might not be the same as that specified by the hardmask attribute.

This could cause problems if a subsequent operation on the returned dask array involves the un-masking of masked values (such as by indexed assignment).

To guarantee that the mask hardness of the returned dask array is correct, set the apply_mask_hardness parameter to True.

New in version 3.14.0.

Parameters
apply_mask_hardness: bool, optional

If True then force the mask hardness of the returned array to be that given by the hardmask attribute.

Returns
dask.array.Array

The dask array contained within the Data instance.

Examples

>>> d = cf.Data([1, 2, 3, 4], 'm')
>>> dx = d.to_dask_array()
>>> dx
>>> dask.array<array, shape=(4,), dtype=int64, chunksize=(4,), chunktype=numpy.ndarray>
>>> dask.array.asanyarray(d) is dx
True
>>> d.to_dask_array(apply_mask_hardness=True)
dask.array<cf_harden_mask, shape=(4,), dtype=int64, chunksize=(4,), chunktype=numpy.ndarray>
>>> d = cf.Data([1, 2, 3, 4], 'm', hardmask=False)
>>> d.to_dask_array(apply_mask_hardness=True)
dask.array<cf_soften_mask, shape=(4,), dtype=int64, chunksize=(4,), chunktype=numpy.ndarray>