smif.data_layer.data_interface module¶
Common data interface
Summary¶
Exceptions:
DataExistsError |
Raise when some data is found unexpectedly |
DataMismatchError |
Raise when some data doesn’t match the context |
DataNotFoundError |
Raise when some data is not found |
Classes:
DataInterface |
Abstract base class to define common data interface |
Reference¶
-
class
smif.data_layer.data_interface.
DataInterface
[source]¶ Bases:
object
Abstract base class to define common data interface
-
read_scenario_data
(scenario_name, parameter_name, spatial_resolution, temporal_resolution, timestep)[source]¶
-
read_state
(modelrun_name, timestep=None, decision_iteration=None)[source]¶ state is a list of (intervention_name, build_year), output of decision module/s
-
write_state
(state, modelrun_name, timestep, decision_iteration=None)[source]¶ State is a list of decision dicts with name and build_year keys,
State is output from the DecisionManager
Parameters:
-
read_parameters
(modelrun_name, model_name)[source]¶ Read global and model-specific parameter values for a given modelrun and model.
-
read_results
(modelrun_name, model_name, output_name, spatial_resolution, temporal_resolution, timestep=None, modelset_iteration=None, decision_iteration=None)[source]¶
-
write_results
(modelrun_name, model_name, output_name, data, spatial_resolution, temporal_resolution, timestep=None, modelset_iteration=None, decision_iteration=None)[source]¶
-
static
ndarray_to_data_list
(data, region_names, interval_names, timestep=None)[source]¶ Convert
numpy.ndarray
to list of observationsParameters: - data (numpy.ndarray) –
- region_names (list of str) –
- interval_names (list of str) –
- timestep (int or None) –
Returns: observations – Each dict has keys: ‘region’ (a region name), ‘interval’ (an interval name) and ‘value’.
Return type: list of dict
-
static
data_list_to_ndarray
(observations, region_names, interval_names)[source]¶ Convert list of observations to
numpy.ndarray
Parameters: Returns: data
Return type: Raises: KeyError
– If an observation is missing a required keyValueError
– If an observation region or interval is not in region_names or interval_namesDataNotFoundError
– If the observations don’t include data for any region/interval combinationDataMismatchError
– If the region_names and interval_names do not match the observations
-
-
exception
smif.data_layer.data_interface.
DataNotFoundError
[source]¶ Bases:
Exception
Raise when some data is not found