Index: wflow-py/wflow/wflow_bmi.py =================================================================== diff -u -r37acfacb11c93d192f1af0e9709a52f4f9eb5fcc -r33871015ad959ac7b7956233337cd77fe46973d2 --- wflow-py/wflow/wflow_bmi.py (.../wflow_bmi.py) (revision 37acfacb11c93d192f1af0e9709a52f4f9eb5fcc) +++ wflow-py/wflow/wflow_bmi.py (.../wflow_bmi.py) (revision 33871015ad959ac7b7956233337cd77fe46973d2) @@ -6,9 +6,9 @@ import wflow.bmi as bmi import numpy as np -#TODO: Set log level also ini to be able to make quiet or non-quiet runs -#TODO: set re-init in the ini file to be able to make cold start runs -#TODO: Rework framework to get rid of max timesteps shit +# TODO: Set log level also ini to be able to make quiet or non-quiet runs +# TODO: set re-init in the ini file to be able to make cold start runs +# TODO: Rework framework to get rid of max timesteps shit class wflowbmi_ligth(object): """ @@ -39,7 +39,6 @@ # .. todo:: # Get name of module from ini file name - maxNrSteps = 10000 if "wflow_sbm.ini" in configfile: import wflow_sbm as wf @@ -60,7 +59,6 @@ self.dynModel._runInitial() self.dynModel._runResume() - return retval def finalize(self): @@ -71,8 +69,6 @@ self.dynModel._runSuspend() self.dynModel._wf_shutdown() - - def update(self, dt): """ Return type string, compatible with numpy. @@ -87,8 +83,6 @@ self.dynModel._runDynamic(self.currenttimestep, self.currenttimestep + nrsteps -1) self.currenttimestep = self.currenttimestep + nrsteps - - def get_time_units(self): """ @@ -99,14 +93,12 @@ return self.dynModel.wf_supplyEpoch() - def get_var_count(self): """ Return number of variables """ return self.dynModel.wf_supplyVariableCount() - def get_var_name(self, i): """ Return variable name @@ -115,7 +107,6 @@ names = self.dynModel.wf_supplyVariableNames() return names[i] - def get_var_type(self, name): """ Return type string, compatible with numpy. @@ -124,7 +115,6 @@ return str(npmap.dtype) - def get_var_rank(self, name): """ Return array rank or 0 for scalar. @@ -133,7 +123,6 @@ return len(npmap.shape) - def get_var_shape(self, name): """ Return shape of the array. @@ -142,21 +131,18 @@ return npmap.shape - def get_start_time(self): """ returns start time """ return self.dynModel.wf_supplyStartTime() - def get_end_time(self): """ returns end time of simulation """ return self.dynModel.wf_supplyEndTime() - def get_current_time(self): """ returns current time of simulation @@ -169,7 +155,6 @@ """ return self.dynModel.wf_supplyMapAsNumpy(name) - def set_var(self, name, var): """ Set the variable name with the values of var @@ -178,8 +163,6 @@ #TODO: check the numpy type self.dynModel.wf_setValuesAsNumpy(name, var) - - def set_var_slice(self, name, start, count, var): """ Overwrite the values in variable name with data @@ -200,7 +183,6 @@ self.set_var(name, name, tmp) - def set_var_index(self, name, index, var): """ Overwrite the values in variable "name" with data @@ -215,24 +197,19 @@ tmp.flat[index] = var self.set_var(name, name, tmp) - - - def inq_compound(self, name): """ Return the number of fields of a compound type. """ pass - def inq_compound_field(self, name, index): """ Lookup the type,rank and shape of a compound field """ pass - class wflowbmi_csdms(bmi.Bmi): """ csdms BMI implementation for pcraster/python models @@ -256,7 +233,6 @@ self.myModel = None self.dynModel = None - def initialize(self, filename,loglevel=logging.DEBUG): """ Initialise the model. Should be call before any other method. @@ -299,7 +275,6 @@ exec "import wflow." + modname + " as wf" self.name = modname - self.myModel = wf.WflowModel(wflow_cloneMap, datadir, runid, inifile) self.dynModel = wf.wf_DynamicFramework(self.myModel, maxNrSteps, firstTimestep = 1) @@ -315,7 +290,6 @@ self.dynModel._runDynamic(self.currenttimestep, self.currenttimestep) self.currenttimestep = self.currenttimestep + 1 - def update_until(self, time): """ Update the model until the given time. Can only go foreward in time. @@ -390,20 +364,13 @@ :return: List of String objects: identifiers of all output variables of the model: """ namesroles = self.dynModel.wf_supplyVariableNamesAndRoles() - - # input variable are all forcing variables and all state variables - #0 = input (to the model) - #1 = is output (from the model) - #2 = input/output (state information) - #3 = model parameter inames = [] for varrol in namesroles: if varrol[1] == 1 or varrol[1] == 2: inames.append(varrol[0]) return inames - def get_var_type(self, long_var_name): """ Gets the variable type as a numpy type string @@ -414,7 +381,6 @@ return str(npmap.dtype) - def get_var_rank(self, long_var_name): """ Gets the number of dimensions for a variable @@ -451,7 +417,6 @@ return npmap.size * npmap.itemsize - def get_start_time(self): """ Gets the start time of the model. @@ -468,7 +433,6 @@ """ return self.dynModel.wf_supplyCurrentTime() - def get_end_time(self): """ Get the end time of the model run in units since the epoch @@ -579,7 +543,6 @@ return self.dynModel.wf_supplyGridDim()[0:2] - def get_grid_x(self, long_var_name): """ Give X coordinates of point in the model grid @@ -647,7 +610,6 @@ """ raise NotImplementedError - def get_grid_offset(self, long_var_name): """ Not applicable raises NotImplementedError