cfdm.Data.todict

Data.todict(optimize_graph=True, _force_mask_hardness=True, _force_to_memory=True)[source]

Return a dictionary of the dask graph key/value pairs.

New in version (cfdm): 1.11.2.0

See also

to_dask_array

Parameters
optimize_graph: bool

If True, the default, then prior to being converted to a dictionary, the graph is optimised to remove unused chunks. Note that optimising the graph can sometimes add a considerable performance overhead.

_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.

Returns
dict

The dictionary of the dask graph key/value pairs.

Examples

>>>
>>> d = cfdm.Data([1, 2, 3, 4], chunks=2)
>>> d.todict()
{('array-1bd38aa2a7096af2b1db281a4309854a', 0): array([1, 2]),
 ('array-1bd38aa2a7096af2b1db281a4309854a', 1): array([3, 4])}
>>> e = d[0]
>>> e.todict()
{('getitem-bb4a18fba86eac0dd2c489748b2b3e2d', 0): (<function dask.array.chunk.getitem(obj, index)>, ('array-1bd38aa2a7096af2b1db281a4309854a', 0), (slice(0, 1, 1),)),
 ('array-1bd38aa2a7096af2b1db281a4309854a', 0): array([1, 2])}
>>> e.todict(optimize_graph=False)
{('array-1bd38aa2a7096af2b1db281a4309854a', 0): array([1, 2]),
 ('array-1bd38aa2a7096af2b1db281a4309854a', 1): array([3, 4]),
 ('getitem-bb4a18fba86eac0dd2c489748b2b3e2d', 0): (<function dask.array.chunk.getitem(obj, index)>, ('array-1bd38aa2a7096af2b1db281a4309854a', 0), (slice(0, 1, 1),))}