Index: wflow-py/wflow/wf_DynamicFramework.py =================================================================== diff -u -r7cbe2c1a4cff6838d760dc90ecb87c2a0dbe6169 -rbec706d676b364d4a89a4e7141382db4511fa485 --- wflow-py/wflow/wf_DynamicFramework.py (.../wf_DynamicFramework.py) (revision 7cbe2c1a4cff6838d760dc90ecb87c2a0dbe6169) +++ wflow-py/wflow/wf_DynamicFramework.py (.../wf_DynamicFramework.py) (revision bec706d676b364d4a89a4e7141382db4511fa485) @@ -499,6 +499,8 @@ self._addMethodToClass(self.wf_supplyStartTimeDOY) self._addMethodToClass(self.wf_supplyStartTime) self._addMethodToClass(self.wf_supplyJulianDOY) + self._addMethodToClass(self.wf_supplyStartDateTime) + self._addMethodToClass(self.wf_supplyCurrentDateTime) self._addAttributeToClass("ParamType", self.ParamType) self._addAttributeToClass("timestepsecs", self.DT.timeStepSecs) self._addAttributeToClass("__version__", __version__) @@ -1399,24 +1401,41 @@ # Print .ini defined outputmaps per timestep toprint = configsection(self._userModel().config, 'outputmaps') + self.logger.info("saving maps") + for a in toprint: report = False + #possible to add variables if '+' in a: a_ = a.split('+') thevar = cover(0.0) for i in arange(0,len(a_)): - if hasattr(self._userModel(), a_[i].strip().replace('self.', '')): + #check for nested objects + if len(a_.replace('self.', '').split('.')) > 1: + if hasattr(self._userModel(), a_.replace('self.', '').split('.')[0]) and hasattr(eval("self._userModel()." + a_.replace('self.', '').split('.')[0]), a.replace('self.', '').split('.')[1]): + thevar = thevar + reduce(getattr, a_.replace('self.', '').split('.'), self._userModel()) + report = True + + elif hasattr(self._userModel(), a_[i].strip().replace('self.', '')): thevar = thevar + getattr(self._userModel(), a_[i].strip().replace('self.', '')) report = True + else: report = False break + else: - if hasattr(self._userModel(), a.replace('self.', '')): + #check for nested objects + if len(a.replace('self.', '').split('.')) > 1: + if hasattr(self._userModel(), a.replace('self.', '').split('.')[0]) and hasattr(eval("self._userModel()." + a.replace('self.', '').split('.')[0]), a.replace('self.', '').split('.')[1]): + thevar = reduce(getattr, a.replace('self.', '').split('.'), self._userModel()) + report = True + + elif hasattr(self._userModel(), a.replace('self.', '')): thevar = getattr(self._userModel(), a.replace('self.', '')) report = True - + if report == True: if type(thevar) is list: a = self._userModel().config.get("outputmaps", a) @@ -1473,7 +1492,14 @@ mpath = os.path.join(directory, var + ".map").replace("\\", "/") tvar = self.wf_readmap(mpath, 0.0, ncfilesource=self.ncinfilestates) #wf_readmtvar = self.wf_readmap(mpath,0.0,ncfilesource=self.ncinfilestates,fail=True) - setattr(self._userModel(), var,tvar) + + #check for nested objects + if '.' in var: + attrs = var.split('.') + c = getattr(self._userModel(), attrs[0]) + setattr(c, attrs[1],tvar) + else: + setattr(self._userModel(), var,tvar) except: self.logger.error( "problem while reading state variable from disk: " + mpath + " Suggest to use the -I option to restart") @@ -2091,7 +2117,36 @@ seconds_since_epoch = calendar.timegm(dtt.utctimetuple()) return seconds_since_epoch + + + def wf_supplyCurrentDateTime(self): + """ + gets the current time in seconds after the start of the run + Assumed daily timesteps if not defined in the user model + Output: + - current model time (since start of the run) + + """ + dtt = self.DT.currentDateTime + + return dtt + + + def wf_supplyStartDateTime(self): + """ + gets the current time in seconds after the start of the run + Assumed daily timesteps if not defined in the user model + + Output: + - current model time (since start of the run) + + """ + dtt = self.DT.runStartTime + + return dtt + + def wf_supplyEpoch(self): """ Supplies the time epoch as a CF string