Commit b559a9c4 authored by Jorn Baayen's avatar Jorn Baayen

Merge branch 'csv_simulation' into 'master'

use initial_state.csv entries to set input variables

See merge request !60
parents 4a96e107 46140303
......@@ -76,10 +76,11 @@ class CSVMixin(SimulationProblem):
self._parameters = {}
try:
self._initial_state = csv.load(os.path.join(
_initial_state = csv.load(os.path.join(
self._input_folder, 'initial_state.csv'), delimiter=self.csv_delimiter)
logger.debug("CSVMixin: Read initial state.")
check_initial_state_array(self._initial_state)
check_initial_state_array(_initial_state)
self._initial_state = {key: float(_initial_state[key]) for key in _initial_state.dtype.names}
except IOError:
self._initial_state = {}
......@@ -120,6 +121,15 @@ class CSVMixin(SimulationProblem):
# Load input variable names
self._input_variables = set(self.get_input_variables().keys())
# Set initial states
for variable, value in self._initial_state.iteritems():
if variable in self._input_variables:
if variable in self._timeseries:
logger.warning("Entry {} in initial_state.csv was also found in timeseries_import.csv.".format(variable))
self.set_var(variable, value)
else:
logger.warning("Entry {} in initial_state.csv is not an input variable.".format(variable))
logger.debug("Model inputs are {}".format(self._input_variables))
# Set initial input values
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment