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_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
(region_names, interval_names)[source]¶ Convert
numpy.ndarray
to list of observationsParameters: - data (numpy.ndarray) –
- region_names (list of str) –
- interval_names (list of str) –
Returns: observations – Each dict has keys: ‘region’ (a region name), ‘interval’ (an interval name) and ‘value’.
Return type: list of dict
-
static
ndarray_to_buffer
()[source]¶ Serialize
numpy.ndarray
and metadata to a byte bufferParameters: data (numpy.ndarray) – Returns: Byte buffer containing the serialized input Return type: pyarrow.lib.Buffer
-
static
data_list_to_ndarray
(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 combination
-
-
exception
smif.data_layer.data_interface.
DataNotFoundError
[source]¶ Bases:
Exception
Raise when some data is not found