ronswanson package
Subpackages
- ronswanson.utils package
- Submodules
- ronswanson.utils.cartesian_product module
- ronswanson.utils.check_complete module
- ronswanson.utils.color module
- ronswanson.utils.colormap_generator module
- ronswanson.utils.configuration module
- ronswanson.utils.file_open module
- ronswanson.utils.hdf5_utils module
- ronswanson.utils.logging module
- ronswanson.utils.package_data module
- ronswanson.utils.quailty_checks module
- Module contents
Submodules
ronswanson.band_simulation module
- class ronswanson.band_simulation.BandSimulation(simulation_id: int, parameter_set: Dict[str, float], energy_grid: EnergyGrid, out_file: str)[source]
Bases:
Simulation
- __init__(simulation_id: int, parameter_set: Dict[str, float], energy_grid: EnergyGrid, out_file: str) None [source]
Generic simulation class
- Parameters:
simulation_id (int) –
parameter_set (Dict[str, float]) –
energy_grid (np.ndarray) –
out_file (str) –
- Returns:
ronswanson.database module
- class ronswanson.database.Database(grid_points: ndarray, parameter_names: List[str], energy_grid: ndarray, run_time: ndarray, values: ndarray, meta_data: Optional[Dict[str, ndarray]] = None)[source]
Bases:
object
- __init__(grid_points: ndarray, parameter_names: List[str], energy_grid: ndarray, run_time: ndarray, values: ndarray, meta_data: Optional[Dict[str, ndarray]] = None) None [source]
Databse of parameters and simulated values
- Parameters:
grid_points (Dict[str, np.ndarray]) –
parameter_names (List[str]) –
energy_grid (np.ndarray) –
values (Dict[str, np.ndarray]) –
- Returns:
- property n_entries: int
the number of entries in the database
- Returns:
- property n_parameters: int
the number of parameters in the database
- Returns:
- property grid_points: ndarray
- property values: ndarray
- property parameter_ranges: Dict[str, ndarray]
- property parameter_names: List[str]
the names of the parameters
- property run_time: ndarray
an array of runtimes for all points in the grid
- Returns:
- property energy_grid: ndarray
The corresponding energy grid of the simulation
- Returns:
- property meta_data: Optional[Dict[str, ndarray]]
- classmethod from_file(file_name: str, output: int = 0) Database [source]
open a database from a file. The output argument specifies which value to collect. For example, a simulation may save photon and electron distributions from a solution.
- replace_nan_inf_with(value: float = 0.0) None [source]
Replace NaN and inf values with a float
- Parameters:
value (float) –
- Returns:
- to_3ml(name: str, desc: str, overwrite: bool = False, **kwargs) TemplateModel [source]
construct a table model from the database. parameter sub-selections are passed as kwargs of dictionaries:
selections = dict(param1=dict(vmin=1, vmax=2))
- Parameters:
name (str) –
desc (str) –
overwrite (bool) –
- Returns:
- check_for_missing_parameters(parameter_grid: ParameterGrid, create_new_grid: bool = False) None [source]
Search a parameter grid for missing values
- Parameters:
parameter_grid (ParameterGrid) –
create_new_grid (bool) –
- Returns:
ronswanson.grids module
- class ronswanson.grids.EnergyGrid(vmin: Union[float, NoneType] = None, vmax: Union[float, NoneType] = None, scale: Union[str, NoneType] = None, n_points: Union[int, NoneType] = None, values: Union[numpy.ndarray, NoneType] = None, custom: bool = False)[source]
Bases:
object
- vmin: Optional[float] = None
- vmax: Optional[float] = None
- scale: Optional[str] = None
- n_points: Optional[int] = None
- values: Optional[ndarray] = None
- custom: bool = False
- property grid: ndarray
- __init__(vmin: Optional[float] = None, vmax: Optional[float] = None, scale: Optional[str] = None, n_points: Optional[int] = None, values: Optional[ndarray] = None, custom: bool = False) None
- class ronswanson.grids.Parameter(name: str, vmin: Union[float, NoneType] = None, vmax: Union[float, NoneType] = None, scale: Union[str, NoneType] = None, n_points: Union[int, NoneType] = None, values: Union[numpy.ndarray, NoneType] = None, custom: bool = False)[source]
Bases:
object
- name: str
- vmin: Optional[float] = None
- vmax: Optional[float] = None
- scale: Optional[str] = None
- n_points: Optional[int] = None
- values: Optional[ndarray] = None
- custom: bool = False
- property grid: ndarray
- __init__(name: str, vmin: Optional[float] = None, vmax: Optional[float] = None, scale: Optional[str] = None, n_points: Optional[int] = None, values: Optional[ndarray] = None, custom: bool = False) None
- class ronswanson.grids.ParameterGrid(parameter_list: List[ronswanson.grids.Parameter], energy_grid: List[ronswanson.grids.EnergyGrid])[source]
Bases:
object
- energy_grid: List[EnergyGrid]
- full_grid: Optional[ndarray]
- property n_points: int
- property n_parameters: int
- classmethod from_dict(d: Dict[str, Dict[str, Any]]) ParameterGrid [source]
- classmethod from_yaml(file_name: str) ParameterGrid [source]
- property parameter_names: List[str]
- at_index(i: int, as_array: bool = False) Union[Dict[str, float], ndarray] [source]
return the ith set of parameters
- Parameters:
i (int) –
- Returns:
- __init__(parameter_list: List[Parameter], energy_grid: List[EnergyGrid]) None
ronswanson.script_generator module
- class ronswanson.script_generator.PythonGenerator(file_name: str, database_file: str, parameter_file: str, base_dir: str, import_line: str, n_procs: int, n_nodes: Optional[int] = None, linear_exceution: bool = False, has_complete_params: bool = False, current_size: int = 0, clean: bool = True)[source]
Bases:
ScriptGenerator
- __init__(file_name: str, database_file: str, parameter_file: str, base_dir: str, import_line: str, n_procs: int, n_nodes: Optional[int] = None, linear_exceution: bool = False, has_complete_params: bool = False, current_size: int = 0, clean: bool = True) None [source]
Generate the python script that will be run
- Parameters:
file_name (str) –
database_file (str) –
parameter_file (str) –
base_dir (str) –
import_line (str) –
n_procs (int) –
n_nodes (Optional[int]) –
linear_exceution (bool) –
- Returns:
- class ronswanson.script_generator.PythonGatherGenerator(file_name: str, database_file_name: str, current_size: int, n_outputs: int, num_meta_parameters: Optional[int] = None, clean: bool = True)[source]
Bases:
ScriptGenerator
ronswanson.simulation module
- class ronswanson.simulation.Simulation(simulation_id: int, parameter_set: Dict[str, float], energy_grid: List[EnergyGrid], out_file: str, num_outputs: int = 1, num_meta_parameters: Optional[int] = None)[source]
Bases:
object
- __init__(simulation_id: int, parameter_set: Dict[str, float], energy_grid: List[EnergyGrid], out_file: str, num_outputs: int = 1, num_meta_parameters: Optional[int] = None) None [source]
Generic simulation class
- Parameters:
simulation_id (int) –
parameter_set (Dict[str, float]) –
energy_grid (np.ndarray) –
out_file (str) –
- Returns:
ronswanson.simulation_builder module
- class ronswanson.simulation_builder.SLURMTime(hrs: int = 0, min: int = 10, sec: int = 0)[source]
Bases:
object
- hrs: int = 0
- min: int = 10
- sec: int = 0
- __init__(hrs: int = 0, min: int = 10, sec: int = 0) None
- class ronswanson.simulation_builder.JobConfig(time: ronswanson.simulation_builder.SLURMTime, n_cores_per_node: int)[source]
Bases:
object
- n_cores_per_node: int
- class ronswanson.simulation_builder.GatherConfig(time: ronswanson.simulation_builder.SLURMTime, n_cores_per_node: int, n_gather_per_core: int)[source]
Bases:
JobConfig
- n_gather_per_core: int
- n_cores_per_node: int
- class ronswanson.simulation_builder.SimulationConfig(time: ronswanson.simulation_builder.SLURMTime, n_cores_per_node: int, n_mp_jobs: int, run_per_node: Union[int, NoneType] = None, use_nodes: bool = False, max_nodes: Union[int, NoneType] = None, linear_execution: bool = False, num_meta_parameters: Union[int, NoneType] = None)[source]
Bases:
JobConfig
- n_mp_jobs: int
- run_per_node: Optional[int] = None
- use_nodes: bool = False
- max_nodes: Optional[int] = None
- linear_execution: bool = False
- num_meta_parameters: Optional[int] = None
- __init__(time: SLURMTime, n_cores_per_node: int, n_mp_jobs: int, run_per_node: Optional[int] = None, use_nodes: bool = False, max_nodes: Optional[int] = None, linear_execution: bool = False, num_meta_parameters: Optional[int] = None) None
- n_cores_per_node: int
- class ronswanson.simulation_builder.JobConfigStructure(time: Union[ronswanson.simulation_builder.SLURMTime, NoneType] = None, n_cores_per_node: Union[int, NoneType] = None)[source]
Bases:
object
- n_cores_per_node: Optional[int] = None
- class ronswanson.simulation_builder.GatherConfigStructure(time: Union[ronswanson.simulation_builder.SLURMTime, NoneType] = None, n_cores_per_node: Union[int, NoneType] = None, n_gather_per_core: int = '???')[source]
Bases:
JobConfigStructure
- n_gather_per_core: int = '???'
- class ronswanson.simulation_builder.SimulationConfigStructure(time: Union[ronswanson.simulation_builder.SLURMTime, NoneType] = None, n_cores_per_node: Union[int, NoneType] = None, n_mp_jobs: int = '???', run_per_node: Union[int, NoneType] = None, use_nodes: bool = False, max_nodes: Union[int, NoneType] = None, linear_execution: bool = False)[source]
Bases:
JobConfigStructure
- n_mp_jobs: int = '???'
- run_per_node: Optional[int] = None
- use_nodes: bool = False
- max_nodes: Optional[int] = None
- linear_execution: bool = False
- class ronswanson.simulation_builder.YAMLStructure(import_line: str = '???', parameter_grid: str = '???', out_file: str = '???', clean: bool = True, simulation: ronswanson.simulation_builder.SimulationConfigStructure = SimulationConfigStructure(time=None, n_cores_per_node=None, n_mp_jobs='???', run_per_node=None, use_nodes=False, max_nodes=None, linear_execution=False), gather: Union[ronswanson.simulation_builder.GatherConfigStructure, NoneType] = None, num_meta_parameters: Union[int, NoneType] = None, finish_missing: bool = False)[source]
Bases:
object
- import_line: str = '???'
- parameter_grid: str = '???'
- out_file: str = '???'
- clean: bool = True
- simulation: SimulationConfigStructure = SimulationConfigStructure(time=None, n_cores_per_node=None, n_mp_jobs='???', run_per_node=None, use_nodes=False, max_nodes=None, linear_execution=False)
- gather: Optional[GatherConfigStructure] = None
- num_meta_parameters: Optional[int] = None
- finish_missing: bool = False
- __init__(import_line: str = '???', parameter_grid: str = '???', out_file: str = '???', clean: bool = True, simulation: SimulationConfigStructure = SimulationConfigStructure(time=None, n_cores_per_node=None, n_mp_jobs='???', run_per_node=None, use_nodes=False, max_nodes=None, linear_execution=False), gather: Optional[GatherConfigStructure] = None, num_meta_parameters: Optional[int] = None, finish_missing: bool = False) None
- class ronswanson.simulation_builder.SimulationBuilder(parameter_grid: ParameterGrid, out_file: str, import_line: str, simulation_config: SimulationConfig, gather_config: Optional[GatherConfig] = None, num_meta_parameters: Optional[int] = None, clean: bool = True, finish_missing: bool = False)[source]
Bases:
object
The simulation builder class constructs the scripts needed for building the table model database
- __init__(parameter_grid: ParameterGrid, out_file: str, import_line: str, simulation_config: SimulationConfig, gather_config: Optional[GatherConfig] = None, num_meta_parameters: Optional[int] = None, clean: bool = True, finish_missing: bool = False)[source]
TODO describe function
- Parameters:
parameter_grid (ParameterGrid) –
out_file (str) –
import_line (str) –
simulation_config (SimulationConfig) –
gather_config (Optional[GatherConfig]) –
num_meta_parameters (Optional[int]) –
clean (bool) –
- Returns:
- classmethod from_yaml(file_name: str) SimulationBuilder [source]
Create a simulation setup from a yaml file.
Module contents
Top-level package for ronswanson.
- class ronswanson.Simulation(simulation_id: int, parameter_set: Dict[str, float], energy_grid: List[EnergyGrid], out_file: str, num_outputs: int = 1, num_meta_parameters: Optional[int] = None)[source]
Bases:
object
- __init__(simulation_id: int, parameter_set: Dict[str, float], energy_grid: List[EnergyGrid], out_file: str, num_outputs: int = 1, num_meta_parameters: Optional[int] = None) None [source]
Generic simulation class
- Parameters:
simulation_id (int) –
parameter_set (Dict[str, float]) –
energy_grid (np.ndarray) –
out_file (str) –
- Returns:
- class ronswanson.ParameterGrid(parameter_list: List[ronswanson.grids.Parameter], energy_grid: List[ronswanson.grids.EnergyGrid])[source]
Bases:
object
- energy_grid: List[EnergyGrid]
- full_grid: Optional[ndarray]
- property n_points: int
- property n_parameters: int
- classmethod from_dict(d: Dict[str, Dict[str, Any]]) ParameterGrid [source]
- classmethod from_yaml(file_name: str) ParameterGrid [source]
- property parameter_names: List[str]
- at_index(i: int, as_array: bool = False) Union[Dict[str, float], ndarray] [source]
return the ith set of parameters
- Parameters:
i (int) –
- Returns:
- __init__(parameter_list: List[Parameter], energy_grid: List[EnergyGrid]) None
- class ronswanson.SimulationBuilder(parameter_grid: ParameterGrid, out_file: str, import_line: str, simulation_config: SimulationConfig, gather_config: Optional[GatherConfig] = None, num_meta_parameters: Optional[int] = None, clean: bool = True, finish_missing: bool = False)[source]
Bases:
object
The simulation builder class constructs the scripts needed for building the table model database
- __init__(parameter_grid: ParameterGrid, out_file: str, import_line: str, simulation_config: SimulationConfig, gather_config: Optional[GatherConfig] = None, num_meta_parameters: Optional[int] = None, clean: bool = True, finish_missing: bool = False)[source]
TODO describe function
- Parameters:
parameter_grid (ParameterGrid) –
out_file (str) –
import_line (str) –
simulation_config (SimulationConfig) –
gather_config (Optional[GatherConfig]) –
num_meta_parameters (Optional[int]) –
clean (bool) –
- Returns:
- classmethod from_yaml(file_name: str) SimulationBuilder [source]
Create a simulation setup from a yaml file.
- class ronswanson.Database(grid_points: ndarray, parameter_names: List[str], energy_grid: ndarray, run_time: ndarray, values: ndarray, meta_data: Optional[Dict[str, ndarray]] = None)[source]
Bases:
object
- __init__(grid_points: ndarray, parameter_names: List[str], energy_grid: ndarray, run_time: ndarray, values: ndarray, meta_data: Optional[Dict[str, ndarray]] = None) None [source]
Databse of parameters and simulated values
- Parameters:
grid_points (Dict[str, np.ndarray]) –
parameter_names (List[str]) –
energy_grid (np.ndarray) –
values (Dict[str, np.ndarray]) –
- Returns:
- property n_entries: int
the number of entries in the database
- Returns:
- property n_parameters: int
the number of parameters in the database
- Returns:
- property grid_points: ndarray
- property values: ndarray
- property parameter_ranges: Dict[str, ndarray]
- property parameter_names: List[str]
the names of the parameters
- property run_time: ndarray
an array of runtimes for all points in the grid
- Returns:
- property energy_grid: ndarray
The corresponding energy grid of the simulation
- Returns:
- property meta_data: Optional[Dict[str, ndarray]]
- classmethod from_file(file_name: str, output: int = 0) Database [source]
open a database from a file. The output argument specifies which value to collect. For example, a simulation may save photon and electron distributions from a solution.
- replace_nan_inf_with(value: float = 0.0) None [source]
Replace NaN and inf values with a float
- Parameters:
value (float) –
- Returns:
- to_3ml(name: str, desc: str, overwrite: bool = False, **kwargs) TemplateModel [source]
construct a table model from the database. parameter sub-selections are passed as kwargs of dictionaries:
selections = dict(param1=dict(vmin=1, vmax=2))
- Parameters:
name (str) –
desc (str) –
overwrite (bool) –
- Returns:
- check_for_missing_parameters(parameter_grid: ParameterGrid, create_new_grid: bool = False) None [source]
Search a parameter grid for missing values
- Parameters:
parameter_grid (ParameterGrid) –
create_new_grid (bool) –
- Returns: