smif.data_layer.results module¶
Results provides a common interface to access results from model runs.
Reference¶
-
class
smif.data_layer.results.Results(store: Union[smif.data_layer.store.Store, dict])[source]¶ Bases:
objectCommon interface to access results from model runs.
Parameters: store (Store or dict) – pre-created Store object or dictionary of the form {‘interface’: <interface>, ‘dir’: <dir>} where <interface> is either ‘local_csv’ or ‘local_parquet’, and <dir> is the model base directory -
list_model_runs()[source]¶ Return a list of model run names.
Returns: Return type: List of model run names
-
list_sector_models(model_run_name: str)[source]¶ Return a list of sector models for given model run.
Parameters: model_run_name (str the requested model run) – Returns: Return type: List of sector models for the given model run
-
list_scenarios(model_run_name: str)[source]¶ Return a dictionary of scenarios for given model run.
Parameters: model_run_name (str the requested model run) – Returns: Return type: Dictionary of (scenario name, variant) for the given model run.
-
list_scenario_outputs(scenario_name: str)[source]¶ Return a list of outputs of a given scenario.
Parameters: scenario_name (str the requested scenario) – Returns: Return type: List of outputs for the requested scenario
-
list_outputs(sector_model_name: str)[source]¶ Return a list of model run names.
Parameters: sector_model_name (str the requested sector model) – Returns: Return type: List of outputs for the given sector model
-
available_results(model_run_name)[source]¶ Return the results available for a given model run.
Parameters: model_run_name (str the requested model run) – Returns: Return type: A nested dictionary data structure of the results available for the given model run
-
read_results(model_run_names: list, model_names: list, output_names: list, timesteps: list = None, decisions: list = None, time_decision_tuples: list = None)[source]¶ Return results from the store as a formatted pandas data frame. There are a number of ways of requesting specific timesteps/decisions. You can specify either:
- a list of (timestep, decision) tuples
- in which case data for all of those tuples matching the available results will be returned
- or:
- a list of timesteps
- in which case data for all of those timesteps (and any decision iterations) matching the available results will be returned
- or:
- a list of decision iterations
- in which case data for all of those decision iterations (and any timesteps) matching the available results will be returned
- or:
- a list of timesteps and a list of decision iterations
- in which case data for the Cartesian product of those timesteps and those decision iterations matching the available results will be returned
- or:
- nothing
- in which case all available results will be returned
Parameters: - model_run_names (list) – the requested model run names
- model_names (list) – the requested sector model names (exactly one required)
- output_names (list) – the requested output names (output specs must all match)
- timesteps (list) – the requested timesteps
- decisions (list) – the requested decision iterations
- time_decision_tuples (list) – a list of requested (timestep, decision) tuples
Raises: SmifDataNotFoundError– If data cannot be found in the store when try to read from the storeSmifDataMismatchError– Data presented to read, write and update methods is in the incorrect format or of wrong dimensions to that expectedSmifDataReadError– When unable to read data e.g. unable to handle file type or connect to database
Returns: Return type:
-
read_scenario_data(scenario_name: str, variant_name: str, variable_name: str, timesteps: list) → <MagicMock id='139756499240720'>[source]¶ Return scenario variant data from the store as a formatted pandas data frame.
Parameters: Raises: SmifDataNotFoundError– If data cannot be found in the store when try to read from the storeSmifDataMismatchError– Data presented to read, write and update methods is in the incorrect format or of wrong dimensions to that expectedSmifDataReadError– When unable to read data e.g. unable to handle file type or connect to database
Returns: Return type:
-