thunderboltz.tb.query_tree
- thunderboltz.tb.query_tree(directory, name_req=None, param_req=None, read_cs_data=False, callback=None, agg=True)[source]
Walk a directory tree and search for ThunderBoltz simulation directories to read. Either return a list of
ThunderBoltzobjects, or a custom aggregation of the output data.- Parameters:
directory (str) – The root path to search for ThunderBoltz data in.
name_req (callable[str,bool]) –
A requirement on the file path names to be included in the query. The callable accepts the file path of a thunderboltz simulation directory and should return
Trueif that directory is to be included in the query.e.g.
name_req=lambda s: "test_type_1" in swould return only data in a subfoldertest_type_1.param_req (dict) –
A requirement on the parameter settings of the ThunderBoltz calculations. The dictionary corresponding to simulation parameters that must be set by the read ThunderBoltz object.
e.g.
param_req={"Ered": 100, "L": 1e-6}would only return data from calculations with a reduced field of 100 Td and a cell length of 1 \(\mu{\rm m}\).callback – (callable[
ThunderBoltz, Any]): A function that accepts a ThunderBoltz object and returns the desired data.agg –
If
callbackis set, attempt to aggregate the data based on the data type:callback Return Type
Behavior
Frames will be concatenated row-wise and one larger DataFrame will be returned.
list[
pandas.DataFrame]A list of frames the same length of the return value will be returned. The frame at index
iwill contain the concatenated data from each simulation returned bycallable(tb)[i].list[Any]
A list of lists will be returned. The list at index
iwill contain a list of items returned from each call tocallable(tb)[i].Any
Return values will be returned in a list.
If
aggis set to False, always return a list of callback data without any concatenation.
- Returns:
See
aggoption for behavior. Default return type is list[ThunderBoltz].- Return type:
list[
ThunderBoltz], orpandas.DataFrame, or list[pandas.DataFrame], or list[list[Any]]