sweepreader.py¶
- class SweepReader(dir_manager, num_para_read=1)[source]¶
Bases:
object
Used to read the output from one or more calls to mooseherd.run_para(). has configurable options for reading in the variable sweep in parallel.
- __init__(dir_manager, num_para_read=1)[source]¶
Construct the sweep reader with a directory manager and the number of simulations to read in parallel.
- Parameters:
dir_manager (
DirectoryManager
) – The directory manager as used by the mooseherd that ran the simulation sweep.num_para_read (
int
, optional) – Number of simulation to read in parallel. Defaults to 1.
- read_output_file_key(sweep_iter)[source]¶
read_output_key: reads the output key json file produced by running the variable sweep. The output key file maps which simulation were run in a given sub directory.
- Parameters:
sweep_iter (
int
) – sweep iteration to read. This is the number that is appended to the output key file e.g. output-key-2.json for the 2nd call to run_seq/para in the mooseherd.- Returns:
list[list[Path]]
– paths to the outputs from the variable sweep the outer list is the simulation iteration and the inner list is the position in the simulation chain.
- read_all_output_file_keys()[source]¶
read_all_output_keys: as read_output_keys() but finds all output key files in the first sub-directory and reads them.
- Returns:
list[list[Path]]
– paths to the outputs from the variable sweep the outer list is the simulation iteration and the inner list is the position in the simulation chain.- Raises:
FileNotFoundError – No output key files found in the first sub- directory.
- read_sweep_var_file(sweep_iter=1)[source]¶
read_sweep_var_file: reads the file containing the sweep variable dictionary for a given sweep iteration and returns it.
- Parameters:
sweep_iter (
int
) – The sweep iteration (i.e. the call number to mooseher.run_seq/para) Defaults to 1.- Returns:
list[list[dict | None]]
– The sweep variables as passed to mooseherd .run_seq/para.- Raises:
FileNotFoundError – Sweep file not found.
- read_all_sweep_var_files()[source]¶
read_all_sweep_var_files: as read sweep variables but finds all sweep variables in the first sub-directory and reads them.
- Returns:
list[list[dict | None]]
– The sweep variables as passed to mooseherd .run_seq/para. Additional sweep iterations are appended to the end of the list.- Raises:
FileNotFoundError – No sweep variable files found.
- get_output_files()[source]¶
- Returns:
list[list[Path]]
– returns the paths to the output files as read from the output key files.
- read_results_once(output_files, read_config=None)[source]¶
read_results_once: reads a specific simulation at the specified path based on the specified read configuration. If the read configuration is None then read everything.
- Parameters:
output_file (
list[Path | None] :
) – Path to the file to readread_config (
SimReadConfig | None
) – class to specify the data to read
- Returns:
list[SimData | None]
– list of data classes holding the simulation data for each simulation in the chain. Will be None for a pre- processor like Gmsh that has not output.
- read_sequential(sweep_iter=None, read_config=None)[source]¶
read_results_sequential: reads the variable sweep results sequentially. Can read a specific iteration with a specific read config but defaults to reading everything found in the simulation directories.
- Parameters:
sweep_iter (
int | None
) – sweep iteration number to read. Reads the output key file for this iteration. Defaults to None.read_config (
SimReadConfig | None
) – object for specifying which variables are to be extracted from the output. Defaults to None.
- Returns:
list[list[SimData]]
– list of lists of SimData objects containing the simulation results corresponding to each combination of variables.
- read_results_para(sweep_iter=None, read_config=None)[source]¶
read_results_para: reads the variable sweep results in parallel Can read a specific iteration with a specific read config but defaults to reading everything found in the simulation directories.
- Parameters:
sweep_iter (
int | None
) – sweep iteration number to read. Reads the output key file for this iteration. Defaults to None.read_config (
SimReadConfig | None
) – object for specifying which variables are to be extracted from the output. Defaults to None.
- Returns:
list[list[SimData]]
– list of lists of SimData objects containing the simulation results corresponding to each combination of variables.