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 ThunderBoltz objects, 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 True if that directory is to be included in the query.

    e.g. name_req=lambda s: "test_type_1" in s would return only data in a subfolder test_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 callback is set, attempt to aggregate the data based on the data type:

    callback Return Type

    Behavior

    pandas.DataFrame

    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 i will contain the concatenated data from each simulation returned by callable(tb)[i].

    list[Any]

    A list of lists will be returned. The list at index i will contain a list of items returned from each call to callable(tb)[i].

    Any

    Return values will be returned in a list.

    If agg is set to False, always return a list of callback data without any concatenation.

Returns:

See agg option for behavior. Default return type is list[ThunderBoltz].

Return type:

list[ThunderBoltz], or pandas.DataFrame, or list[pandas.DataFrame], or list[list[Any]]