shnitsel.data.shnitsel_db_helpers

Attributes

T

R

Functions

unwrap_single_entry_in_tree(tree)

Attempts to unwrap a single dataset from a tree.

aggregate_xr_over_levels(tree, func, level)

Apply an aggregation function to every node at a level of a db structure

get_trajectories_with_path(subtree)

Function to get a list of all datasets in the tree with their respective path

Module Contents

T
R
unwrap_single_entry_in_tree(tree)

Attempts to unwrap a single dataset from a tree.

If multiple or none are found, it will return the original tree If a single entry was found, will return the dataset

Parameters:
  • root (xr.DataTree) – Root of the subtree to parse

  • tree (T)

Returns:

Returns None if no entry was found, a list instance if multiple entries were found or a single dataset if a single entry was found in the subtree

Return type:

xr.Dataset|List[Any]|None

aggregate_xr_over_levels(tree, func, level)

Apply an aggregation function to every node at a level of a db structure

Parameters:
  • tree (T) – The tree to aggregate at the specific level

  • func (callable) – The function to apply to that subtree

  • level (str) – The target level to apply the function func to. See shnitsel_db.datatree_level.py for values.

Returns:

The resulting tree after applying the transform func to the subtrees.

Return type:

T

get_trajectories_with_path(subtree)

Function to get a list of all datasets in the tree with their respective path

Parameters:

subtree (xr.DataTree) – The subtree to generate the collection for.

Returns:

A list of tuples (path, dataset at that path) for all datasets in the respective subtree.

Return type:

List[tuple[str, Trajectory]]