Commit 852267b3 authored by Jorn Baayen's avatar Jorn Baayen

Merge branch 'master' into casadi3

parents 2fb3f455 b559a9c4
......@@ -94,9 +94,10 @@ class CSVMixin(OptimizationProblem):
try:
_parameters = csv.load(os.path.join(
self._input_folder, ensemble_member_name, 'parameters.csv'), delimiter=self.csv_delimiter)
_parameters = {key: float(_parameters[key]) for key in _parameters.dtype.names}
except IOError:
_parameters = {}
self._parameters.append(_parameters)
self._parameters.append(AliasDict(self.alias_relation, _parameters))
logger.debug("CSVMixin: Read parameters.")
for ensemble_member_name in self._ensemble['name']:
......@@ -104,9 +105,10 @@ class CSVMixin(OptimizationProblem):
_initial_state = csv.load(os.path.join(
self._input_folder, ensemble_member_name, 'initial_state.csv'), delimiter=self.csv_delimiter)
check_initial_state_array(_initial_state)
_initial_state = {key: float(_initial_state[key]) for key in _initial_state.dtype.names}
except IOError:
_initial_state = {}
self._initial_state.append(_initial_state)
self._initial_state.append(AliasDict(self.alias_relation, _initial_state))
logger.debug("CSVMixin: Read initial state.")
else:
_timeseries = csv.load(os.path.join(
......@@ -120,18 +122,20 @@ class CSVMixin(OptimizationProblem):
_parameters = csv.load(os.path.join(
self._input_folder, 'parameters.csv'), delimiter=self.csv_delimiter)
logger.debug("CSVMixin: Read parameters.")
_parameters = {key: float(_parameters[key]) for key in _parameters.dtype.names}
except IOError:
_parameters = {}
self._parameters.append(_parameters)
self._parameters.append(AliasDict(self.alias_relation, _parameters))
try:
_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(_initial_state)
_initial_state = {key: float(_initial_state[key]) for key in _initial_state.dtype.names}
except IOError:
_initial_state = {}
self._initial_state.append(_initial_state)
self._initial_state.append(AliasDict(self.alias_relation, _initial_state))
self._timeseries_times_sec = self._datetime_to_sec(
self._timeseries_times)
......
......@@ -74,10 +74,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 = {}
......@@ -118,6 +119,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
......
......@@ -5,7 +5,7 @@
</ns0:parameter>
</ns0:group>
<ns0:group id="states" name="states" readonly="false">
<ns0:parameter id="x">
<ns0:parameter id="alias">
<ns0:dblValue>1.02</ns0:dblValue>
</ns0:parameter>
</ns0:group>
......
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