shnitsel.data.shnitsel_db.db_compound_group¶
Attributes¶
Classes¶
Class to hold identifying and auxiliary info of a compound type in ShnitselDB |
|
DataTree node to keep track of all data associated with a common compound within the datatree |
Module Contents¶
- T¶
- class CompoundInfo¶
Class to hold identifying and auxiliary info of a compound type in ShnitselDB
- class CompoundGroup(compound_info=None, children=None)¶
Bases:
xarray.DataTreeDataTree node to keep track of all data associated with a common compound within the datatree
- Parameters:
compound_info (CompoundInfo | None)
children (Mapping[str, shnitsel.data.shnitsel_db.db_trajectory_group.TrajectoryGroup | shnitsel.data.shnitsel_db.db_trajectory_data.TrajectoryData] | None)
- is_level(target_level)¶
Check whether we are at a certain level
- get_compound_info()¶
Get the store compound info of this Compound group.
- Returns:
_description_
- Return type:
- collect_trajectories()¶
Function to retrieve all trajectories in this subtree
- Returns:
List of all nodes with TrajectoryData type
- Return type:
List[TrajectoryData]
- merge_with(other)¶
Function to merge two compound groups into one.
Called when merging two database states. Will fail if compound_info differs between compounds to avoid loss of information.
- Parameters:
other (CompoundGroup) – The other CompoundGroup to be merged
- Raises:
ValueError – Raised if the compound_info differs.
- Returns:
A CompoundGroup object holding the entire merged subtree
- Return type:
- filter_trajectories(filter_func=None, est_level=None, basis_set=None, **kwargs)¶
Function to filter trajectories based on their attributes.
- Parameters:
filter_func (Callable[[xr.Dataset], bool] | None, optional) – A function to evaluate whether a trajectory should be retained. Should return True if the trajectory should stay in the filtered set. Defaults to None.
est_level (str | List[str] | None, optional) – Option to filter for a certain level of electronic structure theory/calculation method. Can be a single key value or a set of values to retain. Defaults to None.
basis_set (str | List[str] | None, optional) – Option to filter for a certain basis set. Can be a single key value or a set of values to retain. Defaults to None.
**kwargs – Key-value pairs, where the key denotes an attribute
- Returns:
Either returns the CompoundGroup with the remaining set of trajectories or None if the group would be empty.
- Return type:
Compoundgroup|None
- add_trajectory_group(group_name, filter_func_trajectories=None, flatten_trajectories=False, **kwargs)¶
Function to add trajectories within this compound subtree to a TrajectoryGroup of trajectories.
The group_name will be set as the name of the group in the tree. If flatten_trajectories=True all existing groups will be dissolved before filtering and the children will be turned into an ungrouped list of trajectories. The filter_func_trajectories will either be applied to only the current groups and trajectories immediately beneath this compound or to the flattened list of all child directories.
- Parameters:
group_name (str) – The name to be set for the TrajectoryGroup object
filter_func_Trajectories (Callable[[Trajectory|GroupInfo], bool] | None, optional) – A function to return true for Groups and individual trajectories that should be added to the new group. Defaults to None.
flatten_trajectories (bool, optional) – A flag whether all descendant groups should be dissolved and flattened into a list of trajectories first before applying a group. Defaults to False.
filter_func_trajectories (Callable[[shnitsel.data.trajectory_format.Trajectory | shnitsel.data.shnitsel_db.db_trajectory_group.GroupInfo], bool] | None)
- Returns:
The restructured Compound with a new added group if at least one trajectory has satisfied the filter condition.
- Return type:
- map_over_trajectories(map_func, result_as_dict=False, result_var_name='result')¶
Method to apply a function to all trajectories in this subtree.
- Parameters:
map_func (Callable[[Trajectory], T]) – Function to be applied to each individual trajectory in this database structure.
result_as_dict (bool, optional) – Whether to return the result as a dict or as a CompoundGroup structure. Defaults to False which yields a CompoundGroup.
result_var_name (str,optional) – The name of the result variable to be assigned in either the result dataset or in the result dict.
- Returns:
The result, either again as a CompoundGroup structure or as a layered dict structure.
- Return type: