smif.data_layer.memory_interface module¶
Memory-backed store implementations
Summary¶
Data:
MemoryConfigStore |
Config store in memory |
MemoryDataStore |
Store data in-memory |
MemoryMetadataStore |
Store metadata in-memory |
Reference¶
-
class
smif.data_layer.memory_interface.
MemoryConfigStore
[source]¶ Bases:
smif.data_layer.abstract_config_store.ConfigStore
Config store in memory
-
read_model_run
(model_run_name)[source]¶ Read a system-of-system model run
Parameters: model_run_name (str) – Returns: Return type: ModelRun
-
write_model_run
(model_run)[source]¶ Write system-of-system model run
Parameters: model_run (ModelRun) –
-
delete_model_run
(model_run_name)[source]¶ Delete a system-of-system model run
Parameters: model_run_name (str) –
-
read_sos_model
(sos_model_name)[source]¶ Read a specific system-of-system model
Parameters: sos_model_name (str) – Returns: Return type: SosModel
-
delete_sos_model
(sos_model_name)[source]¶ Delete a system-of-system model
Parameters: sos_model_name (str) –
-
read_model
(model_name)[source]¶ Read a model
Parameters: model_name (str) – Returns: Return type: Model
-
update_model
(model_name, model)[source]¶ Update a model
Parameters: - model_name (str) –
- model (Model) –
-
read_scenario
(scenario_name)[source]¶ Read a scenario
Parameters: scenario_name (str) – Returns: Return type: ScenarioModel
-
update_scenario
(scenario_name, scenario)[source]¶ Update scenario
Parameters: - scenario_name (str) –
- scenario (ScenarioModel) –
-
delete_scenario
(scenario_name)[source]¶ Delete scenario from project configuration
Parameters: scenario_name (str) –
-
read_scenario_variants
(scenario_name)[source]¶ Read variants of a given scenario
Parameters: scenario_name (str) – Returns: Return type: list[dict]
-
read_scenario_variant
(scenario_name, variant_name)[source]¶ Read a scenario variant
Parameters: Returns: Return type:
-
write_scenario_variant
(scenario_name, variant)[source]¶ Write scenario to project configuration
Parameters:
-
update_scenario_variant
(scenario_name, variant_name, variant)[source]¶ Update scenario to project configuration
Parameters:
-
delete_scenario_variant
(scenario_name, variant_name)[source]¶ Delete scenario from project configuration
Parameters:
-
-
class
smif.data_layer.memory_interface.
MemoryMetadataStore
[source]¶ Bases:
smif.data_layer.abstract_metadata_store.MetadataStore
Store metadata in-memory
-
write_unit_definitions
(units)[source]¶ Reads custom unit definitions
Parameters: list[str] – Pint-compatible unit definitions
-
read_unit_definitions
()[source]¶ Reads custom unit definitions
Returns: Pint-compatible unit definitions Return type: list[str]
-
read_dimensions
(skip_coords=False)[source]¶ Read dimensions
Parameters: skip_coords (bool, default False) – If True, skip reading dimension elements (names and metadata) Returns: Return type: list[Coords]
-
read_dimension
(dimension_name, skip_coords=False)[source]¶ Return dimension
Parameters: Returns: A dimension definition (including elements)
Return type: Coords
-
write_dimension
(dimension)[source]¶ Write dimension to project configuration
Parameters: dimension (Coords) –
-
-
class
smif.data_layer.memory_interface.
MemoryDataStore
[source]¶ Bases:
smif.data_layer.abstract_data_store.DataStore
Store data in-memory
-
read_scenario_variant_data
(key, spec, timestep=None, timesteps=None)[source]¶ Read scenario variant data array.
If a single timestep is specified, the spec MAY include ‘timestep’ as a dimension, which should match the timestep specified.
If multiple timesteps are specified, the spec MUST include ‘timestep’ as a dimension, which should match the timesteps specified.
If timestep and timesteps are None, read all available timesteps. Whether or not the spec includes ‘timestep’ as a dimension, the returned DataArray will include a ‘timestep’ dimension with all available timesteps included.
Parameters: Returns: data_array
Return type:
-
scenario_variant_data_exists
(key)[source]¶ Test if scenario variant data exists
Parameters: key (str) – Returns: Return type: bool
-
read_narrative_variant_data
(key, spec, timestep=None)[source]¶ Read data array
Parameters: Returns: data_array
Return type:
-
read_model_parameter_default
(key, spec)[source]¶ Read data array
Parameters: Returns: data_array
Return type:
-
write_model_parameter_default
(key, data)[source]¶ Read data array
Parameters: Returns: data_array
Return type:
-
read_interventions
(keys)[source]¶ Read interventions data for key
Parameters: key (str) – Returns: A dict of intervention dictionaries containing intervention attributes keyed by intervention name Return type: dict[str, dict]
-
read_initial_conditions
(keys)[source]¶ Read historical interventions for key
Parameters: key (str) – Returns: Return type: list[dict]
-
write_initial_conditions
(key, initial_conditions)[source]¶ Write historical interventions for key
Parameters:
-
read_state
(modelrun_name, timestep=None, decision_iteration=None)[source]¶ Read list of (name, build_year) for a given model_run, timestep, decision
Parameters: Returns: Return type:
-
write_state
(state, modelrun_name, timestep=None, decision_iteration=None)[source]¶ State is a list of decisions with name and build_year.
State is output from the DecisionManager
Parameters:
-
read_coefficients
(source_dim, destination_dim)[source]¶ Reads coefficients from the store
Coefficients are uniquely identified by their source/destination dimensions. This method and write_coefficients implement caching of conversion coefficients between a single pair of dimensions.
Parameters: Returns: Return type: Notes
To be called from
Adaptor
implementations.
-
write_coefficients
(source_dim, destination_dim, data)[source]¶ Writes coefficients to the store
Coefficients are uniquely identified by their source/destination dimensions. This method and read_coefficients implement caching of conversion coefficients between a single pair of dimensions.
Parameters: - source_dim (str) – dimension name
- destination_dim (str) – dimension name
- data (numpy.ndarray) –
Notes
To be called from
Adaptor
implementations.
-
read_results
(modelrun_name, model_name, output_spec, timestep=None, decision_iteration=None)[source]¶ Return results of a model from a model_run for a given output at a timestep and decision iteration
Parameters: Returns: Return type:
-
write_results
(data_array, modelrun_name, model_name, timestep=None, decision_iteration=None)[source]¶ Write results of a model_name in model_run_name for a given output_name
Parameters:
-