cfdm.Data.to_dask_array¶
-
Data.
to_dask_array
(_force_mask_hardness=True, _force_to_memory=True)[source]¶ Convert the data to a
dask
array.New in version (cfdm): 1.11.2.0
- Parameters
- _force_mask_hardness:
bool
, optional If True (the default) then force the mask hardness of the returned Dask graph to be that given by the
hardmask
attribute. If False then the mask hardness may or may not be correct, depending on the nature of the stack of previously defined lazy operations.Set to False if the intention is to just inspect the state of the Dask graph, or is to add to the returned Dask graph further operations to which can correctly manage the mask hardness.
- _force_to_memory:
bool
, optional If True (the default) then force the data resulting from computing the returned Dask graph to be in memory. If False then the data resulting from computing the Dask graph may or may not be in memory, depending on the nature of the stack of previously defined lazy operations.
Set to False if the intention is to just inspect the state of the Dask graph, or is to add to the returned Dask graph further operations to which can handle any required conversion to data in memory.
- _force_mask_hardness:
- Returns
dask.array.Array
The dask array contained within the
Data
instance.
Examples
>>> d = cfdm.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(_force_mask_hardness=True) dask.array<cfdm_harden_mask, shape=(4,), dtype=int64, chunksize=(4,), chunktype=numpy.ndarray>
>>> d = cfdm.Data([1, 2, 3, 4], 'm', hardmask=False) >>> d.to_dask_array(_force_mask_hardness=True) dask.array<cfdm_soften_mask, shape=(4,), dtype=int64, chunksize=(4,), chunktype=numpy.ndarray>