shnitsel.data.shnitsel_db_helpers#
Attributes#
Functions#
|
Helper function to concatenate the trajectories in a subtree into a multi-trajetctory dataset. |
|
Helper function to layer the trajectories in a subtree into a multi-trajetctory dataset. |
|
Helper function to collect the data in a subtree into a list. |
Attempts to unwrap a single dataset from a tree. |
|
|
Apply an aggregation function to every node at a level of a db structure |
|
Function to get a list of all data in a tree with their respective path |
Module Contents#
- DataType#
- AggType#
- R#
- TrajType#
- concat_subtree(subtree, only_direct_children=False)#
Helper function to concatenate the trajectories in a subtree into a multi-trajetctory dataset.
The resulting dataset has a new frame dimension along which we can iterate through all individual frames of all trajectories.
- layer_subtree(subtree, only_direct_children=False)#
Helper function to layer the trajectories in a subtree into a multi-trajetctory dataset.
The resulting dataset has a new trajectory dimension along which we can iterate through all individual frames of all trajectories.
- Parameters:
- Returns:
The resulting multi-trajectory dataset
- Return type:
xr.Dataset
- list_subtree(subtree, only_direct_children=False)#
Helper function to collect the data in a subtree into a list.
- Parameters:
- Returns:
The resulting data/trajectory list
- Return type:
list[DataType]
- 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 : TreeNode[Any, DataType]
Root of the subtree to parse
- Returns:
Returns either the single point of data in the subtree or the full tree, if unwrapping would be unfeasible.
- Return type:
DataType|TreeNode[Any, DataType]
- Parameters:
tree (shnitsel.data.tree.TreeNode[Any, DataType])
- aggregate_xr_over_levels(tree, func, level_name, dtype=None)#
Apply an aggregation function to every node at a level of a db structure
- Parameters:
tree (TreeNode[Any, DataType]) – The tree to aggregate at the specific level
func (Callable[[TreeNode[Any, DataType]], R]) – The function to apply to the subtree at the specified level
level_name (Literal['root', 'compound', 'group', 'data']) – The target level to apply the function func to. See tree.datatree_level for values.
dtype (type | UnionType, optional) – The dtype of the resulting tree after aggregation.
- Returns:
The resulting tree after applying the transform func to the subtrees.
- Return type:
TreeNode[Any, R]
- get_data_with_path(subtree)#
Function to get a list of all data in a tree with their respective path