get_lazy_patch

method of dascore.core.spool.DataFrameSpool source

get_lazy_patch(
    self ,
    index: int = 0,
)-> ‘PatchType’

Return the patch at index without loading its data.

The patch’s data loads, one source patch at a time, only when it is sliced (e.g. by Patch.select). This lets a long patch, such as one made by spool.chunk(time=None), be processed in pieces without holding it all in memory. The sources must continue one evenly sampled grid, so the patch’s coordinates match spool[index]; attributes come from the first source patch.

Parameters

Parameter Description
index The index of the patch in the spool.

Raises

ParameterError If the patch merges sources which don’t continue one evenly sampled grid, or which have coordinates along the merged dimension. CoordMergeError When a source is loaded whose dtype, samples, or other coordinates differ from what the first source implies.

Examples

import dascore as dc
spool = dc.get_example_spool("random_das").chunk(time=None)
patch = spool.get_lazy_patch()
# Only the sources needed for this selection are loaded.
sub = patch.select(time=(0, 1), relative=True)