MCPcopy Create free account
hub / github.com/DedalusProject/dedalus / load_tasks_to_xarray

Function load_tasks_to_xarray

dedalus/tools/post.py:363–378  ·  view source on GitHub ↗

Load task from Dedalus HDF5 output to an Xarray DataArray.

(filename, tasks=None, squeeze_constant=True)

Source from the content-addressed store, hash-verified

361
362
363def load_tasks_to_xarray(filename, tasks=None, squeeze_constant=True):
364 """Load task from Dedalus HDF5 output to an Xarray DataArray."""
365 with h5py.File(filename, 'r') as file:
366 if tasks is None:
367 tasks = list(file['tasks'].keys())
368 dsets = [file['tasks'][task] for task in tasks]
369 arrays = [dedalus_h5_to_xarray(dset) for dset in dsets]
370 arrays = {array.name: array for array in arrays}
371 # Drop constant dimensions
372 if squeeze_constant:
373 for task in arrays:
374 array = arrays[task]
375 constant_axes = [i for i, name in enumerate(array.dims) if name == 'constant']
376 array = array.squeeze(axis=constant_axes, drop=True)
377 arrays[task] = array
378 return arrays
379
380
381class DedalusXarrayBackend(BackendEntrypoint):

Callers

nothing calls this directly

Calls 1

dedalus_h5_to_xarrayFunction · 0.85

Tested by

no test coverage detected