Scenario¶
The Scenario class initializes a simulation for a single set of parameters and then executes a user-specified number of uncertainty runs within that scenario.
The DES, Cost Graph, and PyLCIA are all instantiated and called from Scenario, as are postprocessing methods and the diagnostic visualizations.
Created January 27, 2022.
@author: rhanes
-
class
celavi.scenario.
Scenario
(parser)¶ Set up, validate, and execute a CELAVI scenario.
Execute multiple runs automatically to quantify uncertainty in results.
-
__init__
(parser)¶ Initialize Scenario and validate inputs.
- parser
Parser object for reading in config files.
- Raises
IOError – Raises IOError if either config file cannot be opened.
-
get_filepaths
()¶ Check that input files exist and assemble paths.
- Raises
Exception – Raises exception if necessary filepaths do not exist.
-
preprocess
()¶ Compute routes, locations, technology units, and step costs.
-
setup
()¶ Create instances of CostGraph, DES (Context and Components) and PyLCIA.
-
execute
()¶ Execute one model run within the scenario.
-
postprocess
()¶ Post-process, visualize, and save results of one model run.
-
static
impact_and_units
(line_item)¶ Cleans up an impact name to return the units and the name of the impact as separate strings. It removes “(“, “)”, “[“, “]” and thw word “substance” from units.
- Parameters
line_item (str) – Impact and unit mixed together from the LCIA.
- Returns
Tuple of impact name and units of that impact.
- Return type
str, str
-
calculate_circularity_metrics
(mass)¶ Calculates the inflow and outflow circularity metrics from the mass flow dataframe provided.
- Parameters
mass (pandas.DataFrame) – The mass flow cumulative history from the scenario run
- Returns
A tuple of the outflow circularity metric and the inflow circularity metric.
- Return type
Tuple[float, float]
-
clear_results
()¶ Move old CSV results files to a timestamped sub-directory.
-
static
simtime
(starttime)¶ Record the current simulation time to one decimal point.
The simulation time does not reset for additional model runs.
- Parameters
starttime (float) – Time that the simulation began.
- Returns
Time since simulation began.
- Return type
[float]
-