smif.data_layer.results module

Results provides a common interface to access results from model runs.

Summary

Data:

Results 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: object

Common 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
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(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 store
  • SmifDataMismatchError – Data presented to read, write and update methods is in the incorrect format or of wrong dimensions to that expected
  • SmifDataReadError – When unable to read data e.g. unable to handle file type or connect to database
Returns:

Return type:

pandas.DataFrame

get_units(output_name: str)[source]

Return the units of a given output.

Parameters:output_name (str) –
Returns:
Return type:str
validate_names(model_run_names, sec_model_names, output_names)[source]