shnitsel.data.tree.xr_conversion#

Attributes#

Functions#

tree_to_xarray_datatree(node)

Helper function to convert a ShnitselDB tree format to xarray.DataTree format

xarray_datatree_to_shnitsel_tree(node[, dtype])

Helper function to invert the operation of tree_to_xarray_datastree and deserialize the

Module Contents#

DataType#
tree_to_xarray_datatree(node)#

Helper function to convert a ShnitselDB tree format to xarray.DataTree format so that we can use the xarray functions to write a netcdf file.

Will recursively convert the tree from the current node starting from the leaves upwards. If the type of the node is not supported or the datatype in leaves is not supported for being stored via the xarray functions, the conversion will fail.

Parameters:

node (TreeNode[Any, DataType]) – The root node of a subtree to be converted to a xr.DataTree structure.

Returns:

Either the converted tree or None if this subtree is not supported.

Return type:

xr.DataTree | None

xarray_datatree_to_shnitsel_tree(node, dtype=None)#

Helper function to invert the operation of tree_to_xarray_datastree and deserialize the shnitsel tree/ShnitselDB from a stored xarray DataTree:

Parameters:
  • node (xr.DataTree) – The root node of a xarray subtree. will convert this subtree recursively.

  • dtype (type[DataType] | TypeForm[DataType], optional) – Optional argument to specify the desired target type of data in the shnitsel tree structure.

Returns:

The converted type or None if the tree could not be converted.

Return type:

ShnitselDBRoot | CompoundGroup | DataGroup | DataLeaf | None