Index: wflow-py/Sandbox/wflow_HRU_test.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Sandbox/wflow_HRU_test.py (.../wflow_HRU_test.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Sandbox/wflow_HRU_test.py (.../wflow_HRU_test.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -37,9 +37,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -206,7 +205,7 @@ except: self.logger.warn("Cannot load initial states, setting to default") for s in self.stateVariables(): - exec "self." + s + " = cover(1.0)" + exec("self." + s + " = cover(1.0)") def default_summarymaps(self): """ @@ -232,28 +231,18 @@ """ HRU 1 """ - print "HRU 1" - self.TSoil[name] = ( - self.TSoil - + 0.1125 - * (self.Temperature - self.TSoil) - * self.timestepsecs - / self.basetimestep - ) + print("HRU 1") + self.TSoil[name] = self.TSoil + 0.1125 * (self.Temperature - self.TSoil) * self.timestepsecs/self.basetimestep - def unit2(self, name): + + def unit2(self,name): """ HRU 2 """ - print "HRU 2" - self.TSoil[name] = ( - self.TSoil - + 0.1125 - * (self.Temperature - self.TSoil) - * self.timestepsecs - / self.basetimestep - ) + print("HRU 2") + self.TSoil[name] = self.TSoil + 0.1125 * (self.Temperature - self.TSoil) * self.timestepsecs/self.basetimestep + def dynamic(self): """ *Required* Index: wflow-py/Sandbox/wflow_mswat.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Sandbox/wflow_mswat.py (.../wflow_mswat.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Sandbox/wflow_mswat.py (.../wflow_mswat.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -31,9 +31,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -478,18 +477,19 @@ setup needed. """ - self.logger.info("Reading initial conditions...") - #: It is advised to use the wf_resume() function - #: here which pick up the variable save by a call to wf_suspend() - try: - self.wf_resume(self.Dir + "/instate/") - except: - self.logger.warn("Cannot load initial states, setting to default") - for s in self.stateVariables(): - exec "self." + s + " = cover(1.0)" + self.logger.info("Reading initial conditions...") + #: It is advised to use the wf_resume() function + #: here which pick up the variable save by a call to wf_suspend() + try: + self.wf_resume(self.Dir + "/instate/") + except: + self.logger.warn("Cannot load initial states, setting to default") + for s in self.stateVariables(): + exec("self." + s + " = cover(1.0)") - def default_summarymaps(self): - """ + + def default_summarymaps(self): + """ *Optional* Return a default list of variables to report as summary maps in the outsum dir. Index: wflow-py/Sandbox/wflow_musle.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Sandbox/wflow_musle.py (.../wflow_musle.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Sandbox/wflow_musle.py (.../wflow_musle.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -31,9 +31,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -483,18 +482,19 @@ setup needed. """ - self.logger.info("Reading initial conditions...") - #: It is advised to use the wf_resume() function - #: here which pick up the variable save by a call to wf_suspend() - try: - self.wf_resume(self.Dir + "/instate/") - except: - self.logger.warn("Cannot load initial states, setting to default") - for s in self.stateVariables(): - exec "self." + s + " = cover(1.0)" + self.logger.info("Reading initial conditions...") + #: It is advised to use the wf_resume() function + #: here which pick up the variable save by a call to wf_suspend() + try: + self.wf_resume(self.Dir + "/instate/") + except: + self.logger.warn("Cannot load initial states, setting to default") + for s in self.stateVariables(): + exec("self." + s + " = cover(1.0)") - def default_summarymaps(self): - """ + + def default_summarymaps(self): + """ *Optional* Return a default list of variables to report as summary maps in the outsum dir. Index: wflow-py/Sandbox/wflow_prepare_rad.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Sandbox/wflow_prepare_rad.py (.../wflow_prepare_rad.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Sandbox/wflow_prepare_rad.py (.../wflow_prepare_rad.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -269,9 +269,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -287,8 +286,8 @@ return try: - opts, args = getopt.getopt(argv, "hD:Mx:y:l:O:S:E:T:s:e:") - except getopt.error, msg: + opts, args = getopt.getopt(argv, 'hD:Mx:y:l:O:S:E:T:s:e:') + except getopt.error as msg: usage(msg) thedem = "mydem.map" @@ -304,34 +303,21 @@ ehour = 23 for o, a in opts: - if o == "-h": - usage() - if o == "-O": - outputdir = a - if o == "-D": - thedem = a - if o == "-M": - xymetres = true - if o == "-x": - lat = int(a) - if o == "-y": - lon = int(a) - if o == "-S": - startday = int(a) - if o == "-E": - endday = int(a) - if o == "-T": - calc_interval = int(a) - if o == "-l": - exec "thelevel = logging." + a - if o == "-s": - shour = int(a) - if o == "-e": - ehour = int(a) + if o == '-h': usage() + if o == '-O': outputdir = a + if o == '-D': thedem = a + if o == '-M': xymetres = true + if o == '-x': lat = int(a) + if o == '-y': lon = int(a) + if o == '-S': startday = int(a) + if o == '-E': endday = int(a) + if o == '-T': calc_interval = int(a) + if o == '-l': exec("thelevel = logging." + a) + if o == '-s': shour = int(a) + if o == '-e': ehour = int(a) - logger = pcr.setlogger( - "wflow_prepare_rad.log", "wflow_prepare_rad", thelevel=loglevel - ) + + logger = pcr.setlogger("wflow_prepare_rad.log","wflow_prepare_rad",thelevel=loglevel) if not os.path.exists(thedem): logger.error("Cannot find dem: " + thedem + " exiting.") sys.exit(1) Index: wflow-py/Sandbox/wflow_usle.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Sandbox/wflow_usle.py (.../wflow_usle.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Sandbox/wflow_usle.py (.../wflow_usle.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -55,9 +55,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -471,18 +470,19 @@ setup needed. """ - self.logger.info("Reading initial conditions...") - #: It is advised to use the wf_resume() function - #: here which pick up the variable save by a call to wf_suspend() - try: - self.wf_resume(self.Dir + "/instate/") - except: - self.logger.warn("Cannot load initial states, setting to default") - for s in self.stateVariables(): - exec "self." + s + " = cover(1.0)" + self.logger.info("Reading initial conditions...") + #: It is advised to use the wf_resume() function + #: here which pick up the variable save by a call to wf_suspend() + try: + self.wf_resume(self.Dir + "/instate/") + except: + self.logger.warn("Cannot load initial states, setting to default") + for s in self.stateVariables(): + exec("self." + s + " = cover(1.0)") - def default_summarymaps(self): - """ + + def default_summarymaps(self): + """ *Optional* Return a default list of variables to report as summary maps in the outsum dir. Index: wflow-py/Sandbox/wflow_vegetation.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Sandbox/wflow_vegetation.py (.../wflow_vegetation.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Sandbox/wflow_vegetation.py (.../wflow_vegetation.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -34,9 +34,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -192,18 +191,19 @@ setup needed. """ - self.logger.info("Reading initial conditions...") - #: It is advised to use the wf_resume() function - #: here which pick up the variable save by a call to wf_suspend() - try: - self.wf_resume(self.Dir + "/instate/") - except: - self.logger.warn("Cannot load initial states, setting to default") - for s in self.stateVariables(): - exec "self." + s + " = cover(1.0)" + self.logger.info("Reading initial conditions...") + #: It is advised to use the wf_resume() function + #: here which pick up the variable save by a call to wf_suspend() + try: + self.wf_resume(self.Dir + "/instate/") + except: + self.logger.warn("Cannot load initial states, setting to default") + for s in self.stateVariables(): + exec("self." + s + " = cover(1.0)") - def default_summarymaps(self): - """ + + def default_summarymaps(self): + """ *Optional* Return a default list of variables to report as summary maps in the outsum dir. Index: wflow-py/Sandbox/wflow_w3.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Sandbox/wflow_w3.py (.../wflow_w3.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Sandbox/wflow_w3.py (.../wflow_w3.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -49,9 +49,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -1072,21 +1071,16 @@ for o, a in opts: - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-c": - configfile = a - if o == "-s": - timestepsecs = int(a) + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-c': configfile = a + if o == '-s': timestepsecs = int(a) + + starttime = dt.datetime(1990,0o1,0o1) - starttime = dt.datetime(1990, 01, 01) - if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) + ") is smaller than the last timestep (" + str( + _lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) Index: wflow-py/Sandbox/wflow_w3ra_v2.py =================================================================== diff -u -rda0c1b4d5ed214ad756b3d7102a147fb84fdb0d0 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Sandbox/wflow_w3ra_v2.py (.../wflow_w3ra_v2.py) (revision da0c1b4d5ed214ad756b3d7102a147fb84fdb0d0) +++ wflow-py/Sandbox/wflow_w3ra_v2.py (.../wflow_w3ra_v2.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -45,9 +45,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -371,18 +370,19 @@ setup needed. """ - self.logger.info("Reading initial conditions...") - #: It is advised to use the wf_resume() function - #: here which pick up the variable save by a call to wf_suspend() - try: - self.wf_resume(self.Dir + "/instate/") - except: - self.logger.warn("Cannot load initial states, setting to default") - for s in self.stateVariables(): - exec "self." + s + " = cover(1.0)" + self.logger.info("Reading initial conditions...") + #: It is advised to use the wf_resume() function + #: here which pick up the variable save by a call to wf_suspend() + try: + self.wf_resume(self.Dir + "/instate/") + except: + self.logger.warn("Cannot load initial states, setting to default") + for s in self.stateVariables(): + exec("self." + s + " = cover(1.0)") - def default_summarymaps(self): - """ + + def default_summarymaps(self): + """ *Optional* Return a default list of variables to report as summary maps in the outsum dir. """ @@ -528,6 +528,8 @@ # for i=1:par.Nhru ChannelSurface = min(0, (0.007 * self.Sr ** 0.75)) OpenWaterFrac = max(ChannelSurface, self.OpenWaterFrac) + + # !! HANDometric functions go here !! # !! HANDometric functions go here !! @@ -606,12 +608,12 @@ Umax = max(Usmax, max(Udmax, Ugmax)) # Maximum transpiration (4.3) - Gsmax = self.Gs_scalar * self.cGsmax * self.Vc - VPD = max(0, pes - pe) - fD = self.Cg / (1 + VPD / self.D50) - gs = fveg * fD * Gsmax - ft = 1 / (1 + (keps / (1 + keps)) * ga / gs) - Etmax = ft * self.E0 + Gsmax = self.Gs_scalar*self.cGsmax*self.Vc + VPD = max(0,pes-pe) + fD = self.Cg/(1+VPD/self.D50) + gs = fveg*fD*Gsmax + ft = 1/(1+(keps/(1+keps))*ga/gs) + Etmax = ft*self.E0 # Actual transpiration (4.1) Et = min(Umax, Etmax) @@ -631,8 +633,8 @@ Eg0 = max(0, fsat - fwater) * self.FsoilEmax * max(0, self.Eeq - Et) Es = Es0 + Eg0 # Open water evaporation (4.7) - Erl = fw_local * self.FwaterE * self.Ept - Err = (fwater - fw_local) * self.FwaterE * self.Ept + Erl = fw_local*self.FwaterE*self.Ept + Err = (fwater-fw_local)*self.FwaterE*self.Ept Er = Erl + Err # Rainfall interception evaporation (4.2) @@ -794,10 +796,10 @@ Dd = ifthenelse(imap, 0, Dd) IFd = ifthenelse(imap, 0, IFd) # saturation case - imap = (self.Sdmax - self.Sd - self.Kdsat) <= (Ds - Ud) - Dd = ifthenelse(imap, self.Kdsat, Dd) - IFd = ifthenelse(imap, self.Sd - self.Sdmax - self.Kdsat + Ds - Ud, IFd) - Sd = ifthenselse(imap, self.Sdmax, Sd) + imap = (self.Sdmax-self.Sd-self.Kdsat)<=(Ds-Ud) + Dd = ifthenelse(imap,self.Kdsat,Dd) + IFd = ifthenelse(imap,self.Sd-self.Sdmax-self.Kdsat+Ds-Ud,IFd) + Sd = ifthenselse(imap,self.Sdmax,Sd) # enforce mass balance (for numerical & rounding errors Sd = max(0, min(Sd, self.Sdmax)) massbal = self.Sd + Ds - Ud - Dd - IFd - Sd @@ -913,15 +915,14 @@ _lastTimeStep = ts _firstTimeStep = 1 else: - print "Failed to get timesteps from runinfo file: " + runinfoFile + print("Failed to get timesteps from runinfo file: " + runinfoFile) exit(2) else: - starttime = dt.datetime(1990, 01, 01) + starttime = dt.datetime(1990,0o1,0o1) if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) + ") is smaller than the last timestep (" + str( + _lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) Index: wflow-py/Scripts/area_in_out.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/area_in_out.py (.../area_in_out.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/area_in_out.py (.../area_in_out.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -36,9 +36,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) Index: wflow-py/Scripts/bmi2runner.py =================================================================== diff -u -r5bc2c6406fea89698faa5d0ca1488dc25760b5e3 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/bmi2runner.py (.../bmi2runner.py) (revision 5bc2c6406fea89698faa5d0ca1488dc25760b5e3) +++ wflow-py/Scripts/bmi2runner.py (.../bmi2runner.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -26,68 +26,52 @@ import wflow.pcrut as pcrut import os import time -import sys -import getopt -import logging -def usage(*args): - sys.stdout = sys.stderr - """Way""" - for msg in args: print msg - print __doc__ - sys.exit(0) -def main(argv=None): - """ - Perform command line execution of the model. - """ +""" +Perform command line execution of the model. +""" - configfile = "bmirunner.ini" +configfile = "bmi2runner.ini" +loglevel = 'INFO' +combilogger = pcrut.setlogger('bmi2runner.log','bmi2runner_logging',thelevel=loglevel) - if argv is None: - argv = sys.argv[1:] - if len(argv) == 0: - usage() - return - ######################################################################## - ## Process command-line options # - ######################################################################## - try: - opts, args = getopt.getopt(argv, 'c:l:') - except getopt.error, msg: - usage(msg) +# Construct object and initilize the models +combilogger.info('Starting combined bmi object') +bmiobj = wfbmi.wflowbmi_csdms() - loglevel=logging.WARN - for o, a in opts: - if o == '-c': configfile = a - if o == '-l': exec "loglevel = logging." + a +#this line is needed when running from batch script +#os.sys.path.append(os.getcwd() +'\\rtc\\rtc_brantas\\bin\\') +bmiobj.initialize_config(configfile,loglevel=loglevel) +bmiobj.initialize_model() +#Get and set start and end times +start = bmiobj.get_start_time() +end = bmiobj.get_end_time() +bmiobj.set_start_time(start) +bmiobj.set_end_time(end) - combilogger = pcrut.setlogger("bmi2runner.log", "bmi2runner_logging", thelevel=loglevel) - - # Construct object and initilize the models - combilogger.info("Starting combined bmi object") - bmiobj = wfbmi.wflowbmi_csdms() - - bmiobj.initialize_config(configfile, loglevel=loglevel) - bmiobj.initialize_model() - - # Get and set start and end times - start = bmiobj.get_start_time() - end = bmiobj.get_end_time() - bmiobj.set_start_time(start) - bmiobj.set_end_time(end) - - # Update models (if necessary) to start time - bmiobj.update_to_start_time(start) - - # Number of steps to run models - ts = bmiobj.get_time_step() - steps = int((end - start) / ts + 1) - +#Update models (if necessary) to start time +bmiobj.update_to_start_time(start) + +#Number of steps to run models +ts = bmiobj.get_time_step() +steps = int((end - start)/ts + 1) + +print('start = ', start)#time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(start)) +print('start time rtc =', time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(bmiobj.bmimodels['RTC-Tools'].get_start_time()))) +print('start time wflow =', time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(bmiobj.bmimodels['wflow_sbm'].get_start_time()))) +print('start time lintul =', time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(bmiobj.bmimodels['wflow_lintul'].get_start_time()))) + + +cts = bmiobj.currenttimestep +# Loop over the time duration +while cts < steps: + + bmiobj.update() cts = bmiobj.currenttimestep # Loop over the time duration while cts < steps: Index: wflow-py/Scripts/e2o-getfromwci.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/e2o-getfromwci.py (.../e2o-getfromwci.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/e2o-getfromwci.py (.../e2o-getfromwci.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -43,7 +43,7 @@ # Processing if verbose: - print "Writing to temporary file " + fileName + ".tif" + print('Writing to temporary file ' + fileName + '.tif') # Create Output filename from (FEWS) product name and date and open for writing TempDataset = driver1.Create( fileName + ".tif", data.shape[1], data.shape[0], 1, gdal.GDT_Float32 @@ -52,9 +52,9 @@ xul = x[0] - (x[1] - x[0]) / 2 yul = y[0] + (y[0] - y[1]) / 2 - print xul - print yul - TempDataset.SetGeoTransform([xul, x[1] - x[0], 0, yul, 0, y[1] - y[0]]) + print(xul) + print(yul) + TempDataset.SetGeoTransform( [ xul, x[1]-x[0], 0, yul, 0, y[1]-y[0] ] ) # get rasterband entry TempBand = TempDataset.GetRasterBand(1) # fill rasterband with array @@ -63,24 +63,25 @@ TempBand.SetNoDataValue(FillVal) # Create data to write to correct format (supported by 'CreateCopy') if verbose: - print "Writing to " + fileName + ".map" + print('Writing to ' + fileName + '.map') outDataset = driver2.CreateCopy(fileName, TempDataset, 0) TempDataset = None outDataset = None if verbose: - print "Removing temporary file " + fileName + ".tif" - os.remove(fileName + ".tif") + print('Removing temporary file ' + fileName + '.tif') + os.remove(fileName + '.tif'); if verbose: - print "Writing to " + fileName + " is done!" + print('Writing to ' + fileName + ' is done!') + tot = [] cnt = 0 for year in years: for mon in months: rainurl = baseurl % (year, year, mon) - print "processing: " + rainurl + print("processing: " + rainurl) # create a dataset object ncdataset = netCDF4.Dataset(rainurl) lat = ncdataset.variables["lat"][:] @@ -94,10 +95,10 @@ (latidx,) = logical_and(lat >= BB["lat"][0], lat < BB["lat"][1]).nonzero() (lonidx,) = logical_and(lon >= BB["lon"][0], lon < BB["lon"][1]).nonzero() - print lonidx - print latidx - print lat[latidx] - print lon[lonidx] + print(lonidx) + print(latidx) + print(lat[latidx]) + print(lon[lonidx]) # get rid of the non used lat/lon now lat = lat[latidx] lon = lon[lonidx] @@ -128,8 +129,8 @@ # mesh = pcolormesh(Lon,Lat,p_select.sum(axis=0)) # title("Cumulative precipitation") p_mean = p_select.mean(axis=1).mean(axis=1) - print lon - print lat + print(lon) + print(lat) ncdataset.close() if len(tot) == 0: @@ -142,26 +143,10 @@ cnt = cnt + 1 below_thousand = cnt % 1000 above_thousand = cnt / 1000 - mapname = str( - mapstackname + "%0" + str(8 - len(mapstackname)) + ".f.%03.f" - ) % (above_thousand, below_thousand) - print "saving map: " + os.path.join(lowresout, mapname) - writeMap( - os.path.join(lowresout, mapname), - "PCRaster", - lon, - lat[::-1], - flipud(p_select[arcnt, :, :]), - -999.0, - ) + mapname = str(mapstackname + '%0' + str(8-len(mapstackname)) + '.f.%03.f') % (above_thousand, below_thousand) + print("saving map: " + os.path.join(lowresout,mapname)) + writeMap(os.path.join(lowresout,mapname),"PCRaster",lon,lat[::-1],flipud(p_select[arcnt,:,:]),-999.0) arcnt = arcnt + 1 - execstr = ( - "resample --clone " - + clonemap - + " " - + os.path.join(lowresout, mapname) - + " " - + os.path.join(finalout, mapname) - ) - print "resampling map: " + execstr + execstr = "resample --clone " + clonemap + " " + os.path.join(lowresout,mapname) + " " + os.path.join(finalout,mapname) + print("resampling map: " + execstr) os.system(execstr) Index: wflow-py/Scripts/gethbvpars.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/gethbvpars.py (.../gethbvpars.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/gethbvpars.py (.../gethbvpars.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -23,9 +23,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -38,7 +37,7 @@ f.close() for l in x: - ll = filter(lambda c: c not in "'", l).split() + ll = [c for c in l if c not in "'"].split() if len(ll) > 0: a[ll[0]] = ll[1] @@ -53,7 +52,7 @@ f.close() for l in x: - ll = filter(lambda c: c not in "'\\", l).split() + ll = [c for c in l if c not in "'\\"].split() if len(ll) > 0: if ll[0] == "basindir": a.append(ll[1]) @@ -65,8 +64,8 @@ catch = {} try: - opts, args = getopt.getopt(sys.argv[1:], "o:p:h") -except getopt.error, msg: + opts, args = getopt.getopt(sys.argv[1:], 'o:p:h') +except getopt.error as msg: usage(msg) for o, a in opts: @@ -92,23 +91,23 @@ f = open(csvfile, "w") i = 0 -print >> f, "Id,Name", +print("Id,Name", end=' ', file=f) for ppar in baspar: - print >> f, sep + ppar, -print >> f, "" + print(sep + ppar, end=' ', file=f) +print("", file=f) # for c in catch: for ii in range(0, len(basstruc) - 1): i = i + 1 c = basstruc[ii] - print >> f, str(i) + sep + c, + print(str(i)+sep+c, end=' ', file=f) for ppar in baspar: if ppar in catch[c]: - print >> f, sep + catch[c][ppar], + print(sep+catch[c][ppar], end=' ', file=f) else: - print >> f, sep + baspar[ppar], - print >> f, "" + print(sep+baspar[ppar], end=' ', file=f) + print("", file=f) f.close() Index: wflow-py/Scripts/mapstack.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/mapstack.py (.../mapstack.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/mapstack.py (.../mapstack.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -27,9 +27,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) Index: wflow-py/Scripts/pcr2netcdf.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/pcr2netcdf.py (.../pcr2netcdf.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/pcr2netcdf.py (.../pcr2netcdf.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -75,7 +75,7 @@ import os import logging import logging.handlers -import ConfigParser +import configparser import wflow.pcrut as _pcrut import osgeo.gdal as gdal import wflow.wf_netcdfio as ncdf @@ -84,9 +84,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -111,8 +110,8 @@ data[isnan(data)] = FillVal # Processing if verbose: - print "Writing to temporary file " + fileName + ".tif" - print "Output format: " + fileFormat + print('Writing to temporary file ' + fileName + '.tif') + print("Output format: " + fileFormat) # Create Output filename from (FEWS) product name and date and open for writing TempDataset = driver1.Create( fileName + ".tif", data.shape[1], data.shape[0], 1, gdal.GDT_Float32 @@ -131,21 +130,19 @@ # Create data to write to correct format (supported by 'CreateCopy') if verbose: - print "Writing to " + fileName + ".map" - if fileFormat == "GTiff": - outDataset = driver2.CreateCopy( - fileName, TempDataset, 0, options=["COMPRESS=LZW"] - ) + print('Writing to ' + fileName + '.map') + if fileFormat == 'GTiff': + outDataset = driver2.CreateCopy(fileName, TempDataset, 0 ,options = ['COMPRESS=LZW']) else: outDataset = driver2.CreateCopy(fileName, TempDataset, 0) TempDataset = None outDataset = None if verbose: - print "Removing temporary file " + fileName + ".tif" - os.remove(fileName + ".tif") + print('Removing temporary file ' + fileName + '.tif') + os.remove(fileName + '.tif'); if verbose: - print "Writing to " + fileName + " is done!" + print('Writing to ' + fileName + ' is done!') def readMap(fileName, fileFormat, logger, unzipcmd="pigz -d -k"): @@ -227,12 +224,12 @@ """ metadata = {} - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.optionxform = str if os.path.exists(inifile): config.read(inifile) else: - print ("Cannot open ini file: " + inifile) + print(("Cannot open ini file: " + inifile)) exit(1) metadata = dict(config.items("metadata")) @@ -249,12 +246,12 @@ """ metadata = {} - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.optionxform = str if os.path.exists(inifile): config.read(inifile) else: - print ("Cannot open ini file: " + inifile) + print(("Cannot open ini file: " + inifile)) exit(1) metadata = dict(config.items(var)) @@ -443,7 +440,7 @@ logger.debug("File logging to " + logfilename) return logger except IOError: - print "ERROR: Failed to initialize logger with logfile: " + logfilename + print("ERROR: Failed to initialize logger with logfile: " + logfilename) sys.exit(2) @@ -532,8 +529,8 @@ ## Main model starts here ######################################################################## try: - opts, args = getopt.getopt(argv, "c:S:E:N:I:O:b:t:F:zs:d:YP:Mi:C:") - except getopt.error, msg: + opts, args = getopt.getopt(argv, 'c:S:E:N:I:O:b:t:F:zs:d:YP:Mi:C:') + except getopt.error as msg: usage(msg) for o, a in opts: Index: wflow-py/Scripts/read_arcinfo_files.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/read_arcinfo_files.py (.../read_arcinfo_files.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/read_arcinfo_files.py (.../read_arcinfo_files.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -31,22 +31,22 @@ the boundaries of a smaller sub-grid that will be extracted.""" try: - f = open(filename, "r") - except IOError, E: - print "ERROR: Unable to open or read the ArcInfo grid file %s" % filename - print E - fileTable = {"Ncells": 0} - return fileTable + f = open(filename,"r") + except IOError as E: + print("ERROR: Unable to open or read the ArcInfo grid file %s" % filename) + print(E) + fileTable = { "Ncells" : 0 } + return ( fileTable ) fileTable = { - "ncols": atoi(split(f.readline())[1]), - "nrows": atoi(split(f.readline())[1]), - "xllcorner": atof(split(f.readline())[1]), - "yllcorner": atof(split(f.readline())[1]), - "cellsize": atof(split(f.readline())[1]), - "NODATA_value": atoi(split(f.readline())[1]), - } - print fileTable + "ncols" : atoi(split(f.readline())[1]), + "nrows" : atoi(split(f.readline())[1]), + "xllcorner" : atof(split(f.readline())[1]), + "yllcorner" : atof(split(f.readline())[1]), + "cellsize" : atof(split(f.readline())[1]), + "NODATA_value" : atoi(split(f.readline())[1]), + } + print(fileTable) if Extent["North"] and Extent["South"] and Extent["East"] and Extent["West"]: # redefine grid size for desired extent @@ -67,17 +67,12 @@ # compute number of cells required fileTable["Ncells"] = nrows * ncols # allocate memory for all cells - fileTable["cell"] = [fileTable["NODATA_value"]] * fileTable["Ncells"] + fileTable["cell"] = [ fileTable["NODATA_value"] ]*fileTable["Ncells"] - print "North %f, South %f, East %f, West %f" % ( - fileTable["yllcorner"] + fileTable["cellsize"] * fileTable["nrows"], - fileTable["yllcorner"], - fileTable["xllcorner"] + fileTable["cellsize"] * fileTable["ncols"], - fileTable["xllcorner"], - ) - print Extent - print fileTable["nrows"], nrows - print fileTable["ncols"], ncols + print("North %f, South %f, East %f, West %f" % ( fileTable["yllcorner"] + fileTable["cellsize"]*fileTable["nrows"], fileTable["yllcorner"], fileTable["xllcorner"] + fileTable["cellsize"]*fileTable["ncols"], fileTable["xllcorner"] )) + print(Extent) + print(fileTable["nrows"], nrows) + print(fileTable["ncols"], ncols) cellidx = 0 tmprcnt = 0 @@ -94,17 +89,11 @@ if lat >= Extent["South"] and lat <= Extent["North"]: tmprcnt = tmprcnt + 1 # if latitude falls within defined extent, split lines to get column values - if INTflag: - tmpvals = map(atoi, split(line)) - else: - tmpvals = map(atof, split(line)) - if len(tmpvals) != fileTable["ncols"]: - print "ERROR: Number of items in row %i (%i) does not match the number of defined columns (%i)." % ( - i, - len(tmpvals), - fileTable["ncols"], - ) - for j in range(fileTable["ncols"]): + if ( INTflag ): tmpvals = list(map(atoi,split(line))) + else: tmpvals = list(map(atof,split(line))) + if ( len(tmpvals) != fileTable["ncols"] ): + print("ERROR: Number of items in row %i (%i) does not match the number of defined columns (%i)." % (i, len(tmpvals), fileTable["ncols"])) + for j in range(fileTable["ncols"]): # compute longitude for current cell lng = ( fileTable["xllcorner"] @@ -122,32 +111,30 @@ "value": tmpvals[j], } cellidx = cellidx + 1 - except IndexError, errstr: + except IndexError as errstr: # did not allocate enough memory, add additional cells fileTable["cell"] = fileTable["cell"] + [ {"lat": lat, "lng": lng, "value": tmpvals[j]} ] cellidx = cellidx + 1 - del (line) + del(line) - print "Number of rows filled: %i of %i" % (tmprcnt, nrows) - print "Number of cols filled: %i of %i" % (tmpccnt, ncols) - print "Number of cells filled: %i of %i" % (cellidx, fileTable["Ncells"]) - if tmprcnt != nrows: - nrows = tmprcnt - if tmpccnt != ncols: - ncols = tmpccnt + print("Number of rows filled: %i of %i" % ( tmprcnt, nrows )) + print("Number of cols filled: %i of %i" % ( tmpccnt, ncols )) + print("Number of cells filled: %i of %i" % ( cellidx, fileTable["Ncells"] )) + if tmprcnt != nrows: nrows = tmprcnt + if tmpccnt != ncols: ncols = tmpccnt if cellidx < fileTable["Ncells"]: fileTable["cell"] = fileTable["cell"][:cellidx] if cellidx != fileTable["Ncells"]: fileTable["Ncells"] = cellidx if FLAG == "FILTERED": - if fileTable["NODATA_value"] == 0: - fileTable["cell"] = filter(lambda x: x["value"] != 0, fileTable["cell"]) - else: - fileTable["cell"] = filter(lambda x: x["value"] != -9999, fileTable["cell"]) - fileTable["Ncells"] = len(fileTable["cell"]) + if fileTable["NODATA_value"] == 0: + fileTable["cell"] = [x for x in fileTable["cell"] if x["value"] != 0] + else: + fileTable["cell"] = [x for x in fileTable["cell"] if x["value"] != -9999] + fileTable["Ncells"] = len(fileTable["cell"]) # reset grid boundaries to agree with defined extent fileTable["ncols"] = ncols @@ -164,10 +151,10 @@ of which are stored in a data dictionary.""" try: - f = open(filename, "w") - except IOError, E: - print "ERROR: Unable to open or write the ArcInfo grid file %s" % filename - return 0 + f = open(filename,"w") + except IOError as E: + print("ERROR: Unable to open or write the ArcInfo grid file %s" % filename) + return ( 0 ) f.write("ncols\t%i\n" % gridTable["ncols"]) f.write("nrows\t%i\n" % gridTable["nrows"]) @@ -212,10 +199,7 @@ f.close() - print "%s: %i cells of %i contain data." % ( - filename, - CellsWritten, - gridTable["ncols"] * gridTable["nrows"], - ) + print("%s: %i cells of %i contain data." % ( filename, CellsWritten, + gridTable["ncols"]*gridTable["nrows"] )) return 1 Index: wflow-py/Scripts/shptoraster.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/shptoraster.py (.../shptoraster.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/shptoraster.py (.../shptoraster.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -2,7 +2,7 @@ import os import os.path import getopt -import ConfigParser +import configparser import sys """ @@ -49,7 +49,7 @@ os.system("gdal_translate -of PCRaster subcatch.tif subcatch.map") for zz in pars: - print pars[zz] + print(pars[zz]) os.system("gdal_translate -of GTiff nilmap.map " + pars[zz] + ".tif") os.system( "gdal_rasterize -a " Index: wflow-py/Scripts/tss2xml.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/tss2xml.py (.../tss2xml.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/tss2xml.py (.../tss2xml.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -20,9 +20,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -44,8 +43,8 @@ return try: - opts, args = getopt.getopt(argv, "X:I:S") - except getopt.error, msg: + opts, args = getopt.getopt(argv, 'X:I:S') + except getopt.error as msg: pcrut.usage(msg) for o, a in opts: Index: wflow-py/Scripts/wfds_core.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/wfds_core.py (.../wfds_core.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/wfds_core.py (.../wfds_core.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -31,8 +31,8 @@ def call_functionality(arguments): - print "hello" - print arguments + print('hello') + print(arguments) mmi.runner.runner(arguments) Index: wflow-py/Scripts/wflow_flood.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/wflow_flood.py (.../wflow_flood.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/wflow_flood.py (.../wflow_flood.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -342,7 +342,7 @@ (options, args) = parser.parse_args() if not os.path.exists(options.inifile): - print "path to ini file cannot be found" + print('path to ini file cannot be found') sys.exit(1) options.dest_path = os.path.abspath(options.dest_path) @@ -975,28 +975,19 @@ options.hand_file_prefix, hand_strahler ) ds_hand, rasterband_hand = inun_lib.get_gdal_rasterband(hand_file) - hand = rasterband_hand.ReadAsArray( - x_start - x_overlap_min, - y_start - y_overlap_min, - (x_end + x_overlap_max) - (x_start - x_overlap_min), - (y_end + y_overlap_max) - (y_start - y_overlap_min), - ) - print ( - "len x-ax: {:d} len y-ax {:d} x-shape {:d} y-shape {:d}".format( - len(x_tile_ax), len(y_tile_ax), hand.shape[1], hand.shape[0] - ) - ) + hand = rasterband_hand.ReadAsArray(x_start - x_overlap_min, + y_start - y_overlap_min, + (x_end + x_overlap_max) - (x_start - x_overlap_min), + (y_end + y_overlap_max) - (y_start - y_overlap_min) + ) + print(('len x-ax: {:d} len y-ax {:d} x-shape {:d} y-shape {:d}'.format(len(x_tile_ax), len(y_tile_ax), hand.shape[1], hand.shape[0]))) - inun_lib.gdal_writemap( - hand_temp_file, - "PCRaster", - x_tile_ax, - y_tile_ax, - hand, - rasterband_hand.GetNoDataValue(), - gdal_type=gdal.GDT_Float32, - logging=logger, - ) + inun_lib.gdal_writemap(hand_temp_file, 'PCRaster', + x_tile_ax, + y_tile_ax, + hand, rasterband_hand.GetNoDataValue(), + gdal_type=gdal.GDT_Float32, + logging=logger) hand_pcr = pcr.readmap(hand_temp_file) Index: wflow-py/Scripts/wflow_flood_lib.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/wflow_flood_lib.py (.../wflow_flood_lib.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/wflow_flood_lib.py (.../wflow_flood_lib.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -15,7 +15,7 @@ import sys import os -import ConfigParser +import configparser import logging import logging.handlers @@ -55,7 +55,7 @@ logger.debug("File logging to " + logfilename) return logger, ch except IOError: - print "ERROR: Failed to initialize logger with logfile: " + logfilename + print("ERROR: Failed to initialize logger with logfile: " + logfilename) sys.exit(1) @@ -74,13 +74,13 @@ def open_conf(fn): - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.optionxform = str if os.path.exists(fn): config.read(fn) else: - print "Cannot open config file: " + fn + print("Cannot open config file: " + fn) sys.exit(1) return config Index: wflow-py/Scripts/wflow_prepare.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/wflow_prepare.py (.../wflow_prepare.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/wflow_prepare.py (.../wflow_prepare.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -42,16 +42,15 @@ import os import os.path import getopt -import ConfigParser +import configparser import sys import gc def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -63,20 +62,20 @@ try: ret = config.get(section, var) except: - print "returning default (" + default + ") for " + section + ":" + var + print("returning default (" + default + ") for " + section + ":" + var) ret = default return ret def OpenConf(fn): - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.optionxform = str if os.path.exists(fn): config.read(fn) else: - print "Cannot open config file: " + fn + print("Cannot open config file: " + fn) sys.exit(1) return config @@ -97,19 +96,11 @@ """ """ if initialscale > 1: - print "Initial scaling of DEM..." - os.system( - "resample -r " - + str(initialscale) - + " " - + masterdem - + " " - + step1dir - + "/dem_scaled.map" - ) - print ("Reading dem...") - dem = tr.readmap(step1dir + "/dem_scaled.map") - ldddem = dem + print("Initial scaling of DEM...") + os.system("resample -r " + str(initialscale) + " " + masterdem + " " + step1dir + "/dem_scaled.map") + print("Reading dem...") + dem = tr.readmap(step1dir + "/dem_scaled.map") + ldddem=dem else: print ("Reading dem...") dem = tr.readmap(masterdem) @@ -260,8 +251,8 @@ snapgaugestoriver = False try: - opts, args = getopt.getopt(sys.argv[1:], "W:hI:f") - except getopt.error, msg: + opts, args = getopt.getopt(sys.argv[1:], 'W:hI:f') + except getopt.error as msg: usage(msg) for o, a in opts: @@ -288,7 +279,7 @@ gauges_x = config.get("settings", "gauges_x") gauges_y = config.get("settings", "gauges_y") except: - print "gauges_x and gauges_y are required entries in the ini file" + print("gauges_x and gauges_y are required entries in the ini file") sys.exit(1) step1dir = configget(config, "directories", "step1dir", "step1") @@ -314,8 +305,8 @@ lu_paved = configget(config, "files", "lu_paved", "") # X/Y coordinates of the gauges the system - exec "X=tr.array(" + gauges_x + ")" - exec "Y=tr.array(" + gauges_y + ")" + exec("X=tr.array(" + gauges_x + ")") + exec("Y=tr.array(" + gauges_y + ")") tr.Verbose = 1 @@ -328,22 +319,23 @@ try: catchmask = config.get("files", "catchment_mask") except: - print "No catchment mask..." + print("No catchment mask...") else: - print "clipping DEM with mask....." - mask = tr.readmap(catchmask) - ldddem = tr.ifthen(tr.boolean(mask), ldddem) - dem = tr.ifthen(tr.boolean(mask), dem) + print("clipping DEM with mask.....") + mask=tr.readmap(catchmask) + ldddem = tr.ifthen(tr.boolean(mask),ldddem) + dem = tr.ifthen(tr.boolean(mask),dem) + # See if there is a shape file of the river to burn in try: rivshp = config.get("files", "river") except: - print "no river file specified" - outletpointX = float(configget(config, "settings", "outflowpointX", "0.0")) - outletpointY = float(configget(config, "settings", "outflowpointY", "0.0")) + print("no river file specified") + outletpointX = float(configget(config,"settings","outflowpointX","0.0")) + outletpointY = float(configget(config,"settings","outflowpointY","0.0")) else: - print "river file specified....." + print("river file specified.....") try: outletpointX = float(configget(config, "settings", "outflowpointX", "0.0")) outletpointY = float(configget(config, "settings", "outflowpointY", "0.0")) @@ -417,10 +409,14 @@ outlmap = tr.points_to_map(dem, X, Y, 0.5) if snapgaugestoriver: - print "Snapping gauges to nearest river cells..." - tr.report(outlmap, step1dir + "/orggauges.map") - outlmap = tr.snaptomap(outlmap, strdir) + print("Snapping gauges to nearest river cells...") + tr.report(outlmap,step1dir + "/orggauges.map") + outlmap= tr.snaptomap(outlmap,strdir) + + #noutletmap = tr.points_to_map(dem,XX,YY,0.5) + #tr.report(noutletmap,'noutlet.map') + # noutletmap = tr.points_to_map(dem,XX,YY,0.5) # tr.report(noutletmap,'noutlet.map') @@ -430,31 +426,23 @@ try: catchmask = config.get("files", "catchment_mask") except: - print "No catchment mask, finding outlet" + print("No catchment mask, finding outlet") # Find catchment (overall) outlet = tr.find_outlet(ldd) sub = tr.subcatch(ldd, outlet) tr.report(sub, step1dir + "/catchment_overall.map") else: - print "reading and converting catchment mask....." - os.system( - "resample -r " - + str(initialscale) - + " " - + catchmask - + " " - + step1dir - + "/catchment_overall.map" - ) + print("reading and converting catchment mask.....") + os.system("resample -r " + str(initialscale) + " " + catchmask + " " + step1dir + "/catchment_overall.map") sub = tr.readmap(step1dir + "/catchment_overall.map") print ("Scatch...") sd = tr.subcatch(ldd, tr.ifthen(outlmap > 0, outlmap)) tr.report(sd, step1dir + "/scatch.map") tr.setglobaloption("unitcell") - print "Upscalefactor: " + str(upscalefactor) - + print("Upscalefactor: " + str(upscalefactor)) + if upscalefactor > 1: gc.collect() print ("upscale river length1 (checkerboard map)...") @@ -493,113 +481,57 @@ perc = tr.area_percentile(dem, ck, n, order, 90.0) tr.report(perc, step1dir + "/dem90.map") else: - print ("No fancy scaling done. Going strait to step2....") - tr.report(dem, step1dir + "/demavg.map") - Xul = float(config.get("settings", "Xul")) - Yul = float(config.get("settings", "Yul")) - Xlr = float(config.get("settings", "Xlr")) - Ylr = float(config.get("settings", "Ylr")) - gdalstr = ( - "gdal_translate -projwin " - + str(Xul) - + " " - + str(Yul) - + " " - + str(Xlr) - + " " - + str(Ylr) - + " -of PCRaster " - ) - # gdalstr = "gdal_translate -a_ullr " + str(Xul) + " " + str(Yul) + " " +str(Xlr) + " " +str(Ylr) + " -of PCRaster " - print gdalstr - tr.report(tr.cover(1.0), step1dir + "/wflow_riverlength_fact.map") - # Now us gdat tp convert the maps - os.system( - gdalstr - + step1dir - + "/wflow_riverlength_fact.map" - + " " - + step2dir - + "/wflow_riverlength_fact.map" - ) - os.system( - gdalstr + step1dir + "/demavg.map" + " " + step2dir + "/wflow_dem.map" - ) - os.system( - gdalstr + step1dir + "/demavg.map" + " " + step2dir + "/wflow_demmin.map" - ) - os.system( - gdalstr + step1dir + "/demavg.map" + " " + step2dir + "/wflow_demmax.map" - ) - os.system( - gdalstr + step1dir + "/gauges.map" + " " + step2dir + "/wflow_gauges.map" - ) - os.system( - gdalstr + step1dir + "/rivers.map" + " " + step2dir + "/wflow_river.map" - ) - os.system( - gdalstr - + step1dir - + "/streamorder.map" - + " " - + step2dir - + "/wflow_streamorder.map" - ) - os.system( - gdalstr + step1dir + "/gauges.map" + " " + step2dir + "/wflow_outlet.map" - ) - os.system( - gdalstr + step1dir + "/scatch.map" + " " + step2dir + "/wflow_catchment.map" - ) - os.system(gdalstr + step1dir + "/ldd.map" + " " + step2dir + "/wflow_ldd.map") - os.system( - gdalstr + step1dir + "/scatch.map" + " " + step2dir + "/wflow_subcatch.map" - ) + print("No fancy scaling done. Going strait to step2....") + tr.report(dem,step1dir + "/demavg.map") + Xul = float(config.get("settings","Xul")) + Yul = float(config.get("settings","Yul")) + Xlr = float(config.get("settings","Xlr")) + Ylr = float(config.get("settings","Ylr")) + gdalstr = "gdal_translate -projwin " + str(Xul) + " " + str(Yul) + " " +str(Xlr) + " " +str(Ylr) + " -of PCRaster " + #gdalstr = "gdal_translate -a_ullr " + str(Xul) + " " + str(Yul) + " " +str(Xlr) + " " +str(Ylr) + " -of PCRaster " + print(gdalstr) + tr.report(tr.cover(1.0),step1dir + "/wflow_riverlength_fact.map") + # Now us gdat tp convert the maps + os.system(gdalstr + step1dir + "/wflow_riverlength_fact.map" + " " + step2dir + "/wflow_riverlength_fact.map") + os.system(gdalstr + step1dir + "/demavg.map" + " " + step2dir + "/wflow_dem.map") + os.system(gdalstr + step1dir + "/demavg.map" + " " + step2dir + "/wflow_demmin.map") + os.system(gdalstr + step1dir + "/demavg.map" + " " + step2dir + "/wflow_demmax.map") + os.system(gdalstr + step1dir + "/gauges.map" + " " + step2dir + "/wflow_gauges.map") + os.system(gdalstr + step1dir + "/rivers.map" + " " + step2dir + "/wflow_river.map") + os.system(gdalstr + step1dir + "/streamorder.map" + " " + step2dir + "/wflow_streamorder.map") + os.system(gdalstr + step1dir + "/gauges.map" + " " + step2dir + "/wflow_outlet.map") + os.system(gdalstr + step1dir + "/scatch.map" + " " + step2dir + "/wflow_catchment.map") + os.system(gdalstr + step1dir + "/ldd.map" + " " + step2dir + "/wflow_ldd.map") + os.system(gdalstr + step1dir + "/scatch.map" + " " + step2dir + "/wflow_subcatch.map") + + if lu_water: + os.system(gdalstr + lu_water + " " + step2dir + "/WaterFrac.map") - if lu_water: - os.system(gdalstr + lu_water + " " + step2dir + "/WaterFrac.map") + if lu_paved: + os.system(gdalstr + lu_paved + " " + step2dir + "/PathFrac.map") - if lu_paved: - os.system(gdalstr + lu_paved + " " + step2dir + "/PathFrac.map") - - try: - lumap = config.get("files", "landuse") - except: - print "no landuse map...creating uniform map" - # clone=tr.readmap(step2dir + "/wflow_dem.map") + try: + lumap = config.get("files","landuse") + except: + print("no landuse map...creating uniform map") + #clone=tr.readmap(step2dir + "/wflow_dem.map") tr.setclone(step2dir + "/wflow_dem.map") - tr.report(tr.nominal(1), step2dir + "/wflow_landuse.map") - else: - os.system( - "resample --clone " - + step2dir - + "/wflow_dem.map " - + lumap - + " " - + step2dir - + "/wflow_landuse.map" - ) + tr.report(tr.nominal(1),step2dir + "/wflow_landuse.map") + else: + os.system("resample --clone " + step2dir + "/wflow_dem.map " + lumap + " " + step2dir + "/wflow_landuse.map") - try: - soilmap = config.get("files", "soil") - except: - print "no soil map..., creating uniform map" - tr.setclone(step2dir + "/wflow_dem.map") - tr.report(tr.nominal(1), step2dir + "/wflow_soil.map") - else: - os.system( - "resample --clone " - + step2dir - + "/wflow_dem.map " - + soilmap - + " " - + step2dir - + "/wflow_soil.map" - ) + try: + soilmap = config.get("files","soil") + except: + print("no soil map..., creating uniform map") + tr.setclone(step2dir + "/wflow_dem.map") + tr.report(tr.nominal(1),step2dir + "/wflow_soil.map") + else: + os.system("resample --clone " + step2dir + "/wflow_dem.map " + soilmap + " " + step2dir + "/wflow_soil.map") - ################################## - # Step 2 starts here - ################################## +################################## +# Step 2 starts here +################################## tr.setclone(step2dir + "/cutout.map") @@ -665,9 +597,9 @@ try: lumap = config.get("files", "landuse") except: - print "no landuse map...creating uniform map" - clone = tr.readmap(step2dir + "/cutout.map") - tr.report(tr.nominal(clone), step2dir + "/wflow_landuse.map") + print("no landuse map...creating uniform map") + clone=tr.readmap(step2dir + "/cutout.map") + tr.report(tr.nominal(clone),step2dir + "/wflow_landuse.map") else: os.system( "resample --clone " @@ -682,9 +614,9 @@ try: soilmap = config.get("files", "soil") except: - print "no soil map..., creating uniform map" - clone = tr.readmap(step2dir + "/cutout.map") - tr.report(tr.nominal(clone), step2dir + "/wflow_soil.map") + print("no soil map..., creating uniform map") + clone=tr.readmap(step2dir + "/cutout.map") + tr.report(tr.nominal(clone),step2dir + "/wflow_soil.map") else: os.system( "resample --clone " @@ -710,19 +642,13 @@ try: rivshp = config.get("files", "river") except: - print "no river file specified" + print("no river file specified") riverburn = tr.readmap(step2dir + "/wflow_riverburnin.map") else: - print "river file speficied....." - rivshpattr = config.get("files", "riverattr") - tr.report(dem * 0.0, step2dir + "/nilmap.map") - thestr = ( - "gdal_translate -of GTiff " - + step2dir - + "/nilmap.map " - + step2dir - + "/wflow_riverburnin.tif" - ) + print("river file speficied.....") + rivshpattr = config.get("files","riverattr") + tr.report(dem * 0.0,step2dir + "/nilmap.map") + thestr = "gdal_translate -of GTiff " + step2dir + "/nilmap.map " + step2dir + "/wflow_riverburnin.tif" os.system(thestr) os.system( "gdal_rasterize -burn 1 -l " @@ -749,21 +675,15 @@ # Now setup a very high wall around the catchment that is scale # based on the distance to the catchment so that it slopes away from the # catchment - if lddmethod != "river": - print "Burning in highres-river ..." - disttocatch = tr.spread(tr.nominal(catchcut), 0.0, 1.0) - demmax = tr.ifthenelse( - tr.scalar(catchcut) >= 1.0, - demmax, - demmax + (tr.celllength() * 100.0) / disttocatch, - ) - tr.setglobaloption("unitcell") - demregional = tr.windowaverage(demmin, 100) - demburn = tr.cover( - tr.ifthen(tr.boolean(riverburn), demregional - 100.0), demmax - ) + if lddmethod != 'river': + print("Burning in highres-river ...") + disttocatch = tr.spread(tr.nominal(catchcut),0.0,1.0) + demmax = tr.ifthenelse(tr.scalar(catchcut) >=1.0, demmax, demmax + (tr.celllength() * 100.0) /disttocatch) + tr.setglobaloption("unitcell") + demregional=tr.windowaverage(demmin,100) + demburn = tr.cover(tr.ifthen(tr.boolean(riverburn), demregional -100.0) ,demmax) else: - print "using average dem.." + print("using average dem..") demburn = dem ldd = tr.lddcreate_save( @@ -790,14 +710,23 @@ tr.report(river, step2dir + "/wflow_river.map") # make subcatchments - # os.system("col2map --clone " + step2dir + "/cutout.map gauges.col " + step2dir + "/wflow_gauges.map") - exec "X=tr.array(" + gauges_x + ")" - exec "Y=tr.array(" + gauges_y + ")" + #os.system("col2map --clone " + step2dir + "/cutout.map gauges.col " + step2dir + "/wflow_gauges.map") + exec("X=tr.array(" + gauges_x + ")") + exec("Y=tr.array(" + gauges_y + ")") + tr.setglobaloption("unittrue") - outlmap = tr.points_to_map(dem, X, Y, 0.5) - tr.report(outlmap, step2dir + "/wflow_gauges_.map") + outlmap = tr.points_to_map(dem,X,Y,0.5) + tr.report(outlmap,step2dir + "/wflow_gauges_.map") + + if snapgaugestoriver: + print("Snapping gauges to river") + tr.report(outlmap,step2dir + "/wflow_orggauges.map") + outlmap= tr.snaptomap(outlmap,river) + + outlmap = tr.ifthen(outlmap > 0, outlmap) + tr.report(outlmap,step2dir + "/wflow_gauges.map") if snapgaugestoriver: print "Snapping gauges to river" Index: wflow-py/Scripts/wflow_prepare_step1.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/wflow_prepare_step1.py (.../wflow_prepare_step1.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/wflow_prepare_step1.py (.../wflow_prepare_step1.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -40,17 +40,16 @@ import os import os.path import getopt -import ConfigParser +import configparser import sys import gc import numpy as np def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -62,20 +61,20 @@ try: ret = config.get(section, var) except: - print "returning default (" + default + ") for " + section + ":" + var + print("returning default (" + default + ") for " + section + ":" + var) ret = default return ret def OpenConf(fn): - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.optionxform = str if os.path.exists(fn): config.read(fn) else: - print "Cannot open config file: " + fn + print("Cannot open config file: " + fn) sys.exit(1) return config @@ -100,8 +99,8 @@ snapgaugestoriver = False try: - opts, args = getopt.getopt(sys.argv[1:], "W:hI:f") - except getopt.error, msg: + opts, args = getopt.getopt(sys.argv[1:], 'W:hI:f') + except getopt.error as msg: usage(msg) for o, a in opts: @@ -128,7 +127,7 @@ gauges_x = config.get("settings", "gauges_x") gauges_y = config.get("settings", "gauges_y") except: - print "gauges_x and gauges_y are required entries in the ini file" + print("gauges_x and gauges_y are required entries in the ini file") sys.exit(1) step1dir = configget(config, "directories", "step1dir", "step1") @@ -154,8 +153,8 @@ lu_paved = configget(config, "files", "lu_paved", "") # X/Y coordinates of the gauges the system - exec "X=np.array(" + gauges_x + ")" - exec "Y=np.array(" + gauges_y + ")" + exec("X=np.array(" + gauges_x + ")") + exec("Y=np.array(" + gauges_y + ")") tr.Verbose = 1 @@ -166,19 +165,11 @@ os.makedirs(step2dir) if initialscale > 1: - print "Initial scaling of DEM..." - os.system( - "resample -r " - + str(initialscale) - + " " - + masterdem - + " " - + step1dir - + "/dem_scaled.map" - ) - print ("Reading dem...") - dem = tr.readmap(step1dir + "/dem_scaled.map") - ldddem = dem + print("Initial scaling of DEM...") + os.system("resample -r " + str(initialscale) + " " + masterdem + " " + step1dir + "/dem_scaled.map") + print("Reading dem...") + dem = tr.readmap(step1dir + "/dem_scaled.map") + ldddem=dem else: print ("Reading dem...") dem = tr.readmap(masterdem) @@ -187,22 +178,22 @@ try: catchmask = config.get("files", "catchment_mask") except: - print "No catchment mask..." + print("No catchment mask...") else: - print "clipping DEM with mask....." - mask = tr.readmap(catchmask) - ldddem = tr.ifthen(tr.boolean(mask), ldddem) - dem = tr.ifthen(tr.boolean(mask), dem) + print("clipping DEM with mask.....") + mask=tr.readmap(catchmask) + ldddem = tr.ifthen(tr.boolean(mask),ldddem) + dem = tr.ifthen(tr.boolean(mask),dem) # See if there is a shape file of the river to burn in try: rivshp = config.get("files", "river") except: - print "no river file specified" - outletpointX = float(configget(config, "settings", "outflowpointX", "0.0")) - outletpointY = float(configget(config, "settings", "outflowpointY", "0.0")) + print("no river file specified") + outletpointX = float(configget(config,"settings","outflowpointX","0.0")) + outletpointY = float(configget(config,"settings","outflowpointY","0.0")) else: - print "river file specified....." + print("river file specified.....") try: outletpointX = float(configget(config, "settings", "outflowpointX", "0.0")) outletpointY = float(configget(config, "settings", "outflowpointY", "0.0")) @@ -278,10 +269,11 @@ outlmap = tr.points_to_map(dem, X, Y, 0.5) if snapgaugestoriver: - print "Snapping gauges to nearest river cells..." - tr.report(outlmap, step1dir + "/orggauges.map") - outlmap = tr.snaptomap(outlmap, strdir) + print("Snapping gauges to nearest river cells...") + tr.report(outlmap,step1dir + "/orggauges.map") + outlmap= tr.snaptomap(outlmap,strdir) + # noutletmap = tr.points_to_map(dem,XX,YY,0.5) # tr.report(noutletmap,'noutlet.map') @@ -291,31 +283,23 @@ try: catchmask = config.get("files", "catchment_mask") except: - print "No catchment mask, finding outlet" + print("No catchment mask, finding outlet") # Find catchment (overall) outlet = tr.find_outlet(ldd) sub = tr.subcatch(ldd, outlet) tr.report(sub, step1dir + "/catchment_overall.map") else: - print "reading and converting catchment mask....." - os.system( - "resample -r " - + str(initialscale) - + " " - + catchmask - + " " - + step1dir - + "/catchment_overall.map" - ) + print("reading and converting catchment mask.....") + os.system("resample -r " + str(initialscale) + " " + catchmask + " " + step1dir + "/catchment_overall.map") sub = tr.readmap(step1dir + "/catchment_overall.map") print ("Scatch...") sd = tr.subcatch(ldd, tr.ifthen(outlmap > 0, outlmap)) tr.report(sd, step1dir + "/scatch.map") tr.setglobaloption("unitcell") - print "Upscalefactor: " + str(upscalefactor) - + print("Upscalefactor: " + str(upscalefactor)) + if upscalefactor > 1: gc.collect() print ("upscale river length1 (checkerboard map)...") @@ -354,109 +338,53 @@ perc = tr.area_percentile(dem, ck, n, order, 90.0) tr.report(perc, step1dir + "/dem90.map") else: - print ("No fancy scaling done. Going strait to step2....") - tr.report(dem, step1dir + "/demavg.map") - Xul = float(config.get("settings", "Xul")) - Yul = float(config.get("settings", "Yul")) - Xlr = float(config.get("settings", "Xlr")) - Ylr = float(config.get("settings", "Ylr")) - gdalstr = ( - "gdal_translate -projwin " - + str(Xul) - + " " - + str(Yul) - + " " - + str(Xlr) - + " " - + str(Ylr) - + " -of PCRaster " - ) - # gdalstr = "gdal_translate -a_ullr " + str(Xul) + " " + str(Yul) + " " +str(Xlr) + " " +str(Ylr) + " -of PCRaster " - print gdalstr - tr.report(tr.cover(1.0), step1dir + "/wflow_riverlength_fact.map") - # Now us gdat tp convert the maps - os.system( - gdalstr - + step1dir - + "/wflow_riverlength_fact.map" - + " " - + step2dir - + "/wflow_riverlength_fact.map" - ) - os.system( - gdalstr + step1dir + "/demavg.map" + " " + step2dir + "/wflow_dem.map" - ) - os.system( - gdalstr + step1dir + "/demavg.map" + " " + step2dir + "/wflow_demmin.map" - ) - os.system( - gdalstr + step1dir + "/demavg.map" + " " + step2dir + "/wflow_demmax.map" - ) - os.system( - gdalstr + step1dir + "/gauges.map" + " " + step2dir + "/wflow_gauges.map" - ) - os.system( - gdalstr + step1dir + "/rivers.map" + " " + step2dir + "/wflow_river.map" - ) - os.system( - gdalstr - + step1dir - + "/streamorder.map" - + " " - + step2dir - + "/wflow_streamorder.map" - ) - os.system( - gdalstr + step1dir + "/gauges.map" + " " + step2dir + "/wflow_outlet.map" - ) - os.system( - gdalstr + step1dir + "/scatch.map" + " " + step2dir + "/wflow_catchment.map" - ) - os.system(gdalstr + step1dir + "/ldd.map" + " " + step2dir + "/wflow_ldd.map") - os.system( - gdalstr + step1dir + "/scatch.map" + " " + step2dir + "/wflow_subcatch.map" - ) + print("No fancy scaling done. Going strait to step2....") + tr.report(dem,step1dir + "/demavg.map") + Xul = float(config.get("settings","Xul")) + Yul = float(config.get("settings","Yul")) + Xlr = float(config.get("settings","Xlr")) + Ylr = float(config.get("settings","Ylr")) + gdalstr = "gdal_translate -projwin " + str(Xul) + " " + str(Yul) + " " +str(Xlr) + " " +str(Ylr) + " -of PCRaster " + #gdalstr = "gdal_translate -a_ullr " + str(Xul) + " " + str(Yul) + " " +str(Xlr) + " " +str(Ylr) + " -of PCRaster " + print(gdalstr) + tr.report(tr.cover(1.0),step1dir + "/wflow_riverlength_fact.map") + # Now us gdat tp convert the maps + os.system(gdalstr + step1dir + "/wflow_riverlength_fact.map" + " " + step2dir + "/wflow_riverlength_fact.map") + os.system(gdalstr + step1dir + "/demavg.map" + " " + step2dir + "/wflow_dem.map") + os.system(gdalstr + step1dir + "/demavg.map" + " " + step2dir + "/wflow_demmin.map") + os.system(gdalstr + step1dir + "/demavg.map" + " " + step2dir + "/wflow_demmax.map") + os.system(gdalstr + step1dir + "/gauges.map" + " " + step2dir + "/wflow_gauges.map") + os.system(gdalstr + step1dir + "/rivers.map" + " " + step2dir + "/wflow_river.map") + os.system(gdalstr + step1dir + "/streamorder.map" + " " + step2dir + "/wflow_streamorder.map") + os.system(gdalstr + step1dir + "/gauges.map" + " " + step2dir + "/wflow_outlet.map") + os.system(gdalstr + step1dir + "/scatch.map" + " " + step2dir + "/wflow_catchment.map") + os.system(gdalstr + step1dir + "/ldd.map" + " " + step2dir + "/wflow_ldd.map") + os.system(gdalstr + step1dir + "/scatch.map" + " " + step2dir + "/wflow_subcatch.map") + + if lu_water: + os.system(gdalstr + lu_water + " " + step2dir + "/WaterFrac.map") - if lu_water: - os.system(gdalstr + lu_water + " " + step2dir + "/WaterFrac.map") + if lu_paved: + os.system(gdalstr + lu_paved + " " + step2dir + "/PathFrac.map") - if lu_paved: - os.system(gdalstr + lu_paved + " " + step2dir + "/PathFrac.map") - - try: - lumap = config.get("files", "landuse") - except: - print "no landuse map...creating uniform map" - # clone=tr.readmap(step2dir + "/wflow_dem.map") + try: + lumap = config.get("files","landuse") + except: + print("no landuse map...creating uniform map") + #clone=tr.readmap(step2dir + "/wflow_dem.map") tr.setclone(step2dir + "/wflow_dem.map") - tr.report(tr.nominal(1), step2dir + "/wflow_landuse.map") - else: - os.system( - "resample --clone " - + step2dir - + "/wflow_dem.map " - + lumap - + " " - + step2dir - + "/wflow_landuse.map" - ) + tr.report(tr.nominal(1),step2dir + "/wflow_landuse.map") + else: + os.system("resample --clone " + step2dir + "/wflow_dem.map " + lumap + " " + step2dir + "/wflow_landuse.map") - try: - soilmap = config.get("files", "soil") - except: - print "no soil map..., creating uniform map" - tr.setclone(step2dir + "/wflow_dem.map") - tr.report(tr.nominal(1), step2dir + "/wflow_soil.map") - else: - os.system( - "resample --clone " - + step2dir - + "/wflow_dem.map " - + soilmap - + " " - + step2dir - + "/wflow_soil.map" - ) + try: + soilmap = config.get("files","soil") + except: + print("no soil map..., creating uniform map") + tr.setclone(step2dir + "/wflow_dem.map") + tr.report(tr.nominal(1),step2dir + "/wflow_soil.map") + else: + os.system("resample --clone " + step2dir + "/wflow_dem.map " + soilmap + " " + step2dir + "/wflow_soil.map") if __name__ == "__main__": Index: wflow-py/Scripts/wflow_prepare_step2.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/wflow_prepare_step2.py (.../wflow_prepare_step2.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/wflow_prepare_step2.py (.../wflow_prepare_step2.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -29,7 +29,7 @@ import os import os.path import getopt -import ConfigParser +import configparser import sys import numpy as np @@ -38,9 +38,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -50,20 +49,20 @@ try: ret = config.get(section, var) except: - print "returning default (" + default + ") for " + section + ":" + var + print("returning default (" + default + ") for " + section + ":" + var) ret = default return ret def OpenConf(fn): - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.optionxform = str if os.path.exists(fn): config.read(fn) else: - print "Cannot open config file: " + fn + print("Cannot open config file: " + fn) sys.exit(1) return config @@ -200,8 +199,8 @@ inifile = "wflow_prepare.ini" try: - opts, args = getopt.getopt(sys.argv[1:], "W:hI:f") - except getopt.error, msg: + opts, args = getopt.getopt(sys.argv[1:], 'W:hI:f') + except getopt.error as msg: usage(msg) for o, a in opts: @@ -237,15 +236,15 @@ Xlr = float(config.get("settings", "Xlr")) Ylr = float(config.get("settings", "Ylr")) except: - print "Xul, Xul, Xlr and Ylr are required entries in the ini file" + print("Xul, Xul, Xlr and Ylr are required entries in the ini file") sys.exit(1) csize = float(configget(config, "settings", "cellsize", "1")) try: gauges_x = config.get("settings", "gauges_x") gauges_y = config.get("settings", "gauges_y") except: - print "gauges_x and gauges_y are required entries in the ini file" + print("gauges_x and gauges_y are required entries in the ini file") sys.exit(1) strRiver = int(configget(config, "settings", "riverorder_step2", "4")) @@ -310,9 +309,9 @@ try: lumap = config.get("files", "landuse") except: - print "no landuse map...creating uniform map" - clone = tr.readmap(step2dir + "/cutout.map") - tr.report(tr.nominal(clone), step2dir + "/wflow_landuse.map") + print("no landuse map...creating uniform map") + clone=tr.readmap(step2dir + "/cutout.map") + tr.report(tr.nominal(clone),step2dir + "/wflow_landuse.map") else: os.system( "resample --clone " @@ -327,9 +326,9 @@ try: soilmap = config.get("files", "soil") except: - print "no soil map..., creating uniform map" - clone = tr.readmap(step2dir + "/cutout.map") - tr.report(tr.nominal(clone), step2dir + "/wflow_soil.map") + print("no soil map..., creating uniform map") + clone=tr.readmap(step2dir + "/cutout.map") + tr.report(tr.nominal(clone),step2dir + "/wflow_soil.map") else: os.system( "resample --clone " @@ -356,19 +355,13 @@ try: rivshp = config.get("files", "river") except: - print "no river file specified" + print("no river file specified") riverburn = tr.readmap(step2dir + "/wflow_riverburnin.map") else: - print "river file speficied....." - # rivshpattr = config.get("files","riverattr") - tr.report(dem * 0.0, step2dir + "/nilmap.map") - thestr = ( - "gdal_translate -of GTiff " - + step2dir - + "/nilmap.map " - + step2dir - + "/wflow_riverburnin.tif" - ) + print("river file speficied.....") + #rivshpattr = config.get("files","riverattr") + tr.report(dem * 0.0,step2dir + "/nilmap.map") + thestr = "gdal_translate -of GTiff " + step2dir + "/nilmap.map " + step2dir + "/wflow_riverburnin.tif" os.system(thestr) rivshpattr = os.path.splitext(os.path.basename(rivshp))[0] os.system( @@ -396,19 +389,15 @@ # Now setup a very high wall around the catchment that is scale # based on the distance to the catchment so that it slopes away from the # catchment - if lddmethod != "river": - print "Burning in highres-river ..." - disttocatch = tr.spread(tr.nominal(catchcut), 0.0, 1.0) - demmax = tr.ifthenelse( - tr.scalar(catchcut) >= 1.0, - demmax, - demmax + (tr.celllength() * 100.0) / disttocatch, - ) - tr.setglobaloption("unitcell") - # demregional=tr.windowaverage(demmin,100) - demburn = tr.cover(tr.ifthen(tr.boolean(riverburn), demmin - 100.0), demmax) + if lddmethod != 'river': + print("Burning in highres-river ...") + disttocatch = tr.spread(tr.nominal(catchcut),0.0,1.0) + demmax = tr.ifthenelse(tr.scalar(catchcut) >=1.0, demmax, demmax + (tr.celllength() * 100.0) /disttocatch) + tr.setglobaloption("unitcell") + #demregional=tr.windowaverage(demmin,100) + demburn = tr.cover(tr.ifthen(tr.boolean(riverburn), demmin -100.0) ,demmax) else: - print "using average dem.." + print("using average dem..") demburn = dem ldd = tr.lddcreate_save( @@ -435,20 +424,23 @@ tr.report(river, step2dir + "/wflow_river.map") # make subcatchments - # os.system("col2map --clone " + step2dir + "/cutout.map gauges.col " + step2dir + "/wflow_gauges.map") - exec "X=np.array(" + gauges_x + ")" - exec "Y=np.array(" + gauges_y + ")" + #os.system("col2map --clone " + step2dir + "/cutout.map gauges.col " + step2dir + "/wflow_gauges.map") + exec("X=np.array(" + gauges_x + ")") + exec("Y=np.array(" + gauges_y + ")") tr.setglobaloption("unittrue") - outlmap = tr.points_to_map(dem, X, Y, 0.5) - tr.report(outlmap, step2dir + "/wflow_gauges_.map") + outlmap = tr.points_to_map(dem,X,Y,0.5) + tr.report(outlmap,step2dir + "/wflow_gauges_.map") + + if snapgaugestoriver: + print("Snapping gauges to river") + tr.report(outlmap,step2dir + "/wflow_orggauges.map") + outlmap= tr.snaptomap(outlmap,river) + + outlmap = tr.ifthen(outlmap > 0, outlmap) + tr.report(outlmap,step2dir + "/wflow_gauges.map") - if snapgaugestoriver: - print "Snapping gauges to river" - tr.report(outlmap, step2dir + "/wflow_orggauges.map") - outlmap = tr.snaptomap(outlmap, river) - outlmap = tr.ifthen(outlmap > 0, outlmap) tr.report(outlmap, step2dir + "/wflow_gauges.map") Index: wflow-py/Scripts/wflow_sbm_rtc.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/wflow_sbm_rtc.py (.../wflow_sbm_rtc.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/wflow_sbm_rtc.py (.../wflow_sbm_rtc.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -20,7 +20,7 @@ import datetime, calendar import os import numpy as np -import ConfigParser +import configparser # reload(bmi) @@ -42,7 +42,7 @@ if dict1[option] == -1: DebugPrint("skip: %s" % option) except: - print ("exception on %s!" % option) + print(("exception on %s!" % option)) dict1[option] = None return dict1 @@ -74,14 +74,14 @@ argv = sys.argv try: - opts, args = getopt.getopt(argv[1:], "c:w:I:") - print opts -except getopt.error, msg: - print "cannot parse commandline" - sys.exit(2) + opts, args = getopt.getopt(argv[1:], 'c:w:I:') + print(opts) +except getopt.error as msg: + print('cannot parse commandline') + sys.exit(2) if not opts: - print "cannot parse commandline" + print('cannot parse commandline') sys.exit(2) for o, a in opts: @@ -92,8 +92,8 @@ if o == "-I": IniFile = a -Config = ConfigParser.ConfigParser() -# inifile = Config.read('c:\FEWS\SI-WAMI\SI-WAMI\Modules\RTC\wflow_rtctools.ini') +Config = configparser.ConfigParser() +#inifile = Config.read('c:\FEWS\SI-WAMI\SI-WAMI\Modules\RTC\wflow_rtctools.ini') inifile = Config.read(configfile) ######################################################################## ## Parse ini-file # @@ -129,13 +129,12 @@ os.chdir(Bin_RTC) from wflow.wrappers.rtc.wrapperExtended import BMIWrapperExtended +#RTC_model = BMIWrapperExtended(engine=os.path.join(Bin_RTC,"RTCTools_BMI")) +RTC_model = BMIWrapperExtended(engine=os.path.join(Bin_RTC,"RTCTools_BMI")) +print('RTCmodel', Bin_RTC,RTC_model) +RTC_model.initialize('..') -# RTC_model = BMIWrapperExtended(engine=os.path.join(Bin_RTC,"RTCTools_BMI")) -RTC_model = BMIWrapperExtended(engine=os.path.join(Bin_RTC, "RTCTools_BMI")) -print "RTCmodel", Bin_RTC, RTC_model -RTC_model.initialize("..") - # In[]: Initialize the WFlow model os.chdir(dir_wflow) LA_model = bmi.wflowbmi_csdms() @@ -152,35 +151,35 @@ # In[]: Investigate start time, end time and time step of both models -print "WFlow:" +print('WFlow:') LA_dt = LA_model.get_time_step() -# LA_start = LA_model.get_start_time() -timeutc = adapter.getStartTimefromRuninfo("inmaps/runinfo.xml") -print timeutc +#LA_start = LA_model.get_start_time() +timeutc = adapter.getStartTimefromRuninfo('inmaps/runinfo.xml') +print(timeutc) LA_start = calendar.timegm(timeutc.timetuple()) timeutc = adapter.getEndTimefromRuninfo("inmaps/runinfo.xml") LA_end = calendar.timegm(timeutc.timetuple()) -# LA_end = LA_model.get_end_time() -print LA_dt -print timeutc -print LA_start -print LA_end +#LA_end = LA_model.get_end_time() +print(LA_dt) +print(timeutc) +print(LA_start) +print(LA_end) -print "RTC-Tools" +print('RTC-Tools') RTC_dt = RTC_model.get_time_step() RTC_start = RTC_model.get_start_time() RTC_end = RTC_model.get_end_time() -print RTC_dt -print RTC_start -print RTC_end +print(RTC_dt) +print(RTC_start) +print(RTC_end) if LA_start != RTC_start: - print "Error: start time of both models is not identical !!!" + print('Error: start time of both models is not identical !!!') if LA_dt != RTC_dt: - print "Error: time step of both models is not identical !!!" + print('Error: time step of both models is not identical !!!') # In[]: Read and map reservoir inflow and outflow locations @@ -220,7 +219,7 @@ ).copy() LA_model.set_value(thisstack, inmstackbuf[thisstack]) - print "calculation timestep = " + str(timecounter) + print("calculation timestep = " + str(timecounter)) # Get the inflow from the wflow model runoff map and map inflowQ = flipud(LA_model.get_value("SurfaceRunoff")).copy() @@ -230,7 +229,7 @@ value = np.ndarray(shape=(1, 1), dtype=float, order="F") value[0][0] = np.sum(inflowQ[np.where(Reservoir_inflow == int(wflow_id))]) rtc_id = id_in_rtc[id_in_wflow.index(str(wflow_id))] - print rtc_id + " = " + str(value[0][0]) + print(rtc_id + ' = ' + str(value[0][0])) RTC_model.set_value(rtc_id, value) # run the RTC-Tools model Index: wflow-py/Scripts/wflow_subcatch.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/wflow_subcatch.py (.../wflow_subcatch.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/wflow_subcatch.py (.../wflow_subcatch.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -48,9 +48,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -74,7 +73,7 @@ # failed raise Exception("Command %s failed" % pollCmd) else: - print "Command %s completed successfully" % pollCmd + print("Command %s completed successfully" % pollCmd) return newProcs processes = [] @@ -93,14 +92,14 @@ while len(processes) > 0: time.sleep(0.5) processes = removeFinishedProcesses(processes) - print "All processes in que (" + str(len(commands)) + ") completed." + print("All processes in que (" + str(len(commands)) + ") completed.") def main(): try: - opts, args = getopt.getopt(sys.argv[1:], "fhC:N:I:s:M:") - except getopt.error, msg: + opts, args = getopt.getopt(sys.argv[1:], 'fhC:N:I:s:M:') + except getopt.error as msg: usage(msg) factor = 1 @@ -139,13 +138,13 @@ ] ext_to_copy = ["*.tss", "*.tbl", "*.col", "*.xml"] if os.path.isdir(caseNameNew) and not force: - print "Refusing to write into an existing directory:" + caseNameNew + print("Refusing to write into an existing directory:" + caseNameNew) exit() # ddir = [] dirs = [] for (path, thedirs, files) in os.walk(caseName): - print path + print(path) dirs.append(path) if not os.path.isdir(caseNameNew): @@ -159,23 +158,21 @@ os.path.join(caseName, "staticmaps", "wflow_subcatch.map"), "PCRaster" ) for ddir in dirs: - print ddir + print(ddir) allcmd = [] for mfile in glob.glob(ddir + "/*.map"): if not os.path.exists(mfile.replace(caseName, caseNameNew)): x, y, data, FillVal = readMap(mfile, "PCRaster") try: good = 1 - xn, yn, datan = cutMapById( - data, subcatchmap, subcatch, x, y, FillVal - ) - except Exception, e: + xn, yn, datan = cutMapById(data,subcatchmap,subcatch,x,y,FillVal) + except Exception as e: good = 0 - print "Skipping: " + mfile + " exception: " + str(e) + print("Skipping: " + mfile + " exception: " + str(e)) if xn == None: good = 0 - print "Skipping: " + mfile + " size does not match..." + print("Skipping: " + mfile + " size does not match...") if good: ofile = mfile.replace(caseName, caseNameNew) @@ -197,16 +194,14 @@ x, y, data, FillVal = readMap(mfile, "PCRaster") try: good = 1 - xn, yn, datan = cutMapById( - data, subcatchmap, subcatch, x, y, FillVal - ) - except Exception, e: + xn, yn, datan = cutMapById(data, subcatchmap, subcatch, x, y, FillVal) + except Exception as e: good = 0 - print "Skipping: " + mfile + " exception: " + str(e) + print("Skipping: " + mfile + " exception: " + str(e)) if xn == None: good = 0 - print "Skipping: " + mfile + " size does not match..." + print("Skipping: " + mfile + " size does not match...") if good: ofile = mfile.replace(caseName, caseNameNew) Index: wflow-py/Scripts/wtools_py/CatchRiver.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/wtools_py/CatchRiver.py (.../CatchRiver.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/Scripts/wtools_py/CatchRiver.py (.../CatchRiver.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -23,36 +23,34 @@ def usage(): - print ("") - print ( - "Usage: CatchRiver [-d dem (raster)] [-l burn_line (shape)] [-p burn_point (shape)] [-a burn_area (shape)]\n " - "[-R riverout (shape)] [-C catchmentout (shape)] [-O min strahler order (integer)] -B -S -K" - ) - print "-d digital elevation model (GeoTiff)" - print "-l polylines (rivers) to be burned in the DEM (optional) (ESRI Shapefile)" - print "-p points (outlets) to be burned in the DEM (optional) (ESRI Shapefile)" - print "-F factor by which the cell-size should be scaled (default=1)" - print "-O minimal strahler order in river shapefile (optional, default=3) (integer)" - print "-s option to snap points (-p) to lines (-l) (default=no)" - print "-R name of output river (optional, default = river.shp) (ESRI Shapefile)" - print "-C name of output catchment (optional, default = catchment.shp) (ESRI Shapefile)" - print "-B burn value by which DEM will be lowered if burned (optional, default=1000) (integer)" - print "-S option to skip generation of LDD (default=no)" - print "-K option to keep all catchments and river networks (default=no)" - print '-I option to force "lddin" (default=no)' + print('') + print('Usage: CatchRiver [-d dem (raster)] [-l burn_line (shape)] [-p burn_point (shape)] [-a burn_area (shape)]\n ' + '[-R riverout (shape)] [-C catchmentout (shape)] [-O min strahler order (integer)] -B -S -K') + print('-d digital elevation model (GeoTiff)') + print('-l polylines (rivers) to be burned in the DEM (optional) (ESRI Shapefile)') + print('-p points (outlets) to be burned in the DEM (optional) (ESRI Shapefile)') + print('-F factor by which the cell-size should be scaled (default=1)') + print('-O minimal strahler order in river shapefile (optional, default=3) (integer)') + print('-s option to snap points (-p) to lines (-l) (default=no)') + print('-R name of output river (optional, default = river.shp) (ESRI Shapefile)') + print('-C name of output catchment (optional, default = catchment.shp) (ESRI Shapefile)') + print('-B burn value by which DEM will be lowered if burned (optional, default=1000) (integer)') + print('-S option to skip generation of LDD (default=no)') + print('-K option to keep all catchments and river networks (default=no)') + print('-I option to force "lddin" (default=no)') - print "" + print('') def removeshp(shapein, directory): if os.path.exists(directory + shapein): - print shapein + " exists and will be deleted" + print(shapein + ' exists and will be deleted') Driver.DeleteDataSource(directory + shapein) shapein = directory + shapein else: shapein = directory + shapein if os.path.exists(directory + shapein): - print "failed to remove " + directory + shapein + print('failed to remove ' + directory + shapein) counter = 1 stopcounting = False shp_att = os.path.splitext(os.path.basename(shapein))[0] @@ -63,7 +61,7 @@ stopcounting = True else: counter += 1 - print "filename used: " + shapein + print('filename used: ' + shapein) return shapein @@ -79,7 +77,7 @@ try: opts, args = getopt.getopt(argv[1:], "d:l:p:F:a:R:C:O:B:SsKI") except getopt.error: - print "error" + print('error') usage() sys.exit(1) @@ -128,77 +126,77 @@ """ check if files exist """ if dem_in == None: if not skipldd: - print "please provide dem" + print('please provide dem') usage() sys.exit(1) else: if not os.path.exists(dem_in): - print "file " + dem_in - print "Your DEM does not exist in the file-system" - print "" + print('file ' + dem_in) + print('Your DEM does not exist in the file-system') + print('') sys.exit(1) if not pointshp == None: if not os.path.exists(pointshp): - print "file " + pointshp - print "Your point-shape does not exist in the file-system" - print "" + print('file ' + pointshp) + print('Your point-shape does not exist in the file-system') + print('') sys.exit(1) if not lineshp == None: if not os.path.exists(lineshp): - print "file " + lineshp - print "Your line-shape does not exist in the file-system" - print "" + print('file ' + lineshp) + print('Your line-shape does not exist in the file-system') + print('') sys.exit(1) """ set property values """ if minorder == None: - print "no minimum strahler order specified" - print "default will be used: 5" + print('no minimum strahler order specified') + print('default will be used: 5') minorder = int(5) if burnvalue == None: - print "no value for burning defined" - print "default will be used: 1000 (map units)" - print "pits will be filled till 500 (map units)" + print('no value for burning defined') + print('default will be used: 1000 (map units)') + print('pits will be filled till 500 (map units)') burnvalue = float(1000) if rivshp == None: - print "default name for river shape will be used: river.shp" - rivshp = "river.shp" + print('default name for river shape will be used: river.shp') + rivshp = 'river.shp' if catchshp == None: - print "default name for river shape will be used: catchment.shp" - catchshp = "catchments.shp" + print('default name for river shape will be used: catchment.shp') + catchshp = 'catchments.shp' if not dem_in == None: ds = gdal.Open(dem_in) if ds == None: - print "Input file specified not available or not a raster" + print('Input file specified not available or not a raster') sys.exit(1) else: spatialref = ds.GetProjection() srs = osr.SpatialReference() - if (srs == None) or (spatialref == ""): - print "Your DEM is not projected" + if (srs == None) or (spatialref == ''): + print('Your DEM is not projected') sys.exit(1) - print srs + print(srs) srs.ImportFromWkt(spatialref) srs.AutoIdentifyEPSG() EPSG = "EPSG:" + srs.GetAttrValue("AUTHORITY", 1) cellsize = ds.GetGeoTransform()[1] # transform = ds.GetGeoTransform() # ds = None else: - print "no DEM provided, no projection will be assigned to output" + print('no DEM provided, no projection will be assigned to output') """ create directories """ if not skipldd: if os.path.isdir(workdir): try: shutil.rmtree(workdir) except: - print "cannot remove work directory" - print "probably blocked by other process" + print('cannot remove work directory') + print('probably blocked by other process') sys.exit(1) os.makedirs(workdir) @@ -329,7 +327,7 @@ ) points = pcr.scalar(pcr.readmap(point_map)) if snapgaugestoriver: - print "Snapping points to line" + print("Snapping points to line") points = wt.snaptomap(pcr.ordinal(points), pcr.boolean(lines)) points = pcr.cover(pcr.scalar(points), pcr.scalar(0)) points = pcr.cover(points, pcr.scalar(0)) @@ -351,17 +349,17 @@ generateldd = True if skipldd: - print "Option -S is set" - print "ldd will be read from " + ldd_map + print('Option -S is set') + print('ldd will be read from ' + ldd_map) if os.path.exists(ldd_map): ldd = pcr.ldd(pcr.readmap(ldd_map)) generateldd = False else: - print "file " + ldd_map + " does not exist" - print "new ldd will be generated" + print('file ' + ldd_map + ' does not exist') + print('new ldd will be generated') if generateldd: - print "Generating ldd..." + print('Generating ldd...') if burndem: linescover = pcr.ifthen(lines == 1, pcr.scalar(0)) pointscover = pcr.ifthen(pcr.scalar(points) == 1, pcr.scalar(0)) @@ -463,9 +461,8 @@ pcr.report(riversid, riversid_map) pcr.report(drain, drain_map) -print "converting river map-file to shape-file..." -wt.PCR_river2Shape( - riversid_map, drain_map, streamorder_map, ldd_map, rivshp, catchments_map, srs -) +print('converting river map-file to shape-file...') +wt.PCR_river2Shape(riversid_map, drain_map, streamorder_map, + ldd_map, rivshp, catchments_map, srs) # if __name__ == "__main__": # main() Index: wflow-py/Scripts/wtools_py/modelbuilder.py =================================================================== diff -u -r2b7633b5f66776fef38edc8519c7bb307db5b0ad -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/Scripts/wtools_py/modelbuilder.py (.../modelbuilder.py) (revision 2b7633b5f66776fef38edc8519c7bb307db5b0ad) +++ wflow-py/Scripts/wtools_py/modelbuilder.py (.../modelbuilder.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -460,7 +460,7 @@ r.raise_for_status() except requests.exceptions.HTTPError as err: print(err) - print(r.text) + print((r.text)) sys.exit(1) return r @@ -472,7 +472,7 @@ r.raise_for_status() except requests.exceptions.HTTPError as err: print(err) - print(r.text) + print((r.text)) sys.exit(1) return r Index: wflow-py/UnitTests/TestBMI.py =================================================================== diff -u -r5bc2c6406fea89698faa5d0ca1488dc25760b5e3 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/UnitTests/TestBMI.py (.../TestBMI.py) (revision 5bc2c6406fea89698faa5d0ca1488dc25760b5e3) +++ wflow-py/UnitTests/TestBMI.py (.../TestBMI.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -18,138 +18,124 @@ def testbmifuncs(self): bmiobj = bmi.wflowbmi_csdms() - bmiobj.initialize("wflow_sceleton/wflow_sceleton.ini", loglevel=logging.ERROR) + bmiobj.initialize('wflow_sceleton/wflow_sceleton.ini',loglevel=logging.ERROR) - print ("-------------- Grid origin: ") - gorigin = bmiobj.get_grid_origin("Altitude") - # print(gorigin) - self.assertAlmostEquals( - sum([45.875934703275561, 5.2088299822062254]), sum(gorigin), places=4 - ) + print("-------------- Grid origin: ") + gorigin = bmiobj.get_grid_origin('Altitude') + #print(gorigin) + self.assertAlmostEqual(sum([45.875934703275561, 5.2088299822062254]), sum(gorigin),places=4) - print ("-------------- Grid shape: ") - print (bmiobj.get_grid_shape("Altitude")) - self.assertAlmostEquals( - sum([169L, 187L]), sum(bmiobj.get_grid_shape("Altitude")), places=4 - ) + print("-------------- Grid shape: ") + print((bmiobj.get_grid_shape('Altitude'))) + self.assertAlmostEqual(sum([169, 187]), sum(bmiobj.get_grid_shape('Altitude')),places=4) - print ("-------------- Grid spacing: ") - print (bmiobj.get_grid_spacing("Altitude")) - self.assertAlmostEquals( - sum([0.036666665, 0.036666665]), - sum(bmiobj.get_grid_spacing("Altitude")), - places=4, - ) + print("-------------- Grid spacing: ") + print((bmiobj.get_grid_spacing('Altitude'))) + self.assertAlmostEqual(sum([0.036666665, 0.036666665]), sum(bmiobj.get_grid_spacing('Altitude')), places=4) - print ("-------------- Grid X: ") - print (bmiobj.get_grid_x("Altitude")) - self.assertAlmostEquals( - 5.22716331, bmiobj.get_grid_x("Altitude")[0, 0], places=4 - ) + print("-------------- Grid X: ") + print((bmiobj.get_grid_x('Altitude'))) + self.assertAlmostEqual( 5.22716331, bmiobj.get_grid_x('Altitude')[0,0], places=4) - print ("-------------- Grid Y: ") - print (bmiobj.get_grid_y("Altitude")) - self.assertAlmostEquals( - 45.89426804, bmiobj.get_grid_y("Altitude")[0, 0], places=4 - ) + print("-------------- Grid Y: ") + print((bmiobj.get_grid_y('Altitude'))) + self.assertAlmostEqual( 45.89426804, bmiobj.get_grid_y('Altitude')[0,0], places=4) - print ("-------------- Grid Z: ") - print (bmiobj.get_grid_z("Altitude")) - self.assertAlmostEquals( - 218.44944763, bmiobj.get_grid_z("Altitude")[0, 0], places=4 - ) + print("-------------- Grid Z: ") + print((bmiobj.get_grid_z('Altitude'))) + self.assertAlmostEqual(218.44944763, bmiobj.get_grid_z('Altitude')[0, 0], places=4) - print ("-------------- Name: ") - print (bmiobj.get_component_name()) - self.assertEquals("wflow_sceleton", bmiobj.get_component_name()) + print("-------------- Name: ") + print((bmiobj.get_component_name())) + self.assertEqual('wflow_sceleton',bmiobj.get_component_name()) - print ("-------------- Input var names: ") - print (bmiobj.get_input_var_names()) + print("-------------- Input var names: ") + print((bmiobj.get_input_var_names())) - print ("-------------- UNit of var TEMP: ") - print (bmiobj.get_var_units("TEMP")) + print("-------------- UNit of var TEMP: ") + print((bmiobj.get_var_units('TEMP'))) - print ("-------------- UNit of var P: ") - print (bmiobj.get_var_units("P")) + print("-------------- UNit of var P: ") + print((bmiobj.get_var_units('P'))) - print ("-------------- Output var names: ") - print (bmiobj.get_output_var_names()) + print("-------------- Output var names: ") + print((bmiobj.get_output_var_names())) - print ("-------------- Time units: ") - print (bmiobj.get_time_units()) + print("-------------- Time units: ") + print((bmiobj.get_time_units())) - print ("-------------- Time step: ") - print (bmiobj.get_time_step()) + print("-------------- Time step: ") + print((bmiobj.get_time_step())) - print ("-------------- Start time: ") - print (bmiobj.get_start_time()) + print("-------------- Start time: ") + print((bmiobj.get_start_time())) - print ("-------------- Current time: ") - print (bmiobj.get_current_time()) + print("-------------- Current time: ") + print((bmiobj.get_current_time())) a = bmiobj.get_current_time() # print(time.localtime(bmiobj.get_current_time())) os.environ["TZ"] = "Europe/London" - print ("-------------- Current time (set to london): ") - print (bmiobj.get_current_time()) + print("-------------- Current time (set to london): ") + print((bmiobj.get_current_time())) b = bmiobj.get_current_time() - self.assertAlmostEquals(a, b) + self.assertAlmostEqual(a,b) print ("-------------- update: ") bmiobj.update() - print ("-------------- Current time after update: ") - print (bmiobj.get_current_time()) - print (time.localtime(bmiobj.get_current_time())) + print("-------------- Current time after update: ") + print((bmiobj.get_current_time())) + print((time.localtime(bmiobj.get_current_time()))) - print ("-------------- Start time: ") - print (bmiobj.get_start_time()) - print (time.localtime(bmiobj.get_start_time())) + print("-------------- Start time: ") + print((bmiobj.get_start_time())) + print((time.localtime(bmiobj.get_start_time()))) - print ("-------------- End time: ") - print (bmiobj.get_end_time()) - print (time.localtime(bmiobj.get_end_time())) + print("-------------- End time: ") + print((bmiobj.get_end_time())) + print((time.localtime(bmiobj.get_end_time()))) - print ("-------------- Grid type: ") - print (bmiobj.get_grid_type("Altitude")) + print("-------------- Grid type: ") + print((bmiobj.get_grid_type('Altitude'))) - print ("-------------- Var type: ") - print (bmiobj.get_var_type("Altitude")) + print("-------------- Var type: ") + print((bmiobj.get_var_type('Altitude'))) - print ("-------------- Var rank: ") - print (bmiobj.get_var_rank("Altitude")) + print("-------------- Var rank: ") + print((bmiobj.get_var_rank('Altitude'))) - print ("-------------- Var size: ") - print (bmiobj.get_var_size("Altitude")) + print("-------------- Var size: ") + print((bmiobj.get_var_size('Altitude'))) - print ("-------------- Var nbytes: ") - print (bmiobj.get_var_nbytes("Altitude")) + print("-------------- Var nbytes: ") + print((bmiobj.get_var_nbytes('Altitude'))) - print ("-------------- Getvalue: ") - print (bmiobj.get_value("Altitude")) + print("-------------- Getvalue: ") + print((bmiobj.get_value('Altitude'))) - print ("-------------- Getvalue: ") - print (bmiobj.get_value("timestepsecs")) + print("-------------- Getvalue: ") + print((bmiobj.get_value('timestepsecs'))) print ("-------------- get_attribute_names: ") names = bmiobj.get_attribute_names() - print names + print(names) - print ("-------------- get_attribute_value: ") - print names[0] - print (bmiobj.get_attribute_value(names[0])) + print("-------------- get_attribute_value: ") + print(names[0]) + print((bmiobj.get_attribute_value(names[0]))) - print ("-------------- set_attribute_value: ") - print names[0] - bmiobj.set_attribute_value(names[0], "SET By TEST") - print (bmiobj.get_attribute_value(names[0])) - self.assertEquals("SET By TEST", bmiobj.get_attribute_value(names[0])) + print("-------------- set_attribute_value: ") + print(names[0]) + bmiobj.set_attribute_value(names[0],"SET By TEST") + print((bmiobj.get_attribute_value(names[0]))) + self.assertEqual("SET By TEST",bmiobj.get_attribute_value(names[0])) print ("-------------- set_start_time: ") bmiobj.set_start_time(0) - print (bmiobj.get_attribute_value("run:starttime")) + print((bmiobj.get_attribute_value("run:starttime"))) print ("-------------- save the state:") bmiobj.save_state(".") @@ -160,9 +146,9 @@ def testbmirun(self): bmiobj = bmi.wflowbmi_csdms() - bmiobj.initialize("wflow_sceleton/wflow_sceleton.ini", loglevel=logging.DEBUG) - bmiobj.set_attribute_value("run:runlengthdetermination", "intervals") - print (bmiobj.get_var_type("IF")) + bmiobj.initialize('wflow_sceleton/wflow_sceleton.ini',loglevel=logging.DEBUG) + bmiobj.set_attribute_value('run:runlengthdetermination', 'intervals') + print((bmiobj.get_var_type("IF"))) et = bmiobj.get_end_time() st = bmiobj.get_start_time() ts = 86400 @@ -171,16 +157,16 @@ bmiobj.update_until(et) bmiobj.get_current_time() bmiobj.finalize() - print et - bmiobj.get_current_time() - self.assertEquals(et, bmiobj.get_current_time()) + print(et - bmiobj.get_current_time()) + self.assertEqual(et,bmiobj.get_current_time()) def testbmirun_hr(self): bmiobj = bmi.wflowbmi_csdms() bmiobj.initialize( "wflow_sceleton/wflow_sceleton_hr.ini", loglevel=logging.DEBUG ) - print (bmiobj.get_var_type("IF")) + print((bmiobj.get_var_type("IF"))) et = bmiobj.get_end_time() st = bmiobj.get_start_time() ts = 3600 @@ -189,34 +175,35 @@ bmiobj.update_until(et) bmiobj.get_current_time() bmiobj.finalize() - print et - bmiobj.get_current_time() - self.assertEquals(et, bmiobj.get_current_time()) + print(et - bmiobj.get_current_time()) + self.assertEqual(et,bmiobj.get_current_time()) + def testbmirun_l(self): - print "Run with update(-1)" + print('Run with update(-1)') bmiobj = bmi.wflowbmi_light() - bmiobj.initialize("wflow_sceleton/wflow_sceleton.ini", loglevel=logging.ERROR) - print bmiobj.get_current_time() + bmiobj.initialize('wflow_sceleton/wflow_sceleton.ini',loglevel=logging.ERROR) + print(bmiobj.get_current_time()) et = bmiobj.get_end_time() st = bmiobj.get_start_time() - print bmiobj.get_current_time() + print(bmiobj.get_current_time()) bmiobj.update(et - st) - print bmiobj.get_current_time() + print(bmiobj.get_current_time()) bmiobj.finalize() - print bmiobj.get_current_time() - print et - print st - self.assertEquals(et, bmiobj.get_current_time()) + print(bmiobj.get_current_time()) + print(et) + print(st) + self.assertEqual(et, bmiobj.get_current_time()) def testbmirun_space_in_name(self): - print "Run with update(-1)" + print('Run with update(-1)') bmiobj = bmi.wflowbmi_light() bmiobj.initialize("wflow_sceleton/wflow_sceleton.ini", loglevel=logging.ERROR) et = bmiobj.get_end_time() st = bmiobj.get_start_time() bmiobj.update(et - st) bmiobj.finalize() - self.assertEquals(et, bmiobj.get_current_time()) + self.assertEqual(et, bmiobj.get_current_time()) def testbmirunnetcdf(self): bmiobj = bmi.wflowbmi_csdms() @@ -238,13 +225,13 @@ bmiobj.set_value("PET", avar + 10.0) cnt = cnt + 1 bmiobj.update_until(curtime + ts) - print (curtime + ts) / ts + print((curtime + ts)/ts) curtime = bmiobj.get_current_time() - print bmiobj.get_current_time() - lastcurtime + print(bmiobj.get_current_time() - lastcurtime) lastcurtime = bmiobj.get_current_time() bmiobj.finalize() - self.assertEquals(ett, bmiobj.get_current_time()) + self.assertEqual(ett, bmiobj.get_current_time()) if __name__ == "__main__": Index: wflow-py/UnitTests/TestBMI_Init.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/UnitTests/TestBMI_Init.py (.../TestBMI_Init.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/UnitTests/TestBMI_Init.py (.../TestBMI_Init.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -20,13 +20,13 @@ "wflow_sceleton/wflow_sceleton_notime.ini", loglevel=logging.INFO ) print("-------------- Time units: ") - print(bmiobj.get_time_units()) + print((bmiobj.get_time_units())) print("-------------- Default current time: ") - print(datetime.datetime.utcfromtimestamp(bmiobj.get_current_time())) + print((datetime.datetime.utcfromtimestamp(bmiobj.get_current_time()))) print("-------------- Default start time: ") - print(datetime.datetime.utcfromtimestamp(bmiobj.get_start_time())) + print((datetime.datetime.utcfromtimestamp(bmiobj.get_start_time()))) print("-------------- Default end time: ") - print(datetime.datetime.utcfromtimestamp(bmiobj.get_end_time())) + print((datetime.datetime.utcfromtimestamp(bmiobj.get_end_time()))) print("-------------- Set start time to 5: ") bmiobj.set_start_time(5 * 86400) print("-------------- Set start time to 10: ") @@ -39,30 +39,30 @@ print("Init model...") bmiobj.initialize_model() - print(bmiobj.dynModel._userModel().config.get("run", "starttime")) + print((bmiobj.dynModel._userModel().config.get("run",'starttime'))) nstime = datetime.datetime.utcfromtimestamp(bmiobj.get_start_time()) netime = datetime.datetime.utcfromtimestamp(bmiobj.get_end_time()) - self.assertEquals(stime, nstime) - self.assertEquals(etime, netime) + self.assertEqual(stime, nstime) + self.assertEqual(etime, netime) print("-------------- Set start time to 5: ") bmiobj.set_start_time(5 * 86400) print("-------------- Get current time: ") - print(datetime.datetime.utcfromtimestamp(bmiobj.get_current_time())) + print((datetime.datetime.utcfromtimestamp(bmiobj.get_current_time()))) print("-------------- Get timestep: ") - print(bmiobj.get_time_step()) + print((bmiobj.get_time_step())) print("-------------- get endtime: ") - print(datetime.datetime.utcfromtimestamp(bmiobj.get_end_time())) + print((datetime.datetime.utcfromtimestamp(bmiobj.get_end_time()))) print("-------------- set endtime: ") bmiobj.set_end_time(10.0 * 86400) print("-------------- get endtime: ") - print(datetime.datetime.utcfromtimestamp(bmiobj.get_end_time())) + print((datetime.datetime.utcfromtimestamp(bmiobj.get_end_time()))) print("-------------- get_var_units: ") - print(bmiobj.get_var_units("SS")) + print((bmiobj.get_var_units("SS"))) bmiobj.finalize() Index: wflow-py/UnitTests/TestBMI_combined.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/UnitTests/TestBMI_combined.py (.../TestBMI_combined.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/UnitTests/TestBMI_combined.py (.../TestBMI_combined.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -20,29 +20,29 @@ bmiobj = bmi.wflowbmi_csdms() bmiobj.initialize("bmirunner.ini", loglevel=logging.INFO) - print bmiobj.get_component_name().split(",") - print bmiobj.get_input_var_names() - print bmiobj.get_output_var_names() - print bmiobj.get_start_time() + print(bmiobj.get_component_name().split(',')) + print(bmiobj.get_input_var_names()) + print(bmiobj.get_output_var_names()) + print(bmiobj.get_start_time()) endtime = bmiobj.get_end_time() curtime = bmiobj.get_current_time() - print endtime - print curtime - print bmiobj.get_time_step() - print bmiobj.get_attribute_names() - steps = 0 - print steps + print(endtime) + print(curtime) + print(bmiobj.get_time_step()) + print(bmiobj.get_attribute_names()) + steps = 0 + print(steps) while curtime < endtime: bmiobj.update() steps = steps + 1 curtime = bmiobj.get_current_time() atn = bmiobj.get_attribute_names() - print atn[0] - print bmiobj.get_attribute_value(atn[0]) + print(atn[0]) + print(bmiobj.get_attribute_value(atn[0])) bmiobj.finalize() - self.assertEquals(steps, 29) - self.assertEquals(curtime, bmiobj.get_current_time()) + self.assertEqual(steps, 29) + self.assertEqual(curtime, bmiobj.get_current_time()) if __name__ == "__main__": Index: wflow-py/UnitTests/TestBMI_combined_mp.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/UnitTests/TestBMI_combined_mp.py (.../TestBMI_combined_mp.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/UnitTests/TestBMI_combined_mp.py (.../TestBMI_combined_mp.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -20,24 +20,22 @@ bmiobj = bmi.wflowbmi_csdms() bmiobj.initialize("bmirunner.ini") - print bmiobj.get_component_name().split(",") - print bmiobj.get_input_var_names() - print bmiobj.get_output_var_names() - print bmiobj.get_start_time() - print bmiobj.get_end_time() - print bmiobj.get_current_time() - print bmiobj.get_time_step() - print bmiobj.get_attribute_names() - steps = ( - bmiobj.get_end_time() - bmiobj.get_start_time() - ) / bmiobj.get_time_step() + 1 - print steps - for a in range(0, steps): + print(bmiobj.get_component_name().split(',')) + print(bmiobj.get_input_var_names()) + print(bmiobj.get_output_var_names()) + print(bmiobj.get_start_time()) + print(bmiobj.get_end_time()) + print(bmiobj.get_current_time()) + print(bmiobj.get_time_step()) + print(bmiobj.get_attribute_names()) + steps = (bmiobj.get_end_time() - bmiobj.get_start_time())/bmiobj.get_time_step() + 1 + print(steps) + for a in range(0,steps): bmiobj.update() atn = bmiobj.get_attribute_names() - print atn[0] - print bmiobj.get_attribute_value(atn[0]) + print(atn[0]) + print(bmiobj.get_attribute_value(atn[0])) bmiobj.finalize() Index: wflow-py/UnitTests/TestFrameWork.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/UnitTests/TestFrameWork.py (.../TestFrameWork.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/UnitTests/TestFrameWork.py (.../TestFrameWork.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -38,12 +38,10 @@ dynModelFw._runSuspend() # saves the state variables dynModelFw._wf_shutdown() - my_data = wf.genfromtxt(os.path.join(caseName, runId, "tes.csv"), delimiter=",") - self.assertAlmostEquals(14.885358393192291, my_data[:, 2].sum()) - my_data_mean = wf.genfromtxt( - os.path.join(caseName, runId, "tes_mean_5.csv"), delimiter="," - ) - self.assertAlmostEquals(20.727288454771042, my_data_mean[:, 2].sum()) + my_data = wf.genfromtxt(os.path.join(caseName,runId,"tes.csv"), delimiter=',') + self.assertAlmostEqual(14.885358393192291,my_data[:,2].sum()) + my_data_mean = wf.genfromtxt(os.path.join(caseName, runId, "tes_mean_5.csv"), delimiter=',') + self.assertAlmostEqual( 20.727288454771042, my_data_mean[:, 2].sum()) if __name__ == "__main__": Index: wflow-py/UnitTests/Test_w3ra_BMI.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/UnitTests/Test_w3ra_BMI.py (.../Test_w3ra_BMI.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/UnitTests/Test_w3ra_BMI.py (.../Test_w3ra_BMI.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -59,9 +59,9 @@ tmean = np.ma.masked_invalid(data.astype(np.float64)).mean() tmax = np.ma.masked_invalid(data.astype(np.float64)).max() tmin = np.ma.masked_invalid(data.astype(np.float64)).min() - self.assertAlmostEquals(266.18075561523438, tmax) - self.assertAlmostEquals(-7.8522729383405979e+37, tmean) - self.assertAlmostEquals(-3.4028234663852886e+38, tmin) + self.assertAlmostEqual(266.18075561523438, tmax) + self.assertAlmostEqual(-7.8522729383405979e+37, tmean) + self.assertAlmostEqual(-3.4028234663852886e+38, tmin) if __name__ == "__main__": Index: wflow-py/UnitTests/Testwflow_hbv.py =================================================================== diff -u -r5bc2c6406fea89698faa5d0ca1488dc25760b5e3 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/UnitTests/Testwflow_hbv.py (.../Testwflow_hbv.py) (revision 5bc2c6406fea89698faa5d0ca1488dc25760b5e3) +++ wflow-py/UnitTests/Testwflow_hbv.py (.../Testwflow_hbv.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -19,17 +19,15 @@ # set runid, clonemap and casename. Also define the ini file runId = "unittest" - configfile = "wflow_hbv.ini" - wflow_cloneMap = "wflow_catchment.map" - caseName = "wflow_hbv" - starttime = starttime = datetime.datetime(1990, 01, 01) + configfile="wflow_hbv.ini" + wflow_cloneMap = 'wflow_catchment.map' + caseName="wflow_hbv" + starttime = starttime = datetime.datetime(1990,0o1,0o1) - myModel = wf.WflowModel(wflow_cloneMap, caseName, runId, configfile) - # initialise the framework - dynModelFw = wf.wf_DynamicFramework( - myModel, stopTime, firstTimestep=startTime, datetimestart=starttime - ) - print dynModelFw.DT + myModel = wf.WflowModel(wflow_cloneMap, caseName,runId,configfile) + # initialise the framework + dynModelFw = wf.wf_DynamicFramework(myModel, stopTime,firstTimestep=startTime,datetimestart=starttime) + print(dynModelFw.DT) # Load model config from files and check directory structure dynModelFw.createRunId(NoOverWrite=False, level=wf.logging.DEBUG) @@ -54,10 +52,15 @@ # nore read the csv results acn check of they match the first run # Sum should be approx c 4.569673676 - my_data = wf.genfromtxt( - os.path.join(caseName, runId, "watbal.csv"), delimiter="," - ) + my_data = wf.genfromtxt(os.path.join(caseName,runId,"watbal.csv"), delimiter=',') + print("Checking water budget ....") + self.assertAlmostEqual(0.0011471913849163684,my_data[:,2].sum(),places=4) + + my_data = wf.genfromtxt(os.path.join(caseName,runId,"run.csv"), delimiter=',') + print("Checking discharge ....") + self.assertAlmostEqual(1092.849374135335,my_data[:,2].mean(),places=4) + print ("Checking water budget ....") self.assertAlmostEquals(0.0011471913849163684, my_data[:, 2].sum(), places=4) Index: wflow-py/UnitTests/Testwflow_hbv2.py =================================================================== diff -u -r5bc2c6406fea89698faa5d0ca1488dc25760b5e3 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/UnitTests/Testwflow_hbv2.py (.../Testwflow_hbv2.py) (revision 5bc2c6406fea89698faa5d0ca1488dc25760b5e3) +++ wflow-py/UnitTests/Testwflow_hbv2.py (.../Testwflow_hbv2.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -19,17 +19,15 @@ # set runid, clonemap and casename. Also define the ini file runId = "unittest" - configfile = "wflow_hbv_hr.ini" - wflow_cloneMap = "wflow_catchment.map" - caseName = "wflow_hbv" - starttime = starttime = datetime.datetime(1990, 01, 01) + configfile="wflow_hbv_hr.ini" + wflow_cloneMap = 'wflow_catchment.map' + caseName="wflow_hbv" + starttime = starttime = datetime.datetime(1990,0o1,0o1) - myModel = wf.WflowModel(wflow_cloneMap, caseName, runId, configfile) - # initialise the framework - dynModelFw = wf.wf_DynamicFramework( - myModel, stopTime, firstTimestep=startTime, datetimestart=starttime - ) - print dynModelFw.DT + myModel = wf.WflowModel(wflow_cloneMap, caseName,runId,configfile) + # initialise the framework + dynModelFw = wf.wf_DynamicFramework(myModel, stopTime,firstTimestep=startTime,datetimestart=starttime) + print(dynModelFw.DT) # Load model config from files and check directory structure dynModelFw.createRunId(NoOverWrite=False, level=wf.logging.DEBUG) @@ -56,10 +54,15 @@ # nore read the csv results acn check of they match the first run # Sum should be approx c 4.569673676 - my_data = wf.genfromtxt( - os.path.join(caseName, runId, "watbal.csv"), delimiter="," - ) + my_data = wf.genfromtxt(os.path.join(caseName,runId,"watbal.csv"), delimiter=',') + print("Checking water budget ....") + self.assertAlmostEqual( 0.0013141632080078125,my_data[:,2].sum(),places=4) + + my_data = wf.genfromtxt(os.path.join(caseName,runId,"run.csv"), delimiter=',') + print("Checking discharge ....") + self.assertAlmostEqual(1837.7918265024821 ,my_data[:,2].mean(),places=4) + print ("Checking water budget ....") self.assertAlmostEquals(0.0013141632080078125, my_data[:, 2].sum(), places=4) Index: wflow-py/UnitTests/Testwflow_sbm.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/UnitTests/Testwflow_sbm.py (.../Testwflow_sbm.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/UnitTests/Testwflow_sbm.py (.../Testwflow_sbm.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -55,15 +55,13 @@ ) print("Checking surface water budget ....") - self.assertAlmostEquals(-1.003901559215592e-06, my_data[:, 2].sum(), places=4) - my_data = wf.genfromtxt( - os.path.join(caseName, runId, "wbsoil.csv"), delimiter="," - ) + self.assertAlmostEqual(-1.003901559215592e-06,my_data[:,2].sum(),places=4) + my_data = wf.genfromtxt(os.path.join(caseName,runId,"wbsoil.csv"), delimiter=',') print("Checking soil water budget ....") - self.assertAlmostEquals(0.00055469494748194847, my_data[:, 2].sum(), places=4) + self.assertAlmostEqual(0.00055469494748194847,my_data[:,2].sum(),places=4) print("Checking precip sum ....") - my_data = wf.genfromtxt(os.path.join(caseName, runId, "P.csv"), delimiter=",") - self.assertAlmostEquals(sump, my_data[:, 2].sum()) + my_data = wf.genfromtxt(os.path.join(caseName,runId,"P.csv"), delimiter=',') + self.assertAlmostEqual(sump,my_data[:,2].sum()) if __name__ == "__main__": Fisheye: Tag 5bc2c6406fea89698faa5d0ca1488dc25760b5e3 refers to a dead (removed) revision in file `wflow-py/UnitTests/Testwflow_sbm2.py'. Fisheye: No comparison available. Pass `N' to diff? Index: wflow-py/UnitTests/Testwflow_sbm_dynveg.py =================================================================== diff -u -r5bc2c6406fea89698faa5d0ca1488dc25760b5e3 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/UnitTests/Testwflow_sbm_dynveg.py (.../Testwflow_sbm_dynveg.py) (revision 5bc2c6406fea89698faa5d0ca1488dc25760b5e3) +++ wflow-py/UnitTests/Testwflow_sbm_dynveg.py (.../Testwflow_sbm_dynveg.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -55,16 +55,15 @@ ) print("Checking surface water budget ....") - self.assertAlmostEquals(-1.003901559215592e-06, my_data[:, 2].sum(), places=4) - my_data = wf.genfromtxt( - os.path.join(caseName, runId, "wbsoil.csv"), delimiter="," - ) + self.assertAlmostEqual(-1.003901559215592e-06,my_data[:,2].sum(),places=4) + my_data = wf.genfromtxt(os.path.join(caseName,runId,"wbsoil.csv"), delimiter=',') print("Checking soil water budget ....") - self.assertAlmostEquals(0.00040802343085033499, my_data[:, 2].sum(), places=4) + self.assertAlmostEqual(0.0006305182757557759,my_data[:,2].sum(),places=4) print("Checking precip sum ....") - my_data = wf.genfromtxt(os.path.join(caseName, runId, "P.csv"), delimiter=",") - self.assertAlmostEquals(sump, my_data[:, 2].sum()) + my_data = wf.genfromtxt(os.path.join(caseName,runId,"P.csv"), delimiter=',') + self.assertAlmostEqual(sump,my_data[:,2].sum()) + if __name__ == "__main__": unittest.main() Index: wflow-py/UnitTests/Testwflow_sbm_example.py =================================================================== diff -u -rdcc18f9ba8bb5af2556d91e412304e012ed60d75 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/UnitTests/Testwflow_sbm_example.py (.../Testwflow_sbm_example.py) (revision dcc18f9ba8bb5af2556d91e412304e012ed60d75) +++ wflow-py/UnitTests/Testwflow_sbm_example.py (.../Testwflow_sbm_example.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -49,8 +49,10 @@ os.chdir(orgdir) print("Checking specific runoff ....") - self.assertAlmostEquals(46.861992001533508, my_data[:, 2].sum(), places=4) + self.assertAlmostEqual(46.839179277420044,my_data[:,2].sum(),places=4) + os.chdir(orgdir) + if __name__ == "__main__": unittest.main() Index: wflow-py/UnitTests/Testwflow_sbm_nc.py =================================================================== diff -u -r5bc2c6406fea89698faa5d0ca1488dc25760b5e3 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/UnitTests/Testwflow_sbm_nc.py (.../Testwflow_sbm_nc.py) (revision 5bc2c6406fea89698faa5d0ca1488dc25760b5e3) +++ wflow-py/UnitTests/Testwflow_sbm_nc.py (.../Testwflow_sbm_nc.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -57,16 +57,15 @@ ) print("Checking surface water budget ....") - self.assertAlmostEquals(3.574188167654313e-09, my_data[:, 2].sum(), places=4) - my_data = wf.genfromtxt( - os.path.join(caseName, runId, "wbsoil.csv"), delimiter="," - ) + self.assertAlmostEqual(3.574188167654313e-09,my_data[:,2].sum(),places=4) + my_data = wf.genfromtxt(os.path.join(caseName,runId,"wbsoil.csv"), delimiter=',') print("Checking soil water budget ....") - self.assertAlmostEquals(0.0027717916473193327, my_data[:, 2].sum(), places=4) + self.assertAlmostEqual(0.002721056049267645,my_data[:,2].sum(),places=4) print("Checking precip sum ....") - my_data = wf.genfromtxt(os.path.join(caseName, runId, "P.csv"), delimiter=",") - self.assertAlmostEquals(sump, my_data[:, 2].sum()) + my_data = wf.genfromtxt(os.path.join(caseName,runId,"P.csv"), delimiter=',') + self.assertAlmostEqual(sump,my_data[:,2].sum()) + if __name__ == "__main__": unittest.main() Index: wflow-py/UnitTests/combined/inmaps/ClimatologyMapFiles/LeapYearCopyRename.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/UnitTests/combined/inmaps/ClimatologyMapFiles/LeapYearCopyRename.py (.../LeapYearCopyRename.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/UnitTests/combined/inmaps/ClimatologyMapFiles/LeapYearCopyRename.py (.../LeapYearCopyRename.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -11,12 +11,12 @@ startYear = src[18:22] -print startYear +print(startYear) for i in range(0, 52, 4): dst = src[0:18] + str(int(startYear) + i) + src[22:26] + str(29) + src[28:38] - print dst + print(dst) shutil.copy(src, dst) Index: wflow-py/WflowDeltashell/Shortcuts.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/WflowDeltashell/Shortcuts.py (.../Shortcuts.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/WflowDeltashell/Shortcuts.py (.../Shortcuts.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -6,72 +6,68 @@ from Fluent import RibbonGroupBox as _RibbonGroupBox from Fluent import Button as _Button +def CreateShortcutButton(name,groupName,tabName,fun,image): + + group = _GetGroup(tabName, groupName) + for item in group.Items : + if (item.Header == name): + # Item already exists, What do we do? + return item + + button = _Button() + button.Header = name + button.Click += lambda o,e,s=fun : _ButtonClicked(o,e,s) -def CreateShortcutButton(name, groupName, tabName, fun, image): + if (image != None and os.path.isfile(image)): + button.LargeIcon = image + button.Icon = image + else: + button.LargeIcon = None + button.Icon = None + + group.Items.Add(button) + + return button - group = _GetGroup(tabName, groupName) - for item in group.Items: - if item.Header == name: - # Item already exists, What do we do? - return item +def RemoveShortcut(name,groupName, tabName): + group = _GetGroup(tabName, groupName,False) + + if (group == None) : + return + + for item in group.Items : + if (item.Header == name): + group.Items.Remove(item) + break + + if (group.Items.Count == 0): + RemoveGroup(groupName,tabName) - button = _Button() - button.Header = name - button.Click += lambda o, e, s=fun: _ButtonClicked(o, e, s) +def _GetShortcutsTab(tabName, create = True): + # Find Ribbon control + ribbon = None + for child in Gui.MainWindow.Content.Children : + if (hasattr(child,'Name') and child.Name == "Ribbon"): + ribbon = child + + if (ribbon == None) : + print("Could not find Ribbon") + return None + + # Search for existing Shortcuts tab + for tab in ribbon.Tabs : + if (tab.Header == tabName) : + return tab + + if not(create): + return None + + #Tab is not yet present, Add a new one + tab = _RibbonTabItem() + tab.Header = tabName + ribbon.Tabs.Add(tab) + return tab - if image != None and os.path.isfile(image): - button.LargeIcon = image - button.Icon = image - else: - button.LargeIcon = None - button.Icon = None - - group.Items.Add(button) - - return button - - -def RemoveShortcut(name, groupName, tabName): - group = _GetGroup(tabName, groupName, False) - - if group == None: - return - - for item in group.Items: - if item.Header == name: - group.Items.Remove(item) - break - - if group.Items.Count == 0: - RemoveGroup(groupName, tabName) - - -def _GetShortcutsTab(tabName, create=True): - # Find Ribbon control - ribbon = None - for child in Gui.MainWindow.Content.Children: - if hasattr(child, "Name") and child.Name == "Ribbon": - ribbon = child - - if ribbon == None: - print "Could not find Ribbon" - return None - - # Search for existing Shortcuts tab - for tab in ribbon.Tabs: - if tab.Header == tabName: - return tab - - if not (create): - return None - - # Tab is not yet present, Add a new one - tab = _RibbonTabItem() - tab.Header = tabName - ribbon.Tabs.Add(tab) - return tab - - def RemoveShortcutsTab(tabName): ribbon = None for child in Gui.MainWindow.Content.Children: Index: wflow-py/WflowDeltashell/addwflowtoolbar.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/WflowDeltashell/addwflowtoolbar.py (.../addwflowtoolbar.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/WflowDeltashell/addwflowtoolbar.py (.../addwflowtoolbar.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -11,9 +11,8 @@ def notimplemented(): - print "Not implemented yet..." + print("Not implemented yet...") - name = "Web Documentation" tabName = "Wflow-Tools" groupName = "Internet" Index: wflow-py/WflowDeltashell/tst.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/WflowDeltashell/tst.py (.../tst.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/WflowDeltashell/tst.py (.../tst.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -33,10 +33,10 @@ casename = os.path.dirname(os.path.dirname(thefile)) csvfile = os.path.basename(thefile) -print casename +print(casename) runs = getrunids(casename) -print runs +print(runs) complot(runs, csvfile, [2]) Index: wflow-py/WflowDeltashell/wflib.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/WflowDeltashell/wflib.py (.../wflib.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/WflowDeltashell/wflib.py (.../wflib.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -45,16 +45,16 @@ """ Ugly method to get the run ids. This is absolutely not failsave """ - from glob import glob - - dirs = glob(casedir + "/*/") - - ret = [] - - for dir in dirs: - dn = os.path.basename(os.path.dirname(dir)) - if dn not in "intbl staticmaps inmaps instate intss outstate": - ret.append(dir) - print dn - - return ret + from glob import glob + dirs = glob(casedir + "/*/") + + ret = [] + + for dir in dirs: + dn = os.path.basename(os.path.dirname(dir)) + if dn not in "intbl staticmaps inmaps instate intss outstate": + ret.append(dir) + print(dn) + + return ret + \ No newline at end of file Index: wflow-py/_version.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/_version.py (.../_version.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/_version.py (.../_version.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -90,20 +90,20 @@ if e.errno == errno.ENOENT: continue if verbose: - print("unable to run %s" % dispcmd) + print(("unable to run %s" % dispcmd)) print(e) return None, None else: if verbose: - print("unable to find command, tried %s" % (commands,)) + print(("unable to find command, tried %s" % (commands,))) return None, None stdout = p.communicate()[0].strip() if sys.version_info[0] >= 3: stdout = stdout.decode() if p.returncode != 0: if verbose: - print("unable to run %s (error)" % dispcmd) - print("stdout was %s" % stdout) + print(("unable to run %s (error)" % dispcmd)) + print(("stdout was %s" % stdout)) return None, p.returncode return stdout, p.returncode @@ -132,10 +132,8 @@ root = os.path.dirname(root) # up a level if verbose: - print( - "Tried directories %s but none started with prefix %s" - % (str(rootdirs), parentdir_prefix) - ) + print(("Tried directories %s but none started with prefix %s" % + (str(rootdirs), parentdir_prefix))) raise NotThisMethod("rootdir doesn't start with parentdir_prefix") @@ -202,22 +200,19 @@ # "stabilization", as well as "HEAD" and "master". tags = set([r for r in refs if re.search(r"\d", r)]) if verbose: - print("discarding '%s', no digits" % ",".join(refs - tags)) + print(("discarding '%s', no digits" % ",".join(refs - tags))) if verbose: - print("likely tags: %s" % ",".join(sorted(tags))) + print(("likely tags: %s" % ",".join(sorted(tags)))) for ref in sorted(tags): # sorting will prefer e.g. "2.0" over "2.0rc1" if ref.startswith(tag_prefix): r = ref[len(tag_prefix) :] if verbose: - print("picking %s" % r) - return { - "version": r, - "full-revisionid": keywords["full"].strip(), - "dirty": False, - "error": None, - "date": date, - } + print(("picking %s" % r)) + return {"version": r, + "full-revisionid": keywords["full"].strip(), + "dirty": False, "error": None, + "date": date} # no suitable tags, so version is "0+unknown", but full hex is still there if verbose: print("no suitable tags, using unknown + full revision id") @@ -245,7 +240,7 @@ out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True) if rc != 0: if verbose: - print("Directory %s not under git control" % root) + print(("Directory %s not under git control" % root)) raise NotThisMethod("'git rev-parse --git-dir' returned error") # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] @@ -302,11 +297,9 @@ if not full_tag.startswith(tag_prefix): if verbose: fmt = "tag '%s' doesn't start with prefix '%s'" - print(fmt % (full_tag, tag_prefix)) - pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % ( - full_tag, - tag_prefix, - ) + print((fmt % (full_tag, tag_prefix))) + pieces["error"] = ("tag '%s' doesn't start with prefix '%s'" + % (full_tag, tag_prefix)) return pieces pieces["closest-tag"] = full_tag[len(tag_prefix) :] Index: wflow-py/make_wflow_openda_exe.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/make_wflow_openda_exe.py (.../make_wflow_openda_exe.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/make_wflow_openda_exe.py (.../make_wflow_openda_exe.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -58,10 +58,11 @@ data_files.append(("./gdal-data", glob.glob(gdaldata + "/*.*"))) -print "Copying extra data files..." + +print("Copying extra data files...") for dirr in data_files: - timake = os.path.join(thename, dirr[0]) - print timake + timake = os.path.join(thename ,dirr[0]) + print(timake) if not os.path.exists(timake): os.makedirs(timake) for tocp in dirr[1]: Index: wflow-py/mkversion.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/mkversion.py (.../mkversion.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/mkversion.py (.../mkversion.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -26,6 +26,10 @@ a.write("__version__ = get_versions()['version']\n") a.write("del get_versions\n") -print "=============================================================================" -print "Now install wflow using setup.py install and regenerate the documentation...." -print "=============================================================================" +print("=============================================================================") +print("Now install wflow using setup.py install and regenerate the documentation....") +print("=============================================================================") + + + + Index: wflow-py/mkversion_buildserver.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/mkversion_buildserver.py (.../mkversion_buildserver.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/mkversion_buildserver.py (.../mkversion_buildserver.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -27,6 +27,6 @@ a.write("del get_versions\n") -print "=============================================================================" -print "Now install wflow using setup.py install and regenerate the documentation...." -print "=============================================================================" +print("=============================================================================") +print("Now install wflow using setup.py install and regenerate the documentation....") +print("=============================================================================") Index: wflow-py/openda_bmi/bmi.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/openda_bmi/bmi.py (.../bmi.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/openda_bmi/bmi.py (.../bmi.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -24,13 +24,11 @@ UNSTRUCTURED = 4 -class Bmi(object): +class Bmi(object, metaclass=ABCMeta): """ Interface (abstract base class) for a model that implements the CSDMS BMI (Basic Model Interface). """ - __metaclass__ = ABCMeta - """ Model Control Functions """ Index: wflow-py/openda_bmi/openda/bmi/thrift/BMIService.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/openda_bmi/openda/bmi/thrift/BMIService.py (.../BMIService.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/openda_bmi/openda/bmi/thrift/BMIService.py (.../BMIService.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -7,7 +7,7 @@ # from thrift.Thrift import TType, TMessageType, TException, TApplicationException -from ttypes import * +from .ttypes import * from thrift.Thrift import TProcessor from thrift.transport import TTransport from thrift.protocol import TBinaryProtocol, TProtocol @@ -2097,760 +2097,610 @@ - file """ - thrift_spec = (None, (1, TType.STRING, "file", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'file', None, None, ), # 1 + ) - def __init__(self, file=None): - self.file = file + def __init__(self, file=None,): + self.file = file - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.file = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.file = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("initialize_args") - if self.file is not None: - oprot.writeFieldBegin("file", TType.STRING, 1) - oprot.writeString(self.file) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('initialize_args') + if self.file is not None: + oprot.writeFieldBegin('file', TType.STRING, 1) + oprot.writeString(self.file) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class initialize_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("initialize_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('initialize_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class update_args(object): - thrift_spec = () + thrift_spec = ( + ) - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("update_args") - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('update_args') + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class update_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("update_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('update_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class update_until_args(object): """ Attributes: - time """ - thrift_spec = (None, (1, TType.DOUBLE, "time", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.DOUBLE, 'time', None, None, ), # 1 + ) - def __init__(self, time=None): - self.time = time + def __init__(self, time=None,): + self.time = time - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.DOUBLE: - self.time = iprot.readDouble() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.DOUBLE: + self.time = iprot.readDouble(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("update_until_args") - if self.time is not None: - oprot.writeFieldBegin("time", TType.DOUBLE, 1) - oprot.writeDouble(self.time) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('update_until_args') + if self.time is not None: + oprot.writeFieldBegin('time', TType.DOUBLE, 1) + oprot.writeDouble(self.time) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class update_until_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("update_until_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('update_until_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class update_frac_args(object): """ Attributes: - frac """ - thrift_spec = (None, (1, TType.DOUBLE, "frac", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.DOUBLE, 'frac', None, None, ), # 1 + ) - def __init__(self, frac=None): - self.frac = frac + def __init__(self, frac=None,): + self.frac = frac - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.DOUBLE: - self.frac = iprot.readDouble() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.DOUBLE: + self.frac = iprot.readDouble(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("update_frac_args") - if self.frac is not None: - oprot.writeFieldBegin("frac", TType.DOUBLE, 1) - oprot.writeDouble(self.frac) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('update_frac_args') + if self.frac is not None: + oprot.writeFieldBegin('frac', TType.DOUBLE, 1) + oprot.writeDouble(self.frac) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class update_frac_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("update_frac_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('update_frac_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class finalize_model_args(object): - thrift_spec = () + thrift_spec = ( + ) - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("finalize_model_args") - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('finalize_model_args') + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class finalize_model_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("finalize_model_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('finalize_model_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_component_name_args(object): - thrift_spec = () + thrift_spec = ( + ) - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_component_name_args") - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_component_name_args') + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_component_name_result(object): """ @@ -2859,1717 +2709,1448 @@ - error """ - thrift_spec = ( - (0, TType.STRING, "success", None, None), # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + (0, TType.STRING, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, success=None, error=None): - self.success = success - self.error = error + def __init__(self, success=None, error=None,): + self.success = success + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.STRING: - self.success = iprot.readString() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_component_name_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.STRING, 0) - oprot.writeString(self.success) - oprot.writeFieldEnd() - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_component_name_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeString(self.success) + oprot.writeFieldEnd() + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_input_var_names_args(object): - thrift_spec = () + thrift_spec = ( + ) - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_input_var_names_args") - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_input_var_names_args') + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_input_var_names_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.LIST, "success", (TType.STRING, None), None),) # 0 + thrift_spec = ( + (0, TType.LIST, 'success', (TType.STRING,None), None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype3, _size0) = iprot.readListBegin() - for _i4 in xrange(_size0): - _elem5 = iprot.readString() - self.success.append(_elem5) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype3, _size0) = iprot.readListBegin() + for _i4 in range(_size0): + _elem5 = iprot.readString(); + self.success.append(_elem5) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_input_var_names_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.LIST, 0) - oprot.writeListBegin(TType.STRING, len(self.success)) - for iter6 in self.success: - oprot.writeString(iter6) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_input_var_names_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.STRING, len(self.success)) + for iter6 in self.success: + oprot.writeString(iter6) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_output_var_names_args(object): - thrift_spec = () + thrift_spec = ( + ) - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_output_var_names_args") - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_output_var_names_args') + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_output_var_names_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.LIST, "success", (TType.STRING, None), None),) # 0 + thrift_spec = ( + (0, TType.LIST, 'success', (TType.STRING,None), None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype10, _size7) = iprot.readListBegin() - for _i11 in xrange(_size7): - _elem12 = iprot.readString() - self.success.append(_elem12) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype10, _size7) = iprot.readListBegin() + for _i11 in range(_size7): + _elem12 = iprot.readString(); + self.success.append(_elem12) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_output_var_names_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.LIST, 0) - oprot.writeListBegin(TType.STRING, len(self.success)) - for iter13 in self.success: - oprot.writeString(iter13) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_output_var_names_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.STRING, len(self.success)) + for iter13 in self.success: + oprot.writeString(iter13) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_var_type_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_var_type_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_var_type_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_var_type_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.STRING, "success", None, None),) # 0 + thrift_spec = ( + (0, TType.STRING, 'success', None, None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.STRING: - self.success = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_var_type_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.STRING, 0) - oprot.writeString(self.success) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_var_type_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeString(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_var_units_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_var_units_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_var_units_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_var_units_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.STRING, "success", None, None),) # 0 + thrift_spec = ( + (0, TType.STRING, 'success', None, None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.STRING: - self.success = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_var_units_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.STRING, 0) - oprot.writeString(self.success) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_var_units_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeString(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_var_rank_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_var_rank_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_var_rank_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_var_rank_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.I32, "success", None, None),) # 0 + thrift_spec = ( + (0, TType.I32, 'success', None, None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.I32: - self.success = iprot.readI32() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.I32: + self.success = iprot.readI32(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_var_rank_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.I32, 0) - oprot.writeI32(self.success) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_var_rank_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.I32, 0) + oprot.writeI32(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_var_size_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_var_size_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_var_size_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_var_size_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.I32, "success", None, None),) # 0 + thrift_spec = ( + (0, TType.I32, 'success', None, None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.I32: - self.success = iprot.readI32() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.I32: + self.success = iprot.readI32(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_var_size_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.I32, 0) - oprot.writeI32(self.success) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_var_size_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.I32, 0) + oprot.writeI32(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_var_nbytes_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_var_nbytes_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_var_nbytes_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_var_nbytes_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.I32, "success", None, None),) # 0 + thrift_spec = ( + (0, TType.I32, 'success', None, None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.I32: - self.success = iprot.readI32() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.I32: + self.success = iprot.readI32(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_var_nbytes_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.I32, 0) - oprot.writeI32(self.success) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_var_nbytes_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.I32, 0) + oprot.writeI32(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_start_time_args(object): - thrift_spec = () + thrift_spec = ( + ) - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_start_time_args") - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_start_time_args') + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_start_time_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.DOUBLE, "success", None, None),) # 0 + thrift_spec = ( + (0, TType.DOUBLE, 'success', None, None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.DOUBLE: - self.success = iprot.readDouble() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.DOUBLE: + self.success = iprot.readDouble(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_start_time_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.DOUBLE, 0) - oprot.writeDouble(self.success) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_start_time_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.DOUBLE, 0) + oprot.writeDouble(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_current_time_args(object): - thrift_spec = () + thrift_spec = ( + ) - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_current_time_args") - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_current_time_args') + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_current_time_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.DOUBLE, "success", None, None),) # 0 + thrift_spec = ( + (0, TType.DOUBLE, 'success', None, None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.DOUBLE: - self.success = iprot.readDouble() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.DOUBLE: + self.success = iprot.readDouble(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_current_time_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.DOUBLE, 0) - oprot.writeDouble(self.success) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_current_time_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.DOUBLE, 0) + oprot.writeDouble(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_end_time_args(object): - thrift_spec = () + thrift_spec = ( + ) - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_end_time_args") - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_end_time_args') + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_end_time_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.DOUBLE, "success", None, None),) # 0 + thrift_spec = ( + (0, TType.DOUBLE, 'success', None, None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.DOUBLE: - self.success = iprot.readDouble() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.DOUBLE: + self.success = iprot.readDouble(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_end_time_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.DOUBLE, 0) - oprot.writeDouble(self.success) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_end_time_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.DOUBLE, 0) + oprot.writeDouble(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_time_step_args(object): - thrift_spec = () + thrift_spec = ( + ) - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_time_step_args") - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_time_step_args') + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_time_step_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.DOUBLE, "success", None, None),) # 0 + thrift_spec = ( + (0, TType.DOUBLE, 'success', None, None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.DOUBLE: - self.success = iprot.readDouble() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.DOUBLE: + self.success = iprot.readDouble(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_time_step_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.DOUBLE, 0) - oprot.writeDouble(self.success) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_time_step_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.DOUBLE, 0) + oprot.writeDouble(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_time_units_args(object): - thrift_spec = () + thrift_spec = ( + ) - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_time_units_args") - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_time_units_args') + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_time_units_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.STRING, "success", None, None),) # 0 + thrift_spec = ( + (0, TType.STRING, 'success', None, None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.STRING: - self.success = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_time_units_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.STRING, 0) - oprot.writeString(self.success) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_time_units_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeString(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_value_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_value_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_value_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_value_result(object): """ @@ -4578,88 +4159,70 @@ - error """ - thrift_spec = ( - (0, TType.STRING, "success", None, None), # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + (0, TType.STRING, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, success=None, error=None): - self.success = success - self.error = error + def __init__(self, success=None, error=None,): + self.success = success + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.STRING: - self.success = iprot.readString() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_value_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.STRING, 0) - oprot.writeString(self.success) - oprot.writeFieldEnd() - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_value_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeString(self.success) + oprot.writeFieldEnd() + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_value_at_indices_args(object): """ @@ -4668,90 +4231,78 @@ - inds """ - thrift_spec = ( - None, # 0 - (1, TType.STRING, "long_var_name", None, None), # 1 - (2, TType.LIST, "inds", (TType.I32, None), None), # 2 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + (2, TType.LIST, 'inds', (TType.I32,None), None, ), # 2 + ) - def __init__(self, long_var_name=None, inds=None): - self.long_var_name = long_var_name - self.inds = inds + def __init__(self, long_var_name=None, inds=None,): + self.long_var_name = long_var_name + self.inds = inds - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.LIST: - self.inds = [] - (_etype17, _size14) = iprot.readListBegin() - for _i18 in xrange(_size14): - _elem19 = iprot.readI32() - self.inds.append(_elem19) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.LIST: + self.inds = [] + (_etype17, _size14) = iprot.readListBegin() + for _i18 in range(_size14): + _elem19 = iprot.readI32(); + self.inds.append(_elem19) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_value_at_indices_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - if self.inds is not None: - oprot.writeFieldBegin("inds", TType.LIST, 2) - oprot.writeListBegin(TType.I32, len(self.inds)) - for iter20 in self.inds: - oprot.writeI32(iter20) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_value_at_indices_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + if self.inds is not None: + oprot.writeFieldBegin('inds', TType.LIST, 2) + oprot.writeListBegin(TType.I32, len(self.inds)) + for iter20 in self.inds: + oprot.writeI32(iter20) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_value_at_indices_result(object): """ @@ -4760,88 +4311,70 @@ - error """ - thrift_spec = ( - (0, TType.STRING, "success", None, None), # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + (0, TType.STRING, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, success=None, error=None): - self.success = success - self.error = error + def __init__(self, success=None, error=None,): + self.success = success + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.STRING: - self.success = iprot.readString() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_value_at_indices_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.STRING, 0) - oprot.writeString(self.success) - oprot.writeFieldEnd() - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_value_at_indices_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeString(self.success) + oprot.writeFieldEnd() + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class set_value_args(object): """ @@ -4850,161 +4383,131 @@ - src """ - thrift_spec = ( - None, # 0 - (1, TType.STRING, "long_var_name", None, None), # 1 - (2, TType.STRING, "src", None, None), # 2 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + (2, TType.STRING, 'src', None, None, ), # 2 + ) - def __init__(self, long_var_name=None, src=None): - self.long_var_name = long_var_name - self.src = src + def __init__(self, long_var_name=None, src=None,): + self.long_var_name = long_var_name + self.src = src - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.src = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.src = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("set_value_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - if self.src is not None: - oprot.writeFieldBegin("src", TType.STRING, 2) - oprot.writeString(self.src) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('set_value_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + if self.src is not None: + oprot.writeFieldBegin('src', TType.STRING, 2) + oprot.writeString(self.src) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class set_value_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("set_value_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('set_value_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class set_value_at_indices_args(object): """ @@ -5014,249 +4517,210 @@ - src """ - thrift_spec = ( - None, # 0 - (1, TType.STRING, "long_var_name", None, None), # 1 - (2, TType.LIST, "inds", (TType.I32, None), None), # 2 - (3, TType.STRING, "src", None, None), # 3 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + (2, TType.LIST, 'inds', (TType.I32,None), None, ), # 2 + (3, TType.STRING, 'src', None, None, ), # 3 + ) - def __init__(self, long_var_name=None, inds=None, src=None): - self.long_var_name = long_var_name - self.inds = inds - self.src = src + def __init__(self, long_var_name=None, inds=None, src=None,): + self.long_var_name = long_var_name + self.inds = inds + self.src = src - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.LIST: - self.inds = [] - (_etype24, _size21) = iprot.readListBegin() - for _i25 in xrange(_size21): - _elem26 = iprot.readI32() - self.inds.append(_elem26) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRING: - self.src = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.LIST: + self.inds = [] + (_etype24, _size21) = iprot.readListBegin() + for _i25 in range(_size21): + _elem26 = iprot.readI32(); + self.inds.append(_elem26) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRING: + self.src = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("set_value_at_indices_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - if self.inds is not None: - oprot.writeFieldBegin("inds", TType.LIST, 2) - oprot.writeListBegin(TType.I32, len(self.inds)) - for iter27 in self.inds: - oprot.writeI32(iter27) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.src is not None: - oprot.writeFieldBegin("src", TType.STRING, 3) - oprot.writeString(self.src) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('set_value_at_indices_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + if self.inds is not None: + oprot.writeFieldBegin('inds', TType.LIST, 2) + oprot.writeListBegin(TType.I32, len(self.inds)) + for iter27 in self.inds: + oprot.writeI32(iter27) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.src is not None: + oprot.writeFieldBegin('src', TType.STRING, 3) + oprot.writeString(self.src) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class set_value_at_indices_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("set_value_at_indices_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('set_value_at_indices_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_type_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_type_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_type_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_type_result(object): """ @@ -5265,2031 +4729,1721 @@ - error """ - thrift_spec = ( - (0, TType.I32, "success", None, None), # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + (0, TType.I32, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, success=None, error=None): - self.success = success - self.error = error + def __init__(self, success=None, error=None,): + self.success = success + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.I32: - self.success = iprot.readI32() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.I32: + self.success = iprot.readI32(); + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_type_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.I32, 0) - oprot.writeI32(self.success) - oprot.writeFieldEnd() - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_type_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.I32, 0) + oprot.writeI32(self.success) + oprot.writeFieldEnd() + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_shape_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_shape_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_shape_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_shape_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.LIST, "success", (TType.I32, None), None),) # 0 + thrift_spec = ( + (0, TType.LIST, 'success', (TType.I32,None), None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype31, _size28) = iprot.readListBegin() - for _i32 in xrange(_size28): - _elem33 = iprot.readI32() - self.success.append(_elem33) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype31, _size28) = iprot.readListBegin() + for _i32 in range(_size28): + _elem33 = iprot.readI32(); + self.success.append(_elem33) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_shape_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.LIST, 0) - oprot.writeListBegin(TType.I32, len(self.success)) - for iter34 in self.success: - oprot.writeI32(iter34) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_shape_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.I32, len(self.success)) + for iter34 in self.success: + oprot.writeI32(iter34) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_spacing_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_spacing_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_spacing_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_spacing_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.LIST, "success", (TType.DOUBLE, None), None),) # 0 + thrift_spec = ( + (0, TType.LIST, 'success', (TType.DOUBLE,None), None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype38, _size35) = iprot.readListBegin() - for _i39 in xrange(_size35): - _elem40 = iprot.readDouble() - self.success.append(_elem40) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype38, _size35) = iprot.readListBegin() + for _i39 in range(_size35): + _elem40 = iprot.readDouble(); + self.success.append(_elem40) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_spacing_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.LIST, 0) - oprot.writeListBegin(TType.DOUBLE, len(self.success)) - for iter41 in self.success: - oprot.writeDouble(iter41) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_spacing_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.DOUBLE, len(self.success)) + for iter41 in self.success: + oprot.writeDouble(iter41) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_origin_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_origin_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_origin_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_origin_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.LIST, "success", (TType.DOUBLE, None), None),) # 0 + thrift_spec = ( + (0, TType.LIST, 'success', (TType.DOUBLE,None), None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype45, _size42) = iprot.readListBegin() - for _i46 in xrange(_size42): - _elem47 = iprot.readDouble() - self.success.append(_elem47) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype45, _size42) = iprot.readListBegin() + for _i46 in range(_size42): + _elem47 = iprot.readDouble(); + self.success.append(_elem47) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_origin_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.LIST, 0) - oprot.writeListBegin(TType.DOUBLE, len(self.success)) - for iter48 in self.success: - oprot.writeDouble(iter48) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_origin_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.DOUBLE, len(self.success)) + for iter48 in self.success: + oprot.writeDouble(iter48) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_x_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_x_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_x_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_x_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.LIST, "success", (TType.DOUBLE, None), None),) # 0 + thrift_spec = ( + (0, TType.LIST, 'success', (TType.DOUBLE,None), None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype52, _size49) = iprot.readListBegin() - for _i53 in xrange(_size49): - _elem54 = iprot.readDouble() - self.success.append(_elem54) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype52, _size49) = iprot.readListBegin() + for _i53 in range(_size49): + _elem54 = iprot.readDouble(); + self.success.append(_elem54) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_x_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.LIST, 0) - oprot.writeListBegin(TType.DOUBLE, len(self.success)) - for iter55 in self.success: - oprot.writeDouble(iter55) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_x_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.DOUBLE, len(self.success)) + for iter55 in self.success: + oprot.writeDouble(iter55) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_y_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_y_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_y_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_y_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.LIST, "success", (TType.DOUBLE, None), None),) # 0 + thrift_spec = ( + (0, TType.LIST, 'success', (TType.DOUBLE,None), None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype59, _size56) = iprot.readListBegin() - for _i60 in xrange(_size56): - _elem61 = iprot.readDouble() - self.success.append(_elem61) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype59, _size56) = iprot.readListBegin() + for _i60 in range(_size56): + _elem61 = iprot.readDouble(); + self.success.append(_elem61) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_y_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.LIST, 0) - oprot.writeListBegin(TType.DOUBLE, len(self.success)) - for iter62 in self.success: - oprot.writeDouble(iter62) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_y_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.DOUBLE, len(self.success)) + for iter62 in self.success: + oprot.writeDouble(iter62) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_z_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_z_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_z_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_z_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.LIST, "success", (TType.DOUBLE, None), None),) # 0 + thrift_spec = ( + (0, TType.LIST, 'success', (TType.DOUBLE,None), None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype66, _size63) = iprot.readListBegin() - for _i67 in xrange(_size63): - _elem68 = iprot.readDouble() - self.success.append(_elem68) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype66, _size63) = iprot.readListBegin() + for _i67 in range(_size63): + _elem68 = iprot.readDouble(); + self.success.append(_elem68) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_z_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.LIST, 0) - oprot.writeListBegin(TType.DOUBLE, len(self.success)) - for iter69 in self.success: - oprot.writeDouble(iter69) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_z_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.DOUBLE, len(self.success)) + for iter69 in self.success: + oprot.writeDouble(iter69) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_connectivity_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_connectivity_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_connectivity_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_connectivity_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.LIST, "success", (TType.I32, None), None),) # 0 + thrift_spec = ( + (0, TType.LIST, 'success', (TType.I32,None), None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype73, _size70) = iprot.readListBegin() - for _i74 in xrange(_size70): - _elem75 = iprot.readI32() - self.success.append(_elem75) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype73, _size70) = iprot.readListBegin() + for _i74 in range(_size70): + _elem75 = iprot.readI32(); + self.success.append(_elem75) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_connectivity_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.LIST, 0) - oprot.writeListBegin(TType.I32, len(self.success)) - for iter76 in self.success: - oprot.writeI32(iter76) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_connectivity_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.I32, len(self.success)) + for iter76 in self.success: + oprot.writeI32(iter76) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_offset_args(object): """ Attributes: - long_var_name """ - thrift_spec = (None, (1, TType.STRING, "long_var_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'long_var_name', None, None, ), # 1 + ) - def __init__(self, long_var_name=None): - self.long_var_name = long_var_name + def __init__(self, long_var_name=None,): + self.long_var_name = long_var_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.long_var_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.long_var_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_offset_args") - if self.long_var_name is not None: - oprot.writeFieldBegin("long_var_name", TType.STRING, 1) - oprot.writeString(self.long_var_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_offset_args') + if self.long_var_name is not None: + oprot.writeFieldBegin('long_var_name', TType.STRING, 1) + oprot.writeString(self.long_var_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_grid_offset_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.LIST, "success", (TType.I32, None), None),) # 0 + thrift_spec = ( + (0, TType.LIST, 'success', (TType.I32,None), None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype80, _size77) = iprot.readListBegin() - for _i81 in xrange(_size77): - _elem82 = iprot.readI32() - self.success.append(_elem82) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype80, _size77) = iprot.readListBegin() + for _i81 in range(_size77): + _elem82 = iprot.readI32(); + self.success.append(_elem82) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_grid_offset_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.LIST, 0) - oprot.writeListBegin(TType.I32, len(self.success)) - for iter83 in self.success: - oprot.writeI32(iter83) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_grid_offset_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.I32, len(self.success)) + for iter83 in self.success: + oprot.writeI32(iter83) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class initialize_config_args(object): """ Attributes: - file """ - thrift_spec = (None, (1, TType.STRING, "file", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'file', None, None, ), # 1 + ) - def __init__(self, file=None): - self.file = file + def __init__(self, file=None,): + self.file = file - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.file = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.file = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("initialize_config_args") - if self.file is not None: - oprot.writeFieldBegin("file", TType.STRING, 1) - oprot.writeString(self.file) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('initialize_config_args') + if self.file is not None: + oprot.writeFieldBegin('file', TType.STRING, 1) + oprot.writeString(self.file) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class initialize_config_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("initialize_config_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('initialize_config_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class initialize_model_args(object): - thrift_spec = () + thrift_spec = ( + ) - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("initialize_model_args") - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('initialize_model_args') + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class initialize_model_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("initialize_model_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('initialize_model_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class set_start_time_args(object): """ Attributes: - start_time """ - thrift_spec = (None, (1, TType.DOUBLE, "start_time", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.DOUBLE, 'start_time', None, None, ), # 1 + ) - def __init__(self, start_time=None): - self.start_time = start_time + def __init__(self, start_time=None,): + self.start_time = start_time - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.DOUBLE: - self.start_time = iprot.readDouble() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.DOUBLE: + self.start_time = iprot.readDouble(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("set_start_time_args") - if self.start_time is not None: - oprot.writeFieldBegin("start_time", TType.DOUBLE, 1) - oprot.writeDouble(self.start_time) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('set_start_time_args') + if self.start_time is not None: + oprot.writeFieldBegin('start_time', TType.DOUBLE, 1) + oprot.writeDouble(self.start_time) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class set_start_time_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("set_start_time_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('set_start_time_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class set_end_time_args(object): """ Attributes: - end_time """ - thrift_spec = (None, (1, TType.DOUBLE, "end_time", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.DOUBLE, 'end_time', None, None, ), # 1 + ) - def __init__(self, end_time=None): - self.end_time = end_time + def __init__(self, end_time=None,): + self.end_time = end_time - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.DOUBLE: - self.end_time = iprot.readDouble() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.DOUBLE: + self.end_time = iprot.readDouble(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("set_end_time_args") - if self.end_time is not None: - oprot.writeFieldBegin("end_time", TType.DOUBLE, 1) - oprot.writeDouble(self.end_time) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('set_end_time_args') + if self.end_time is not None: + oprot.writeFieldBegin('end_time', TType.DOUBLE, 1) + oprot.writeDouble(self.end_time) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class set_end_time_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("set_end_time_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('set_end_time_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_attribute_names_args(object): - thrift_spec = () + thrift_spec = ( + ) - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_attribute_names_args") - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_attribute_names_args') + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_attribute_names_result(object): """ Attributes: - success """ - thrift_spec = ((0, TType.LIST, "success", (TType.STRING, None), None),) # 0 + thrift_spec = ( + (0, TType.LIST, 'success', (TType.STRING,None), None, ), # 0 + ) - def __init__(self, success=None): - self.success = success + def __init__(self, success=None,): + self.success = success - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype87, _size84) = iprot.readListBegin() - for _i88 in xrange(_size84): - _elem89 = iprot.readString() - self.success.append(_elem89) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype87, _size84) = iprot.readListBegin() + for _i88 in range(_size84): + _elem89 = iprot.readString(); + self.success.append(_elem89) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_attribute_names_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.LIST, 0) - oprot.writeListBegin(TType.STRING, len(self.success)) - for iter90 in self.success: - oprot.writeString(iter90) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_attribute_names_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.STRING, len(self.success)) + for iter90 in self.success: + oprot.writeString(iter90) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_attribute_value_args(object): """ Attributes: - attribute_name """ - thrift_spec = (None, (1, TType.STRING, "attribute_name", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'attribute_name', None, None, ), # 1 + ) - def __init__(self, attribute_name=None): - self.attribute_name = attribute_name + def __init__(self, attribute_name=None,): + self.attribute_name = attribute_name - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.attribute_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.attribute_name = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_attribute_value_args") - if self.attribute_name is not None: - oprot.writeFieldBegin("attribute_name", TType.STRING, 1) - oprot.writeString(self.attribute_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_attribute_value_args') + if self.attribute_name is not None: + oprot.writeFieldBegin('attribute_name', TType.STRING, 1) + oprot.writeString(self.attribute_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class get_attribute_value_result(object): """ @@ -7298,88 +6452,70 @@ - error """ - thrift_spec = ( - (0, TType.STRING, "success", None, None), # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + (0, TType.STRING, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, success=None, error=None): - self.success = success - self.error = error + def __init__(self, success=None, error=None,): + self.success = success + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.STRING: - self.success = iprot.readString() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("get_attribute_value_result") - if self.success is not None: - oprot.writeFieldBegin("success", TType.STRING, 0) - oprot.writeString(self.success) - oprot.writeFieldEnd() - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_attribute_value_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeString(self.success) + oprot.writeFieldEnd() + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class set_attribute_value_args(object): """ @@ -7388,456 +6524,370 @@ - attribute_value """ - thrift_spec = ( - None, # 0 - (1, TType.STRING, "attribute_name", None, None), # 1 - (2, TType.STRING, "attribute_value", None, None), # 2 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'attribute_name', None, None, ), # 1 + (2, TType.STRING, 'attribute_value', None, None, ), # 2 + ) - def __init__(self, attribute_name=None, attribute_value=None): - self.attribute_name = attribute_name - self.attribute_value = attribute_value + def __init__(self, attribute_name=None, attribute_value=None,): + self.attribute_name = attribute_name + self.attribute_value = attribute_value - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.attribute_name = iprot.readString() - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.attribute_value = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.attribute_name = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.attribute_value = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("set_attribute_value_args") - if self.attribute_name is not None: - oprot.writeFieldBegin("attribute_name", TType.STRING, 1) - oprot.writeString(self.attribute_name) - oprot.writeFieldEnd() - if self.attribute_value is not None: - oprot.writeFieldBegin("attribute_value", TType.STRING, 2) - oprot.writeString(self.attribute_value) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('set_attribute_value_args') + if self.attribute_name is not None: + oprot.writeFieldBegin('attribute_name', TType.STRING, 1) + oprot.writeString(self.attribute_name) + oprot.writeFieldEnd() + if self.attribute_value is not None: + oprot.writeFieldBegin('attribute_value', TType.STRING, 2) + oprot.writeString(self.attribute_value) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class set_attribute_value_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("set_attribute_value_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('set_attribute_value_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class save_state_args(object): """ Attributes: - destination_directory """ - thrift_spec = ( - None, # 0 - (1, TType.STRING, "destination_directory", None, None), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'destination_directory', None, None, ), # 1 + ) - def __init__(self, destination_directory=None): - self.destination_directory = destination_directory + def __init__(self, destination_directory=None,): + self.destination_directory = destination_directory - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.destination_directory = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.destination_directory = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("save_state_args") - if self.destination_directory is not None: - oprot.writeFieldBegin("destination_directory", TType.STRING, 1) - oprot.writeString(self.destination_directory) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('save_state_args') + if self.destination_directory is not None: + oprot.writeFieldBegin('destination_directory', TType.STRING, 1) + oprot.writeString(self.destination_directory) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class save_state_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("save_state_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('save_state_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class load_state_args(object): """ Attributes: - source_directory """ - thrift_spec = (None, (1, TType.STRING, "source_directory", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'source_directory', None, None, ), # 1 + ) - def __init__(self, source_directory=None): - self.source_directory = source_directory + def __init__(self, source_directory=None,): + self.source_directory = source_directory - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.source_directory = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.source_directory = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("load_state_args") - if self.source_directory is not None: - oprot.writeFieldBegin("source_directory", TType.STRING, 1) - oprot.writeString(self.source_directory) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('load_state_args') + if self.source_directory is not None: + oprot.writeFieldBegin('source_directory', TType.STRING, 1) + oprot.writeString(self.source_directory) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __ne__(self, other): + return not (self == other) class load_state_result(object): """ Attributes: - error """ - thrift_spec = ( - None, # 0 - ( - 1, - TType.STRUCT, - "error", - (ModelException, ModelException.thrift_spec), - None, - ), # 1 - ) + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'error', (ModelException, ModelException.thrift_spec), None, ), # 1 + ) - def __init__(self, error=None): - self.error = error + def __init__(self, error=None,): + self.error = error - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.error = ModelException() - self.error.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.error = ModelException() + self.error.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("load_state_result") - if self.error is not None: - oprot.writeFieldBegin("error", TType.STRUCT, 1) - self.error.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('load_state_result') + if self.error is not None: + oprot.writeFieldBegin('error', TType.STRUCT, 1) + self.error.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - return + def validate(self): + return - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) Index: wflow-py/openda_bmi/openda/bmi/thrift/constants.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/openda_bmi/openda/bmi/thrift/constants.py (.../constants.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/openda_bmi/openda/bmi/thrift/constants.py (.../constants.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -7,4 +7,5 @@ # from thrift.Thrift import TType, TMessageType, TException, TApplicationException -from ttypes import * +from .ttypes import * + Index: wflow-py/openda_bmi/openda/bmi/thrift/ttypes.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/openda_bmi/openda/bmi/thrift/ttypes.py (.../ttypes.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/openda_bmi/openda/bmi/thrift/ttypes.py (.../ttypes.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -47,71 +47,61 @@ - message """ - thrift_spec = (None, (1, TType.STRING, "message", None, None)) # 0 # 1 + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'message', None, None, ), # 1 + ) - def __init__(self, message=None): - self.message = message + def __init__(self, message=None,): + self.message = message - def read(self, iprot): - if ( - iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and isinstance(iprot.trans, TTransport.CReadableTransport) - and self.thrift_spec is not None - and fastbinary is not None - ): - fastbinary.decode_binary( - self, iprot.trans, (self.__class__, self.thrift_spec) - ) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.message = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.message = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def write(self, oprot): - if ( - oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated - and self.thrift_spec is not None - and fastbinary is not None - ): - oprot.trans.write( - fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)) - ) - return - oprot.writeStructBegin("ModelException") - if self.message is not None: - oprot.writeFieldBegin("message", TType.STRING, 1) - oprot.writeString(self.message) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('ModelException') + if self.message is not None: + oprot.writeFieldBegin('message', TType.STRING, 1) + oprot.writeString(self.message) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() - def validate(self): - if self.message is None: - raise TProtocol.TProtocolException( - message="Required field message is unset!" - ) - return + def validate(self): + if self.message is None: + raise TProtocol.TProtocolException(message='Required field message is unset!') + return - def __str__(self): - return repr(self) - def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.iteritems()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + def __str__(self): + return repr(self) - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - def __ne__(self, other): - return not (self == other) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) Index: wflow-py/versioneer.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/versioneer.py (.../versioneer.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/versioneer.py (.../versioneer.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -276,12 +276,11 @@ """ -from __future__ import print_function try: import configparser except ImportError: - import ConfigParser as configparser + import configparser as configparser import errno import json import os Index: wflow-py/wflow/JarvisCoefficients.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/JarvisCoefficients.py (.../JarvisCoefficients.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/JarvisCoefficients.py (.../JarvisCoefficients.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -23,7 +23,7 @@ try: from wflow.wf_DynamicFramework import * except ImportError: - from wf_DynamicFramework import * + from .wf_DynamicFramework import * import scipy Index: wflow-py/wflow/bmi.py =================================================================== diff -u -r8fc4e26c9cf424be10a5204df5d8f4b86a21c5bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/bmi.py (.../bmi.py) (revision 8fc4e26c9cf424be10a5204df5d8f4b86a21c5bb) +++ wflow-py/wflow/bmi.py (.../bmi.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -29,13 +29,11 @@ UNSTRUCTURED = 4 -class Bmi(object): +class Bmi(object, metaclass=ABCMeta): """ Interface (abstract base class) for a model that implements the CSDMS BMI (Basic Model Interface). """ - __metaclass__ = ABCMeta - """ Model Control Functions """ Index: wflow-py/wflow/create_grid.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/create_grid.py (.../create_grid.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/create_grid.py (.../create_grid.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -95,7 +95,7 @@ (options, args) = parser.parse_args() - print options.__dict__.items() + print(list(options.__dict__.items())) if options.inputfile is None: parser.error("No input file (-f filename) given") @@ -236,7 +236,7 @@ yorg = extent_out[3] # +cellsize # create clone raster - print ("rows: {0} cols: {1}".format(rows, cols)) + print(('rows: {0} cols: {1}'.format(rows, cols))) dummy_raster = np.zeros((rows, cols)) - 9999. clone_file_map = os.path.abspath(os.path.join(destination, "mask.map")) Index: wflow-py/wflow/ogr2ogr.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/ogr2ogr.py (.../ogr2ogr.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/ogr2ogr.py (.../ogr2ogr.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -295,7 +295,7 @@ elif EQUAL(args[iArg + 1], "MULTIPOLYGON25D"): eGType = ogr.wkbMultiPolygon25D else: - print("-nlt %s: type not recognised." % args[iArg + 1]) + print(("-nlt %s: type not recognised." % args[iArg+1])) return False iArg = iArg + 1 @@ -304,7 +304,7 @@ nCoordDim = int(args[iArg + 1]) if nCoordDim != 2 and nCoordDim != 3: - print("-dim %s: value not handled." % args[iArg + 1]) + print(("-dim %s: value not handled." % args[iArg+1])) return False iArg = iArg + 1 @@ -396,7 +396,7 @@ break else: - print("Unhandled type for fieldtypeasstring option : %s " % token) + print(("Unhandled type for fieldtypeasstring option : %s " % token)) return Usage() elif EQUAL(args[iArg], "-progress"): @@ -546,10 +546,8 @@ if poSpatialFilter is not None: poClipSrc = poSpatialFilter.Clone() if poClipSrc is None: - print( - "FAILURE: -clipsrc must be used with -spat option or a\n" - + "bounding box, WKT string or datasource must be specified\n" - ) + print(("FAILURE: -clipsrc must be used with -spat option or a\n" + \ + "bounding box, WKT string or datasource must be specified\n")) return Usage() if pszClipDstDS is not None: @@ -569,14 +567,11 @@ # Report failure # -------------------------------------------------------------------- if poDS is None: - print( - "FAILURE:\n" - + "Unable to open datasource `%s' with the following drivers." - % pszDataSource - ) + print(("FAILURE:\n" + \ + "Unable to open datasource `%s' with the following drivers." % pszDataSource)) for iDriver in range(ogr.GetDriverCount()): - print(" -> " + ogr.GetDriver(iDriver).GetName()) + print((" -> " + ogr.GetDriver(iDriver).GetName() )) return False @@ -600,18 +595,13 @@ poODS = None if bUpdate: - print( - "FAILURE:\n" - + "Unable to open existing output datasource `%s'." - % pszDestDataSource - ) + print(("FAILURE:\n" + + "Unable to open existing output datasource `%s'." % pszDestDataSource)) return False elif len(papszDSCO) > 0: - print( - "WARNING: Datasource creation options ignored since an existing datasource\n" - + " being updated." - ) + print(("WARNING: Datasource creation options ignored since an existing datasource\n" + \ + " being updated." )) if poODS is not None: poDriver = poODS.GetDriver() @@ -622,16 +612,16 @@ if not bUpdate: poDriver = ogr.GetDriverByName(pszFormat) if poDriver is None: - print("Unable to find driver `%s'." % pszFormat) - print("The following drivers are available:") + print(("Unable to find driver `%s'." % pszFormat)) + print( "The following drivers are available:" ) for iDriver in range(ogr.GetDriverCount()): - print(" -> %s" % ogr.GetDriver(iDriver).GetName()) + print((" -> %s" % ogr.GetDriver(iDriver).GetName() )) return False - if poDriver.TestCapability(ogr.ODrCCreateDataSource) == False: - print("%s driver does not support data source creation." % pszFormat) + if poDriver.TestCapability( ogr.ODrCCreateDataSource ) == False: + print(( "%s driver does not support data source creation." % pszFormat)) return False # -------------------------------------------------------------------- @@ -661,36 +651,34 @@ # this syntax is only supported by Python >= 2.6 os.mkdir(pszDestDataSource, 493) except: - print( - "Failed to create directory %s\n" - "for shapefile datastore.\n" % pszDestDataSource - ) + print(("Failed to create directory %s\n" + "for shapefile datastore.\n" % pszDestDataSource )) return False # -------------------------------------------------------------------- # Create the output data source. # -------------------------------------------------------------------- poODS = poDriver.CreateDataSource(pszDestDataSource, options=papszDSCO) if poODS is None: - print("%s driver failed to create %s" % (pszFormat, pszDestDataSource)) + print(( "%s driver failed to create %s" % (pszFormat, pszDestDataSource ))) return False # -------------------------------------------------------------------- # Parse the output SRS definition if possible. # -------------------------------------------------------------------- if pszOutputSRSDef is not None: poOutputSRS = osr.SpatialReference() - if poOutputSRS.SetFromUserInput(pszOutputSRSDef) != 0: - print("Failed to process SRS definition: %s" % pszOutputSRSDef) + if poOutputSRS.SetFromUserInput( pszOutputSRSDef ) != 0: + print(( "Failed to process SRS definition: %s" % pszOutputSRSDef )) return False # -------------------------------------------------------------------- # Parse the source SRS definition if possible. # -------------------------------------------------------------------- if pszSourceSRSDef is not None: poSourceSRS = osr.SpatialReference() - if poSourceSRS.SetFromUserInput(pszSourceSRSDef) != 0: - print("Failed to process SRS definition: %s" % pszSourceSRSDef) + if poSourceSRS.SetFromUserInput( pszSourceSRSDef ) != 0: + print(( "Failed to process SRS definition: %s" % pszSourceSRSDef )) return False # -------------------------------------------------------------------- @@ -770,31 +758,18 @@ poResultSet.ResetReading() - if psInfo is None or not TranslateLayer( - psInfo, - poDS, - poResultSet, - poODS, - poOutputSRS, - bNullifyOutputSRS, - eGType, - bPromoteToMulti, - nCoordDim, - eGeomOp, - dfGeomOpParam, - nCountLayerFeatures, - poClipSrc, - poClipDst, - bExplodeCollections, - nSrcFileSize, - None, - pfnProgress, - pProgressArg, - ): - print( - "Terminating translation prematurely after failed\n" - + "translation from sql statement." - ) + if psInfo is None or not TranslateLayer( psInfo, poDS, poResultSet, poODS, \ + poOutputSRS, bNullifyOutputSRS, \ + eGType, bPromoteToMulti, nCoordDim, \ + eGeomOp, dfGeomOpParam, \ + nCountLayerFeatures, \ + poClipSrc, poClipDst, \ + bExplodeCollections, \ + nSrcFileSize, None, \ + pfnProgress, pProgressArg ): + print(( + "Terminating translation prematurely after failed\n" + \ + "translation from sql statement." )) return False @@ -848,7 +823,7 @@ for iLayer in range(nSrcLayerCount): poLayer = poDS.GetLayer(iLayer) if poLayer is None: - print("FAILURE: Couldn't fetch advertised layer %d!" % iLayer) + print(("FAILURE: Couldn't fetch advertised layer %d!" % iLayer)) return False papszLayers[iLayer] = poLayer.GetName() @@ -868,18 +843,15 @@ for iLayer in range(nSrcLayerCount): poLayer = poDS.GetLayer(iLayer) if poLayer is None: - print("FAILURE: Couldn't fetch advertised layer %d!" % iLayer) + print(("FAILURE: Couldn't fetch advertised layer %d!" % iLayer)) return False pasAssocLayers[iLayer].poSrcLayer = poLayer if CSLFindString(papszLayers, poLayer.GetName()) >= 0: if pszWHERE is not None: - if poLayer.SetAttributeFilter(pszWHERE) != 0: - print( - "FAILURE: SetAttributeFilter(%s) on layer '%s' failed.\n" - % (pszWHERE, poLayer.GetName()) - ) + if poLayer.SetAttributeFilter( pszWHERE ) != 0: + print(("FAILURE: SetAttributeFilter(%s) on layer '%s' failed.\n" % (pszWHERE, poLayer.GetName()) )) if not bSkipFailures: return False @@ -929,36 +901,20 @@ anReadFeatureCount = [0] if psInfo is not None: - if ( - not TranslateLayer( - psInfo, - poDS, - poLayer, - poODS, - poOutputSRS, - bNullifyOutputSRS, - eGType, - bPromoteToMulti, - nCoordDim, - eGeomOp, - dfGeomOpParam, - 0, - poClipSrc, - poClipDst, - bExplodeCollections, - nSrcFileSize, - anReadFeatureCount, - pfnProgress, - pProgressArg, - ) - and not bSkipFailures - ): - print( - "Terminating translation prematurely after failed\n" - + "translation of layer " - + poLayer.GetName() - + " (use -skipfailures to skip errors)" - ) + if not TranslateLayer(psInfo, poDS, poLayer, poODS, \ + poOutputSRS, bNullifyOutputSRS, \ + eGType, bPromoteToMulti, nCoordDim, \ + eGeomOp, dfGeomOpParam, \ + 0, \ + poClipSrc, poClipDst, \ + bExplodeCollections, \ + nSrcFileSize, \ + anReadFeatureCount, \ + pfnProgress, pProgressArg ) \ + and not bSkipFailures: + print(( + "Terminating translation prematurely after failed\n" + \ + "translation of layer " + poLayer.GetName() + " (use -skipfailures to skip errors)")) return False else: @@ -989,7 +945,7 @@ poLayer = poDS.GetLayer(iLayer) if poLayer is None: - print("FAILURE: Couldn't fetch advertised layer %d!" % iLayer) + print(("FAILURE: Couldn't fetch advertised layer %d!" % iLayer)) return False papoLayers[iLayer] = poLayer @@ -1007,7 +963,7 @@ poLayer = poDS.GetLayerByName(layername) if poLayer is None: - print("FAILURE: Couldn't fetch advertised layer %s!" % layername) + print(("FAILURE: Couldn't fetch advertised layer %s!" % layername)) return False papoLayers[iLayer] = poLayer @@ -1022,8 +978,8 @@ poLayer = papoLayers[iLayer] if pszWHERE is not None: - if poLayer.SetAttributeFilter(pszWHERE) != 0: - print("FAILURE: SetAttributeFilter(%s) failed." % pszWHERE) + if poLayer.SetAttributeFilter( pszWHERE ) != 0: + print(("FAILURE: SetAttributeFilter(%s) failed." % pszWHERE)) if not bSkipFailures: return False @@ -1103,36 +1059,20 @@ poLayer.ResetReading() - if ( - psInfo is None - or not TranslateLayer( - psInfo, - poDS, - poLayer, - poODS, - poOutputSRS, - bNullifyOutputSRS, - eGType, - bPromoteToMulti, - nCoordDim, - eGeomOp, - dfGeomOpParam, - panLayerCountFeatures[iLayer], - poClipSrc, - poClipDst, - bExplodeCollections, - nSrcFileSize, - None, - pfnProgress, - pProgressArg, - ) - ) and not bSkipFailures: - print( - "Terminating translation prematurely after failed\n" - + "translation of layer " - + poLayer.GetLayerDefn().GetName() - + " (use -skipfailures to skip errors)" - ) + if (psInfo is None or \ + not TranslateLayer( psInfo, poDS, poLayer, poODS, \ + poOutputSRS, bNullifyOutputSRS, \ + eGType, bPromoteToMulti, nCoordDim, \ + eGeomOp, dfGeomOpParam, \ + panLayerCountFeatures[iLayer], \ + poClipSrc, poClipDst, \ + bExplodeCollections, \ + nSrcFileSize, None, \ + pfnProgress, pProgressArg )) \ + and not bSkipFailures: + print(( + "Terminating translation prematurely after failed\n" + \ + "translation of layer " + poLayer.GetLayerDefn().GetName() + " (use -skipfailures to skip errors)")) return False @@ -1154,61 +1094,54 @@ def Usage(): - print( - "Usage: ogr2ogr [--help-general] [-skipfailures] [-append] [-update] [-gt n]\n" - + " [-select field_list] [-where restricted_where] \n" - + " [-progress] [-sql ] \n" - + " [-spat xmin ymin xmax ymax] [-preserve_fid] [-fid FID]\n" - + " [-a_srs srs_def] [-t_srs srs_def] [-s_srs srs_def]\n" - + " [-f format_name] [-overwrite] [[-dsco NAME=VALUE] ...]\n" - + " [-simplify tolerance]\n" - + - # // " [-segmentize max_dist] [-fieldTypeToString All|(type1[,type2]*)]\n" + \ - " [-fieldTypeToString All|(type1[,type2]*)] [-explodecollections] \n" - + " dst_datasource_name src_datasource_name\n" - + " [-lco NAME=VALUE] [-nln name] [-nlt type] [-dim 2|3] [layer [layer ...]]\n" - + "\n" - + " -f format_name: output file format name, possible values are:" - ) + print(( "Usage: ogr2ogr [--help-general] [-skipfailures] [-append] [-update] [-gt n]\n" + \ + " [-select field_list] [-where restricted_where] \n" + \ + " [-progress] [-sql ] \n" + \ + " [-spat xmin ymin xmax ymax] [-preserve_fid] [-fid FID]\n" + \ + " [-a_srs srs_def] [-t_srs srs_def] [-s_srs srs_def]\n" + \ + " [-f format_name] [-overwrite] [[-dsco NAME=VALUE] ...]\n" + \ + " [-simplify tolerance]\n" + \ + #// " [-segmentize max_dist] [-fieldTypeToString All|(type1[,type2]*)]\n" + \ + " [-fieldTypeToString All|(type1[,type2]*)] [-explodecollections] \n" + \ + " dst_datasource_name src_datasource_name\n" + \ + " [-lco NAME=VALUE] [-nln name] [-nlt type] [-dim 2|3] [layer [layer ...]]\n" + \ + "\n" + \ + " -f format_name: output file format name, possible values are:")) for iDriver in range(ogr.GetDriverCount()): poDriver = ogr.GetDriver(iDriver) - if poDriver.TestCapability(ogr.ODrCCreateDataSource): - print(' -f "' + poDriver.GetName() + '"') + if poDriver.TestCapability( ogr.ODrCCreateDataSource ): + print(( " -f \"" + poDriver.GetName() + "\"" )) - print( - " -append: Append to existing layer instead of creating new if it exists\n" - + " -overwrite: delete the output layer and recreate it empty\n" - + " -update: Open existing output datasource in update mode\n" - + ' -progress: Display progress on terminal. Only works if input layers have the "fast feature count" capability\n' - + " -select field_list: Comma-delimited list of fields from input layer to\n" - + " copy to the new layer (defaults to all)\n" - + " -where restricted_where: Attribute query (like SQL WHERE)\n" - + " -sql statement: Execute given SQL statement and save result.\n" - + " -skipfailures: skip features or layers that fail to convert\n" - + " -gt n: group n features per transaction (default 200)\n" - + " -spat xmin ymin xmax ymax: spatial query extents\n" - + " -simplify tolerance: distance tolerance for simplification.\n" - + - # //" -segmentize max_dist: maximum distance between 2 nodes.\n" + \ - # //" Used to create intermediate points\n" + \ - " -dsco NAME=VALUE: Dataset creation option (format specific)\n" - + " -lco NAME=VALUE: Layer creation option (format specific)\n" - + " -nln name: Assign an alternate name to the new layer\n" - + " -nlt type: Force a geometry type for new layer. One of NONE, GEOMETRY,\n" - + " POINT, LINESTRING, POLYGON, GEOMETRYCOLLECTION, MULTIPOINT,\n" - + ' MULTIPOLYGON, or MULTILINESTRING. Add "25D" for 3D layers.\n' - + " Default is type of source layer.\n" - + " -dim dimension: Force the coordinate dimension to the specified value.\n" - + " -fieldTypeToString type1,...: Converts fields of specified types to\n" - + " fields of type string in the new layer. Valid types are : \n" - + " Integer, Real, String, Date, Time, DateTime, Binary, IntegerList, RealList,\n" - + " StringList. Special value All can be used to convert all fields to strings." - ) + print(( " -append: Append to existing layer instead of creating new if it exists\n" + \ + " -overwrite: delete the output layer and recreate it empty\n" + \ + " -update: Open existing output datasource in update mode\n" + \ + " -progress: Display progress on terminal. Only works if input layers have the \"fast feature count\" capability\n" + \ + " -select field_list: Comma-delimited list of fields from input layer to\n" + \ + " copy to the new layer (defaults to all)\n" + \ + " -where restricted_where: Attribute query (like SQL WHERE)\n" + \ + " -sql statement: Execute given SQL statement and save result.\n" + \ + " -skipfailures: skip features or layers that fail to convert\n" + \ + " -gt n: group n features per transaction (default 200)\n" + \ + " -spat xmin ymin xmax ymax: spatial query extents\n" + \ + " -simplify tolerance: distance tolerance for simplification.\n" + \ + #//" -segmentize max_dist: maximum distance between 2 nodes.\n" + \ + #//" Used to create intermediate points\n" + \ + " -dsco NAME=VALUE: Dataset creation option (format specific)\n" + \ + " -lco NAME=VALUE: Layer creation option (format specific)\n" + \ + " -nln name: Assign an alternate name to the new layer\n" + \ + " -nlt type: Force a geometry type for new layer. One of NONE, GEOMETRY,\n" + \ + " POINT, LINESTRING, POLYGON, GEOMETRYCOLLECTION, MULTIPOINT,\n" + \ + " MULTIPOLYGON, or MULTILINESTRING. Add \"25D\" for 3D layers.\n" + \ + " Default is type of source layer.\n" + \ + " -dim dimension: Force the coordinate dimension to the specified value.\n" + \ + " -fieldTypeToString type1,...: Converts fields of specified types to\n" + \ + " fields of type string in the new layer. Valid types are : \n" + \ + " Integer, Real, String, Date, Time, DateTime, Binary, IntegerList, RealList,\n" + \ + " StringList. Special value All can be used to convert all fields to strings.")) - print( - " -a_srs srs_def: Assign an output SRS\n" + print(" -a_srs srs_def: Assign an output SRS\n" " -t_srs srs_def: Reproject/transform to this SRS on output\n" " -s_srs srs_def: Override source SRS\n" "\n" @@ -1364,10 +1297,8 @@ poSourceSRS = poSrcLayer.GetSpatialRef() if poSourceSRS is None: - print( - "Can't transform coordinates, source layer has no\n" - + "coordinate system. Use -s_srs to set one." - ) + print(("Can't transform coordinates, source layer has no\n" + \ + "coordinate system. Use -s_srs to set one." )) return None poCT = osr.CoordinateTransformation(poSourceSRS, poOutputSRS) @@ -1377,18 +1308,16 @@ if poCT is None: pszWKT = None - print( - "Failed to create coordinate transformation between the\n" - + "following coordinate systems. This may be because they\n" - + "are not transformable, or because projection services\n" - + "(PROJ.4 DLL/.so) could not be loaded." - ) + print(("Failed to create coordinate transformation between the\n" + \ + "following coordinate systems. This may be because they\n" + \ + "are not transformable, or because projection services\n" + \ + "(PROJ.4 DLL/.so) could not be loaded." )) - pszWKT = poSourceSRS.ExportToPrettyWkt(0) - print("Source:\n" + pszWKT) + pszWKT = poSourceSRS.ExportToPrettyWkt( 0 ) + print(( "Source:\n" + pszWKT )) - pszWKT = poOutputSRS.ExportToPrettyWkt(0) - print("Target:\n" + pszWKT) + pszWKT = poOutputSRS.ExportToPrettyWkt( 0 ) + print(( "Target:\n" + pszWKT )) return None # -------------------------------------------------------------------- @@ -1470,12 +1399,8 @@ elif nCoordDim == 3: eGType = eGType | ogr.wkb25DBit - if poDstDS.TestCapability(ogr.ODsCCreateLayer) == False: - print( - "Layer " - + pszNewLayerName - + "not found, and CreateLayer not supported by driver." - ) + if poDstDS.TestCapability( ogr.ODsCCreateLayer ) == False: + print(("Layer " + pszNewLayerName + "not found, and CreateLayer not supported by driver.")) return None gdal.ErrorReset() @@ -1491,26 +1416,20 @@ # Otherwise we will append to it, if append was requested. # -------------------------------------------------------------------- elif not bAppend: - print( - "FAILED: Layer " - + pszNewLayerName - + "already exists, and -append not specified.\n" - + " Consider using -append, or -overwrite." - ) + print(("FAILED: Layer " + pszNewLayerName + "already exists, and -append not specified.\n" + \ + " Consider using -append, or -overwrite.")) return None else: if len(papszLCO) > 0: - print( - "WARNING: Layer creation options ignored since an existing layer is\n" - + " being appended to." - ) + print(("WARNING: Layer creation options ignored since an existing layer is\n" + \ + " being appended to." )) - # -------------------------------------------------------------------- - # Add fields. Default to copy all field. - # If only a subset of all fields requested, then output only - # the selected fields, and in the order that they were - # selected. - # -------------------------------------------------------------------- +# -------------------------------------------------------------------- +# Add fields. Default to copy all field. +# If only a subset of all fields requested, then output only +# the selected fields, and in the order that they were +# selected. +# -------------------------------------------------------------------- # Initialize the index-to-index map to -1's nSrcFieldCount = poSrcFDefn.GetFieldCount() @@ -1558,22 +1477,15 @@ poDstFDefn = poDstLayer.GetLayerDefn() # Sanity check : if it fails, the driver is buggy - if ( - poDstFDefn is not None - and poDstFDefn.GetFieldCount() != nDstFieldCount + 1 - ): - print( - "The output driver has claimed to have added the %s field, but it did not!" - % oFieldDefn.GetNameRef() - ) + if poDstFDefn is not None and \ + poDstFDefn.GetFieldCount() != nDstFieldCount + 1: + print(("The output driver has claimed to have added the %s field, but it did not!" % oFieldDefn.GetNameRef() )) else: panMap[iSrcField] = nDstFieldCount nDstFieldCount = nDstFieldCount + 1 else: - print( - "Field '" + papszSelFields[iField] + "' not found in source layer." - ) + print(("Field '" + papszSelFields[iField] + "' not found in source layer.")) if not bSkipFailures: return None @@ -1641,14 +1553,9 @@ poDstFDefn = poDstLayer.GetLayerDefn() # Sanity check : if it fails, the driver is buggy - if ( - poDstFDefn is not None - and poDstFDefn.GetFieldCount() != nDstFieldCount + 1 - ): - print( - "The output driver has claimed to have added the %s field, but it did not!" - % oFieldDefn.GetNameRef() - ) + if poDstFDefn is not None and \ + poDstFDefn.GetFieldCount() != nDstFieldCount + 1: + print(("The output driver has claimed to have added the %s field, but it did not!" % oFieldDefn.GetNameRef() )) else: panMap[iField] = nDstFieldCount nDstFieldCount = nDstFieldCount + 1 @@ -1785,10 +1692,7 @@ if nGroupTransactions > 0: poDstLayer.CommitTransaction() - print( - "Unable to translate feature %d from layer %s" - % (poFeature.GetFID(), poSrcLayer.GetName()) - ) + print(("Unable to translate feature %d from layer %s" % (poFeature.GetFID() , poSrcLayer.GetName() ))) return False @@ -1847,10 +1751,7 @@ if nGroupTransactions > 0: poDstLayer.CommitTransaction() - print( - "Failed to reproject feature %d (geometry probably out of source or destination SRS)." - % poFeature.GetFID() - ) + print(("Failed to reproject feature %d (geometry probably out of source or destination SRS)." % poFeature.GetFID())) if not bSkipFailures: return False Index: wflow-py/wflow/ops_scalar2grid.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/ops_scalar2grid.py (.../ops_scalar2grid.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/ops_scalar2grid.py (.../ops_scalar2grid.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -32,9 +32,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -187,18 +186,19 @@ setup needed. """ - self.logger.info("Reading initial conditions...") - #: It is advised to use the wf_resume() function - #: here which pick up the variable save by a call to wf_suspend() - try: - self.wf_resume(self.Dir + "/instate/") - except: - self.logger.warn("Cannot load initial states, setting to default") - for s in self.stateVariables(): - exec "self." + s + " = cover(1.0)" + self.logger.info("Reading initial conditions...") + #: It is advised to use the wf_resume() function + #: here which pick up the variable save by a call to wf_suspend() + try: + self.wf_resume(self.Dir + "/instate/") + except: + self.logger.warn("Cannot load initial states, setting to default") + for s in self.stateVariables(): + exec("self." + s + " = cover(1.0)") - def default_summarymaps(self): - """ + + def default_summarymaps(self): + """ *Optional* Return a default list of variables to report as summary maps in the outsum dir. @@ -214,8 +214,25 @@ output should also be saved here. """ - self.wf_updateparameters() # read the temperature map for each step (see parameters()) + self.wf_updateparameters() # read the temperature map for each step (see parameters()) + self.Stations = ordinal(self.Stations) + + for var in self.ToInterpolate: + tss = configget(self.config,'interpolate',var,None) + tmp = timeinputscalar(self.Dir + '/' + tss ,self.Stations) + + + if self.interpolationmethod == 'thiessen': + Unq = uniqueid(boolean(abs(tmp) + 1.0 )) + GaugeArea = spreadzone(ordinal(cover(Unq,0)),0,1); + exec('self.' + var + ' = areaaverage(tmp,GaugeArea)') + elif self.interpolationmethod == 'inverse': + exec('self.' + var + '=inversedistance(1,tmp,' + str(self.inversepower) + ',0,0)') + else: + print('not implemented:' + self.interpolationmethod) + + self.Stations = ordinal(self.Stations) for var in self.ToInterpolate: Index: wflow-py/wflow/pcrglobwb/groundwater.py =================================================================== diff -u -r831722412888fabe904a22d2548ac77be2c1a5f4 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/pcrglobwb/groundwater.py (.../groundwater.py) (revision 831722412888fabe904a22d2548ac77be2c1a5f4) +++ wflow-py/wflow/pcrglobwb/groundwater.py (.../groundwater.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -33,8 +33,8 @@ logger = logging.getLogger("wflow_pcrglobwb") -import virtualOS as vos -from ncConverter import * +from . import virtualOS as vos +from .ncConverter import * from wflow.wf_DynamicFramework import configsection from wflow.wf_DynamicFramework import configget @@ -229,10 +229,8 @@ ) # calculate the reccession coefficient based on the given parameters - if ( - isinstance(self.recessionCoeff, types.NoneType) - and "recessionCoeff" not in iniItems._sections["groundwaterOptions"] - ): + if isinstance(self.recessionCoeff,type(None)) and\ + 'recessionCoeff' not in iniItems._sections['groundwaterOptions']: msg = "Calculating the groundwater linear reccesion coefficient based on the given parameters." logger.info(msg) Index: wflow-py/wflow/pcrglobwb/landCover.py =================================================================== diff -u -r831722412888fabe904a22d2548ac77be2c1a5f4 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/pcrglobwb/landCover.py (.../landCover.py) (revision 831722412888fabe904a22d2548ac77be2c1a5f4) +++ wflow-py/wflow/pcrglobwb/landCover.py (.../landCover.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -32,8 +32,8 @@ logger = logging.getLogger("wflow_pcrglobwb") -import virtualOS as vos -from ncConverter import * +from . import virtualOS as vos +from .ncConverter import * from wflow.wf_DynamicFramework import configsection from wflow.wf_DynamicFramework import configget @@ -104,8 +104,8 @@ # - "Original" is principally the same as defined in van Beek et al., 2014 (default) # - "Modified" is with a modification by Edwin Sutanudjaja: extending interception definition, using totalPotET for the available energy self.interceptionModuleType = "Original" - if "interceptionModuleType" in self.iniItemsLC.keys(): - if self.iniItemsLC["interceptionModuleType"] == "Modified": + if "interceptionModuleType" in list(self.iniItemsLC.keys()): + if self.iniItemsLC['interceptionModuleType'] == "Modified": msg = 'Using the "Modified" version of the interception module (i.e. extending interception definition, using totalPotET for the available energy for the interception process).' logger.info(msg) self.interceptionModuleType = "Modified" @@ -122,10 +122,7 @@ # minimum interception capacity (only used if interceptionModuleType == "Modified", extended interception definition) self.minInterceptCap = 0.0 - if ( - self.interceptionModuleType == "Original" - and "minInterceptCap" in self.iniItemsLC.keys() - ): + if self.interceptionModuleType == "Original" and "minInterceptCap" in list(self.iniItemsLC.keys()): msg = 'As the "Original" interceptionModuleType is used, the "minInterceptCap" value is ignored. The interception scope is only "canopy".' logger.warning(msg) if self.interceptionModuleType == "Modified": @@ -160,30 +157,18 @@ # In the original oldcalc script of Rens (2 layer model), the percolation percUpp (P1) can be negative # - To avoid this, Edwin changed few lines (see the method updateSoilStates) self.allowNegativePercolation = False - if ( - "allowNegativePercolation" in self.iniItemsLC.keys() - and self.iniItemsLC["allowNegativePercolation"] == "True" - ): - msg = "Allowing negative values of percolation percUpp (P1), as done in the oldcalc script of PCR-GLOBWB 1.0. " # \n' - msg += ( - "Note that this option is only relevant for the two layer soil model." - ) + if 'allowNegativePercolation' in list(self.iniItemsLC.keys()) and self.iniItemsLC['allowNegativePercolation'] == "True": + msg = 'Allowing negative values of percolation percUpp (P1), as done in the oldcalc script of PCR-GLOBWB 1.0. ' #\n' + msg += 'Note that this option is only relevant for the two layer soil model.' logger.warning(msg) self.allowNegativePercolation = True # In the original oldcalc script of Rens, there is a possibility that rootFraction/transpiration is only defined in the bottom layer, while no root in upper layer(s) # - To avoid this, Edwin changed few lines (see the methods 'scaleRootFractionsFromTwoLayerSoilParameters' and 'estimateTranspirationAndBareSoilEvap') self.usingOriginalOldCalcRootTranspirationPartitioningMethod = False - if ( - "usingOriginalOldCalcRootTranspirationPartitioningMethod" - in self.iniItemsLC.keys() - and self.iniItemsLC[ - "usingOriginalOldCalcRootTranspirationPartitioningMethod" - ] - == "True" - ): - msg = "Using the original rootFraction/transpiration as defined in the oldcalc script of PCR-GLOBWB 1.0. " # \n' - msg += "There is a possibility that rootFraction/transpiration is only defined in the bottom layer, while no root in upper layer(s)." + if 'usingOriginalOldCalcRootTranspirationPartitioningMethod' in list(self.iniItemsLC.keys()) and self.iniItemsLC['usingOriginalOldCalcRootTranspirationPartitioningMethod'] == "True": + msg = 'Using the original rootFraction/transpiration as defined in the oldcalc script of PCR-GLOBWB 1.0. '#\n' + msg += 'There is a possibility that rootFraction/transpiration is only defined in the bottom layer, while no root in upper layer(s).' logger.warning(msg) self.usingOriginalOldCalcRootTranspirationPartitioningMethod = True @@ -327,16 +312,11 @@ # ~ self.iniItemsLC['coverFractionNC'], self.inputDir) # get the file names of interceptCap and coverFraction files: - if ( - "interceptCapNC" in self.iniItemsLC.keys() - and "coverFractionNC" in self.iniItemsLC.keys() - ): - self.interceptCapNC = vos.getFullPath( - self.iniItemsLC["interceptCapNC"], self.inputDir - ) - self.coverFractionNC = vos.getFullPath( - self.iniItemsLC["coverFractionNC"], self.inputDir - ) + if 'interceptCapNC' in list(self.iniItemsLC.keys()) and 'coverFractionNC' in list(self.iniItemsLC.keys()): + self.interceptCapNC = vos.getFullPath(\ + self.iniItemsLC['interceptCapNC'], self.inputDir) + self.coverFractionNC = vos.getFullPath(\ + self.iniItemsLC['coverFractionNC'], self.inputDir) else: msg = ( "The netcdf files for interceptCapNC (interception capacity) and/or coverFraction (canopy cover fraction) are NOT defined for the landCover type: " @@ -493,12 +473,8 @@ # 2. included in the netcdf file (i.e. self.iniItemsLC['landCoverMapsNC']) # 3. approximated from the minSoilDepthFrac and maxSoilDepthFrac - lc_parameters["arnoBeta"] = None - if ( - "arnoBeta" not in self.iniItemsLC.keys() - and get_only_fracVegCover == False - ): - self.iniItemsLC["arnoBeta"] = "None" + lc_parameters['arnoBeta'] = None + if 'arnoBeta' not in list(self.iniItemsLC.keys()) and get_only_fracVegCover == False: self.iniItemsLC['arnoBeta'] = "None" # - option one (top priority): using a pcraster file if self.iniItemsLC["arnoBeta"] != "None" and get_only_fracVegCover == False: @@ -514,12 +490,8 @@ ) # - option two: included in the netcdf file - if ( - isinstance(lc_parameters["arnoBeta"], types.NoneType) - and landCoverPropertiesNC != None - and get_only_fracVegCover == False - ): - + if isinstance(lc_parameters['arnoBeta'], type(None)) and landCoverPropertiesNC != None and get_only_fracVegCover == False: + if vos.checkVariableInNC(landCoverPropertiesNC, "arnoBeta"): logger.debug( @@ -531,15 +503,10 @@ ) # - option three: approximated from the minSoilDepthFrac and maxSoilDepthFrac - if ( - isinstance(lc_parameters["arnoBeta"], types.NoneType) - and get_only_fracVegCover == False - ): - - logger.debug( - "The parameter arnoBeta is approximated from the minSoilDepthFrac and maxSoilDepthFrac values." - ) - + if isinstance(lc_parameters['arnoBeta'], type(None)) and get_only_fracVegCover == False: + + logger.debug("The parameter arnoBeta is approximated from the minSoilDepthFrac and maxSoilDepthFrac values.") + # make sure that maxSoilDepthFrac >= minSoilDepthFrac: # - Note that maxSoilDepthFrac is needed only for calculating arnoBeta, # while minSoilDepthFrac is needed not only for arnoBeta, but also for rootZoneWaterStorageMin @@ -608,9 +575,8 @@ ) # if not defined, arnoBeta would be approximated from the minSoilDepthFrac and maxSoilDepthFrac - if get_only_fracVegCover == False and isinstance( - lc_parameters["arnoBeta"], types.NoneType - ): + if get_only_fracVegCover == False and\ + isinstance(lc_parameters['arnoBeta'], type(None)): logger.debug( "The parameter arnoBeta is approximated from the minSoilDepthFrac and maxSoilDepthFrac values." @@ -715,26 +681,12 @@ min_percolation_loss = 0.006 max_percolation_loss = 0.008 # - Minimum and maximum percolation loss values given in the ini or configuration file: - if ( - "minPercolationLoss" in iniPaddyOptions.keys() - and iniPaddyOptions["minPercolationLoss"] != "None" - ): - min_percolation_loss = vos.readPCRmapClone( - iniPaddyOptions["minPercolationLoss"], - self.cloneMap, - self.tmpDir, - self.inputDir, - ) - if ( - "maxPercolationLoss" in iniPaddyOptions.keys() - and iniPaddyOptions["maxPercolationLoss"] != "None" - ): - min_percolation_loss = vos.readPCRmapClone( - iniPaddyOptions["maxPercolationLoss"], - self.cloneMap, - self.tmpDir, - self.inputDir, - ) + if 'minPercolationLoss' in list(iniPaddyOptions.keys()) and iniPaddyOptions['minPercolationLoss'] != "None": + min_percolation_loss = vos.readPCRmapClone(iniPaddyOptions['minPercolationLoss'], self.cloneMap, + self.tmpDir, self.inputDir) + if 'maxPercolationLoss' in list(iniPaddyOptions.keys()) and iniPaddyOptions['maxPercolationLoss'] != "None": + min_percolation_loss = vos.readPCRmapClone(iniPaddyOptions['maxPercolationLoss'], self.cloneMap, + self.tmpDir, self.inputDir) # - percolation loss at paddy fields (m/day) design_percolation_loss = pcr.max( min_percolation_loss, pcr.min(max_percolation_loss, design_percolation_loss) Index: wflow-py/wflow/pcrglobwb/landSurface.py =================================================================== diff -u -r831722412888fabe904a22d2548ac77be2c1a5f4 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/pcrglobwb/landSurface.py (.../landSurface.py) (revision 831722412888fabe904a22d2548ac77be2c1a5f4) +++ wflow-py/wflow/pcrglobwb/landSurface.py (.../landSurface.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -24,16 +24,16 @@ import types import pcraster as pcr -import virtualOS as vos +from . import virtualOS as vos import logging logger = logging.getLogger("wflow_pcrglobwb") -from ncConverter import * +from .ncConverter import * -import landCover as lc -import parameterSoilAndTopo as parSoilAndTopo +from . import landCover as lc +from . import parameterSoilAndTopo as parSoilAndTopo import os from wflow.wf_DynamicFramework import configsection @@ -441,30 +441,17 @@ self.soil_topo_parameters["default"].read(iniItems) # - specific soil and topography parameter (per land cover type) for coverType in self.coverTypes: - name_of_section_given_in_ini_file = str(coverType) + "Options" - dictionary_of_land_cover_settings = iniItems._sections[ - name_of_section_given_in_ini_file - ] # __getattribute__(name_of_section_given_in_ini_file) - - if "usingSpecificSoilTopo" not in dictionary_of_land_cover_settings.keys(): - dictionary_of_land_cover_settings["usingSpecificSoilTopo"] = "False" - if dictionary_of_land_cover_settings["usingSpecificSoilTopo"] == "True": - - msg = "Using a specific set of soil and topo parameters " - msg += ( - "as defined in the " - + name_of_section_given_in_ini_file - + " of the ini/configuration file." - ) - - self.soil_topo_parameters[ - coverType - ] = parSoilAndTopo.SoilAndTopoParameters( - iniItems, self.landmask, self.inputDir, self.cloneMap, self.tmpDir - ) - self.soil_topo_parameters[coverType].read( - iniItems, dictionary_of_land_cover_settings - ) + name_of_section_given_in_ini_file = str(coverType)+'Options' + dictionary_of_land_cover_settings = iniItems._sections[name_of_section_given_in_ini_file] #__getattribute__(name_of_section_given_in_ini_file) + + if 'usingSpecificSoilTopo' not in list(dictionary_of_land_cover_settings.keys()): dictionary_of_land_cover_settings['usingSpecificSoilTopo'] = "False" + if dictionary_of_land_cover_settings['usingSpecificSoilTopo'] == "True": + + msg = "Using a specific set of soil and topo parameters " + msg += "as defined in the "+name_of_section_given_in_ini_file+" of the ini/configuration file." + + self.soil_topo_parameters[coverType] = parSoilAndTopo.SoilAndTopoParameters(iniItems,self.landmask,self.inputDir,self.cloneMap,self.tmpDir) + self.soil_topo_parameters[coverType].read(iniItems, dictionary_of_land_cover_settings) else: msg = "Using the default set of soil and topo parameters " @@ -775,24 +762,14 @@ # correcting land cover fractions total_fractions = pcr.scalar(0.0) for coverType in self.coverTypes: - total_fractions += self.landCoverObj[coverType].previousFracVegCover + total_fractions += self.landCoverObj[coverType].previousFracVegCover - if "grassland" in self.landCoverObj.keys(): - self.landCoverObj["grassland"].previousFracVegCover = pcr.ifthenelse( - total_fractions > 0.1, - self.landCoverObj["grassland"].previousFracVegCover, - 1.0, - ) + if 'grassland' in list(self.landCoverObj.keys()): + self.landCoverObj['grassland'].previousFracVegCover = pcr.ifthenelse(total_fractions > 0.1, self.landCoverObj['grassland'].previousFracVegCover, 1.0) + + if 'short_natural' in list(self.landCoverObj.keys()): + self.landCoverObj['short_natural'].previousFracVegCover = pcr.ifthenelse(total_fractions > 0.1, self.landCoverObj['short_natural'].previousFracVegCover, 1.0) - if "short_natural" in self.landCoverObj.keys(): - self.landCoverObj[ - "short_natural" - ].previousFracVegCover = pcr.ifthenelse( - total_fractions > 0.1, - self.landCoverObj["short_natural"].previousFracVegCover, - 1.0, - ) - total_fractions = pcr.scalar(0.0) for coverType in self.coverTypes: total_fractions += self.landCoverObj[coverType].previousFracVegCover @@ -826,24 +803,14 @@ # correcting land cover fractions total_fractions = pcr.scalar(0.0) for coverType in self.coverTypes: - total_fractions += self.landCoverObj[coverType].previousFracVegCover + total_fractions += self.landCoverObj[coverType].previousFracVegCover - if "grassland" in self.landCoverObj.keys(): - self.landCoverObj["grassland"].previousFracVegCover = pcr.ifthenelse( - total_fractions > 0.1, - self.landCoverObj["grassland"].previousFracVegCover, - 1.0, - ) + if 'grassland' in list(self.landCoverObj.keys()): + self.landCoverObj['grassland'].previousFracVegCover = pcr.ifthenelse(total_fractions > 0.1, self.landCoverObj['grassland'].previousFracVegCover, 1.0) + + if 'short_natural' in list(self.landCoverObj.keys()): + self.landCoverObj['short_natural'].previousFracVegCover = pcr.ifthenelse(total_fractions > 0.1, self.landCoverObj['short_natural'].previousFracVegCover, 1.0) - if "short_natural" in self.landCoverObj.keys(): - self.landCoverObj[ - "short_natural" - ].previousFracVegCover = pcr.ifthenelse( - total_fractions > 0.1, - self.landCoverObj["short_natural"].previousFracVegCover, - 1.0, - ) - total_fractions = pcr.scalar(0.0) for coverType in self.coverTypes: total_fractions += self.landCoverObj[coverType].previousFracVegCover @@ -868,13 +835,9 @@ self.landCoverObj[coverType].getICsLC(iniItems) # summarize/aggregate the initial states/storages (using the initial land cover fractions: previousFracVegCover) for var in self.mainStates: - # - initial land cover fractions (dimensionless) - if isinstance( - self.landCoverObj[coverType].previousFracVegCover, types.NoneType - ): - self.landCoverObj[ - coverType - ].previousFracVegCover = self.landCoverObj[coverType].fracVegCover + # - initial land cover fractions (dimensionless) + if isinstance(self.landCoverObj[coverType].previousFracVegCover, type(None)): + self.landCoverObj[coverType].previousFracVegCover = self.landCoverObj[coverType].fracVegCover land_cover_fraction = self.landCoverObj[coverType].previousFracVegCover # - initial land cover states (unit: m) land_cover_states = vars(self.landCoverObj[coverType])[var] @@ -1831,33 +1794,21 @@ # # - a treshold fraction value to minimize fossil groundwater withdrawal, particularly to remove the unrealistic areas of fossil groundwater abstraction # Principle: Areas with swAbstractionFractionDict['irrigation'] above this treshold will not extract fossil groundwater. - swAbstractionFractionDict[ - "treshold_to_minimize_fossil_groundwater_irrigation" - ] = self.treshold_to_minimize_fossil_groundwater_irrigation + swAbstractionFractionDict['treshold_to_minimize_fossil_groundwater_irrigation'] = self.treshold_to_minimize_fossil_groundwater_irrigation + + # if defined, incorporating the pre-defined fraction of surface water sources (e.g. based on Siebert et al., 2014 and McDonald et al., 2014) + if not isinstance(self.swAbstractionFractionData, type(None)): + + logger.debug('Using/incorporating the predefined fractions of surface water source.') + swAbstractionFractionDict['estimate'] = swAbstractionFraction + swAbstractionFractionDict['irrigation'] = self.partitioningGroundSurfaceAbstractionForIrrigation(swAbstractionFraction,\ + self.swAbstractionFractionData,\ + self.swAbstractionFractionDataQuality) + swAbstractionFractionDict['max_for_non_irrigation'] = self.maximumNonIrrigationSurfaceWaterAbstractionFractionData + + else: + logger.debug('NOT using/incorporating the predefined fractions of surface water source.') - # if defined, incorporating the pre-defined fraction of surface water sources (e.g. based on Siebert et al., 2014 and McDonald et al., 2014) - if not isinstance(self.swAbstractionFractionData, types.NoneType): - - logger.debug( - "Using/incorporating the predefined fractions of surface water source." - ) - swAbstractionFractionDict["estimate"] = swAbstractionFraction - swAbstractionFractionDict[ - "irrigation" - ] = self.partitioningGroundSurfaceAbstractionForIrrigation( - swAbstractionFraction, - self.swAbstractionFractionData, - self.swAbstractionFractionDataQuality, - ) - swAbstractionFractionDict[ - "max_for_non_irrigation" - ] = self.maximumNonIrrigationSurfaceWaterAbstractionFractionData - - else: - logger.debug( - "NOT using/incorporating the predefined fractions of surface water source." - ) - return swAbstractionFractionDict def partitioningGroundSurfaceAbstractionForIrrigation( @@ -2048,22 +1999,14 @@ # correcting land cover fractions total_fractions = pcr.scalar(0.0) for coverType in self.coverTypes: - total_fractions += self.landCoverObj[coverType].fracVegCover - - if "grassland" in self.landCoverObj.keys(): - self.landCoverObj["grassland"].fracVegCover = pcr.ifthenelse( - total_fractions > 0.1, - self.landCoverObj["grassland"].fracVegCover, - 1.0, - ) - - if "short_natural" in self.landCoverObj.keys(): - self.landCoverObj["short_natural"].fracVegCover = pcr.ifthenelse( - total_fractions > 0.1, - self.landCoverObj["short_natural"].fracVegCover, - 1.0, - ) - + total_fractions += self.landCoverObj[coverType].fracVegCover + + if 'grassland' in list(self.landCoverObj.keys()): + self.landCoverObj['grassland'].fracVegCover = pcr.ifthenelse(total_fractions > 0.1, self.landCoverObj['grassland'].fracVegCover, 1.0) + + if 'short_natural' in list(self.landCoverObj.keys()): + self.landCoverObj['short_natural'].fracVegCover = pcr.ifthenelse(total_fractions > 0.1, self.landCoverObj['short_natural'].fracVegCover, 1.0) + total_fractions = pcr.scalar(0.0) for coverType in self.coverTypes: total_fractions += self.landCoverObj[coverType].fracVegCover @@ -2095,22 +2038,14 @@ # correcting land cover fractions total_fractions = pcr.scalar(0.0) for coverType in self.coverTypes: - total_fractions += self.landCoverObj[coverType].fracVegCover - - if "grassland" in self.landCoverObj.keys(): - self.landCoverObj["grassland"].fracVegCover = pcr.ifthenelse( - total_fractions > 0.1, - self.landCoverObj["grassland"].fracVegCover, - 1.0, - ) - - if "short_natural" in self.landCoverObj.keys(): - self.landCoverObj["short_natural"].fracVegCover = pcr.ifthenelse( - total_fractions > 0.1, - self.landCoverObj["short_natural"].fracVegCover, - 1.0, - ) - + total_fractions += self.landCoverObj[coverType].fracVegCover + + if 'grassland' in list(self.landCoverObj.keys()): + self.landCoverObj['grassland'].fracVegCover = pcr.ifthenelse(total_fractions > 0.1, self.landCoverObj['grassland'].fracVegCover, 1.0) + + if 'short_natural' in list(self.landCoverObj.keys()): + self.landCoverObj['short_natural'].fracVegCover = pcr.ifthenelse(total_fractions > 0.1, self.landCoverObj['short_natural'].fracVegCover, 1.0) + total_fractions = pcr.scalar(0.0) for coverType in self.coverTypes: total_fractions += self.landCoverObj[coverType].fracVegCover Index: wflow-py/wflow/pcrglobwb/ncConverter.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/pcrglobwb/ncConverter.py (.../ncConverter.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/pcrglobwb/ncConverter.py (.../ncConverter.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -32,7 +32,7 @@ import netCDF4 as nc import numpy as np import pcraster as pcr -import virtualOS as vos +from . import virtualOS as vos # TODO: defined the dictionary (e.g. filecache = dict()) to avoid open and closing files @@ -52,12 +52,8 @@ # Let users decide what their preference regarding latitude order. self.netcdf_y_orientation_follow_cf_convention = False - if ( - "netcdf_y_orientation_follow_cf_convention" - in iniItems.reportingOptions.keys() - and iniItems.reportingOptions["netcdf_y_orientation_follow_cf_convention"] - == "True" - ): + if 'netcdf_y_orientation_follow_cf_convention' in list(iniItems.reportingOptions.keys()) and\ + iniItems.reportingOptions['netcdf_y_orientation_follow_cf_convention'] == "True": msg = "Latitude (y) orientation for output netcdf files start from the bottom to top." self.netcdf_y_orientation_follow_cf_convention = True self.latitudes = np.unique(pcr.pcr2numpy(pcr.ycoordinate(cloneMap), vos.MV)) @@ -68,15 +64,15 @@ # netcdf format and zlib setup self.format = "NETCDF3_CLASSIC" self.zlib = False - if "formatNetCDF" in iniItems.reportingOptions.keys(): - self.format = str(iniItems.reportingOptions["formatNetCDF"]) - if "zlib" in iniItems.reportingOptions.keys(): - if iniItems.reportingOptions["zlib"] == "True": - self.zlib = True + if "formatNetCDF" in list(iniItems.reportingOptions.keys()): + self.format = str(iniItems.reportingOptions['formatNetCDF']) + if "zlib" in list(iniItems.reportingOptions.keys()): + if iniItems.reportingOptions['zlib'] == "True": self.zlib = True + # if given in the ini file, use the netcdf as given in the section 'specific_attributes_for_netcdf_output_files' - if "specific_attributes_for_netcdf_output_files" in iniItems.allSections: - for key in iniItems.specific_attributes_for_netcdf_output_files.keys(): + if 'specific_attributes_for_netcdf_output_files' in iniItems.allSections: + for key in list(iniItems.specific_attributes_for_netcdf_output_files.keys()): self.attributeDictionary[ key @@ -163,8 +159,7 @@ var.units = varUnits attributeDictionary = self.attributeDictionary - for k, v in attributeDictionary.items(): - setattr(rootgrp, k, v) + for k, v in list(attributeDictionary.items()): setattr(rootgrp,k,v) rootgrp.sync() rootgrp.close() @@ -173,8 +168,7 @@ rootgrp = nc.Dataset(ncFileName, "a") - for k, v in attributeDictionary.items(): - setattr(rootgrp, k, v) + for k, v in list(attributeDictionary.items()): setattr(rootgrp,k,v) rootgrp.sync() rootgrp.close() Index: wflow-py/wflow/pcrglobwb/parameterSoilAndTopo.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/pcrglobwb/parameterSoilAndTopo.py (.../parameterSoilAndTopo.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/pcrglobwb/parameterSoilAndTopo.py (.../parameterSoilAndTopo.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -25,7 +25,7 @@ import os import pcraster as pcr -import virtualOS as vos +from . import virtualOS as vos from wflow.wflow_lib import configsection from wflow.wflow_lib import configget Index: wflow-py/wflow/pcrglobwb/routing.py =================================================================== diff -u -r831722412888fabe904a22d2548ac77be2c1a5f4 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/pcrglobwb/routing.py (.../routing.py) (revision 831722412888fabe904a22d2548ac77be2c1a5f4) +++ wflow-py/wflow/pcrglobwb/routing.py (.../routing.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -34,10 +34,10 @@ logger = logging.getLogger("wflow_pcrglobwb") -import virtualOS as vos -from ncConverter import * +from . import virtualOS as vos +from .ncConverter import * -import waterBodies +from . import waterBodies from wflow.wf_DynamicFramework import configsection from wflow.wf_DynamicFramework import configget @@ -413,11 +413,10 @@ ) else: msg = "The bankfull channel storage capacity is NOT defined in the configuration file. " - - if isinstance( - self.predefinedChannelWidth, types.NoneType - ) or isinstance(self.predefinedChannelDepth, types.NoneType): - + + if isinstance(self.predefinedChannelWidth, type(None)) or\ + isinstance(self.predefinedChannelDepth, type(None)): + msg += "The bankfull capacity is estimated from average discharge (5 year long term average)." else: @@ -609,10 +608,8 @@ self.avgInflow = pcr.ifthen(self.landmask, pcr.cover(self.avgInflow, 0.0)) self.avgOutflow = pcr.ifthen(self.landmask, pcr.cover(self.avgOutflow, 0.0)) - if not isinstance(self.waterBodyStorage, types.NoneType): - self.waterBodyStorage = pcr.ifthen( - self.landmask, pcr.cover(self.waterBodyStorage, 0.0) - ) + if not isinstance(self.waterBodyStorage, type(None)): + self.waterBodyStorage = pcr.ifthen(self.landmask, pcr.cover(self.waterBodyStorage, 0.0)) def estimateBankfullDischarge(self, bankfullWidth, factor=4.8): @@ -672,11 +669,8 @@ iniItems.get("globalOptions", "inputDir"), ) - # a dictionary contains areaFractions (dimensionless): fractions of flooded/innundated areas - areaFractions = map( - float, - iniItems.get("routingOptions", "relativeElevationLevels").split(","), - ) + # a dictionary contains areaFractions (dimensionless): fractions of flooded/innundated areas + areaFractions = list(map(float, iniItems.get("routingOptions","relativeElevationLevels").split(','))) # number of levels/intervals nrZLevels = len(areaFractions) # - TODO: Read areaFractions and nrZLevels automatically. @@ -798,8 +792,8 @@ yMean = pcr.cover(yMean, 0.01) # option to use constant channel width (m) - if not isinstance(self.predefinedChannelWidth, types.NoneType): - wMean = pcr.cover(self.predefinedChannelWidth, wMean) + if not isinstance(self.predefinedChannelWidth,type(None)):\ + wMean = pcr.cover(self.predefinedChannelWidth, wMean) # # minimum channel width (m) wMean = pcr.max(self.minChannelWidth, wMean) @@ -1207,10 +1201,8 @@ self.channelDepth = pcr.max(0.0, self.yMean) # # option to use constant channel depth (m) - if not isinstance(self.predefinedChannelDepth, types.NoneType): - self.channelDepth = pcr.cover( - self.predefinedChannelDepth, self.channelDepth - ) + if not isinstance(self.predefinedChannelDepth, type(None)):\ + self.channelDepth = pcr.cover(self.predefinedChannelDepth, self.channelDepth) # channel bankfull capacity (unit: m3) if self.floodPlain: Index: wflow-py/wflow/pcrglobwb/virtualOS.py =================================================================== diff -u -rea74d7d019652362ccf1714f1c6448955e24b49d -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/pcrglobwb/virtualOS.py (.../virtualOS.py) (revision ea74d7d019652362ccf1714f1c6448955e24b49d) +++ wflow-py/wflow/pcrglobwb/virtualOS.py (.../virtualOS.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -79,7 +79,9 @@ + str(ncFile) ) - if ncFile in filecache.keys(): + logger.debug('Check whether the variable: '+str(varName)+' is defined in the file: '+str(ncFile)) + + if ncFile in list(filecache.keys()): f = filecache[ncFile] # ~ print "Cached: ", ncFile else: @@ -88,10 +90,10 @@ # ~ print "New: ", ncFile varName = str(varName) + + return varName in list(f.variables.keys()) - return varName in f.variables.keys() - def netcdf2PCRobjCloneWithoutTime( ncFile, varName, @@ -112,7 +114,7 @@ # Only works if cells are 'square'. # Only works if cellsizeClone <= cellsizeInput # Get netCDF file and variable name: - if ncFile in filecache.keys(): + if ncFile in list(filecache.keys()): f = filecache[ncFile] # ~ print "Cached: ", ncFile else: @@ -219,12 +221,12 @@ # Only works if cells are 'square'. # Only works if cellsizeClone <= cellsizeInput # Get netCDF file and variable name: - - # ~ print ncFile - - logger.debug("reading variable: " + str(varName) + " from the file: " + str(ncFile)) - - if ncFile in filecache.keys(): + + #~ print ncFile + + logger.debug('reading variable: '+str(varName)+' from the file: '+str(ncFile)) + + if ncFile in list(filecache.keys()): f = filecache[ncFile] # ~ print "Cached: ", ncFile else: @@ -567,12 +569,12 @@ # Only works if cells are 'square'. # Only works if cellsizeClone <= cellsizeInput # Get netCDF file and variable name: - - # ~ print ncFile - - logger.debug("reading variable: " + str(varName) + " from the file: " + str(ncFile)) - - if ncFile in filecache.keys(): + + #~ print ncFile + + logger.debug('reading variable: '+str(varName)+' from the file: '+str(ncFile)) + + if ncFile in list(filecache.keys()): f = filecache[ncFile] # ~ print "Cached: ", ncFile else: @@ -1419,50 +1421,26 @@ return False -def getMapAttributesALL(cloneMap, arcDegree=True): - cOut, err = subprocess.Popen( - str("mapattr -p %s " % (cloneMap)), - stdout=subprocess.PIPE, - stderr=open(os.devnull), - shell=True, - ).communicate() - - if err != None or cOut == []: - print "Something wrong with mattattr in virtualOS, maybe clone Map does not exist ? " + if err !=None or cOut == []: + print("Something wrong with mattattr in virtualOS, maybe clone Map does not exist ? ") sys.exit() cellsize = float(cOut.split()[7]) - if arcDegree == True: - cellsize = round(cellsize * 360000.) / 360000. - mapAttr = { - "cellsize": float(cellsize), - "rows": float(cOut.split()[3]), - "cols": float(cOut.split()[5]), - "xUL": float(cOut.split()[17]), - "yUL": float(cOut.split()[19]), - } - co = None - cOut = None - err = None - del co - del cOut - del err - n = gc.collect() - del gc.garbage[:] - n = None - del n - return mapAttr + if arcDegree == True: cellsize = round(cellsize * 360000.)/360000. + mapAttr = {'cellsize': float(cellsize) ,\ + 'rows' : float(cOut.split()[3]) ,\ + 'cols' : float(cOut.split()[5]) ,\ + 'xUL' : float(cOut.split()[17]),\ + 'yUL' : float(cOut.split()[19])} + co = None; cOut = None; err = None + del co; del cOut; del err + n = gc.collect() ; del gc.garbage[:] ; n = None ; del n + return mapAttr - -def getMapAttributes(cloneMap, attribute, arcDegree=True): - cOut, err = subprocess.Popen( - str("mapattr -p %s " % (cloneMap)), - stdout=subprocess.PIPE, - stderr=open(os.devnull), - shell=True, - ).communicate() - # print cOut - if err != None or cOut == []: - print "Something wrong with mattattr in virtualOS, maybe clone Map does not exist ? " +def getMapAttributes(cloneMap,attribute,arcDegree=True): + cOut,err = subprocess.Popen(str('mapattr -p %s ' %(cloneMap)), stdout=subprocess.PIPE,stderr=open(os.devnull),shell=True).communicate() + #print cOut + if err !=None or cOut == []: + print("Something wrong with mattattr in virtualOS, maybe clone Map does not exist ? ") sys.exit() # print cOut.split() co = None @@ -1573,38 +1551,36 @@ def secondsPerDay(): return float(3600 * 24) + +def getValDivZero(x,y,y_lim=smallNumber,z_def= 0.): + #-returns the result of a division that possibly involves a zero + # denominator; in which case, a default value is substituted: + # x/y= z in case y > y_lim, + # x/y= z_def in case y <= y_lim, where y_lim -> 0. + # z_def is set to zero if not otherwise specified + return pcr.ifthenelse(y > y_lim,x/pcr.max(y_lim,y),z_def) +def getValFloatDivZero(x,y,y_lim,z_def= 0.): + #-returns the result of a division that possibly involves a zero + # denominator; in which case, a default value is substituted: + # x/y= z in case y > y_lim, + # x/y= z_def in case y <= y_lim, where y_lim -> 0. + # z_def is set to zero if not otherwise specified + if y > y_lim: + return x / max(y_lim,y) + else: + return z_def -def getValDivZero(x, y, y_lim=smallNumber, z_def=0.): - # -returns the result of a division that possibly involves a zero - # denominator; in which case, a default value is substituted: - # x/y= z in case y > y_lim, - # x/y= z_def in case y <= y_lim, where y_lim -> 0. - # z_def is set to zero if not otherwise specified - return pcr.ifthenelse(y > y_lim, x / pcr.max(y_lim, y), z_def) - -def getValFloatDivZero(x, y, y_lim, z_def=0.): - # -returns the result of a division that possibly involves a zero - # denominator; in which case, a default value is substituted: - # x/y= z in case y > y_lim, - # x/y= z_def in case y <= y_lim, where y_lim -> 0. - # z_def is set to zero if not otherwise specified - if y > y_lim: - return x / max(y_lim, y) - else: - return z_def - - -def retrieveMapValue(pcrX, coordinates): - # -retrieves values from a map and returns an array conform the IDs stored in properties - nrRows = coordinates.shape[0] - x = np.ones((nrRows)) * MV - tmpIDArray = pcr.pcr2numpy(pcrX, MV) - for iCnt in xrange(nrRows): - row, col = coordinates[iCnt, :] - if row != MV and col != MV: - x[iCnt] = tmpIDArray[row, col] +def retrieveMapValue(pcrX,coordinates): + #-retrieves values from a map and returns an array conform the IDs stored in properties + nrRows= coordinates.shape[0] + x= np.ones((nrRows))* MV + tmpIDArray= pcr.pcr2numpy(pcrX,MV) + for iCnt in range(nrRows): + row,col= coordinates[iCnt,:] + if row != MV and col != MV: + x[iCnt]= tmpIDArray[row,col] return x @@ -1613,16 +1589,16 @@ if x.ndim == 1: nrRows = 1 - tempIDArray = pcr.pcr2numpy(pcrX, MV) - # print tempIDArray - temporary = tempIDArray - nrRows = coord.shape[0] - for iCnt in xrange(nrRows): - row, col = coord[iCnt, :] - if row != MV and col != MV: - tempIDArray[row, col] = x[iCnt] - # print iCnt,row,col,x[iCnt] - pcrX = pcr.numpy2pcr(pcr.Scalar, tempIDArray, MV) + tempIDArray= pcr.pcr2numpy(pcrX,MV) + #print tempIDArray + temporary= tempIDArray + nrRows= coord.shape[0] + for iCnt in range(nrRows): + row,col= coord[iCnt,:] + if row != MV and col != MV: + tempIDArray[row,col]= (x[iCnt]) + # print iCnt,row,col,x[iCnt] + pcrX= pcr.numpy2pcr(pcr.Scalar,tempIDArray,MV) return pcrX @@ -1795,7 +1771,7 @@ # if abs(a) > 1e-5 or abs(b) > 1e-5: # if abs(a) > 1e-4 or abs(b) > 1e-4: if abs(a) > threshold or abs(b) > threshold: - print "WBError %s Min %f Max %f Mean %f" % (processName, a, b, c) + print("WBError %s Min %f Max %f Mean %f" %(processName,a,b,c)) # if abs(inflow + deltaS - outflow) > 1e-5: # print "Water balance Error for %s on %s: in = %f\tout=%f\tdeltaS=%f\tBalance=%f" \ # %(processName,dateStr,inflow,outflow,deltaS,inflow + deltaS - outflow) @@ -1904,27 +1880,14 @@ ) # water balance check - if debug_water_balance and not isinstance(zone_area, types.NoneType): - waterBalanceCheck( - [ - pcr.cover( - pcr.areatotal(cellAbstraction, allocation_zones) / zone_area, - 0.0, - ) - ], - [ - pcr.cover( - pcr.areatotal(cellAllocation, allocation_zones) / zone_area, 0.0 - ) - ], - [pcr.scalar(0.0)], - [pcr.scalar(0.0)], - "abstraction - allocation per zone/segment (with high precision) - loop (power number): " - + str(power_number), - True, - extra_info_for_water_balance_reporting, - threshold=1e-5, - ) + if debug_water_balance and not isinstance(zone_area,type(None)): + waterBalanceCheck([pcr.cover(pcr.areatotal(cellAbstraction, allocation_zones)/zone_area, 0.0)],\ + [pcr.cover(pcr.areatotal(cellAllocation , allocation_zones)/zone_area, 0.0)],\ + [pcr.scalar(0.0)],\ + [pcr.scalar(0.0)],\ + 'abstraction - allocation per zone/segment (with high precision) - loop (power number): ' + str(power_number) ,\ + True,\ + extra_info_for_water_balance_reporting, threshold = 1e-5) # actual water abstraction and allocation in this current loop (power number) cell_abstrac_for_every_power_number[str(power_number)] = cellAbstraction @@ -1942,26 +1905,15 @@ sumCellAllocation += cell_allocat_for_every_power_number[str(power_number)] # water balance check - if debug_water_balance and not isinstance(zone_area, types.NoneType): - waterBalanceCheck( - [ - pcr.cover( - pcr.areatotal(sumCellAbstraction, allocation_zones) / zone_area, 0.0 - ) - ], - [ - pcr.cover( - pcr.areatotal(sumCellAllocation, allocation_zones) / zone_area, 0.0 - ) - ], - [pcr.scalar(0.0)], - [pcr.scalar(0.0)], - "abstraction - allocation per zone/segment (with high precision) - sum after loop", - True, - extra_info_for_water_balance_reporting, - threshold=1e-5, - ) - + if debug_water_balance and not isinstance(zone_area,type(None)): + waterBalanceCheck([pcr.cover(pcr.areatotal(sumCellAbstraction, allocation_zones)/zone_area, 0.0)],\ + [pcr.cover(pcr.areatotal(sumCellAllocation , allocation_zones)/zone_area, 0.0)],\ + [pcr.scalar(0.0)],\ + [pcr.scalar(0.0)],\ + 'abstraction - allocation per zone/segment (with high precision) - sum after loop' ,\ + True,\ + extra_info_for_water_balance_reporting, threshold = 1e-5) + return sumCellAbstraction, sumCellAllocation @@ -1981,7 +1933,7 @@ # demand volume in each cell (unit: m3) cellVolDemand = pcr.max(0.0, water_demand_volume) - if not isinstance(landmask, types.NoneType): + if not isinstance(landmask, type(None)): cellVolDemand = pcr.ifthen(landmask, pcr.cover(cellVolDemand, 0.0)) if ignore_small_values: # ignore small values to avoid runding error cellVolDemand = pcr.rounddown(pcr.max(0.0, water_demand_volume)) @@ -1993,16 +1945,16 @@ # total available water volume in each cell cellAvlWater = pcr.max(0.0, available_water_volume) - if not isinstance(landmask, types.NoneType): + if not isinstance(landmask, type(None)): cellAvlWater = pcr.ifthen(landmask, pcr.cover(cellAvlWater, 0.0)) if ignore_small_values: # ignore small values to avoid runding error cellAvlWater = pcr.rounddown(pcr.max(0.00, available_water_volume)) else: cellAvlWater = pcr.max(0.0, available_water_volume) # total available water volume in each zone/segment (unit: m3) - # - to minimize numerical errors, separating cellAvlWater - if not isinstance(high_volume_treshold, types.NoneType): + # - to minimize numerical errors, separating cellAvlWater + if not isinstance(high_volume_treshold,type(None)): # mask: 0 for small volumes ; 1 for large volumes (e.g. in lakes and reservoirs) mask = pcr.cover( pcr.ifthen(cellAvlWater > high_volume_treshold, pcr.boolean(1)), @@ -2028,8 +1980,8 @@ cellAbstraction = pcr.min(cellAbstraction, cellAvlWater) if ignore_small_values: # ignore small values to avoid runding error cellAbstraction = pcr.rounddown(pcr.max(0.00, cellAbstraction)) - # to minimize numerical errors, separating cellAbstraction - if not isinstance(high_volume_treshold, types.NoneType): + # to minimize numerical errors, separating cellAbstraction + if not isinstance(high_volume_treshold,type(None)): # mask: 0 for small volumes ; 1 for large volumes (e.g. in lakes and reservoirs) mask = pcr.cover( pcr.ifthen(cellAbstraction > high_volume_treshold, pcr.boolean(1)), @@ -2069,40 +2021,28 @@ - pcr.areatotal(cellAllocation, allocation_zones), ) remainingCellDemand = pcr.max(0.0, cellVolDemand - cellAllocation) - cellAllocation += zoneDeficitAllocation * getValDivZero( - remainingCellDemand, - pcr.areatotal(remainingCellDemand, allocation_zones), - smallNumber, - ) + cellAllocation += zoneDeficitAllocation * getValDivZero(\ + remainingCellDemand, + pcr.areatotal(remainingCellDemand, allocation_zones), + smallNumber) + + if debug_water_balance and not isinstance(zone_area,type(None)): - if debug_water_balance and not isinstance(zone_area, types.NoneType): - - waterBalanceCheck( - [ - pcr.cover( - pcr.areatotal(cellAbstraction, allocation_zones) / zone_area, 0.0 - ) - ], - [ - pcr.cover( - pcr.areatotal(cellAllocation, allocation_zones) / zone_area, 0.0 - ) - ], - [pcr.scalar(0.0)], - [pcr.scalar(0.0)], - "abstraction - allocation per zone/segment (PS: Error here may be caused by rounding error.)", - True, - extra_info_for_water_balance_reporting, - threshold=1e-4, - ) - + waterBalanceCheck([pcr.cover(pcr.areatotal(cellAbstraction, allocation_zones)/zone_area, 0.0)],\ + [pcr.cover(pcr.areatotal(cellAllocation , allocation_zones)/zone_area, 0.0)],\ + [pcr.scalar(0.0)],\ + [pcr.scalar(0.0)],\ + 'abstraction - allocation per zone/segment (PS: Error here may be caused by rounding error.)' ,\ + True,\ + extra_info_for_water_balance_reporting,threshold=1e-4) + return cellAbstraction, cellAllocation def findLastYearInNCFile(ncFile): # open a netcdf file: - if ncFile in filecache.keys(): + if ncFile in list(filecache.keys()): f = filecache[ncFile] else: f = nc.Dataset(ncFile) Index: wflow-py/wflow/pcrglobwb/waterBodies.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/pcrglobwb/waterBodies.py (.../waterBodies.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/pcrglobwb/waterBodies.py (.../waterBodies.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -32,7 +32,7 @@ logger = logging.getLogger("wflow_pcrglobwb") -import virtualOS as vos +from . import virtualOS as vos from wflow.wf_DynamicFramework import configsection from wflow.wf_DynamicFramework import configget @@ -414,9 +414,9 @@ avgInflow = initial_condition["avgLakeReservoirInflowShort"] avgOutflow = initial_condition["avgLakeReservoirOutflowLong"] # - if not isinstance(initial_condition["waterBodyStorage"], types.NoneType): - # read directly - waterBodyStorage = initial_condition["waterBodyStorage"] + if not isinstance(initial_condition['waterBodyStorage'],type(None)): + # read directly + waterBodyStorage = initial_condition['waterBodyStorage'] else: # calculate waterBodyStorage at cells where lakes and/or reservoirs are defined # @@ -543,16 +543,13 @@ downstreamDemand=None, ): - # outflow in volume from water bodies with lake type (m3): - lakeOutflow = self.getLakeOutflow(avgChannelDischarge, length_of_time_step) + # outflow in volume from water bodies with lake type (m3): + lakeOutflow = self.getLakeOutflow(avgChannelDischarge,length_of_time_step) + + # outflow in volume from water bodies with reservoir type (m3): + if isinstance(downstreamDemand, type(None)): downstreamDemand = pcr.scalar(0.0) + reservoirOutflow = self.getReservoirOutflow(avgChannelDischarge,length_of_time_step,downstreamDemand) - # outflow in volume from water bodies with reservoir type (m3): - if isinstance(downstreamDemand, types.NoneType): - downstreamDemand = pcr.scalar(0.0) - reservoirOutflow = self.getReservoirOutflow( - avgChannelDischarge, length_of_time_step, downstreamDemand - ) - # outgoing/release volume from lakes and/or reservoirs self.waterBodyOutflow = pcr.cover(reservoirOutflow, lakeOutflow) Index: wflow-py/wflow/pcrut.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/pcrut.py (.../pcrut.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/pcrut.py (.../pcrut.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -75,9 +75,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -110,7 +109,7 @@ logger.debug("File logging to " + logfilename) return logger except IOError: - print "ERROR: Failed to initialize logger with logfile: " + logfilename + print("ERROR: Failed to initialize logger with logfile: " + logfilename) sys.exit(2) @@ -163,8 +162,8 @@ # dumm[:] = 1E-31 # return numpy.vstack((dumm,mat[1:])), head else: - print nname + " does not exists." - + print(nname + " does not exists.") + return @@ -233,19 +232,19 @@ fname_tbl = table + str(step) + ".tbl" if os.path.exists(fname_map): - print "found: " + fname_map + print("found: " + fname_map) tableToMapSparse._tableToMap_LastMap[map] = step if os.path.exists(fname_tbl): - print "found: " + fname_tbl + print("found: " + fname_tbl) tableToMapSparse._tableToMap_LastTbl[table] = step - if tableToMapSparse._tableToMap_LastTbl.has_key(table) == False: + if (table in tableToMapSparse._tableToMap_LastTbl) == False: fname_tbl = table + ".tbl" else: fname_tbl = table + str(tableToMapSparse._tableToMap_LastTbl[table]) + ".tbl" - if tableToMapSparse._tableToMap_LastMap.has_key(map) == False: + if (map in tableToMapSparse._tableToMap_LastMap) == False: fname_map = map + ".map" else: fname_map = map + str(tableToMapSparse._tableToMap_LastMap[map]) + ".map" Index: wflow-py/wflow/plottss.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/plottss.py (.../plottss.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/plottss.py (.../plottss.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -38,9 +38,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) Index: wflow-py/wflow/reservoir_Sa.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/reservoir_Sa.py (.../reservoir_Sa.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/reservoir_Sa.py (.../reservoir_Sa.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -21,9 +21,9 @@ try: from wflow.wf_DynamicFramework import * except ImportError: - from wf_DynamicFramework import * + from .wf_DynamicFramework import * import scipy -import JarvisCoefficients +from . import JarvisCoefficients def selectSaR(i): Index: wflow-py/wflow/reservoir_Sf.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/reservoir_Sf.py (.../reservoir_Sf.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/reservoir_Sf.py (.../reservoir_Sf.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -14,7 +14,7 @@ try: from wflow.wf_DynamicFramework import * except ImportError: - from wf_DynamicFramework import * + from .wf_DynamicFramework import * import scipy Index: wflow-py/wflow/reservoir_Si.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/reservoir_Si.py (.../reservoir_Si.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/reservoir_Si.py (.../reservoir_Si.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -13,8 +13,8 @@ try: from wflow.wf_DynamicFramework import * except ImportError: - from wf_DynamicFramework import * -import JarvisCoefficients + from .wf_DynamicFramework import * +from . import JarvisCoefficients def selectSiR(i): Index: wflow-py/wflow/reservoir_Ss.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/reservoir_Ss.py (.../reservoir_Ss.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/reservoir_Ss.py (.../reservoir_Ss.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -17,7 +17,7 @@ try: from wflow.wf_DynamicFramework import * except ImportError: - from wf_DynamicFramework import * + from .wf_DynamicFramework import * import scipy Index: wflow-py/wflow/reservoir_Su.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/reservoir_Su.py (.../reservoir_Su.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/reservoir_Su.py (.../reservoir_Su.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -14,9 +14,9 @@ try: from wflow.wf_DynamicFramework import * except ImportError: - from wf_DynamicFramework import * + from .wf_DynamicFramework import * import scipy -import JarvisCoefficients +from . import JarvisCoefficients def selectSuR(i): Index: wflow-py/wflow/reservoir_Sw.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/reservoir_Sw.py (.../reservoir_Sw.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/reservoir_Sw.py (.../reservoir_Sw.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -21,9 +21,9 @@ try: from wflow.wf_DynamicFramework import * except ImportError: - from wf_DynamicFramework import * + from .wf_DynamicFramework import * import scipy -import JarvisCoefficients +from . import JarvisCoefficients def selectSwR(i): Index: wflow-py/wflow/sphy/glacier.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/sphy/glacier.py (.../glacier.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/sphy/glacier.py (.../glacier.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -1,4 +1,4 @@ -print "glacier module imported" +print('glacier module imported') # -Function to calculate melt from clean ice or debris covered glaciers def GlacCDMelt(pcr, temp, ddf, glacfrac): Index: wflow-py/wflow/sphy/groundwater.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/sphy/groundwater.py (.../groundwater.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/sphy/groundwater.py (.../groundwater.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -1,4 +1,4 @@ -print "groundwater module imported" +print('groundwater module imported') # -Function to calculate groundwater recharge def GroundWaterRecharge(pcr, deltagw, gwrecharge, subperc, glacperc): Index: wflow-py/wflow/sphy/routing.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/sphy/routing.py (.../routing.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/sphy/routing.py (.../routing.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -1,6 +1,5 @@ -print "routing module imported" +print('routing module imported') - def ROUT(pcr, q, oldq, flowdir, kx): rr = (q * 0.001 * pcr.cellarea()) / (24 * 3600) ra = pcr.accuflux(flowdir, rr) Index: wflow-py/wflow/sphy/snow.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/sphy/snow.py (.../snow.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/sphy/snow.py (.../snow.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -1,4 +1,4 @@ -print "snow module imported" +print('snow module imported') # -Function to calculate the potential snow melt def PotSnowMelt(pcr, temp, ddfs): Index: wflow-py/wflow/sphy/timecalc.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/sphy/timecalc.py (.../timecalc.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/sphy/timecalc.py (.../timecalc.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -11,14 +11,6 @@ # -Function to calculate the number of timesteps for the model run def timesteps(self): nrTimeSteps = (self.enddate - self.startdate).days + 1 - print "Running SPHY for " + str(self.startdate.day) + "-" + str( - self.startdate.month - ) + "-" + str(self.startdate.year) + " through " + str( - self.enddate.day - ) + "-" + str( - self.enddate.month - ) + "-" + str( - self.enddate.year - ) - print "with " + str(nrTimeSteps) + " daily timesteps" - return nrTimeSteps + print('Running SPHY for '+str(self.startdate.day)+'-'+str(self.startdate.month)+'-'+str(self.startdate.year)+' through '+str(self.enddate.day)+'-'+str(self.enddate.month)+'-'+str(self.enddate.year)) + print('with '+str(nrTimeSteps)+' daily timesteps') + return nrTimeSteps \ No newline at end of file Index: wflow-py/wflow/static_maps.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/static_maps.py (.../static_maps.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/static_maps.py (.../static_maps.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -21,7 +21,7 @@ import numpy as np # import admin packages -import ConfigParser +import configparser from optparse import OptionParser # import general packages @@ -182,11 +182,12 @@ # parse other maps into an array if not other_maps == None: if type(other_maps) == str: - print other_maps - other_maps = ( - other_maps.replace(" ", "").replace("[", "").replace("]", "").split(",") - ) + print(other_maps) + other_maps = other_maps.replace( + ' ', '').replace('[', '').replace(']', '').split(',') + + source = os.path.abspath(source) clone_map = os.path.join(source, "mask.map") clone_shp = os.path.join(source, "mask.shp") @@ -202,16 +203,16 @@ parser.print_help() sys.exit(1) if (inifile is not None) and (not os.path.exists(inifile)): - print "path to ini file cannot be found" + print('path to ini file cannot be found') sys.exit(1) if not os.path.exists(rivshp): - print "path to river shape cannot be found" + print('path to river shape cannot be found') sys.exit(1) if not os.path.exists(catchshp): - print "path to catchment shape cannot be found" + print('path to catchment shape cannot be found') sys.exit(1) if not os.path.exists(dem_in): - print "path to DEM cannot be found" + print('path to DEM cannot be found') sys.exit(1) # open a logger, dependent on verbose print to screen or not @@ -249,7 +250,7 @@ # READ CONFIG FILE # open config-file if inifile is None: - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.optionxform = str else: config = wt.OpenConf(inifile) @@ -279,13 +280,8 @@ burn_gauges = wt.configget(config, "parameters", "burn_gauges", 100, datatype="int") minorder = wt.configget(config, "parameters", "riverorder_min", 3, datatype="int") try: - percentiles = np.array( - config.get("parameters", "statisticmaps", "0, 100") - .replace(" ", "") - .split(","), - dtype="float", - ) - except ConfigParser.NoOptionError: + percentiles = np.array(config.get('parameters', 'statisticmaps', '0, 100').replace(' ', '').split(','), dtype='float') + except configparser.NoOptionError: percentiles = [0.0, 100.0] # read the parameters for generating a temporary very high resolution grid if unit_clone == "degree": Index: wflow-py/wflow/stats.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/stats.py (.../stats.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/stats.py (.../stats.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -702,19 +702,10 @@ try: while tmpvalues[0] == NoData and len(tmpvalues) > 0: del tmpvalues[0] - except IndexError, errstr: - return ( - NoData, - NoData, - NoData, - NoData, - NoData, - NoData, - NoData, - [NoData], - [NoData], - ) - + except IndexError as errstr: + return ( NoData, NoData, NoData, NoData, NoData, NoData, NoData, + [NoData], [NoData] ) + Nact = len(values) # get median SubSetVals = [0] * 2 Index: wflow-py/wflow/testrunner_wflowhbv.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/testrunner_wflowhbv.py (.../testrunner_wflowhbv.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/testrunner_wflowhbv.py (.../testrunner_wflowhbv.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -31,7 +31,7 @@ """ -from wflow_hbv import * +from .wflow_hbv import * npmap0 = [] ltt = [] @@ -66,8 +66,8 @@ # Get list of variables supplied by the model dd = dynModelFw.wf_supplyVariableNamesAndRoles() - print dd - dynModelFw.wf_setValueLdd("TopoLdd", 5.0, 6.46823, 51.6821) + print(dd) + dynModelFw.wf_setValueLdd("TopoLdd",5.0,6.46823,51.6821) npmap0 = dynModelFw.wf_supplyMapAsNumpy("TopoLdd") ltt = dynModelFw.wf_supplyMapAsList("SurfaceRunoff") Index: wflow-py/wflow/wf_DynamicFramework.py =================================================================== diff -u -rba40a6612e674bbeaf3688a22ca91d7ebf9571f9 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wf_DynamicFramework.py (.../wf_DynamicFramework.py) (revision ba40a6612e674bbeaf3688a22ca91d7ebf9571f9) +++ wflow-py/wflow/wf_DynamicFramework.py (.../wf_DynamicFramework.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -14,29 +14,28 @@ # TODO: Fix timestep not forewarding in BMI runs (for reading writing maps) import datetime -import ConfigParser +import configparser from wflow.wf_netcdfio import * import wflow -import pcrut +from . import pcrut import glob import traceback -import wflow_adapt +from . import wflow_adapt from collections import namedtuple import logging from pcraster.framework import * -from wflow_lib import * +from .wflow_lib import * import time import calendar from wflow import __version__ +from functools import reduce +#from wflow import __release__ +#from wflow import __build__ -# from wflow import __release__ -# from wflow import __build__ - - def log_uncaught_exceptions(ex_cls, ex, tb): global logging logging.error("".join(traceback.format_tb(tb))) @@ -55,14 +54,8 @@ an interval base method (each model timestep is the interval between two input timesteps) """ - - def __init__( - self, - datetimestart=dt.datetime(1990, 01, 01), - datetimeend=dt.datetime(1990, 01, 05), - timestepsecs=86400, - mode="steps", - ): + def __init__(self, datetimestart=dt.datetime(1990, 0o1, 0o1),datetimeend=dt.datetime(1990, 0o1, 0o5), + timestepsecs=86400,mode='steps'): self.runStartTime = datetimestart self.runEndTime = datetimeend self.timeStepSecs = timestepsecs @@ -508,14 +501,8 @@ # \param firstTimestep sets the starting timestep of the model (optional, # default is 1) # - def __init__( - self, - userModel, - lastTimeStep=0, - firstTimestep=1, - datetimestart=dt.datetime(1990, 01, 01), - timestepsecs=86400, - ): + def __init__(self, userModel, lastTimeStep=0, firstTimestep=1, datetimestart=dt.datetime(1990, 0o1, 0o1), + timestepsecs=86400): frameworkBase.FrameworkBase.__init__(self) self.ParamType = namedtuple( @@ -627,7 +614,7 @@ for cmdd in self.modelparameters_changes_timestep: execstr = cmdd + " = " + self.modelparameters_changes_timestep[cmdd] try: - exec execstr + exec(execstr) except: self.logger.error( "Variable change string (apply_timestep) could not be executed: " @@ -638,7 +625,7 @@ for cmdd in self.modelparameters_changes_once: execstr = cmdd + " = " + self.modelparameters_changes_once[cmdd] try: - exec execstr + exec(execstr) except: self.logger.error( "Variable change string (apply_once) could not be executed: " @@ -748,11 +735,9 @@ if par.type == "hourlyclim": if not hasattr(self._userModel(), par.name): - self._userModel().logger.info( - "Adding " + par.name + " to model." - ) - print "hourlyclim has " + par.name + par.stack - print "not been implemented yet" + self._userModel().logger.info("Adding " + par.name + " to model.") + print("hourlyclim has " + par.name + par.stack) + print("not been implemented yet") if par.type == "dailyclim": if not hasattr(self._userModel(), par.name): @@ -851,7 +836,7 @@ ) self._userModel().config.write(fp) - for key, value in self.oscv.iteritems(): + for key, value in self.oscv.items(): value.closeall() def loggingSetUp( @@ -1134,7 +1119,7 @@ else: if os.path.exists(caseName + "/" + runId + "/run.tss"): if NoOverWrite: - print "ERROR: refusing to overwrite an existing run: " + caseName + "/" + runId + "/run.tss" + print("ERROR: refusing to overwrite an existing run: " + caseName + "/" + runId + "/run.tss") sys.exit(1) for file in glob.glob(caseName + "/" + intbl + "/*.tbl"): @@ -1144,7 +1129,7 @@ caseName + "/" + configfile, caseName + "/" + runId + "/runinfo" ) except: - print "Cannot find config file: " + caseName + "/" + configfile + print("Cannot find config file: " + caseName + "/" + configfile) self._userModel().logger = self.loggingSetUp( caseName, runId, logfname, model, modelVersion, level=level @@ -1721,7 +1706,7 @@ try: fname = os.path.join(directory, var).replace("\\", "/") + ".map" execstr = "savevar = self._userModel()." + var - exec execstr + exec(execstr) try: # Check if we have a list of maps b = len(savevar) @@ -1763,7 +1748,7 @@ for a in self.samplenamecsv: found = 1 try: - exec "tmpvar = " + self.varnamecsv[a] + exec("tmpvar = " + self.varnamecsv[a]) except: found = 0 self.logger.fatal( @@ -1793,7 +1778,7 @@ for a in toprint: b = a.replace("self.", "") try: - exec "pcrmap = self._userModel()." + b + exec('pcrmap = self._userModel().' + b) # report( pcrmap , os.path.join(self._userModel().Dir, self._userModel().runId, "outsum", self._userModel().config.get("summary",a)) ) self.reportStatic( pcrmap, @@ -1967,9 +1952,9 @@ silent=True, ) if nr == 0: - exec "self._userModel()." + var + "= []" + exec("self._userModel()." + var + "= []") execstr = "self._userModel()." + var + ".append(tvar)" - exec execstr + exec(execstr) nr = nr + 1 else: if nr > 0: @@ -2020,7 +2005,7 @@ for var in allvars: try: - exec "self._userModel()." + var + "_laststep = self._userModel()." + var + exec("self._userModel()." + var + "_laststep = self._userModel()." + var) except: self.logger.warn("Problem saving state variable: " + var) @@ -2034,7 +2019,7 @@ allvars = self._userModel().stateVariables() for var in allvars: - exec "self._userModel()." + var + " = self._userModel()." + var + "_laststep" + exec("self._userModel()." + var + " = self._userModel()." + var + "_laststep") ts = self._userModel().currentTimeStep() self._userModel()._setCurrentTimeStep(ts) @@ -2062,7 +2047,7 @@ """ - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.optionxform = str if os.path.exists(os.path.join(caseName, configfile)): config.read(os.path.join(caseName, configfile)) @@ -2095,7 +2080,7 @@ if hasattr(self._userModel(), mapname): if "LDD" in mapname.upper(): - exec "self._userModel()." + mapname + " = lddrepair(ldd(arpcr))" + exec("self._userModel()." + mapname + " = lddrepair(ldd(arpcr))") else: setattr(self._userModel(), mapname, arpcr) @@ -2123,13 +2108,11 @@ self.setviaAPI[mapname] = 1 if hasattr(self._userModel(), mapname): - exec "self._userModel()." + mapname + " = arpcr" + exec("self._userModel()." + mapname + " = arpcr") return 1 else: - self.logger.debug( - mapname + " is not defined in the usermodel: setting anyway" - ) - exec "self._userModel()." + mapname + " = arpcr" + self.logger.debug(mapname + " is not defined in the usermodel: setting anyway") + exec("self._userModel()." + mapname + " = arpcr") return 0 def wf_setValues(self, mapname, values): @@ -2156,13 +2139,11 @@ arpcr = cover(scalar(values)) if hasattr(self._userModel(), mapname): - exec "self._userModel()." + mapname + " = arpcr" + exec("self._userModel()." + mapname + " = arpcr") return 1 else: - self.logger.debug( - mapname + " is not defined in the usermodel: setting anyway" - ) - exec "self._userModel()." + mapname + " = arpcr" + self.logger.debug(mapname + " is not defined in the usermodel: setting anyway") + exec("self._userModel()." + mapname + " = arpcr") return 0 def wf_setValueRowCol(self, mapname, value, row, col): @@ -2180,10 +2161,10 @@ """ self.setviaAPI[mapname] = 1 if hasattr(self._userModel(), mapname): - exec "ar = pcr2numpy(self._userModel()." + mapname + ",-999)" + exec("ar = pcr2numpy(self._userModel()." + mapname + ",-999)") ar[row, col] = value arpcr = numpy2pcr(Scalar, ar.copy(), -999) - exec "self._userModel()." + mapname + " = arpcr" + exec("self._userModel()." + mapname + " = arpcr") return 1 else: self.logger.debug( @@ -2213,7 +2194,7 @@ save("tt.np", ar) pcrmap = numpy2pcr(Scalar, ar.copy(), -999) report(pcrmap, "zz.map") - exec "self._userModel()." + mapname + " = pcrmap" + exec("self._userModel()." + mapname + " = pcrmap") return 1 else: self.logger.debug(mapname + " is not defined in the usermodel") @@ -2235,12 +2216,12 @@ """ self.setviaAPI[mapname] = 1 if hasattr(self._userModel(), mapname): - exec "pcrmap = self._userModel()." + mapname + exec("pcrmap = self._userModel()." + mapname) ar = pcr2numpy(pcrmap, -999) row, col = getRowColPoint(pcrmap, xcor, ycor) ar[row, col] = value arpcr = numpy2pcr(Scalar, ar.copy(), -999) - exec "self._userModel()." + mapname + " = lddrepair(ldd(arpcr))" + exec("self._userModel()." + mapname + " = lddrepair(ldd(arpcr))") return 1 else: self.logger.debug( @@ -2265,7 +2246,7 @@ arpcr = cover(value) self.setviaAPI[mapname] = 1 if hasattr(self._userModel(), mapname): - exec "self._userModel()." + mapname + " = arpcr * " + "self._userModel()." + mapname + exec("self._userModel()." + mapname + " = arpcr * " + "self._userModel()." + mapname) return 1 else: self.logger.debug( @@ -2293,9 +2274,8 @@ self.setviaAPI[mapname] = 1 if hasattr(self._userModel(), mapname): # exec "self._userModel()." + mapname + " = arpcr * " + "self._userModel()." + mapname - exec "self._userModel()." + mapname + " = ifthenelse(self._userModel()." + areamapname + " == " + str( - areacode - ) + " arpcr * self._userModel()." + areamapname + ", self._userModel()." + areamapname + " )" + exec("self._userModel()." + mapname + " = ifthenelse(self._userModel()." + areamapname + " == " + str( + areacode) + " arpcr * self._userModel()." + areamapname + ", self._userModel()." + areamapname + " )") return 1 else: self.logger.debug( @@ -2328,7 +2308,7 @@ arpcr = cover(values) if hasattr(self._userModel(), mapname): - exec "self._userModel()." + mapname + " = arpcr" + exec("self._userModel()." + mapname + " = arpcr") return 1 else: self.logger.debug( @@ -2349,7 +2329,7 @@ - list """ if hasattr(self._userModel(), mapname): - exec "retval = pcr2numpy(self._userModel()." + mapname + ",-999)" + exec("retval = pcr2numpy(self._userModel()." + mapname + ",-999)") return retval.flatten().tolist() else: self.logger.debug( @@ -2373,7 +2353,7 @@ """ if hasattr(self._userModel(), mapname): - exec "retval = pcr2numpy(self._userModel()." + mapname + ",-999)" + exec("retval = pcr2numpy(self._userModel()." + mapname + ",-999)") if self.APIDebug: self.logger.debug("wf_supplyMapAsList returning: " + mapname) @@ -2572,7 +2552,7 @@ - the a list of variable names """ varlist = self.wf_supplyVariableNamesAndRoles() - ret = range(len(varlist)) + ret = list(range(len(varlist))) for ss in range(len(varlist)): ret[ss] = varlist[ss][0] @@ -2587,7 +2567,7 @@ - the a list of variable roles """ varlist = self.wf_supplyVariableNamesAndRoles() - ret = range(len(varlist)) + ret = list(range(len(varlist))) for ss in range(len(varlist)): ret[ss] = varlist[ss][1] @@ -2616,7 +2596,7 @@ - the a list of variable units """ varlist = self.wf_supplyVariableNamesAndRoles() - ret = range(len(varlist)) + ret = list(range(len(varlist))) for ss in range(len(varlist)): ret[ss] = varlist[ss][2] @@ -3311,15 +3291,13 @@ # first get basename (last bit of path) name = os.path.basename(name) if hasattr(self._userModel(), name): - exec "retval = cover(self._userModel()." + name + ",scalar(default))" + exec("retval = cover(self._userModel()." + name + ",scalar(default))") return retval else: - self.logger.warn( - "Variable: " + name + " not set by API, returning default" - ) - exec "self._userModel()." + name + " = cover(scalar(default))" + self.logger.warn("Variable: " + name + " not set by API, returning default") + exec("self._userModel()." + name + " = cover(scalar(default))") # setattr(self._userModel(),name,clone()) - exec "retval = self._userModel()." + name + exec("retval = self._userModel()." + name) return retval else: self.logger.warn( Index: wflow-py/wflow/wf_netcdfio.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wf_netcdfio.py (.../wf_netcdfio.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/wf_netcdfio.py (.../wf_netcdfio.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -376,7 +376,7 @@ miss = float(nc_var._FillValue) data = pcr2numpy(scalar(pcrdata), miss) - if self.bufflst.has_key(var): + if var in self.bufflst: self.bufflst[var][bufpos, :, :] = data else: self.bufflst[var] = self.timestepbuffer.copy() @@ -551,7 +551,7 @@ miss = float(nc_var._FillValue) data = pcr2numpy(scalar(pcrdata), miss) - if self.bufflst.has_key(var): + if var in self.bufflst: self.bufflst[var][bufpos, :, :] = data self.buffdirty = True else: @@ -780,29 +780,19 @@ ) ncindex = pos - if self.alldat.has_key(var): - # if ncindex == self.lstep: # Read new block of data in mem - # logging.debug("reading new netcdf data block starting at: " + str(ncindex)) - # for vars in self.alldat: - # self.alldat[vars] = self.dataset.variables[vars][ncindex:ncindex + self.maxsteps] - # - # self.fstep = ncindex - # self.lstep = ncindex + self.maxsteps - if len(self.alldat[var].dimensions) == 3: - np_step = self.alldat[var][ - ncindex - self.fstep, - self.latidx.min() : self.latidx.max() + 1, - self.lonidx.min() : self.lonidx.max() + 1, - ] - if len(self.alldat[var].dimensions) == 4: - np_step = self.alldat[var][ - ncindex - self.fstep, - 0, - self.latidx.min() : self.latidx.max() + 1, - self.lonidx.min() : self.lonidx.max() + 1, - ] + if var in self.alldat: + if ncindex == self.lstep: # Read new block of data in mem + logging.debug("reading new netcdf data block starting at: " + str(ncindex)) + for vars in self.alldat: + self.alldat[vars] = reshape(self.dataset.variables[vars],(self.maxlentime,len(self.y),len(self.x)))[ncindex:ncindex + self.maxsteps] + self.fstep = ncindex + self.lstep = ncindex + self.maxsteps + + np_step = self.alldat[var][ncindex - self.fstep,self.latidx.min():self.latidx.max()+1, + self.lonidx.min():self.lonidx.max()+1] + miss = float(self.dataset.variables[var]._FillValue) if self.flip: return numpy2pcr(Scalar, flipud(np_step).copy(), miss), True @@ -1035,12 +1025,9 @@ var: variable to get from the file """ - if self.dataset.variables.has_key(var): - np_step = self.alldat[var][ - timestep - 1, - self.latidx.min() : self.latidx.max() + 1, - self.lonidx.min() : self.lonidx.max() + 1, - ] + if var in self.dataset.variables: + np_step = self.alldat[var][timestep-1, self.latidx.min():self.latidx.max() + 1, + self.lonidx.min():self.lonidx.max() + 1] miss = float(self.dataset.variables[var]._FillValue) return numpy2pcr(Scalar, np_step, miss), True else: Index: wflow-py/wflow/wflow_adapt.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_adapt.py (.../wflow_adapt.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_adapt.py (.../wflow_adapt.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -62,7 +62,7 @@ from glob import * import logging import logging.handlers -import ConfigParser +import configparser import numpy import wflow.wflow_lib as wflow_lib @@ -131,7 +131,7 @@ logger.debug("File logging to " + logfilename) return logger except IOError: - print "ERROR: Failed to initialize logger with logfile: " + logfilename + print("ERROR: Failed to initialize logger with logfile: " + logfilename) sys.exit(2) @@ -203,9 +203,9 @@ fo.write(aline) else: - print (inxml + " does not exists.") + print((inxml + " does not exists.")) + - def pixml_totss_dates(nname, outputdir): """ Gets Date/time info from XML file and creates .tss files with: @@ -243,9 +243,9 @@ ff.write(str(i) + "\t" + dt.strftime("%H\n")) i += 1 else: - print (nname + " does not exists.") + print((nname + " does not exists.")) + - def pixml_totss(nname, outputdir): """ Converts and PI xml timeseries file to a number of tss files. @@ -297,26 +297,31 @@ i = 0 for ev in events: parlocs[par] = 1 - if val.has_key((i, par)): - theval = val[i, par] + "\t" + ev.attrib["value"] - val[i, par] = theval - parlocs[par] = parlocs[par] + 1 - else: - val[i, par] = ev.attrib["value"] + if (i,par) in val: + theval = val[i,par] + '\t' + ev.attrib['value'] + val[i,par] = theval + parlocs[par] = parlocs[par] + 1 + else: + val[i,par] = ev.attrib['value'] i += 1 nrevents = i for par in uniqueParList: with open(outputdir + "/" + par + ".tss", "w") as f: # write the header - f.write("Parameter " + par + " taken from " + nname + "\n") - f.write(str(colsinfile + 1) + "\n") - f.write("Timestep\n") - for i in range(0, colsinfile): - f.write("Data column " + str(i) + "\n") - for i in range(0, nrevents): - f.write(str(i + 1) + "\t" + val[i, par] + "\n") + f.write('Parameter ' + par + ' taken from ' + nname + '\n') + f.write(str(colsinfile + 1) + '\n') + f.write('Timestep\n') + for i in range(0,colsinfile): + f.write('Data column ' + str(i) + '\n') + for i in range(0,nrevents): + f.write(str(i+1) + '\t' + val[i,par] + '\n') + + else: + print((nname + " does not exists.")) + + else: print (nname + " does not exists.") @@ -464,9 +469,10 @@ else: return diff.days + 1 # Should actually be + 1 but fews starts at 0! else: - print (xmlfile + " does not exists.") + print((xmlfile + " does not exists.")) + def getEndTimefromRuninfo(xmlfile): """ Gets the endtime of the run from the FEWS runinfo file @@ -480,7 +486,7 @@ edate.attrib["date"] + edate.attrib["time"], "%Y-%m-%d%H:%M:%S" ) else: - print (xmlfile + " does not exists.") + print((xmlfile + " does not exists.")) ed = None return ed @@ -520,8 +526,8 @@ edate.attrib["date"] + edate.attrib["time"], "%Y-%m-%d%H:%M:%S" ) else: - print (xmlfile + " does not exists.") - + print((xmlfile + " does not exists.")) + return ed @@ -554,9 +560,9 @@ try: opts, _ = getopt.getopt(sys.argv[1:], "-M:-t:-s:-o:-r:-w:-C:-I:R:") - except getopt.GetoptError, err: + except getopt.GetoptError as err: # print help information and exit: - print str(err) + print(str(err)) usage() sys.exit(2) @@ -593,7 +599,7 @@ assert False, "unhandled option" # Try and read config file and set default options - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.optionxform = str config.read(workdir + "/" + case + "/" + iniFile) Index: wflow-py/wflow/wflow_bmi.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_bmi.py (.../wflow_bmi.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_bmi.py (.../wflow_bmi.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -6,11 +6,11 @@ import parser import wflow.bmi as bmi -import wflow_lib +from . import wflow_lib import numpy as np from wflow.pcrut import setlogger from pcraster import * -import ConfigParser +import configparser def iniFileSetUp(configfile): @@ -19,7 +19,7 @@ """ - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.optionxform = str ret = config.read(configfile) return config @@ -169,23 +169,19 @@ maxNrSteps = 10000 maxNrSteps = 0 try: - exec "import wflow." + self.name + " as wf" + exec("import wflow." + self.name + " as wf") except: if "wflow" in configfile and "sbm" in configfile and ".ini" in configfile: - import wflow_sbm as wf - + from . import wflow_sbm as wf self.name = "wflow_sbm" elif "wflow" in configfile and "hbv" in configfile and ".ini" in configfile: - import wflow_hbv as wf - + from . import wflow_hbv as wf self.name = "wflow_hbv" - elif ( - "wflow" in configfile - and "routing" in configfile - and ".ini" in configfile - ): - import wflow_routing as wf + elif "wflow" in configfile and "routing" in configfile and ".ini" in configfile: + from . import wflow_routing as wf + self.name = "wflow_routing" + self.name = "wflow_routing" self.bmilogger.info( @@ -606,8 +602,8 @@ self.bmilogger.warn("Assuming " + self.name + " as model type.") try: - exec "import wflow." + self.name + " as wf" - except: # old method, shoudl not be used + exec("import wflow." + self.name + " as wf") + except: # old method, shoudl not be used if "wflow_sbm" in inifile: import wflow.wflow_sbm as wf @@ -630,7 +626,7 @@ self.name = "wflow_lintul" else: modname = os.path.splitext(os.path.basename(filename))[0] - exec "import wflow." + modname + " as wf" + exec("import wflow." + modname + " as wf") self.name = modname self.bmilogger.info( Index: wflow-py/wflow/wflow_bmi_combined.py =================================================================== diff -u -r5bc2c6406fea89698faa5d0ca1488dc25760b5e3 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_bmi_combined.py (.../wflow_bmi_combined.py) (revision 5bc2c6406fea89698faa5d0ca1488dc25760b5e3) +++ wflow-py/wflow/wflow_bmi_combined.py (.../wflow_bmi_combined.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -6,7 +6,7 @@ import os from wflow.pcrut import setlogger from wflow.wflow_lib import configget -import ConfigParser +import configparser import logging import numpy as np import json @@ -19,7 +19,7 @@ """ - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.optionxform = str config.read(configfile) return config @@ -175,28 +175,27 @@ # Initialize rtc bmi model object for mod in self.models: - if mod.startswith("RTC"): - bin_rtc = os.path.join( - self.datadir, self.config.get("RTC wrapper engine", "bin_rtc") - ) - print bin_rtc + if mod.startswith('RTC'): + bin_rtc = os.path.join(self.datadir,self.config.get('RTC wrapper engine','bin_rtc')) + print(bin_rtc) os.chdir(bin_rtc) import wflow.rtc_wflow_bmi as rtcwfbmi - - print bin_rtc - self.bmimodels[mod] = rtcwfbmi.rtcbmi_csdms( - os.path.join(bin_rtc, "RTCTools_BMI") - ) - + print(bin_rtc) + self.bmimodels[mod] = rtcwfbmi.rtcbmi_csdms(os.path.join(bin_rtc,"RTCTools_BMI")) + else: self.bmimodels[mod] = wfbmi.wflowbmi_csdms() # Initialize all wflow bmi model objects - for key, value in self.bmimodels.iteritems(): - if key.startswith("wflow"): - modconf = os.path.join(self.datadir, self.config.get("models", key)) - self.bmimodels[key].initialize_config(modconf, loglevel=loglevel) + for key, value in self.bmimodels.items(): + if key.startswith('wflow'): + modconf = os.path.join(self.datadir,self.config.get('models',key)) + self.bmimodels[key].initialize_config(modconf,loglevel=loglevel) + + + + def initialize_model(self): """ *Extended functionality*, see https://github.com/eWaterCycle/bmi/blob/master/src/main/python/bmi.py @@ -207,11 +206,11 @@ :return: nothing """ - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): self.bmimodels[key].initialize_model() # Copy and set the variables to be exchanged for step 0 - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): # step one update first model curmodel = self.bmimodels[key].get_component_name() for (item, idfrom, idto) in zip( @@ -248,7 +247,7 @@ :var double time: time in the units and epoch returned by the function get_time_units. """ - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): time = self.bmimodels[key].get_start_time() @@ -266,8 +265,8 @@ :param start_time: time in units (seconds) since the epoch :return: nothing """ - for key, value in self.bmimodels.iteritems(): - if key.startswith("wflow"): + for key, value in self.bmimodels.items(): + if key.startswith('wflow'): self.bmimodels[key].set_start_time(start_time) def set_end_time(self, end_time): @@ -277,8 +276,8 @@ :param end_time: time in units (seconds) since the epoch :return: """ - for key, value in self.bmimodels.iteritems(): - if key.startswith("wflow"): + for key, value in self.bmimodels.items(): + if key.startswith('wflow'): self.bmimodels[key].set_end_time(end_time) def get_attribute_names(self): @@ -288,7 +287,7 @@ :return: list of attributes """ names = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): names.append(self.bmimodels[key].get_attribute_names()) names[-1] = [ self.bmimodels[key].get_component_name() + self.comp_sep + s @@ -335,7 +334,7 @@ The function iterates over all models """ - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): self.bmimodels[key].update() @@ -389,7 +388,7 @@ nrstepsback = int(timespan / self.get_time_step()) if nrstepsback > 1: raise ValueError("Time more than one timestep before current time.") - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): self.bmimodels[key].dynModel.wf_QuickResume() else: @@ -417,7 +416,7 @@ :var destination_directory: the directory in which the state files should be written. """ - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): self.bmimodels[key].save_state(destination_directory) def load_state(self, source_directory): @@ -428,15 +427,15 @@ :var source_directory: the directory from which the state files should be read. """ - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): self.bmimodels[key].load_state(source_directory) def finalize(self): """ Shutdown the library and clean up the model. Uses the default (model configured) state location to also save states. """ - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): self.bmimodels[key].finalize() self.bmilogger.info("finalize.") @@ -446,7 +445,7 @@ :return: identifier of the models separated by a comma (,) """ names = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): names.append(self.bmimodels[key].get_component_name()) return ",".join(names) @@ -457,7 +456,7 @@ :return: List of String objects: identifiers of all input variables of the model: """ names = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): names.append(self.bmimodels[key].get_input_var_names()) names[-1] = [ self.bmimodels[key].get_component_name() + self.comp_sep + s @@ -474,7 +473,7 @@ :return: List of String objects: identifiers of all output variables of the model: """ names = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): names.append(self.bmimodels[key].get_output_var_names()) names[-1] = [ self.bmimodels[key].get_component_name() + self.comp_sep + s @@ -494,7 +493,7 @@ # first part should be the component name cname = long_var_name.split(self.comp_sep) - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): nn = self.bmimodels[key].get_component_name() if nn == cname[0]: ret = self.bmimodels[key].get_var_type(cname[1]) @@ -510,7 +509,7 @@ """ # first part should be the component name cname = long_var_name.split(self.comp_sep) - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): nn = self.bmimodels[key].get_component_name() if nn == cname[0]: ret = self.bmimodels[key].get_var_rank(cname[1]) @@ -526,7 +525,7 @@ """ # first part should be the component name cname = long_var_name.split(self.comp_sep) - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): nn = self.bmimodels[key].get_component_name() if nn == cname[0]: ret = self.bmimodels[key].get_var_size(cname[1]) @@ -542,7 +541,7 @@ """ # first part should be the component name cname = long_var_name.split(self.comp_sep) - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): nn = self.bmimodels[key].get_component_name() if nn == cname[0]: ret = self.bmimodels[key].get_var_nbytes(cname[1]) @@ -556,7 +555,7 @@ :return: start time of last model in the list. Tiem sare assumed to be identical """ st = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): st.append(self.bmimodels[key].get_start_time()) return numpy.array(st).max() @@ -569,7 +568,7 @@ """ st = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): st.append(self.bmimodels[key].get_current_time()) return st[-1] @@ -582,7 +581,7 @@ :return: end time of simulation n the units and epoch returned by the function get_time_units """ st = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): st.append(self.bmimodels[key].get_end_time()) return numpy.array(st).min() @@ -594,7 +593,7 @@ :return: duration of one time step of the model with the largest! timestep. """ st = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): st.append(self.bmimodels[key].get_time_step()) return max(st)[0] @@ -607,7 +606,7 @@ (http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/cf-conventions.html#time-coordinate) """ st = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): st.append(self.bmimodels[key].get_time_units()) return st[-1] @@ -622,7 +621,7 @@ # first part should be the component name self.bmilogger.debug("get_value: " + long_var_name) cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: tmp = self.bmimodels[cname[0]].get_value(cname[1]) if self.wrtodisk: report( @@ -645,7 +644,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: tmp = self.bmimodels[cname[0]].get_value(cname[1]) if self.wrtodisk: report( @@ -668,8 +667,8 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): - self.bmimodels[cname[0]].set_value_at_indices(cname[1], inds, src) + if cname[0] in self.bmimodels: + self.bmimodels[cname[0]].set_value_at_indices(cname[1], inds,src) if self.wrtodisk: npmap = self.bmimodels[cname[0]].getnumpy(cname[1], inds, src) report( @@ -687,7 +686,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_type(cname[1]) else: return None @@ -702,7 +701,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_shape(cname[1]) else: return None @@ -717,7 +716,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_spacing(cname[1]) else: return None @@ -732,7 +731,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_origin(cname[1]) else: return None @@ -748,7 +747,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_x(cname[1]) else: return None @@ -765,7 +764,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_y(cname[1]) else: return None @@ -780,7 +779,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_z(cname[1]) else: return None @@ -797,7 +796,7 @@ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_var_units(cname[1]) else: return None @@ -813,8 +812,8 @@ # first part should be the component name self.bmilogger.debug("set_value: " + long_var_name) cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): - self.bmimodels[cname[0]].set_value(cname[1], src) + if cname[0] in self.bmimodels: + self.bmimodels[cname[0]].set_value(cname[1],src) if self.wrtodisk: report( numpy2pcr(Scalar, src, -999), Index: wflow-py/wflow/wflow_bmi_combined_mp.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_bmi_combined_mp.py (.../wflow_bmi_combined_mp.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/wflow_bmi_combined_mp.py (.../wflow_bmi_combined_mp.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -5,7 +5,7 @@ import os from wflow.pcrut import setlogger from wflow.wflow_lib import configget -import ConfigParser +import configparser import logging from pcraster import * import multiprocessing @@ -17,7 +17,7 @@ """ - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.optionxform = str config.read(configfile) return config @@ -122,10 +122,12 @@ self.bmimodels[mod] = wfbmi.wflowbmi_csdms() # Initialize all bmi model objects - for key, value in self.bmimodels.iteritems(): - modconf = os.path.join(self.datadir, self.config.get("models", key)) - self.bmimodels[key].initialize_config(modconf, loglevel=loglevel) + for key, value in self.bmimodels.items(): + modconf = os.path.join(self.datadir,self.config.get('models',key)) + self.bmimodels[key].initialize_config(modconf,loglevel=loglevel) + + def initialize_model(self): """ *Extended functionality*, see https://github.com/eWaterCycle/bmi/blob/master/src/main/python/bmi.py @@ -136,11 +138,11 @@ :return: nothing """ - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): self.bmimodels[key].initialize_model() # Copy and set the variables to be exchanged for step 0 - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): # step one update first model curmodel = self.bmimodels[key].get_component_name() for item in self.exchanges: @@ -159,7 +161,7 @@ :param start_time: time in units (seconds) since the epoch :return: nothing """ - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): self.bmimodels[key].set_start_time(start_time) def set_end_time(self, end_time): @@ -169,7 +171,7 @@ :param end_time: time in units (seconds) since the epoch :return: """ - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): self.bmimodels[key].set_end_time(end_time) def get_attribute_names(self): @@ -179,7 +181,7 @@ :return: list of attributes """ names = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): names.append(self.bmimodels[key].get_attribute_names()) names[-1] = [ self.bmimodels[key].get_component_name() + self.comp_sep + s @@ -225,7 +227,7 @@ The function iterates over all models """ - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): # step one update model self.bmimodels[key].update() # do all exchanges @@ -258,7 +260,7 @@ nrstepsback = int(timespan / self.get_time_step()) if nrstepsback > 1: raise ValueError("Time more than one timestep before current time.") - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): self.bmimodels[key].dynModel.wf_QuickResume() else: @@ -286,7 +288,7 @@ :var destination_directory: the directory in which the state files should be written. """ - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): self.bmimodels[key].save_state(destination_directory) def load_state(self, source_directory): @@ -297,15 +299,15 @@ :var source_directory: the directory from which the state files should be read. """ - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): self.bmimodels[key].save_state(source_directory) def finalize(self): """ Shutdown the library and clean up the model. Uses the default (model configured) state location to also save states. """ - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): self.bmimodels[key].finalize() self.bmilogger.info("finalize.") @@ -315,7 +317,7 @@ :return: identifier of the models separated by a comma (,) """ names = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): names.append(self.bmimodels[key].get_component_name()) return ",".join(names) @@ -326,7 +328,7 @@ :return: List of String objects: identifiers of all input variables of the model: """ names = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): names.append(self.bmimodels[key].get_input_var_names()) names[-1] = [ self.bmimodels[key].get_component_name() + self.comp_sep + s @@ -343,7 +345,7 @@ :return: List of String objects: identifiers of all output variables of the model: """ names = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): names.append(self.bmimodels[key].get_output_var_names()) names[-1] = [ self.bmimodels[key].get_component_name() + self.comp_sep + s @@ -363,7 +365,7 @@ # first part should be the component name cname = long_var_name.split(self.comp_sep) - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): nn = self.bmimodels[key].get_component_name() if nn == cname[0]: ret = self.bmimodels[key].get_var_type(cname[1]) @@ -379,7 +381,7 @@ """ # first part should be the component name cname = long_var_name.split(self.comp_sep) - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): nn = self.bmimodels[key].get_component_name() if nn == cname[0]: ret = self.bmimodels[key].get_var_rank(cname[1]) @@ -395,7 +397,7 @@ """ # first part should be the component name cname = long_var_name.split(self.comp_sep) - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): nn = self.bmimodels[key].get_component_name() if nn == cname[0]: ret = self.bmimodels[key].get_var_size(cname[1]) @@ -411,7 +413,7 @@ """ # first part should be the component name cname = long_var_name.split(self.comp_sep) - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): nn = self.bmimodels[key].get_component_name() if nn == cname[0]: ret = self.bmimodels[key].get_var_nbytes(cname[1]) @@ -425,7 +427,7 @@ :return: start time of last model in the list. Tiem sare assumed to be identical """ st = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): st.append(self.bmimodels[key].get_start_time()) return numpy.array(st).max() @@ -438,7 +440,7 @@ """ st = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): st.append(self.bmimodels[key].get_current_time()) return st[-1] @@ -450,7 +452,7 @@ :return: end time of simulation n the units and epoch returned by the function get_time_units """ st = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): st.append(self.bmimodels[key].get_end_time()) return numpy.array(st).min() @@ -462,7 +464,7 @@ :return: duration of one time step of the model with the largest! timestep. """ st = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): st.append(self.bmimodels[key].get_time_step()) return max(st)[0] @@ -475,7 +477,7 @@ (http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/cf-conventions.html#time-coordinate) """ st = [] - for key, value in self.bmimodels.iteritems(): + for key, value in self.bmimodels.items(): st.append(self.bmimodels[key].get_time_units()) return st[-1] @@ -490,7 +492,7 @@ # first part should be the component name self.bmilogger.debug("get_value: " + long_var_name) cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: tmp = self.bmimodels[cname[0]].get_value(cname[1]) if self.wrtodisk: report( @@ -513,8 +515,8 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): - return self.bmimodels[cname[0]].get_value_at_indices(cname[1], inds) + if cname[0] in self.bmimodels: + return self.bmimodels[cname[0]].get_value_at_indices(cname[1],inds) else: return None @@ -529,9 +531,10 @@ :var src: Numpy array of values. one value to set for each of the indicated elements: """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): - self.bmimodels[cname[0]].set_value_at_indices(cname[1], inds, src) + if cname[0] in self.bmimodels: + self.bmimodels[cname[0]].set_value_at_indices(cname[1], inds,src) + def get_grid_type(self, long_var_name): """ Get the grid type according to the enumeration in BmiGridType @@ -542,7 +545,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_type(cname[1]) else: return None @@ -557,7 +560,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_shape(cname[1]) else: return None @@ -572,7 +575,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_spacing(cname[1]) else: return None @@ -587,7 +590,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_origin(cname[1]) else: return None @@ -603,7 +606,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_x(cname[1]) else: return None @@ -620,7 +623,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_y(cname[1]) else: return None @@ -635,7 +638,7 @@ """ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_grid_z(cname[1]) else: return None @@ -652,7 +655,7 @@ cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): + if cname[0] in self.bmimodels: return self.bmimodels[cname[0]].get_var_units(cname[1]) else: return None @@ -668,8 +671,8 @@ # first part should be the component name self.bmilogger.debug("set_value: " + long_var_name) cname = long_var_name.split(self.comp_sep) - if self.bmimodels.has_key(cname[0]): - self.bmimodels[cname[0]].set_value(cname[1], src) + if cname[0] in self.bmimodels: + self.bmimodels[cname[0]].set_value(cname[1],src) if self.wrtodisk: report( numpy2pcr(Scalar, src, -999), Index: wflow-py/wflow/wflow_cqf.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_cqf.py (.../wflow_cqf.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_cqf.py (.../wflow_cqf.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -108,7 +108,7 @@ from wflow.wflow_adapt import * import scipy -import ConfigParser +import configparser wflow = "wflow_cqf: " @@ -124,9 +124,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -942,10 +941,193 @@ self.TSoil = self.ZeroMap + 10.0 self.CanopyStorage = self.ZeroMap - else: - self.logger.info("Setting initial conditions from state files") - self.wf_resume(self.Dir + "/instate/") + + # static maps to use (normally default) + wflow_subcatch = configget(self.config,"model","wflow_subcatch","staticmaps/wflow_subcatch.map") + wflow_dem = configget(self.config,"model","wflow_dem","staticmaps/wflow_dem.map") + wflow_ldd = configget(self.config,"model","wflow_ldd","staticmaps/wflow_ldd.map") + wflow_river = configget(self.config,"model","wflow_river","staticmaps/wflow_river.map") + wflow_riverlength = configget(self.config,"model","wflow_riverlength","staticmaps/wflow_riverlength.map") + wflow_riverlength_fact = configget(self.config,"model","wflow_riverlength_fact","staticmaps/wflow_riverlength_fact.map") + wflow_landuse = configget(self.config,"model","wflow_landuse","staticmaps/wflow_landuse.map") + wflow_soil = configget(self.config,"model","wflow_soil","staticmaps/wflow_soil.map") + wflow_gauges = configget(self.config,"model","wflow_gauges","staticmaps/wflow_gauges.map") + wflow_inflow = configget(self.config,"model","wflow_inflow","staticmaps/wflow_inflow.map") + wflow_mgauges = configget(self.config,"model","wflow_mgauges","staticmaps/wflow_mgauges.map") + + + # 2: Input base maps ######################################################## + subcatch=ordinal(readmap(self.Dir + wflow_subcatch)) # Determines the area of calculations (all cells > 0) + subcatch = ifthen(subcatch > 0, subcatch) + if self.sCatch > 0: + subcatch = ifthen(subcatch == sCatch,subcatch) + + self.Altitude=readmap(self.Dir + wflow_dem)# * scalar(defined(subcatch)) # DEM + self.TopoLdd=readmap(self.Dir + wflow_ldd) # Local + self.TopoId=ordinal(readmap(self.Dir + wflow_subcatch)) # area map + self.River=cover(boolean(readmap(self.Dir + wflow_river)),0) + self.RiverLength=pcrut.readmapSave(self.Dir + wflow_riverlength,0.0) + # Factor to multiply riverlength with (defaults to 1.0) + self.RiverLengthFac=pcrut.readmapSave(self.Dir + wflow_riverlength_fact,1.0) + # read landuse and soilmap and make sure there are no missing points related to the + # subcatchment map. Currently sets the lu and soil type type to 1 + self.LandUse=readmap(self.Dir + wflow_landuse) + self.LandUse=cover(self.LandUse,nominal(ordinal(subcatch) > 0)) + self.Soil=readmap(self.Dir + wflow_soil) + self.Soil=cover(self.Soil,nominal(ordinal(subcatch) > 0)) + self.OutputLoc=ordinal(readmap(self.Dir + wflow_gauges)) # location of output gauge(s) + self.InflowLoc=pcrut.readmapSave(self.Dir + wflow_inflow,0.0) # location abstractions/inflows. + self.SeepageLoc=pcrut.readmapSave(self.Dir + wflow_inflow,0.0) # location abstractions/inflows. + + + # Experimental + self.RunoffGenSigmaFunction = int(configget(self.config,'model','RunoffGenSigmaFunction','0')) + self.RunoffGeneratingGWPerc = float(configget(self.config,'defaultfortbl','RunoffGeneratingGWPerc','0.1')) + self.RunoffGeneratingThickness = float(configget(self.config,'defaultfortbl','RunoffGeneratingThickness','0.0')) + + if self.scalarInput: + self.gaugesMap=readmap(self.Dir + wflow_mgauges) # location of rainfall/evap/temp gauge(s) + self.OutputId=ordinal(readmap(self.Dir + wflow_subcatch)) # location of subcatchment + # Temperature correction poer cell to add + + self.TempCor=pcrut.readmapSave(self.Dir + configget(self.config,"model","TemperatureCorrectionMap","staticmaps/wflow_tempcor.map"),0.0) + + self.ZeroMap=0.0*scalar(subcatch) #map with only zero's + + # 3: Input time series ################################################### + self.P_mapstack=self.Dir + configget(self.config,"inputmapstacks","Precipitation","/inmaps/P") # timeseries for rainfall + self.PET_mapstack=self.Dir + configget(self.config,"inputmapstacks","EvapoTranspiration","/inmaps/PET") # timeseries for rainfall"/inmaps/PET" # potential evapotranspiration + self.TEMP_mapstack=self.Dir + configget(self.config,"inputmapstacks","Temperature","/inmaps/TEMP") # timeseries for rainfall "/inmaps/TEMP" # global radiation + self.Inflow_mapstack=self.Dir + configget(self.config,"inputmapstacks","Inflow","/inmaps/IF") # timeseries for rainfall "/inmaps/IF" # in/outflow locations (abstractions) + self.RH_mapstack=self.Dir + configget(self.config,"inputmapstacks","RH","/inmaps/RH") # timeseries for rainfall "/inmaps/SE" # in/outflow locations (abstractions) + self.WindSpeed_mapstack=self.Dir + configget(self.config,"inputmapstacks","WindSpeed","/inmaps/wins") # timeseries for rainfall "/inmaps/SE" # in/outflow locations (abstractions) + self.RAD_mapstack=self.Dir + configget(self.config,"inputmapstacks","Radiation","/inmaps/RAD") # timeseries for rainfall "/inmaps/SE" # in/outflow locations (abstractions) + self.Seepage_mapstack=self.Dir + configget(self.config,"inputmapstacks","Seepage","/inmaps/SE") # timeseries for rainfall "/inmaps/SE" # in/outflow locations (abstractions) + self.HP_mapstack=self.Dir + configget(self.config,"inputmapstacks","HP","/inmaps/HP") # timeseries for rainfall "/inmaps/SE" # in/outflow locations (abstractions) + self.WaterCatch_mapstack=self.Dir + configget(self.config,"inputmapstacks","WaterCatch","/inmaps/WC") # timeseries for rainfall "/inmaps/SE" # in/outflow locations (abstractions) + # 3: Input time series ################################################### + + + # Set static initial values here ######################################### + self.SoilAlbedo = 0.1 # Not used at the moment + self.pi = 3.1416 + self.e = 2.7183 + self.SScale = 100.0 + + self.Latitude = ycoordinate(boolean(self.Altitude)) + self.Longitude = xcoordinate(boolean(self.Altitude)) + + self.logger.info("Linking parameters to landuse, catchment and soil...") + self.RunoffGeneratingGWPerc=self.readtblDefault(self.Dir + "/" + self.intbl + "/RunoffGeneratingGWPerc.tbl",self.LandUse,subcatch,self.Soil,self.RunoffGeneratingGWPerc) + self.RunoffGeneratingThickness=self.readtblDefault(self.Dir + "/" + self.intbl + "/RunoffGeneratingThickness.tbl",self.LandUse,subcatch,self.Soil,self.RunoffGeneratingThickness) + self.Cmax=self.readtblDefault(self.Dir + "/" + self.intbl + "/MaxCanopyStorage.tbl",self.LandUse,subcatch,self.Soil,1.0) + self.EoverR=self.readtblDefault(self.Dir + "/" + self.intbl + "/EoverR.tbl",self.LandUse,subcatch,self.Soil,0.1) + # self.Albedo=lookupscalar(self.Dir + "\intbl\Albedo.tbl",self.LandUse) # Not used anymore + self.CanopyGapFraction=self.readtblDefault(self.Dir + "/" + self.intbl + "/CanopyGapFraction.tbl",self.LandUse,subcatch,self.Soil,0.1) + self.RootingDepth=self.readtblDefault(self.Dir + "/" + self.intbl + "/RootingDepth.tbl",self.LandUse,subcatch,self.Soil,750.0) #rooting depth + #: rootdistpar determien how roots are linked to water table.The number shoudl be negative. A high number means that all roots are wet if + #: the water table is above the lowest part of the roots. A lower number smooths this. + self.rootdistpar=self.readtblDefault(self.Dir + "/" + self.intbl + "/rootdistpar.tbl",self.LandUse,subcatch,self.Soil,-80000.0) #rrootdistpar + + # Soil parameters + # infiltration capacity if the soil [mm/day] + self.InfiltCapSoil=self.readtblDefault(self.Dir + "/" + self.intbl + "/InfiltCapSoil.tbl",self.LandUse,subcatch,self.Soil,100.0) * self.timestepsecs/self.basetimestep + self.CapScale=self.readtblDefault(self.Dir + "/" + self.intbl + "/CapScale.tbl",self.LandUse,subcatch,self.Soil,100.0) # + # infiltration capacity of the compacted + self.InfiltCapPath=self.readtblDefault(self.Dir + "/" + self.intbl + "/InfiltCapPath.tbl",self.LandUse,subcatch,self.Soil,10.0) * self.timestepsecs/self.basetimestep + self.MaxLeakage=self.readtblDefault(self.Dir + "/" + self.intbl + "/MaxLeakage.tbl",self.LandUse,subcatch,self.Soil,0.0) * self.timestepsecs/self.basetimestep + # areas (paths) in [mm/day] + # Fraction area with compacted soil (Paths etc.) + self.PathFrac=self.readtblDefault(self.Dir + "/" + self.intbl + "/PathFrac.tbl",self.LandUse,subcatch,self.Soil,0.01) + # thickness of the soil + self.FirstZoneThickness = self.readtblDefault(self.Dir + "/" + self.intbl + "/FirstZoneCapacity.tbl",self.LandUse,subcatch,self.Soil,2000.0) + self.thetaR = self.readtblDefault(self.Dir + "/" + self.intbl + "/thetaR.tbl",self.LandUse,subcatch,self.Soil,0.01) + self.thetaS = self.readtblDefault(self.Dir + "/" + self.intbl + "/thetaS.tbl",self.LandUse,subcatch,self.Soil,0.6) + # minimum thickness of soild + self.FirstZoneMinCapacity = self.readtblDefault(self.Dir + "/" + self.intbl + "/FirstZoneMinCapacity.tbl",self.LandUse,subcatch,self.Soil,500.0) + + # FirstZoneKsatVer = $2\inmaps\FirstZoneKsatVer.map + self.FirstZoneKsatVer=self.readtblDefault(self.Dir + "/" + self.intbl + "/FirstZoneKsatVer.tbl",self.LandUse,subcatch,self.Soil,3000.0) * self.timestepsecs/self.basetimestep + self.Beta = scalar(0.6) # For sheetflow + + self.M=self.readtblDefault(self.Dir + "/" + self.intbl + "/M.tbl" ,self.LandUse,subcatch,self.Soil,300.0) # Decay parameter in Topog_cqf + self.N=self.readtblDefault(self.Dir + "/" + self.intbl + "/N.tbl",self.LandUse,subcatch,self.Soil,0.072) # Manning overland flow + self.NRiver=self.readtblDefault(self.Dir + "/" + self.intbl + "/N_River.tbl",self.LandUse,subcatch,self.Soil,0.036) # Manning river + self.WaterFrac=self.readtblDefault(self.Dir + "/" + self.intbl + "/WaterFrac.tbl",self.LandUse,subcatch,self.Soil,0.0) # Fraction Open water + + #cqflow specific stuff + self.Albedo=self.readtblDefault(self.Dir + "/" + self.intbl + "/Albedo.tbl",self.LandUse,subcatch,self.Soil,0.18) # + self.LeafAreaIndex=self.readtblDefault(self.Dir + "/" + self.intbl + "/LeafAreaIndex.tbl",self.LandUse,subcatch,self.Soil,4.0) # + self.WindSpeedHeigth=self.readtblDefault(self.Dir + "/" + self.intbl + "/WindSpeedHeigth.tbl",self.LandUse,subcatch,self.Soil,4.0) # + self.VegetationHeigth=self.readtblDefault(self.Dir + "/" + self.intbl + "/VegetationHeigth.tbl",self.LandUse,subcatch,self.Soil,4.0) # + + self.xl,self.yl,self.reallength = pcrut.detRealCellLength(self.ZeroMap,sizeinmetres) + self.Slope= slope(self.Altitude) + #self.Slope=ifthen(boolean(self.TopoId),max(0.001,self.Slope*celllength()/self.reallength)) + self.Slope=max(0.001,self.Slope*celllength()/self.reallength) + Terrain_angle=scalar(atan(self.Slope)) + + + # Multiply parameters with a factor (for calibration etc) -P option in command line + for k, v in multpars.items(): + estr = k + "=" + k + "*" + str(v) + self.logger.info("Parameter multiplication: " + estr) + exec(estr) + + self.N=ifthenelse(self.River, self.NRiver, self.N) + + # Determine river width from DEM, upstream area and yearly average discharge + # Scale yearly average Q at outlet with upstream are to get Q over whole catchment + # Alf ranges from 5 to > 60. 5 for hardrock. large values for sediments + # "Noah J. Finnegan et al 2005 Controls on the channel width of rivers: + # Implications for modeling fluvial incision of bedrock" + + upstr = catchmenttotal(1, self.TopoLdd) + Qscale = upstr/mapmaximum(upstr) * Qmax + W = (alf * (alf + 2.0)**(0.6666666667))**(0.375) * Qscale**(0.375) * (max(0.0001,windowaverage(self.Slope,celllength() * 4.0)))**(-0.1875) * self.N **(0.375) + RiverWidth = W + + + # soil thickness based on topographical index (see Environmental modelling: finding simplicity in complexity) + # 1: calculate wetness index + # 2: Scale the capacity (now actually a max capacity) based on the index, also apply a minmum capacity + WI = ln(accuflux(self.TopoLdd,1)/self.Slope) # Topographical wetnesss. Scale WI by zone/subcatchment assuming these ara also geological units + WIMax = areamaximum(WI, self.TopoId) * WIMaxScale + self.FirstZoneThickness = max(min(self.FirstZoneThickness,(WI/WIMax) * self.FirstZoneThickness), self.FirstZoneMinCapacity) + + self.FirstZoneCapacity = self.FirstZoneThickness * (self.thetaS -self.thetaR) + + # limit roots to top 99% of first zone + self.RootingDepth = min(self.FirstZoneThickness * 0.99,self.RootingDepth) + + # subgrid runoff generation + self.DemMax=readmap(self.Dir + "/staticmaps/wflow_demmax") + self.DrainageBase=readmap(self.Dir + "/staticmaps/wflow_demmin") + self.CC = min(100.0,-log(1.0/0.1 - 1)/min(-0.1,self.DrainageBase - self.Altitude)) + + #if maptotal(self.RunoffGeneratingThickness <= 0.0): + self.GWScale = (self.DemMax-self.DrainageBase)/self.FirstZoneThickness / self.RunoffGeneratingGWPerc + #else: + # self.GWScale = (self.DemMax-self.DrainageBase)/min(self.RunoffGeneratingThickness, self.FirstZoneThickness) + + + # Which columns/gauges to use/ignore in updating + self.UpdateMap = self.ZeroMap + + if self.updating: + touse = numpy.zeros(gaugear.shape,dtype='int') + + for thecol in updateCols: + idx = (gaugear == thecol).nonzero() + touse[idx] = thecol + + + self.UpdateMap = numpy2pcr(Nominal,touse,0.0) + # Calulate distance to updating points (upstream) annd use to scale the correction + # ldddist returns zero for cell at the gauges so add 1.0 tp result + self.DistToUpdPt = cover(min(ldddist(self.TopoLdd,boolean(cover(self.UpdateMap,0)),1) * self.reallength/celllength(),self.UpdMaxDist),self.UpdMaxDist) + P = self.Bw + (2.0 * self.WaterLevel) self.Alpha = self.AlpTerm * pow(P, self.AlpPow) self.OldSurfaceRunoff = self.SurfaceRunoff @@ -997,7 +1179,33 @@ :var self.DLC: length of the river within a cell [m] :var self.ToCubic: Mutiplier to convert mm to m^3/s for fluxes """ + + self.logger.debug("Step: "+str(int(self.thestep + self._d_firstTimeStep))+"/"+str(int(self._d_nrTimeSteps))) + self.thestep = self.thestep + 1 + + + + self.Precipitation=cover(self.wf_readmap(self.P_mapstack,0.0),0) + self.HP=cover(self.wf_readmap(self.HP_mapstack,0.0),0) + #self.PotenEvap=cover(self.wf_readmap(self.PET_mapstack,0.0),0) + self.Radiation=cover(self.wf_readmap(self.RAD_mapstack,0.0),0) + #Inflow=cover(self.readmap(self.Inflow),0) + self.Inflow=pcrut.readmapSave(self.Inflow_mapstack,0.0) + self.Seepage=pcrut.readmapSave(self.Seepage_mapstack,0.0) + #Inflow=spatial(scalar(0.0)) + self.Temperature=cover(self.wf_readmap(self.TEMP_mapstack,0.0),0) + self.RH=cover(self.wf_readmap(self.RH_mapstack,0.0),0) + self.WindSpeed=cover(self.wf_readmap(self.WindSpeed_mapstack,0.0),0) + self.WaterCatch=cover(self.wf_readmap(self.WaterCatch_mapstack,0.0),0) + + for k, v in multdynapars.items(): + estr = k + "=" + k + "*" + str(v) + self.logger.debug("Dynamic Parameter multiplication: " + estr) + exec(estr) + + #PotEvap = self.PotenEvap # + self.logger.debug( "Step: " + str(int(self.thestep + self._d_firstTimeStep)) @@ -1556,35 +1764,28 @@ ## Main model starts here ######################################################################## try: - opts, args = getopt.getopt( - sys.argv[1:], "XF:L:hC:Ii:v:S:T:WNR:u:s:EP:p:Xx:U:fOc:" - ) - except getopt.error, msg: + opts, args = getopt.getopt(sys.argv[1:], 'XF:L:hC:Ii:v:S:T:WNR:u:s:EP:p:Xx:U:fOc:') + except getopt.error as msg: pcrut.usage(msg) for o, a in opts: - if o == "-P": - exec ("multpars =" + a, globals(), globals()) - if o == "-p": - exec "multdynapars =" + a - exec ("multdynapars =" + a, globals(), globals()) - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-c": - configfile = a - if o == "-s": - timestepsecs = int(a) - if o == "-T": - _lastTimeStep = int(a) - if o == "-S": - _firstTimeStep = int(a) - if o == "-h": - usage() - if o == "-f": - NoOverWrite = 0 + if o == '-P': + exec ("multpars =" + a,globals(), globals()) + if o == '-p': + exec("multdynapars =" + a) + exec ("multdynapars =" + a,globals(), globals()) + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-c': configfile = a + if o == '-s': timestepsecs = int(a) + if o == '-T': _lastTimeStep=int(a) + if o == '-S': _firstTimeStep=int(a) + if o == '-h': usage() + if o == '-f': NoOverWrite = 0 + + + if _lastTimeStep < _firstTimeStep: usage() @@ -1595,36 +1796,24 @@ dynModelFw.createRunId(NoOverWrite=NoOverWrite) for o, a in opts: - if o == "-X": - configset(myModel.config, "model", "OverWriteInit", "1", overwrite=True) - if o == "-I": - configset(myModel.config, "model", "reinit", "1", overwrite=True) - if o == "-i": - configset(myModel.config, "model", "intbl", a, overwrite=True) - if o == "-s": - configset(myModel.config, "model", "timestepsecs", a, overwrite=True) - if o == "-x": - configset(myModel.config, "model", "sCatch", a, overwrite=True) - if o == "-c": - configset(myModel.config, "model", "configfile", a, overwrite=True) - if o == "-M": - configset(myModel.config, "model", "MassWasting", "1", overwrite=True) - if o == "-N": - configset(myModel.config, "model", "nolateral", "1", overwrite=True) - if o == "-Q": - configset(myModel.config, "model", "ExternalQbase", "1", overwrite=True) - if o == "-U": - configset(myModel.config, "model", "updateFile", a, overwrite=True) - configset(myModel.config, "model", "updating", "1", overwrite=True) - if o == "-u": - print a - exec "updateCols =" + a - if o == "-E": - configset(myModel.config, "model", "reInfilt", "1", overwrite=True) - if o == "-R": - runId = a - if o == "-W": - configset(myModel.config, "model", "waterdem", "1", overwrite=True) + if o == '-X': configset(myModel.config,'model','OverWriteInit','1',overwrite=True) + if o == '-I': configset(myModel.config,'model','reinit','1',overwrite=True) + if o == '-i': configset(myModel.config,'model','intbl',a,overwrite=True) + if o == '-s': configset(myModel.config,'model','timestepsecs',a,overwrite=True) + if o == '-x': configset(myModel.config,'model','sCatch',a,overwrite=True) + if o == '-c': configset(myModel.config,'model','configfile', a,overwrite=True) + if o == '-M': configset(myModel.config,'model','MassWasting',"1",overwrite=True) + if o == '-N': configset(myModel.config,'model','nolateral','1',overwrite=True) + if o == '-Q': configset(myModel.config,'model','ExternalQbase','1',overwrite=True) + if o == '-U': + configset(myModel.config,'model','updateFile',a,overwrite=True) + configset(myModel.config,'model','updating',"1",overwrite=True) + if o == '-u': + print(a) + exec("updateCols =" + a) + if o == '-E': configset(myModel.config,'model','reInfilt','1',overwrite=True) + if o == '-R': runId = a + if o == '-W': configset(myModel.config,'model','waterdem','1',overwrite=True) dynModelFw._runInitial() dynModelFw._runResume() Index: wflow-py/wflow/wflow_delwaq.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_delwaq.py (.../wflow_delwaq.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_delwaq.py (.../wflow_delwaq.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -86,7 +86,7 @@ import time import struct import shutil -import __builtin__ +import builtins from wflow import wf_netcdfio @@ -103,9 +103,9 @@ B3\_nrofseg.inc """ - exfile = open(fname, "w") - print >> exfile, ";Written by dw_WriteNrSegments" - print >> exfile, str(nr) + " ; nr of segments" + exfile = open(fname,'w') + print(";Written by dw_WriteNrSegments", file=exfile) + print(str(nr) + " ; nr of segments", file=exfile) exfile.close() @@ -115,49 +115,49 @@ B4\_nrofexch.inc """ - exfile = open(fname, "w") - print >> exfile, ";Written by dw_WriteNrExChnages" - print >> exfile, str(nr) + " 0 0 ; x, y, z direction" + exfile = open(fname,'w') + print(";Written by dw_WriteNrExChnages", file=exfile) + print(str(nr) + " 0 0 ; x, y, z direction", file=exfile) exfile.close() def dw_WriteBoundData(fname, areas): """ writes B5\_bounddata.inc - """ - - areas = sorted(areas, reverse=True) - exfile = open(fname, "w") - print >> exfile, ";Written by dw_WriteBoundData" + """ + + areas = sorted(areas,reverse=True) + exfile = open(fname,'w') + print(";Written by dw_WriteBoundData", file=exfile) for i in areas: - print >> exfile, "ITEM 'Area_%s'" % (i) - print >> exfile, "CONCENTRATION 'Area_%s' 'Check' 'Initial'" % (i) - print >> exfile, "DATA" - print >> exfile, "1.0 1.0 0.0" - print >> exfile, "" - + print("ITEM \'Area_%s\'" % (i), file=exfile) + print("CONCENTRATION \'Area_%s\' \'Check\' \'Initial\'" % (i), file=exfile) + print("DATA", file=exfile) + print("1.0 1.0 0.0", file=exfile) + print("", file=exfile) + exfile.close() def dw_WriteInitials(fname, inmaps): """ B8_initials.inc """ - - maps = ["Initial", "Check"] - exfile = open(fname, "w") - print >> exfile, "INITIALS" + + maps = ['Initial','Check'] + exfile = open(fname,'w') + print("INITIALS", file=exfile) for rr in inmaps: - print >> exfile, "'" + rr + "'", + print("'" + rr + "'", end=' ', file=exfile) for rr in maps: - print >> exfile, "'" + rr + "'", - print >> exfile - print >> exfile, "DEFAULTS" + print("'" + rr + "'", end=' ', file=exfile) + print(file=exfile) + print("DEFAULTS", file=exfile) for rr in inmaps: - print >> exfile, str(0.0) + " ", + print(str(0.0) + " ", end=' ', file=exfile) for rr in maps: - print >> exfile, str(1.0) + " ", - print >> exfile + print(str(1.0) + " ", end=' ', file=exfile) + print(file=exfile) exfile.close() @@ -175,9 +175,9 @@ - add labeling of different inflows ( the information is already present) """ totareas = areas - exfile = open(fname, "w") - print >> exfile, ";Written by dw_WriteBoundlist" - print >> exfile, ";'NodeID' 'Number' 'Type'" + exfile = open(fname,'w') + print(";Written by dw_WriteBoundlist", file=exfile) + print(";'NodeID' 'Number' 'Type'", file=exfile) nr_inflowtypes = len(inflowtypes) # for i in range(nr_inflowtypes-1): @@ -186,16 +186,12 @@ arid = 0 for i in range(len(pointer)): - if pointer[i, 1] < 0: - print >> exfile, "'BD_" + str(absolute(pointer[i, 1])) + "' '" + str( - absolute(pointer[i, 1]) - ) + "'" + " 'Outflow'" - elif pointer[i, 0] < 0: - # ar = int(absolute(totareas[arid])) + if pointer[i,1] < 0: + print("'BD_" + str(absolute(pointer[i,1])) + "' '" + str(absolute(pointer[i,1])) + "'" + " 'Outflow'", file=exfile) + elif pointer[i,0] < 0: + #ar = int(absolute(totareas[arid])) ar = totareas[arid] - print >> exfile, "'BD_" + str(absolute(pointer[i, 0])) + "' " + "'" + str( - absolute(pointer[i, 0]) - ) + "'" + " 'Area_" + str(ar) + "'" + print("'BD_" +str(absolute(pointer[i,0])) + "' " + "'" + str(absolute(pointer[i,0])) + "'" + " 'Area_" + str(ar) + "'", file=exfile) arid = arid + 1 exfile.close() @@ -208,11 +204,11 @@ """ if not binary: # Write ASCII file - exfile = open(fname, "w") - print >> exfile, ";Written by dw_WritePointer" - print >> exfile, ";nr of pointers is: ", str(pointer.shape[0]) - savetxt(exfile, pointer, fmt="%10.0f") - exfile.close() + exfile = open(fname,'w') + print(";Written by dw_WritePointer", file=exfile) + print(";nr of pointers is: ", str(pointer.shape[0]), file=exfile) + savetxt(exfile,pointer,fmt='%10.0f') + exfile.close() else: # Write binary file f = open(fname, "wb") @@ -378,12 +374,12 @@ res = [] for idd in range(1, difboun + 1): ct = list(np_catchid) - print "ct: " - print unique(ct) - for i in range(0, len(np_catchid)): + print("ct: ") + print(unique(ct)) + for i in range(0,len(np_catchid)): ct[i] = np_catchid[i] + "_" + str(idd) res = res + ct - print unique(res) + print(unique(res)) np_catchid = res # pointer = vstack((pointer,extraboun)) # now catchment id's @@ -465,8 +461,8 @@ Assumes daily timesteps for now! """ # B1_T0.inc - exfile = open(dwdir + "/B1_T0.inc", "w") - print >> exfile, "'T0: " + T0.strftime("%Y.%m.%d %H:%M:%S") + " (scu= 1s)'" + exfile = open(dwdir + "/B1_T0.inc",'w') + print("\'T0: " + T0.strftime("%Y.%m.%d %H:%M:%S") + " (scu= 1s)\'", file=exfile) exfile.close() # B2_outputtimers.inc @@ -482,29 +478,23 @@ exfile = open(dwdir + "/B2_outputtimers.inc", "w") etime = T0 + timeRange - print >> exfile, " " + T0.strftime("%Y/%m/%d-%H:%M:%S") + " " + etime.strftime( - "%Y/%m/%d-%H:%M:%S" - ) + timestepstring - print >> exfile, " " + T0.strftime("%Y/%m/%d-%H:%M:%S") + " " + etime.strftime( - "%Y/%m/%d-%H:%M:%S" - ) + timestepstring - print >> exfile, " " + T0.strftime("%Y/%m/%d-%H:%M:%S") + " " + etime.strftime( - "%Y/%m/%d-%H:%M:%S" - ) + timestepstring + print(" " + T0.strftime("%Y/%m/%d-%H:%M:%S") + " " + etime.strftime("%Y/%m/%d-%H:%M:%S") + timestepstring, file=exfile) + print(" " + T0.strftime("%Y/%m/%d-%H:%M:%S") + " " + etime.strftime("%Y/%m/%d-%H:%M:%S") + timestepstring, file=exfile) + print(" " + T0.strftime("%Y/%m/%d-%H:%M:%S") + " " + etime.strftime("%Y/%m/%d-%H:%M:%S") + timestepstring, file=exfile) exfile.close() - - # B2_simtimers.inc - exfile = open(dwdir + "/B2_simtimers.inc", "w") - print >> exfile, " " + T0.strftime("%Y/%m/%d-%H:%M:%S") - print >> exfile, " " + etime.strftime("%Y/%m/%d-%H:%M:%S") - print >> exfile, " 0 ; timestep constant" - print >> exfile, "; dddhhmmss format for timestep" - print >> exfile, timestepstring + " ; timestep" + + #B2_simtimers.inc + exfile = open(dwdir + "/B2_simtimers.inc",'w') + print(" " + T0.strftime("%Y/%m/%d-%H:%M:%S"), file=exfile) + print(" " + etime.strftime("%Y/%m/%d-%H:%M:%S"), file=exfile) + print(" 0 ; timestep constant", file=exfile) + print("; dddhhmmss format for timestep", file=exfile) + print(timestepstring + " ; timestep", file=exfile) exfile.close() - - # B2_sysclock.inc - exfile = open(dwdir + "/B2_sysclock.inc", "w") - print >> exfile, "%7d 'DDHHMMSS' 'DDHHMMSS' ; system clock" % timeStepSec + + #B2_sysclock.inc + exfile = open(dwdir + "/B2_sysclock.inc",'w') + print("%7d \'DDHHMMSS\' \'DDHHMMSS\' ; system clock" % timeStepSec, file=exfile) exfile.close() @@ -518,19 +508,20 @@ """ - exfile = open(fname, "w") - areas = sorted(areas, reverse=True) - print >> exfile, "; number of active and inactive substances" - print >> exfile, "%d 0" % (len(areas) + 2) - print >> exfile, "; active substances" - print >> exfile, "1 'Initial' ; " - print >> exfile, "2 'Check' ; " + exfile = open(fname,'w') + areas = sorted(areas,reverse=True) + print("; number of active and inactive substances", file=exfile) + print("%d 0" % (len(areas) + 2), file=exfile) + print("; active substances", file=exfile) + print("1 \'Initial\' ; ", file=exfile) + print("2 'Check' ; ", file=exfile) j = 2 for i in areas: j = j + 1 - print >> exfile, "%d 'Area_%s'" % (j, i) - print >> exfile, "; passive substances" - + print("%d \'Area_%s\'" % (j,i), file=exfile) + print("; passive substances", file=exfile) + + exfile.close() @@ -551,12 +542,12 @@ logger.error("Gauges and segments do not match!") pts = size(np_segs) - exfile = open(fname, "w") - print >> exfile, "%d ; nr of locations" % pts - print >> exfile, "; 'outlocname' numberofsegments segment list" + exfile = open(fname,'w') + print("%d ; nr of locations" % pts, file=exfile) + print("; \'outlocname\' numberofsegments segment list", file=exfile) i = 0 for loc in np_gauges: - print >> exfile, " '%d' 1 %d" % (loc, np_segs[i]) + print(" \'%d\' 1 %d" % (loc, np_segs[i]), file=exfile) i = i + 1 exfile.close() @@ -572,11 +563,11 @@ zero_map = scalar(ptid_map) * 0.0 allx = dw_pcrToDataBlock(xcoordinate(boolean(cover(zero_map + 1, 1)))) i = 0 - diff = round(__builtin__.abs(allx[i] - allx[i + 1]), 5) + diff = round(builtins.abs(allx[i] - allx[i+1]), 5) diff_next = diff while diff_next == diff: i += 1 - diff_next = __builtin__.abs(allx[i] - allx[i + 1]) + diff_next = builtins.abs(allx[i] - allx[i+1]) diff_next = round(diff_next, 5) m = i + 1 n = allx.shape[0] / m @@ -1186,9 +1177,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -1214,8 +1204,8 @@ # T0 = datetime.strptime("2000-01-01 00:00:00",'%Y-%m-%d %H:%M:%S') try: - opts, args = getopt.getopt(sys.argv[1:], "adD:C:R:S:hT:s:O:A:jc:n:") - except getopt.error, msg: + opts, args = getopt.getopt(sys.argv[1:], 'adD:C:R:S:hT:s:O:A:jc:n:') + except getopt.error as msg: pcrut.usage(msg) nc_outmap_file = None Index: wflow-py/wflow/wflow_extract.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_extract.py (.../wflow_extract.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_extract.py (.../wflow_extract.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -45,9 +45,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -87,7 +86,7 @@ dirs = ["/intbl/", "/inmaps/", "/staticmaps/", "/intss/", "/instate/", "/outstate/"] if os.path.isdir(caseNameNew) and not force: - print "Refusing to write into an existing directory:" + caseNameNew + print("Refusing to write into an existing directory:" + caseNameNew) sys.exit() if not os.path.isdir(caseNameNew): @@ -97,51 +96,35 @@ shutil.copy(inifile, inifile.replace(caseName, caseNameNew)) for ddir in dirs: - for mfile in glob.glob(caseName + ddir + "/*.map"): - mstr = ( - "resample --clone " - + cloneMap - + " " - + mfile - + " " - + mfile.replace(caseName, caseNameNew) - ) - print mstr + for mfile in glob.glob(caseName + ddir + '/*.map'): + mstr = "resample --clone " + cloneMap + ' ' + mfile + " " + mfile.replace(caseName,caseNameNew) + print(mstr) os.system(mstr) if inmaps: - for mfile in glob.glob(caseName + ddir + "/*.[0-9][0-9][0-9]"): - mstr = ( - "resample --clone " - + cloneMap - + " " - + mfile - + " " - + mfile.replace(caseName, caseNameNew) - ) - if not os.path.exists(mfile.replace(caseName, caseNameNew)): - print mstr + for mfile in glob.glob(caseName + ddir + '/*.[0-9][0-9][0-9]'): + mstr = "resample --clone " + cloneMap + ' ' + mfile + " " + mfile.replace(caseName,caseNameNew) + if not os.path.exists(mfile.replace(caseName,caseNameNew)): + print(mstr) os.system(mstr) else: - print "skipping " + mfile.replace(caseName, caseNameNew) - for mfile in glob.glob(caseName + ddir + "*.tbl"): - shutil.copy(mfile, mfile.replace(caseName, caseNameNew)) - for mfile in glob.glob(caseName + ddir + "*.col"): - shutil.copy(mfile, mfile.replace(caseName, caseNameNew)) - for mfile in glob.glob(caseName + ddir + "*.tss"): - shutil.copy(mfile, mfile.replace(caseName, caseNameNew)) + print("skipping " + mfile.replace(caseName,caseNameNew)) + for mfile in glob.glob(caseName + ddir + '*.tbl'): + shutil.copy(mfile, mfile.replace(caseName,caseNameNew)) + for mfile in glob.glob(caseName + ddir + '*.col'): + shutil.copy(mfile, mfile.replace(caseName,caseNameNew)) + for mfile in glob.glob(caseName + ddir + '*.tss'): + shutil.copy(mfile, mfile.replace(caseName,caseNameNew)) - print "recreating static maps ..." + print("recreating static maps ...") # Create new ldd using old river network dem = readmap(caseNameNew + "/staticmaps/wflow_dem.map") # orig low res river riverburn = readmap(caseNameNew + "/staticmaps/wflow_river.map") # save it - report(riverburn, caseNameNew + "/staticmaps/wflow_riverburnin.map") - demburn = cover(ifthen(boolean(riverburn), dem - 600), dem) - print "Creating ldd..." - ldd = lddcreate_save( - caseNameNew + "/staticmaps/wflow_ldd.map", demburn, True, 10.0E35 - ) + report(riverburn,caseNameNew + "/staticmaps/wflow_riverburnin.map") + demburn = cover(ifthen(boolean(riverburn), dem - 600) ,dem) + print("Creating ldd...") + ldd = lddcreate_save(caseNameNew + "/staticmaps/wflow_ldd.map",demburn, True, 10.0E35) # ## Find catchment (overall) outlet = find_outlet(ldd) Index: wflow-py/wflow/wflow_fit.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_fit.py (.../wflow_fit.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_fit.py (.../wflow_fit.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -90,7 +90,7 @@ try: ret = config.get(section, var) except: - print "returning default (" + default + ") for " + section + ":" + var + print("returning default (" + default + ") for " + section + ":" + var) ret = default return ret @@ -177,6 +177,15 @@ self.AreaMap = self.WF.readmap(os.path.join(self.caseName, self.AreaMapName)) exec "self.AreaCodeS = " + configget(self.conf, "fit", "areacode", "[1]") + + + exec("self.ColSimS = " + configget(self.conf,"fit","ColSim","[1]")) + exec("self.ColMeasS = " + configget(self.conf,"fit","ColMeas","[1]")) + self.WarmUpSteps = int(configget(self.conf,"fit","WarmUpSteps","1")) + self.AreaMapName = configget(self.conf,"fit","areamap","wflow_catchment.map") + self.AreaMap = self.WF.readmap(os.path.join(self.caseName,self.AreaMapName)) + exec("self.AreaCodeS = " + configget(self.conf,"fit","areacode","[1]")) + # Shift columns as the maps are one bases and the cols 0 based i = 0 for a in self.ColSimS: @@ -223,18 +232,8 @@ i = 0 for j in self.pars: self.log.info("Saving parameter (initial values): " + self.calibpars[i]) - strr_org = ( - "self.WF.report(self.dynModelFw._userModel()." - + self.calibpars[i] - + ',"' - + self.caseName - + "/" - + self.runId - + "/" - + self.calibpars[i] - + '_org.map")' - ) - exec strr_org + strr_org = "self.WF.report(self.dynModelFw._userModel()." + self.calibpars[i] + ",\"" + self.caseName + "/"+self.runId +"/"+ self.calibpars[i] +"_org.map\")" + exec(strr_org) i = i + 1 def run(self, pars): @@ -272,40 +271,16 @@ # !!!!!!!!!! Not sure if the last version of the par is the best fit!! i = 0 for j in pars: - self.log.log(45, "Saving parameter: " + self.calibpars[i]) - exec "newmap = self.dynModelFw._userModel()." + self.calibpars[i] - newmap = self.WF.ifthenelse( - self.AreaMap == self.AreaCode, newmap * j, newmap - ) - strr_new = ( - "self.WF.report(newmap," - + '"' - + self.caseName - + "/" - + self.runId - + "/" - + self.calibpars[i] - + "_" - + str(self.ColSim) - + "_" - + str(self.ColMeas) - + "_" - + str(self.AreaCode) - + '.map")' - ) + self.log.log(45,"Saving parameter: " + self.calibpars[i]) + exec("newmap = self.dynModelFw._userModel()." + self.calibpars[i]) + newmap = self.WF.ifthenelse(self.AreaMap == self.AreaCode,newmap * j, newmap) + strr_new = "self.WF.report(newmap," + "\""+ self.caseName + "/" + self.runId +"/" + self.calibpars[i] + "_" + str(self.ColSim) + "_" + str(self.ColMeas) + "_" + str(self.AreaCode)+ ".map\")" if savetoinput: - self.log.log(45, "Saving adjusted map to input!!") - str_save = ( - "self.WF.report(newmap," - + '"' - + self.caseName - + "/staticmaps/" - + self.calibpars[i] - + '.map")' - ) - exec str_save + self.log.log(45,"Saving adjusted map to input!!") + str_save = "self.WF.report(newmap," + "\""+ self.caseName + "/staticmaps/" + self.calibpars[i] + ".map\")" + exec(str_save) - exec strr_new + exec(strr_new) i = i + 1 def shutdown(self, pars): @@ -353,9 +328,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -364,29 +338,29 @@ ff = open(fname, "w") i = 0 - print >> ff, "Optimised parameter multiplication values:" + print("Optimised parameter multiplication values:", file=ff) if np.iterable(pp): for par in pp: - print >> ff, "Parameter " + calibpars[i] + " = " + str(par) + print("Parameter " + calibpars[i] + " = " + str(par), file=ff) i = i + 1 else: - print >> ff, "Parameter " + calibpars[0] + " = " + str(pp) - - print >> ff, "Estimate of the jacobian around the solution: " + str(a) - for dtc in b: - print >> ff, dtc + " = " + str(b[dtc]) - - if d in [1, 2, 3, 4]: - print >> ff, "A solution was found (" + str(d) + ")" - print >> ff, c + print("Parameter " + calibpars[0] + " = " + str(pp), file=ff) + + print("Estimate of the jacobian around the solution: " + str(a), file=ff) + for dtc in b: + print(dtc + " = " + str(b[dtc]), file=ff) + + if d in [1,2,3,4]: + print("A solution was found (" + str(d) + ")", file=ff) + print(c, file=ff) else: - print >> ff, "No solution was found (" + str(d) + ")" - print >> ff, c - - print >> ff, "NS: " + str(model.NS) - print >> ff, "BIAS: " + str(model.BIAS) - print >> ff, "CORR: " + str(model.CORR) - print >> ff, "MABSE: " + str(model.MABSE) + print("No solution was found (" + str(d) + ")", file=ff) + print(c, file=ff) + + print("NS: " +str(model.NS), file=ff) + print("BIAS: " +str(model.BIAS), file=ff) + print("CORR: " +str(model.CORR), file=ff) + print("MABSE: " +str(model.MABSE), file=ff) ff.close() Index: wflow-py/wflow/wflow_fit_brute.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_fit_brute.py (.../wflow_fit_brute.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_fit_brute.py (.../wflow_fit_brute.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -88,7 +88,7 @@ try: ret = config.get(section, var) except: - print "returning default (" + default + ") for " + section + ":" + var + print("returning default (" + default + ") for " + section + ":" + var) ret = default return ret @@ -160,7 +160,7 @@ ) if len(parstr) == 2: par = parstr[0] - exec "ar = np.array(" + parstr[1] + ")" + exec("ar = np.array(" + parstr[1] + ")") self.range[par] = ar else: par = parstr[0] @@ -183,6 +183,15 @@ self.AreaMap = self.WF.readmap(os.path.join(self.caseName, self.AreaMapName)) exec "self.AreaCodeS = " + configget(self.conf, "fit", "areacode", "[1]") + + + exec("self.ColSimS = " + configget(self.conf,"fit","ColSim","[1]")) + exec("self.ColMeasS = " + configget(self.conf,"fit","ColMeas","[1]")) + self.WarmUpSteps = int(configget(self.conf,"fit","WarmUpSteps","1")) + self.AreaMapName = configget(self.conf,"fit","areamap","wflow_catchment.map") + self.AreaMap = self.WF.readmap(os.path.join(self.caseName,self.AreaMapName)) + exec("self.AreaCodeS = " + configget(self.conf,"fit","areacode","[1]")) + # Shift columns as the maps are one bases and the cols 0 based i = 0 for a in self.ColSimS: @@ -229,18 +238,8 @@ i = 0 for j in self.pars: self.log.info("Saving parameter (initial values): " + self.calibpars[i]) - strr_org = ( - "self.WF.report(self.dynModelFw._userModel()." - + self.calibpars[i] - + ',"' - + self.caseName - + "/" - + self.runId - + "/" - + self.calibpars[i] - + '_org.map")' - ) - exec strr_org + strr_org = "self.WF.report(self.dynModelFw._userModel()." + self.calibpars[i] + ",\"" + self.caseName + "/"+self.runId +"/"+ self.calibpars[i] +"_org.map\")" + exec(strr_org) i = i + 1 def run(self, pars): @@ -277,40 +276,16 @@ # !!!!!!!!!! Not sure if the last version of the par is the best fit!! i = 0 for j in pars: - self.log.log(45, "Saving parameter: " + self.calibpars[i]) - exec "newmap = self.dynModelFw._userModel()." + self.calibpars[i] - newmap = self.WF.ifthenelse( - self.AreaMap == self.AreaCode, newmap * j, newmap - ) - strr_new = ( - "self.WF.report(newmap," - + '"' - + self.caseName - + "/" - + self.runId - + "/" - + self.calibpars[i] - + "_" - + str(self.ColSim) - + "_" - + str(self.ColMeas) - + "_" - + str(self.AreaCode) - + '.map")' - ) + self.log.log(45,"Saving parameter: " + self.calibpars[i]) + exec("newmap = self.dynModelFw._userModel()." + self.calibpars[i]) + newmap = self.WF.ifthenelse(self.AreaMap == self.AreaCode,newmap * j, newmap) + strr_new = "self.WF.report(newmap," + "\""+ self.caseName + "/" + self.runId +"/" + self.calibpars[i] + "_" + str(self.ColSim) + "_" + str(self.ColMeas) + "_" + str(self.AreaCode)+ ".map\")" if savetoinput: - self.log.log(45, "Saving adjusted map to input!!") - str_save = ( - "self.WF.report(newmap," - + '"' - + self.caseName - + "/staticmaps/" - + self.calibpars[i] - + '.map")' - ) - exec str_save + self.log.log(45,"Saving adjusted map to input!!") + str_save = "self.WF.report(newmap," + "\""+ self.caseName + "/staticmaps/" + self.calibpars[i] + ".map\")" + exec(str_save) - exec strr_new + exec(strr_new) i = i + 1 def shutdown(self): @@ -326,25 +301,25 @@ """ """ nowpars = mimo.pars - print nowpars + print(nowpars) i = 0 results = [] execstr = "mimo.range[mimo.calibpars[" + str(i) + "]]" - print "=========" - for i in range(0, len(mimo.calibpars)): - if i > 0: + print("=========") + for i in range(0,len(mimo.calibpars)): + if i>0: execstr = execstr + ", mimo.range[mimo.calibpars[" + str(i) + "]]" - print execstr - for parmult in mimo.range[mimo.calibpars[i]]: + print(execstr) + for parmult in mimo.range[mimo.calibpars[i]]: nowpars[i] = parmult + + exec("combi = itertools.product(" + execstr + ")") - exec "combi = itertools.product(" + execstr + ")" - while 1: try: - thisparset = combi.next() - print "Parameters:" + str(thisparset) + thisparset = next(combi) + print("Parameters:" + str(thisparset)) q = mimo.run(thisparset) res = q - qmeas @@ -389,7 +364,7 @@ pylab.savefig(os.path.join(caseName, runId, str(mimo.ColSim) + "fit.png")) # zz = errfuncFIT(thisparset,qmeas,mimo,caseName,runId) except: - print "Unexpected error:", sys.exc_info()[0] + print("Unexpected error:", sys.exc_info()[0]) break return results @@ -431,9 +406,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -442,29 +416,29 @@ ff = open(fname, "w") i = 0 - print >> ff, "Optimised parameter multiplication values:" + print("Optimised parameter multiplication values:", file=ff) if np.iterable(pp): for par in pp: - print >> ff, "Parameter " + calibpars[i] + " = " + str(par) + print("Parameter " + calibpars[i] + " = " + str(par), file=ff) i = i + 1 else: - print >> ff, "Parameter " + calibpars[0] + " = " + str(pp) - - print >> ff, "Estimate of the jacobian around the solution: " + str(a) - for dtc in b: - print >> ff, dtc + " = " + str(b[dtc]) - - if d in [1, 2, 3, 4]: - print >> ff, "A solution was found (" + str(d) + ")" - print >> ff, c + print("Parameter " + calibpars[0] + " = " + str(pp), file=ff) + + print("Estimate of the jacobian around the solution: " + str(a), file=ff) + for dtc in b: + print(dtc + " = " + str(b[dtc]), file=ff) + + if d in [1,2,3,4]: + print("A solution was found (" + str(d) + ")", file=ff) + print(c, file=ff) else: - print >> ff, "No solution was found (" + str(d) + ")" - print >> ff, c - - print >> ff, "NS: " + str(model.NS) - print >> ff, "BIAS: " + str(model.BIAS) - print >> ff, "CORR: " + str(model.CORR) - print >> ff, "MABSE: " + str(model.MABSE) + print("No solution was found (" + str(d) + ")", file=ff) + print(c, file=ff) + + print("NS: " +str(model.NS), file=ff) + print("BIAS: " +str(model.BIAS), file=ff) + print("CORR: " +str(model.CORR), file=ff) + print("MABSE: " +str(model.MABSE), file=ff) ff.close() Index: wflow-py/wflow/wflow_floodmap.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_floodmap.py (.../wflow_floodmap.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_floodmap.py (.../wflow_floodmap.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -73,9 +73,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -372,28 +371,20 @@ opts, args = getopt.getopt(argv, "C:S:T:c:s:R:fIs:l:") for o, a in opts: - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-c": - configfile = a - if o == "-l": - exec "loglevel = logging." + a - if o == "-s": - timestepsecs = int(a) - if o == "-T": - _lastTimeStep = int(a) - if o == "-S": - _firstTimeStep = int(a) + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-c': configfile = a + if o == '-l': exec("loglevel = logging." + a) + if o == '-s': timestepsecs = int(a) + if o == '-T': _lastTimeStep=int(a) + if o == '-S': _firstTimeStep=int(a) - if len(opts) <= 1: + + if (len(opts) <=1): usage() if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is cmaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) +") is cmaller than the last timestep (" + str(_lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) Index: wflow-py/wflow/wflow_funcs.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_funcs.py (.../wflow_funcs.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/wflow_funcs.py (.../wflow_funcs.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -174,31 +174,29 @@ def bf_oneparam(discharge, k): - bf = range(0, len(discharge)) - for i in range(1, len(discharge)): - bf[i] = (k * bf[i - 1] / (2.0 - k)) + ((1.0 - k) * discharge[i] / (2.0 - k)) + bf = list(range(0,len(discharge))) + for i in range(1,len(discharge)): + bf[i] = (k*bf[i-1]/(2.0-k)) + ((1.0-k)*discharge[i]/(2.0-k)) if bf[i] > discharge[i]: bf[i] = discharge[i] return bf -def bf_twoparam(discharge, k, C): - bf = range(0, len(discharge)) - for i in range(1, len(discharge)): - bf[i] = (k * bf[i - 1] / (1.0 + C)) + ((C) * discharge[i] / (1.0 + C)) +def bf_twoparam(discharge, k,C): + bf = list(range(0,len(discharge))) + for i in range(1,len(discharge)): + bf[i] = (k*bf[i-1]/(1.0+C)) + ((C)*discharge[i]/(1.0+C)) if bf[i] > discharge[i]: bf[i] = discharge[i] return bf -def bf_threeparam(discharge, k, C, a): - bf = range(0, len(discharge)) - for i in range(1, len(discharge)): - bf[i] = (k * bf[i - 1] / (1.0 + C)) + ( - (C) * discharge[i] + a * discharge[i - 1] / (1.0 + C) - ) +def bf_threeparam(discharge, k,C,a): + bf = list(range(0,len(discharge))) + for i in range(1,len(discharge)): + bf[i] = (k*bf[i-1]/(1.0+C)) + ((C)*discharge[i] + a*discharge[i-1]/(1.0+C)) if bf[i] > discharge[i]: bf[i] = discharge[i] Index: wflow-py/wflow/wflow_gr4.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_gr4.py (.../wflow_gr4.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_gr4.py (.../wflow_gr4.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -48,9 +48,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -488,32 +487,21 @@ opts, args = getopt.getopt(argv, "C:S:T:c:s:R:fhIXi:l:") for o, a in opts: - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-c": - configfile = a - if o == "-s": - timestepsecs = int(a) - if o == "-T": - _lastTimeStep = int(a) - if o == "-S": - _firstTimeStep = int(a) - if o == "-f": - NoOverWrite = 0 - if o == "-h": - usage() - if o == "-l": - exec "loglevel = logging." + a + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-c': configfile = a + if o == '-s': timestepsecs = int(a) + if o == '-T': _lastTimeStep=int(a) + if o == '-S': _firstTimeStep=int(a) + if o == '-f': NoOverWrite = 0 + if o == '-h': usage() + if o == '-l': exec("loglevel = logging." + a) if len(opts) <= 1: usage() if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) +") is smaller than the last timestep (" + str(_lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) Index: wflow-py/wflow/wflow_hbv.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_hbv.py (.../wflow_hbv.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_hbv.py (.../wflow_hbv.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -110,9 +110,8 @@ - *args: command line arguments given """ sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -1527,48 +1526,40 @@ ## Main model starts here ######################################################################## try: - opts, args = getopt.getopt(argv, "c:QXS:F:hC:Ii:T:R:u:s:P:p:Xx:U:fl:L:") - except getopt.error, msg: + opts, args = getopt.getopt(argv, 'c:QXS:F:hC:Ii:T:R:u:s:P:p:Xx:U:fl:L:') + except getopt.error as msg: pcrut.usage(msg) for o, a in opts: if o == "-F": runinfoFile = a fewsrun = True - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-L": - LogFileName = a - if o == "-l": - exec "loglevel = logging." + a - if o == "-c": - configfile = a - if o == "-s": - timestepsecs = int(a) - if o == "-h": - usage() - if o == "-f": - NoOverWrite = 0 + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-L': LogFileName = a + if o == '-l': exec("loglevel = logging." + a) + if o == '-c': configfile = a + if o == '-s': timestepsecs = int(a) + if o == '-h': usage() + if o == '-f': NoOverWrite = 0 + + if fewsrun: ts = getTimeStepsfromRuninfo(runinfoFile, timestepsecs) starttime = getStartTimefromRuninfo(runinfoFile) if ts: _lastTimeStep = ts # * 86400/timestepsecs _firstTimeStep = 1 else: - print "Failed to get timesteps from runinfo file: " + runinfoFile + print("Failed to get timesteps from runinfo file: " + runinfoFile) sys.exit(2) else: - starttime = dt.datetime(1990, 01, 01) + starttime = dt.datetime(1990,0o1,0o1) if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) +") is smaller than the last timestep (" + str(_lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) @@ -1583,39 +1574,27 @@ ) for o, a in opts: - if o == "-P": - left = a.split("=")[0] - right = a.split("=")[1] - configset( - myModel.config, "variable_change_once", left, right, overwrite=True - ) - if o == "-p": - left = a.split("=")[0] - right = a.split("=")[1] - configset( - myModel.config, "variable_change_timestep", left, right, overwrite=True - ) - if o == "-X": - configset(myModel.config, "model", "OverWriteInit", "1", overwrite=True) - if o == "-I": - configset(myModel.config, "run", "reinit", "1", overwrite=True) - if o == "-i": - configset(myModel.config, "model", "intbl", a, overwrite=True) - if o == "-s": - configset(myModel.config, "model", "timestepsecs", a, overwrite=True) - if o == "-x": - configset(myModel.config, "model", "sCatch", a, overwrite=True) - if o == "-c": - configset(myModel.config, "model", "configfile", a, overwrite=True) - if o == "-M": - configset(myModel.config, "model", "MassWasting", "0", overwrite=True) - if o == "-Q": - configset(myModel.config, "model", "ExternalQbase", "1", overwrite=True) - if o == "-U": - configset(myModel.config, "model", "updateFile", a, overwrite=True) - configset(myModel.config, "model", "updating", "1", overwrite=True) - if o == "-u": - exec "zz =" + a + if o == '-P': + left = a.split('=')[0] + right = a.split('=')[1] + configset(myModel.config,'variable_change_once',left,right,overwrite=True) + if o == '-p': + left = a.split('=')[0] + right = a.split('=')[1] + configset(myModel.config,'variable_change_timestep',left,right,overwrite=True) + if o == '-X': configset(myModel.config,'model','OverWriteInit','1',overwrite=True) + if o == '-I': configset(myModel.config,'run','reinit','1',overwrite=True) + if o == '-i': configset(myModel.config,'model','intbl',a,overwrite=True) + if o == '-s': configset(myModel.config,'model','timestepsecs',a,overwrite=True) + if o == '-x': configset(myModel.config,'model','sCatch',a,overwrite=True) + if o == '-c': configset(myModel.config,'model','configfile', a,overwrite=True) + if o == '-M': configset(myModel.config,'model','MassWasting',"0",overwrite=True) + if o == '-Q': configset(myModel.config,'model','ExternalQbase','1',overwrite=True) + if o == '-U': + configset(myModel.config,'model','updateFile',a,overwrite=True) + configset(myModel.config,'model','updating',"1",overwrite=True) + if o == '-u': + exec("zz =" + a) updateCols = zz if o == "-T": configset(myModel.config, "run", "endtime", a, overwrite=True) Index: wflow-py/wflow/wflow_hbvl.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_hbvl.py (.../wflow_hbvl.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_hbvl.py (.../wflow_hbvl.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -1,862 +1,604 @@ -#!/usr/bin/python -# Wflow is Free software, see below: -# -# Copyright (c) Hylke Beck (JRC) J. Schellekens 2005-2013 -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# TODO: split off routing - -""" -Run the wflow_hbvl (hbv light) hydrological model.. - -usage: -wflow_hbv:: - - [-h][-v level][-F runinfofile][-L logfile][-C casename][-R runId] - [-c configfile][-T timesteps][-s seconds][-W][-E][-N][-U discharge] - [-P parameter multiplication][-X][-l loglevel] - - --f: Force overwrite of existing results - --T: Set the number of timesteps to run - --N: No lateral flow, use runoff response function to generate fast runoff - --s: Set the model timesteps in seconds - --I: re-initialize the initial model conditions with default - --i: Set input table directory (default is intbl) - --x: run for subcatchment only (e.g. -x 1) - --C: set the name of the case (directory) to run - --R: set the name runId within the current case - --L: set the logfile - --c: name of wflow the configuration file (default: Casename/wflow_hbv.ini). - --h: print usage information - --U: The argument to this option should be a .tss file with measured discharge in - [m^3/s] which the program will use to update the internal state to match - the measured flow. The number of columns in this file should match the - number of gauges in the wflow\_gauges.map file. - --u: list of gauges/columns to use in update. Format: - -u [1 , 4 ,13] - The above example uses column 1, 4 and 13 - --P: set parameter change string (e.g: -P 'self.FC = self.FC * 1.6') for non-dynamic variables - --p: set parameter change string (e.g: -P 'self.Precipitation = self.Precipitation * 1.11') for - dynamic variables - --l: loglevel (most be one of DEBUG, WARNING, ERROR) - --X overwrites the initial values at the end of each timestep - - -""" - -import numpy -import os -import os.path -import shutil, glob -import getopt - -from wflow.wf_DynamicFramework import * -from wflow.wf_DynamicFramework import * -from wflow.wflow_adapt import * -from wflow_adapt import * - -# import scipy -# import pcrut - - -wflow = "wflow_hbv" - - -#: columns used in updating -updateCols = [] #: columns used in updating -""" Column used in updating """ - - -def usage(*args): - """ - Print usage information - - - *args: command line arguments given - """ - sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ - sys.exit(0) - - -class WflowModel(DynamicModel): - - """ - The user defined model class. - - """ - - def __init__(self, cloneMap, Dir, RunDir, configfile): - DynamicModel.__init__(self) - self.caseName = os.path.abspath(Dir) - self.clonemappath = os.path.join(os.path.abspath(Dir), "staticmaps", cloneMap) - setclone(self.clonemappath) - self.runId = RunDir - self.Dir = os.path.abspath(Dir) - self.configfile = configfile - self.SaveDir = os.path.join(self.Dir, self.runId) - - def stateVariables(self): - """ - returns a list of state variables that are essential to the model. - This list is essential for the resume and suspend functions to work. - - This function is specific for each model and **must** be present. - - :var self.DrySnow: Snow pack [mm] - :var self.FreeWater: Available free water [mm] - :var self.UpperZoneStorage: Water in the upper zone [mm] - :var self.LowerZoneStorage: Water in the lower zone [mm] - :var self.SoilMoisture: Soil moisture [mm] - - """ - states = [ - "FreeWater", - "SoilMoisture", - "UpperZoneStorage", - "LowerZoneStorage", - "DrySnow", - ] - - return states - - # The following are made to better connect to deltashell/openmi - def supplyCurrentTime(self): - """ - gets the current time in seconds after the start of the run - - Ouput: - - time in seconds since the start of the model run - """ - return self.currentTimeStep() * int( - configget(self.config, "model", "timestepsecs", "86400") - ) - - def parameters(self): - """ - Define all model parameters here that the framework should handle for the model - See wf_updateparameters and the parameters section of the ini file - If you use this make sure to all wf_updateparameters at the start of the dynamic section - and at the start/end of the initial section - """ - modelparameters = [] - - # Static model parameters e.g. - # modelparameters.append(self.ParamType(name="RunoffGeneratingGWPerc",stack="intbl/RunoffGeneratingGWPerc.tbl",type="static",default=0.1)) - - # Meteo and other forcing - - modelparameters.append( - self.ParamType( - name="Precipitation", - stack="inmaps/P", - type="timeseries", - default=0.0, - verbose=False, - lookupmaps=[], - ) - ) - modelparameters.append( - self.ParamType( - name="PotEvaporation", - stack="inmaps/PET", - type="timeseries", - default=0.0, - verbose=False, - lookupmaps=[], - ) - ) - modelparameters.append( - self.ParamType( - name="Temperature", - stack="inmaps/TEMP", - type="timeseries", - default=10.0, - verbose=False, - lookupmaps=[], - ) - ) - - return modelparameters - - def suspend(self): - """ - Suspends the model to disk. All variables needed to restart the model - are saved to disk as pcraster maps. Use resume() to re-read them - """ - - self.logger.info("Saving initial conditions...") - self.wf_suspend(os.path.join(self.SaveDir, "outstate")) - - if self.OverWriteInit: - self.logger.info("Saving initial conditions over start conditions...") - self.wf_suspend(os.path.join(self.SaveDir, "instate")) - - def initial(self): - - """ - Initial part of the model, executed only once. Reads all static model - information (parameters) and sets-up the variables used in modelling. - - *HBV Soil* - - :var FC.tbl: Field Capacity (260.0) [mm] - :var BETA.tbl: exponent in soil runoff generation equation (1.8) [-] - :var LP.tbl: fraction of Fieldcapacity below which actual evaporation=potential evaporation (0.53000) - :var K2.tbl: Recession constant baseflow (0.02307) - - *If SetKquickFlow is set to 1* - - :var K1.tbl: (0.09880) - :var SUZ.tbl: Level over wich K0 is used (100.0) - :var K0.tbl: (0.3) - - - :var PERC.tbl: Percolation from Upper to Lowerzone (0.4000) [mm/day] - :var CFR.tbl: Refreezing efficiency constant in refreezing of freewater in snow (0.05000) - :var PCORR.tbl: Correction factor for precipitation (1.0) - :var RFCF.tbl: Correction factor for rainfall (1.0) - :var SFCF.tbl: Correction factor for snowfall(1.0) - :var CEVPF.tbl: Correction factor for potential evaporation (1.0) - :var EPF.tbl: Exponent of correction factor for evaporation on days with precipitation(0.0) - :var ECORR.tbl: Evap correction (1.0) - - - *Snow modelling parameters* - - :var TTI.tbl: critical temperature for snowmelt and refreezing (1.000) [oC] - :var TT.tbl: defines interval in which precipitation falls as rainfall and snowfall (-1.41934) [oC] - :var CFMAX.tbl: meltconstant in temperature-index ( 3.75653) [-] - :var WHC.tbl: fraction of Snowvolume that can store water (0.1) [-] - - - """ - global statistics - global multpars - global updateCols - - setglobaloption("unittrue") - - self.thestep = scalar(0) - - #: files to be used in case of timesries (scalar) input to the model - - #: name of the tss file with precipitation data ("../intss/P.tss") - - self.logger.info("running for " + str(self.nrTimeSteps()) + " timesteps") - - # Set and get defaults from ConfigFile here ################################### - - self.interpolMethod = configget( - self.config, "model", "InterpolationMethod", "inv" - ) - self.reinit = int(configget(self.config, "run", "reinit", "0")) - self.OverWriteInit = int(configget(self.config, "model", "OverWriteInit", "0")) - - self.intbl = configget(self.config, "model", "intbl", "intbl") - self.timestepsecs = int( - configget(self.config, "model", "timestepsecs", "86400") - ) - self.P_style = int(configget(self.config, "model", "P_style", "1")) - self.PET_style = int(configget(self.config, "model", "PET_style", "1")) - self.TEMP_style = int(configget(self.config, "model", "TEMP_style", "1")) - - sizeinmetres = int(configget(self.config, "layout", "sizeinmetres", "0")) - - # static maps to use (normally default) - wflow_subcatch = configget( - self.config, "model", "wflow_subcatch", "staticmaps/wflow_subcatch.map" - ) - wflow_dem = configget( - self.config, "model", "wflow_dem", "staticmaps/wflow_dem.map" - ) - wflow_landuse = configget( - self.config, "model", "wflow_landuse", "staticmaps/wflow_landuse.map" - ) - wflow_soil = configget( - self.config, "model", "wflow_soil", "staticmaps/wflow_soil.map" - ) - wflow_gauges = configget( - self.config, "model", "wflow_gauges", "staticmaps/wflow_gauges.map" - ) - - # 2: Input base maps ######################################################## - subcatch = ordinal( - self.wf_readmap(os.path.join(self.Dir, wflow_subcatch), 0.0, fail=True) - ) # Determines the area of calculations (all cells > 0) - subcatch = ifthen(subcatch > 0, subcatch) - - self.Altitude = self.wf_readmap( - os.path.join(self.Dir, wflow_dem), 0.0, fail=True - ) * scalar( - defined(subcatch) - ) #: The digital elevation map (DEM) - self.TopoId = self.wf_readmap( - os.path.join(self.Dir, wflow_subcatch), 0.0, fail=True - ) #: Map define the area over which the calculations are done (mask) - - # read landuse and soilmap and make sure there are no missing points related to the - # subcatchment map. Currently sets the lu and soil type type to 1 - self.LandUse = self.wf_readmap( - os.path.join(self.Dir, wflow_landuse), 0.0, fail=True - ) #: Map with lan-use/cover classes - self.LandUse = cover(self.LandUse, nominal(ordinal(subcatch) > 0)) - self.Soil = self.wf_readmap( - os.path.join(self.Dir, wflow_soil), 0.0, fail=True - ) #: Map with soil classes - self.Soil = cover(self.Soil, nominal(ordinal(subcatch) > 0)) - self.OutputLoc = self.wf_readmap( - os.path.join(self.Dir, wflow_gauges), 0.0, fail=True - ) #: Map with locations of output gauge(s) - - # Temperature correction per cell to add - self.TempCor = self.wf_readmap( - os.path.join( - self.Dir, - configget( - self.config, - "model", - "TemperatureCorrectionMap", - "staticmap/swflow_tempcor.map", - ), - ), - 0.0, - ) - self.OutputId = self.wf_readmap( - os.path.join(self.Dir, wflow_subcatch), 0.0, fail=True - ) # location of subcatchment - - self.ZeroMap = 0.0 * scalar(defined(self.Altitude)) # map with only zero's - - # 3: Input time series ################################################### - self.P_mapstack = self.Dir + configget( - self.config, "inputmapstacks", "Precipitation", "/inmaps/P" - ) # timeseries for rainfall - self.PET_mapstack = self.Dir + configget( - self.config, "inputmapstacks", "EvapoTranspiration", "/inmaps/PET" - ) # timeseries for rainfall"/inmaps/PET" # potential evapotranspiration - self.TEMP_mapstack = self.Dir + configget( - self.config, "inputmapstacks", "Temperature", "/inmaps/TEMP" - ) # timeseries for rainfall "/inmaps/TEMP" # global radiation - # For in memory override: - self.P = self.ZeroMap - self.PET = self.ZeroMap - self.TEMP = self.ZeroMap - # Set static initial values here ######################################### - - self.Latitude = ycoordinate(boolean(self.Altitude)) - self.Longitude = xcoordinate(boolean(self.Altitude)) - - self.logger.info("Linking parameters to landuse, catchment and soil...") - - # TODO: Set default properly - # TODO: make unit test, running model - # HBV Soil params - # + BETA.tif - # + CFMAX.tif - # + CFR.tif - # + CWH.tif -> WHC.tif - # + FC.tif - # + K0.tif - # + K1.tif - # + K2.tif - # + LP.tif - # MAXBAS.tif - # + PCORR.tif - # + PERC.tif - # + SFCF.tif - # + TT.tif - # + UZL.tif - - self.FC = self.readtblDefault( - self.Dir + "/" + self.intbl + "/FC.tbl", - self.LandUse, - subcatch, - self.Soil, - 260.0, - ) - - self.BETA = self.readtblDefault( - self.Dir + "/" + self.intbl + "/BETA.tbl", - self.LandUse, - subcatch, - self.Soil, - 1.8, - ) # exponent in soil runoff generation equation - self.K0 = self.readtblDefault( - self.Dir + "/" + self.intbl + "/K0.tbl", - self.LandUse, - subcatch, - self.Soil, - 0.02307, - ) # Recession constant baseflow #K4=0.07; BASEFLOW:LINEARRESERVOIR - self.K1 = self.readtblDefault( - self.Dir + "/" + self.intbl + "/K2.tbl", - self.LandUse, - subcatch, - self.Soil, - 0.02307, - ) # Recession constant baseflow #K4=0.07; BASEFLOW:LINEARRESERVOIR - self.K2 = self.readtblDefault( - self.Dir + "/" + self.intbl + "/K2.tbl", - self.LandUse, - subcatch, - self.Soil, - 0.02307, - ) # Recession constant baseflow #K4=0.07; BASEFLOW:LINEARRESERVOIR - self.LP = self.readtblDefault( - self.Dir + "/" + self.intbl + "/LP.tbl", - self.LandUse, - subcatch, - self.Soil, - 0.4000, - ) # percolation from Upper to Lowerzone (mm/day) - self.UZL = self.readtblDefault( - self.Dir + "/" + self.intbl + "/UZL.tbl", - self.LandUse, - subcatch, - self.Soil, - 0.4000, - ) # percolation from Upper to Lowerzone (mm/day) - self.PERC = self.readtblDefault( - self.Dir + "/" + self.intbl + "/PERC.tbl", - self.LandUse, - subcatch, - self.Soil, - 0.4000, - ) # percolation from Upper to Lowerzone (mm/day) - self.CFR = self.readtblDefault( - self.Dir + "/" + self.intbl + "/CFR.tbl", - self.LandUse, - subcatch, - self.Soil, - 0.05000, - ) # refreezing efficiency constant in refreezing of freewater in snow - self.PCORR = self.readtblDefault( - self.Dir + "/" + self.intbl + "/PCORR.tbl", - self.LandUse, - subcatch, - self.Soil, - 1.0, - ) # correction factor for precipitation - self.SFCF = self.readtblDefault( - self.Dir + "/" + self.intbl + "/SFCF.tbl", - self.LandUse, - subcatch, - self.Soil, - 1.0, - ) # correction factor for snowfall - self.CFMAX = self.readtblDefault( - self.Dir + "/" + self.intbl + "/CFMAX.tbl", - self.LandUse, - subcatch, - self.Soil, - 2.0, - ) # maximum capillary rise from runoff response routine to soil moisture routine - self.WHC = self.readtblDefault( - self.Dir + "/" + self.intbl + "/WHC.tbl", - self.LandUse, - subcatch, - self.Soil, - 2.0, - ) # maximum capillary rise from runoff response routine to soil moisture routine - self.TTI = self.readtblDefault( - self.Dir + "/" + self.intbl + "/TTI.tbl", - self.LandUse, - subcatch, - self.Soil, - 1.0, - ) - self.TT = self.readtblDefault( - self.Dir + "/" + self.intbl + "/TT.tbl", - self.LandUse, - subcatch, - self.Soil, - -1.41934, - ) - # Cfmax = 3.75653 # meltconstant in temperature-index - self.RFCF = self.readtblDefault( - self.Dir + "/" + self.intbl + "/RFCF.tbl", - self.LandUse, - subcatch, - self.Soil, - 1.0, - ) # correction factor for rainfall - self.CEVPF = self.readtblDefault( - self.Dir + "/" + self.intbl + "/CEVPF.tbl", - self.LandUse, - subcatch, - self.Soil, - 1.0, - ) # correction factor for potential evaporation (1.15 in in forested areas ) - self.EPF = self.readtblDefault( - self.Dir + "/" + self.intbl + "/EPF.tbl", - self.LandUse, - subcatch, - self.Soil, - 0.0, - ) # exponent of correction factor for evaporation on days with precipitation - self.ECORR = self.readtblDefault( - self.Dir + "/" + self.intbl + "/ECORR.tbl", - self.LandUse, - subcatch, - self.Soil, - 1.0, - ) # evap correction - - # Determine real slope and cell length - self.xl, self.yl, self.reallength = pcrut.detRealCellLength( - self.ZeroMap, sizeinmetres - ) - - # Multiply parameters with a factor (for calibration etc) -P option in command line - self.wf_multparameters() - - self.SnowWater = self.ZeroMap - - # Initializing of variables - self.logger.info("Initializing of model variables..") - self.QMMConv = self.timestepsecs / ( - self.reallength * self.reallength * 0.001 - ) # m3/s --> mm - self.ToCubic = ( - self.reallength * self.reallength * 0.001 - ) / self.timestepsecs # m3/s - - self.FieldCapacity = self.FC #: total water holding capacity of the soil - self.Treshold = ( - self.LP * self.FieldCapacity - ) # Threshold soilwaterstorage above which AE=PE - - self.logger.info("End of initial section.") - - def default_summarymaps(self): - """ - Returns a list of default summary-maps at the end of a run. - This is model specific. You can also add them to the [summary]section of the ini file but stuff - you think is crucial to the model should be listed here - - Example: - - """ - lst = [ - "self.csize", - "self.upsize", - "self.TTI", - "self.TT", - "self.WHC", - "self.Slope", - "self.N", - "self.xl", - "self.yl", - "self.reallength", - "self.DCL", - "self.Bw", - ] - - return lst - - def resume(self): - """ read initial state maps (they are output of a previous call to suspend()) """ - - if self.reinit == 1: - self.logger.info("Setting initial conditions to default (zero!)") - self.FreeWater = cover(0.0) #: Water on surface (state variable [mm]) - self.SoilMoisture = self.FC #: Soil moisture (state variable [mm]) - self.UpperZoneStorage = ( - 0.2 * self.FC - ) #: Storage in Upper Zone (state variable [mm]) - self.LowerZoneStorage = 1.0 / ( - 3.0 * self.K2 - ) #: Storage in Uppe Zone (state variable [mm]) - self.DrySnow = cover(0.0) #: Snow amount (state variable [mm]) - else: - self.wf_resume(os.path.join(self.Dir, "instate")) - - self.initstorage = ( - self.FreeWater - + self.DrySnow - + self.SoilMoisture - + self.UpperZoneStorage - + self.LowerZoneStorage - ) - - def dynamic(self): - - """ - Below a list of variables that can be save to disk as maps or as - timeseries (see ini file for syntax): - - *Dynamic variables* - - :var self.Snow: Snow depth [mm] - :var self.SnowWater: water content of the snow [mm] - :var self.LowerZoneStorage: water content of the lower zone [mm] - :var self.UpperZoneStorage: water content of the Upper zone [mm] - :var self.Q2: Specific runoff (baseflow part) per cell [mm] - :var self.Percolation: actual percolation to the lower zone [mm] - :var self.SoilMoisture: actual soil moisture [mm] - :var self.Q1: specific runoff (quickflow part) [mm] - :var self.Q0: specific runoff (quickflow), If K upper zone is precalculated [mm] - - - *Static variables* - - :var self.Altitude: The altitude of each cell [m] - :var self.ToCubic: Mutiplier to convert mm to m^3/s for fluxes - """ - - self.logger.debug( - "Step: " + str(int(self.currentStep)) + "/" + str(int(self._d_nrTimeSteps)) - ) - self.thestep = self.thestep + 1 - - self.wf_updateparameters() # read forcing an dynamic parameters - - # Apply correction factor to precipitation - self.Precipitation = self.PCORR * self.Precipitation - self.Temperature = cover(self.wf_readmap(self.TEMP_mapstack, 10.0), 10.0) - self.Temperature = self.Temperature + self.TempCor - - # Multiply input parameters with a factor (for calibration etc) -p option in command line (no also in ini) - - self.wf_multparameters() - - RainFrac = ifthenelse( - 1.0 * self.TTI == 0.0, - ifthenelse(self.Temperature <= self.TT, scalar(0.0), scalar(1.0)), - min( - (self.Temperature - (self.TT - self.TTI / 2.0)) / self.TTI, scalar(1.0) - ), - ) - RainFrac = max( - RainFrac, scalar(0.0) - ) # fraction of precipitation which falls as rain - SnowFrac = 1.0 - RainFrac # fraction of self.Precipitation which falls as snow - self.Precipitation = ( - self.SFCF * SnowFrac * self.Precipitation - + self.RFCF * RainFrac * self.Precipitation - ) # different correction for rainfall and snowfall - - self.PotEvaporation = ( - exp(-self.EPF * self.Precipitation) * self.ECORR * self.PotEvaporation - ) # correction for potential evaporation on wet days - self.PotEvaporation = self.CEVPF * self.PotEvaporation # Correct per landuse - - SnowFall = SnowFrac * self.Precipitation #: snowfall depth - RainFall = RainFrac * self.Precipitation #: rainfall depth - PotSnowMelt = ifthenelse( - self.Temperature > self.TT, - self.CFMAX * (self.Temperature - self.TT), - scalar(0.0), - ) # Potential snow melt, based on temperature - PotRefreezing = ifthenelse( - self.Temperature < self.TT, - self.CFMAX * self.CFR * (self.TT - self.Temperature), - 0.0, - ) # Potential refreezing, based on temperature - - Refreezing = ifthenelse( - self.Temperature < self.TT, min(PotRefreezing, self.FreeWater), 0.0 - ) # actual refreezing - self.SnowMelt = min(PotSnowMelt, self.DrySnow) # actual snow melt - self.DrySnow = ( - self.DrySnow + SnowFall + Refreezing - self.SnowMelt - ) # dry snow content - self.FreeWater = self.FreeWater - Refreezing # free water content in snow - MaxFreeWater = self.DrySnow * self.WHC - self.FreeWater = self.FreeWater + self.SnowMelt + RainFall - InSoil = max( - self.FreeWater - MaxFreeWater, 0.0 - ) # abundant water in snow pack which goes into soil - self.FreeWater = self.FreeWater - InSoil - - # Soil and evaporation - soil_wetness = (self.SoilMoisture / self.FC) ** self.BETA - soil_wetness = max(min(soil_wetness, 1.0), 0.0) - recharge = (self.Precipitation + InSoil) * soil_wetness - self.SoilMoisture = self.SoilMoisture + self.Precipitation + InSoil - recharge - excess = self.SoilMoisture - self.FC - excess = max(excess, 0.0) - self.SoilMoisture = self.SoilMoisture - excess - evapfactor = self.SoilMoisture / (self.LP * self.FC) - evapfactor = min(max(evapfactor, 0.0), 1.0) - # ---------------- - self.ActEvap = self.PotEvaporation * evapfactor - self.ActEvap = min(self.SoilMoisture, self.ActEvap) - self.SoilMoisture = self.SoilMoisture - self.ActEvap - - # Groundwater boxes - self.UpperZoneStorage = self.UpperZoneStorage + recharge + excess - self.actPERC = min(self.UpperZoneStorage, self.PERC) - self.UpperZoneStorage = self.UpperZoneStorage - self.actPERC - self.Q0 = self.K0 * max(self.UpperZoneStorage - self.UZL, 0.0) - self.UpperZoneStorage = self.UpperZoneStorage - self.Q0 - self.Q1 = self.K1 * self.UpperZoneStorage - self.UpperZoneStorage = self.UpperZoneStorage - self.Q1 - self.LowerZoneStorage = self.LowerZoneStorage + self.actPERC - self.Q2 = self.K2 * self.LowerZoneStorage - self.LowerZoneStorage = self.LowerZoneStorage - self.Q2 - - DirectRunoffStorage = self.Q0 + self.Q1 + self.Q2 - - self.InwaterMM = max(0.0, DirectRunoffStorage) - self.Inwater = self.InwaterMM * self.ToCubic - self.QuickFlowCubic = (self.Q0 + self.Q1) * self.ToCubic - self.BaseFlowCubic = self.Q2 * self.ToCubic - - -# The main function is used to run the program from the command line - - -def main(argv=None): - """ - Perform command line execution of the model. - """ - global multpars - global updateCols - caseName = "default_hbv" - runId = "run_default" - configfile = "wflow_hbvl.ini" - LogFileName = "wflow.log" - _lastTimeStep = 0 - _firstTimeStep = 1 - runinfoFile = "runinfo.xml" - timestepsecs = 86400 - wflow_cloneMap = "wflow_subcatch.map" - NoOverWrite = 1 - loglevel = logging.DEBUG - - if argv is None: - argv = sys.argv[1:] - if len(argv) == 0: - usage() - return - - ## Main model starts here - ######################################################################## - try: - opts, args = getopt.getopt(argv, "c:QXS:hC:Ii:T:R:u:s:P:p:Xx:U:fl:L:") - except getopt.error, msg: - pcrut.usage(msg) - - for o, a in opts: - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-L": - LogFileName = a - if o == "-l": - exec "loglevel = logging." + a - if o == "-c": - configfile = a - if o == "-s": - timestepsecs = int(a) - if o == "-T": - _lastTimeStep = int(a) - if o == "-S": - _firstTimeStep = int(a) - if o == "-h": - usage() - if o == "-f": - NoOverWrite = 0 - - starttime = dt.datetime(1990, 01, 01) - - if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" - usage() - - myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) - dynModelFw = wf_DynamicFramework( - myModel, _lastTimeStep, firstTimestep=_firstTimeStep, datetimestart=starttime - ) - dynModelFw.createRunId( - NoOverWrite=NoOverWrite, - logfname=LogFileName, - level=loglevel, - doSetupFramework=False, - ) - - for o, a in opts: - if o == "-P": - left = a.split("=")[0] - right = a.split("=")[1] - configset( - myModel.config, "variable_change_once", left, right, overwrite=True - ) - if o == "-p": - left = a.split("=")[0] - right = a.split("=")[1] - configset( - myModel.config, "variable_change_timestep", left, right, overwrite=True - ) - if o == "-X": - configset(myModel.config, "model", "OverWriteInit", "1", overwrite=True) - if o == "-I": - configset(myModel.config, "model", "reinit", "1", overwrite=True) - if o == "-i": - configset(myModel.config, "model", "intbl", a, overwrite=True) - if o == "-s": - configset(myModel.config, "model", "timestepsecs", a, overwrite=True) - if o == "-x": - configset(myModel.config, "model", "sCatch", a, overwrite=True) - if o == "-c": - configset(myModel.config, "model", "configfile", a, overwrite=True) - if o == "-M": - configset(myModel.config, "model", "MassWasting", "0", overwrite=True) - if o == "-Q": - configset(myModel.config, "model", "ExternalQbase", "1", overwrite=True) - if o == "-U": - configset(myModel.config, "model", "updateFile", a, overwrite=True) - configset(myModel.config, "model", "updating", "1", overwrite=True) - if o == "-u": - exec "zz =" + a - updateCols = zz - - dynModelFw.setupFramework() - dynModelFw._runInitial() - dynModelFw._runResume() - dynModelFw._runDynamic(_firstTimeStep, _lastTimeStep) - dynModelFw._runSuspend() - dynModelFw._wf_shutdown() - - os.chdir("../../") - - -if __name__ == "__main__": - main() +#!/usr/bin/python +# Wflow is Free software, see below: +# +# Copyright (c) Hylke Beck (JRC) J. Schellekens 2005-2013 +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +#TODO: split off routing + +""" +Run the wflow_hbvl (hbv light) hydrological model.. + +usage: +wflow_hbv:: + + [-h][-v level][-F runinfofile][-L logfile][-C casename][-R runId] + [-c configfile][-T timesteps][-s seconds][-W][-E][-N][-U discharge] + [-P parameter multiplication][-X][-l loglevel] + + +-f: Force overwrite of existing results + +-T: Set the number of timesteps to run + +-N: No lateral flow, use runoff response function to generate fast runoff + +-s: Set the model timesteps in seconds + +-I: re-initialize the initial model conditions with default + +-i: Set input table directory (default is intbl) + +-x: run for subcatchment only (e.g. -x 1) + +-C: set the name of the case (directory) to run + +-R: set the name runId within the current case + +-L: set the logfile + +-c: name of wflow the configuration file (default: Casename/wflow_hbv.ini). + +-h: print usage information + +-U: The argument to this option should be a .tss file with measured discharge in + [m^3/s] which the program will use to update the internal state to match + the measured flow. The number of columns in this file should match the + number of gauges in the wflow\_gauges.map file. + +-u: list of gauges/columns to use in update. Format: + -u [1 , 4 ,13] + The above example uses column 1, 4 and 13 + +-P: set parameter change string (e.g: -P 'self.FC = self.FC * 1.6') for non-dynamic variables + +-p: set parameter change string (e.g: -P 'self.Precipitation = self.Precipitation * 1.11') for + dynamic variables + +-l: loglevel (most be one of DEBUG, WARNING, ERROR) + +-X overwrites the initial values at the end of each timestep + + +""" + +import numpy +import os +import os.path +import shutil, glob +import getopt + +from wflow.wf_DynamicFramework import * +from wflow.wf_DynamicFramework import * +from wflow.wflow_adapt import * +from .wflow_adapt import * + +#import scipy +#import pcrut + + + +wflow = "wflow_hbv" + + +#: columns used in updating +updateCols = [] #: columns used in updating +""" Column used in updating """ + + +def usage(*args): + """ + Print usage information + + - *args: command line arguments given + """ + sys.stdout = sys.stderr + for msg in args: print(msg) + print(__doc__) + sys.exit(0) + +class WflowModel(DynamicModel): + + """ + The user defined model class. + + """ + + + def __init__(self, cloneMap,Dir,RunDir,configfile): + DynamicModel.__init__(self) + self.caseName = os.path.abspath(Dir) + self.clonemappath = os.path.join(os.path.abspath(Dir),"staticmaps",cloneMap) + setclone(self.clonemappath) + self.runId = RunDir + self.Dir = os.path.abspath(Dir) + self.configfile = configfile + self.SaveDir = os.path.join(self.Dir,self.runId) + + + def stateVariables(self): + """ + returns a list of state variables that are essential to the model. + This list is essential for the resume and suspend functions to work. + + This function is specific for each model and **must** be present. + + :var self.DrySnow: Snow pack [mm] + :var self.FreeWater: Available free water [mm] + :var self.UpperZoneStorage: Water in the upper zone [mm] + :var self.LowerZoneStorage: Water in the lower zone [mm] + :var self.SoilMoisture: Soil moisture [mm] + + """ + states = ['FreeWater', 'SoilMoisture', + 'UpperZoneStorage', + 'LowerZoneStorage', + 'DrySnow'] + + return states + + + # The following are made to better connect to deltashell/openmi + def supplyCurrentTime(self): + """ + gets the current time in seconds after the start of the run + + Ouput: + - time in seconds since the start of the model run + """ + return self.currentTimeStep() * int(configget(self.config,'model','timestepsecs','86400')) + + def parameters(self): + """ + Define all model parameters here that the framework should handle for the model + See wf_updateparameters and the parameters section of the ini file + If you use this make sure to all wf_updateparameters at the start of the dynamic section + and at the start/end of the initial section + """ + modelparameters = [] + + #Static model parameters e.g. + #modelparameters.append(self.ParamType(name="RunoffGeneratingGWPerc",stack="intbl/RunoffGeneratingGWPerc.tbl",type="static",default=0.1)) + + # Meteo and other forcing + + modelparameters.append(self.ParamType(name="Precipitation",stack="inmaps/P",type="timeseries",default=0.0,verbose=False,lookupmaps=[])) + modelparameters.append(self.ParamType(name="PotEvaporation",stack="inmaps/PET",type="timeseries",default=0.0,verbose=False,lookupmaps=[])) + modelparameters.append(self.ParamType(name="Temperature",stack="inmaps/TEMP",type="timeseries",default=10.0,verbose=False,lookupmaps=[])) + + + + + return modelparameters + + + def suspend(self): + """ + Suspends the model to disk. All variables needed to restart the model + are saved to disk as pcraster maps. Use resume() to re-read them + """ + + + self.logger.info("Saving initial conditions...") + self.wf_suspend(os.path.join(self.SaveDir,"outstate")) + + if self.OverWriteInit: + self.logger.info("Saving initial conditions over start conditions...") + self.wf_suspend(os.path.join(self.SaveDir,"instate")) + + + + def initial(self): + + """ + Initial part of the model, executed only once. Reads all static model + information (parameters) and sets-up the variables used in modelling. + + *HBV Soil* + + :var FC.tbl: Field Capacity (260.0) [mm] + :var BETA.tbl: exponent in soil runoff generation equation (1.8) [-] + :var LP.tbl: fraction of Fieldcapacity below which actual evaporation=potential evaporation (0.53000) + :var K2.tbl: Recession constant baseflow (0.02307) + + *If SetKquickFlow is set to 1* + + :var K1.tbl: (0.09880) + :var SUZ.tbl: Level over wich K0 is used (100.0) + :var K0.tbl: (0.3) + + + :var PERC.tbl: Percolation from Upper to Lowerzone (0.4000) [mm/day] + :var CFR.tbl: Refreezing efficiency constant in refreezing of freewater in snow (0.05000) + :var PCORR.tbl: Correction factor for precipitation (1.0) + :var RFCF.tbl: Correction factor for rainfall (1.0) + :var SFCF.tbl: Correction factor for snowfall(1.0) + :var CEVPF.tbl: Correction factor for potential evaporation (1.0) + :var EPF.tbl: Exponent of correction factor for evaporation on days with precipitation(0.0) + :var ECORR.tbl: Evap correction (1.0) + + + *Snow modelling parameters* + + :var TTI.tbl: critical temperature for snowmelt and refreezing (1.000) [oC] + :var TT.tbl: defines interval in which precipitation falls as rainfall and snowfall (-1.41934) [oC] + :var CFMAX.tbl: meltconstant in temperature-index ( 3.75653) [-] + :var WHC.tbl: fraction of Snowvolume that can store water (0.1) [-] + + + """ + global statistics + global multpars + global updateCols + + setglobaloption("unittrue") + + + self.thestep = scalar(0) + + #: files to be used in case of timesries (scalar) input to the model + + #: name of the tss file with precipitation data ("../intss/P.tss") + + + self.logger.info("running for " + str(self.nrTimeSteps()) + " timesteps") + + + # Set and get defaults from ConfigFile here ################################### + + self.interpolMethod = configget(self.config,"model","InterpolationMethod","inv") + self.reinit = int(configget(self.config,"run","reinit","0")) + self.OverWriteInit = int(configget(self.config,"model","OverWriteInit","0")) + + self.intbl = configget(self.config,"model","intbl","intbl") + self.timestepsecs = int(configget(self.config,"model","timestepsecs","86400")) + self.P_style = int(configget(self.config,"model","P_style","1")) + self.PET_style = int(configget(self.config,"model","PET_style","1")) + self.TEMP_style = int(configget(self.config,"model","TEMP_style","1")) + + sizeinmetres = int(configget(self.config,"layout","sizeinmetres","0")) + + # static maps to use (normally default) + wflow_subcatch = configget(self.config,"model","wflow_subcatch","staticmaps/wflow_subcatch.map") + wflow_dem = configget(self.config,"model","wflow_dem","staticmaps/wflow_dem.map") + wflow_landuse = configget(self.config,"model","wflow_landuse","staticmaps/wflow_landuse.map") + wflow_soil = configget(self.config,"model","wflow_soil","staticmaps/wflow_soil.map") + wflow_gauges = configget(self.config,"model","wflow_gauges","staticmaps/wflow_gauges.map") + + # 2: Input base maps ######################################################## + subcatch = ordinal(self.wf_readmap(os.path.join(self.Dir,wflow_subcatch),0.0,fail=True)) # Determines the area of calculations (all cells > 0) + subcatch = ifthen(subcatch > 0, subcatch) + + self.Altitude=self.wf_readmap(os.path.join(self.Dir,wflow_dem),0.0,fail=True) * scalar(defined(subcatch)) #: The digital elevation map (DEM) + self.TopoId=self.wf_readmap(os.path.join(self.Dir, wflow_subcatch),0.0,fail=True) #: Map define the area over which the calculations are done (mask) + + # read landuse and soilmap and make sure there are no missing points related to the + # subcatchment map. Currently sets the lu and soil type type to 1 + self.LandUse=self.wf_readmap(os.path.join(self.Dir , wflow_landuse),0.0,fail=True)#: Map with lan-use/cover classes + self.LandUse=cover(self.LandUse,nominal(ordinal(subcatch) > 0)) + self.Soil=self.wf_readmap(os.path.join(self.Dir , wflow_soil),0.0,fail=True)#: Map with soil classes + self.Soil=cover(self.Soil,nominal(ordinal(subcatch) > 0)) + self.OutputLoc=self.wf_readmap(os.path.join(self.Dir , wflow_gauges),0.0,fail=True) #: Map with locations of output gauge(s) + + + # Temperature correction per cell to add + self.TempCor=self.wf_readmap(os.path.join(self.Dir , configget(self.config,"model","TemperatureCorrectionMap","staticmap/swflow_tempcor.map")),0.0) + self.OutputId=self.wf_readmap(os.path.join(self.Dir , wflow_subcatch),0.0,fail=True) # location of subcatchment + + self.ZeroMap=0.0*scalar(defined(self.Altitude)) #map with only zero's + + # 3: Input time series ################################################### + self.P_mapstack=self.Dir + configget(self.config,"inputmapstacks","Precipitation","/inmaps/P") # timeseries for rainfall + self.PET_mapstack=self.Dir + configget(self.config,"inputmapstacks","EvapoTranspiration","/inmaps/PET") # timeseries for rainfall"/inmaps/PET" # potential evapotranspiration + self.TEMP_mapstack=self.Dir + configget(self.config,"inputmapstacks","Temperature","/inmaps/TEMP") # timeseries for rainfall "/inmaps/TEMP" # global radiation + # For in memory override: + self.P = self.ZeroMap + self.PET = self.ZeroMap + self.TEMP = self.ZeroMap + # Set static initial values here ######################################### + + self.Latitude = ycoordinate(boolean(self.Altitude)) + self.Longitude = xcoordinate(boolean(self.Altitude)) + + self.logger.info("Linking parameters to landuse, catchment and soil...") + + # TODO: Set default properly + # TODO: make unit test, running model + #HBV Soil params + # + BETA.tif + # + CFMAX.tif + # + CFR.tif + # + CWH.tif -> WHC.tif + # + FC.tif + # + K0.tif + # + K1.tif + # + K2.tif + # + LP.tif + # MAXBAS.tif + # + PCORR.tif + # + PERC.tif + # + SFCF.tif + # + TT.tif + # + UZL.tif + + self.FC = self.readtblDefault(self.Dir + "/" + self.intbl + "/FC.tbl",self.LandUse,subcatch,self.Soil,260.0) + + self.BETA= self.readtblDefault(self.Dir + "/" + self.intbl + "/BETA.tbl",self.LandUse,subcatch,self.Soil,1.8) # exponent in soil runoff generation equation + self.K0= self.readtblDefault(self.Dir + "/" + self.intbl + "/K0.tbl",self.LandUse,subcatch,self.Soil, 0.02307) # Recession constant baseflow #K4=0.07; BASEFLOW:LINEARRESERVOIR + self.K1= self.readtblDefault(self.Dir + "/" + self.intbl + "/K2.tbl",self.LandUse,subcatch,self.Soil, 0.02307) # Recession constant baseflow #K4=0.07; BASEFLOW:LINEARRESERVOIR + self.K2= self.readtblDefault(self.Dir + "/" + self.intbl + "/K2.tbl",self.LandUse,subcatch,self.Soil, 0.02307) # Recession constant baseflow #K4=0.07; BASEFLOW:LINEARRESERVOIR + self.LP= self.readtblDefault(self.Dir + "/" + self.intbl + "/LP.tbl",self.LandUse,subcatch,self.Soil, 0.4000) # percolation from Upper to Lowerzone (mm/day) + self.UZL= self.readtblDefault(self.Dir + "/" + self.intbl + "/UZL.tbl",self.LandUse,subcatch,self.Soil, 0.4000) # percolation from Upper to Lowerzone (mm/day) + self.PERC= self.readtblDefault(self.Dir + "/" + self.intbl + "/PERC.tbl",self.LandUse,subcatch,self.Soil, 0.4000) # percolation from Upper to Lowerzone (mm/day) + self.CFR=self.readtblDefault(self.Dir + "/" + self.intbl + "/CFR.tbl",self.LandUse,subcatch,self.Soil, 0.05000) # refreezing efficiency constant in refreezing of freewater in snow + self.PCORR=self.readtblDefault(self.Dir + "/" + self.intbl + "/PCORR.tbl",self.LandUse,subcatch,self.Soil, 1.0) # correction factor for precipitation + self.SFCF=self.readtblDefault(self.Dir + "/" + self.intbl + "/SFCF.tbl",self.LandUse,subcatch,self.Soil, 1.0) # correction factor for snowfall + self.CFMAX= self.readtblDefault(self.Dir + "/" + self.intbl + "/CFMAX.tbl",self.LandUse,subcatch,self.Soil, 2.0) # maximum capillary rise from runoff response routine to soil moisture routine + self.WHC= self.readtblDefault(self.Dir + "/" + self.intbl + "/WHC.tbl",self.LandUse,subcatch,self.Soil, 2.0) # maximum capillary rise from runoff response routine to soil moisture routine + self.TTI=self.readtblDefault(self.Dir + "/" + self.intbl + "/TTI.tbl" ,self.LandUse,subcatch,self.Soil,1.0) + self.TT=self.readtblDefault(self.Dir + "/" + self.intbl + "/TT.tbl" ,self.LandUse,subcatch,self.Soil,-1.41934) + #Cfmax = 3.75653 # meltconstant in temperature-index + self.RFCF=self.readtblDefault(self.Dir + "/" + self.intbl + "/RFCF.tbl",self.LandUse,subcatch,self.Soil,1.0) # correction factor for rainfall + self.CEVPF= self.readtblDefault(self.Dir + "/" + self.intbl + "/CEVPF.tbl",self.LandUse,subcatch,self.Soil, 1.0) # correction factor for potential evaporation (1.15 in in forested areas ) + self.EPF= self.readtblDefault(self.Dir + "/" + self.intbl + "/EPF.tbl",self.LandUse,subcatch,self.Soil, 0.0) # exponent of correction factor for evaporation on days with precipitation + self.ECORR= self.readtblDefault(self.Dir + "/" + self.intbl + "/ECORR.tbl",self.LandUse,subcatch,self.Soil, 1.0) # evap correction + + # Determine real slope and cell length + self.xl,self.yl,self.reallength = pcrut.detRealCellLength(self.ZeroMap,sizeinmetres) + + # Multiply parameters with a factor (for calibration etc) -P option in command line + self.wf_multparameters() + + self.SnowWater = self.ZeroMap + + # Initializing of variables + self.logger.info("Initializing of model variables..") + self.QMMConv = self.timestepsecs/(self.reallength * self.reallength * 0.001) #m3/s --> mm + self.ToCubic = (self.reallength * self.reallength * 0.001) / self.timestepsecs # m3/s + + self.FieldCapacity=self.FC #: total water holding capacity of the soil + self.Treshold=self.LP*self.FieldCapacity # Threshold soilwaterstorage above which AE=PE + + self.logger.info("End of initial section.") + + + def default_summarymaps(self): + """ + Returns a list of default summary-maps at the end of a run. + This is model specific. You can also add them to the [summary]section of the ini file but stuff + you think is crucial to the model should be listed here + + Example: + + """ + lst = ['self.csize','self.upsize','self.TTI','self.TT','self.WHC', + 'self.Slope','self.N','self.xl','self.yl','self.reallength','self.DCL','self.Bw',] + + return lst + + def resume(self): + """ read initial state maps (they are output of a previous call to suspend()) """ + + if self.reinit == 1: + self.logger.info("Setting initial conditions to default (zero!)") + self.FreeWater = cover(0.0) #: Water on surface (state variable [mm]) + self.SoilMoisture = self.FC #: Soil moisture (state variable [mm]) + self.UpperZoneStorage = 0.2 * self.FC #: Storage in Upper Zone (state variable [mm]) + self.LowerZoneStorage = 1.0/(3.0 * self.K2) #: Storage in Uppe Zone (state variable [mm]) + self.DrySnow=cover(0.0) #: Snow amount (state variable [mm]) + else: + self.wf_resume(os.path.join(self.Dir, "instate")) + + self.initstorage=self.FreeWater + self.DrySnow + self.SoilMoisture + self.UpperZoneStorage + self.LowerZoneStorage + + + + def dynamic(self): + + """ + Below a list of variables that can be save to disk as maps or as + timeseries (see ini file for syntax): + + *Dynamic variables* + + :var self.Snow: Snow depth [mm] + :var self.SnowWater: water content of the snow [mm] + :var self.LowerZoneStorage: water content of the lower zone [mm] + :var self.UpperZoneStorage: water content of the Upper zone [mm] + :var self.Q2: Specific runoff (baseflow part) per cell [mm] + :var self.Percolation: actual percolation to the lower zone [mm] + :var self.SoilMoisture: actual soil moisture [mm] + :var self.Q1: specific runoff (quickflow part) [mm] + :var self.Q0: specific runoff (quickflow), If K upper zone is precalculated [mm] + + + *Static variables* + + :var self.Altitude: The altitude of each cell [m] + :var self.ToCubic: Mutiplier to convert mm to m^3/s for fluxes + """ + + self.logger.debug("Step: " + str(int(self.currentStep)) + "/" + str(int(self._d_nrTimeSteps))) + self.thestep = self.thestep + 1 + + self.wf_updateparameters() # read forcing an dynamic parameters + + + # Apply correction factor to precipitation + self.Precipitation = self.PCORR * self.Precipitation + self.Temperature=cover(self.wf_readmap(self.TEMP_mapstack,10.0),10.0) + self.Temperature = self.Temperature + self.TempCor + + # Multiply input parameters with a factor (for calibration etc) -p option in command line (no also in ini) + + self.wf_multparameters() + + RainFrac=ifthenelse(1.0*self.TTI == 0.0,ifthenelse(self.Temperature <= self.TT,scalar(0.0),scalar(1.0)),min((self.Temperature-(self.TT-self.TTI/2.0))/self.TTI,scalar(1.0))) + RainFrac=max(RainFrac,scalar(0.0)) #fraction of precipitation which falls as rain + SnowFrac=1.0-RainFrac #fraction of self.Precipitation which falls as snow + self.Precipitation=self.SFCF*SnowFrac*self.Precipitation+self.RFCF*RainFrac*self.Precipitation # different correction for rainfall and snowfall + + self.PotEvaporation=exp(-self.EPF*self.Precipitation)*self.ECORR * self.PotEvaporation # correction for potential evaporation on wet days + self.PotEvaporation=self.CEVPF*self.PotEvaporation # Correct per landuse + + SnowFall=SnowFrac*self.Precipitation #: snowfall depth + RainFall=RainFrac*self.Precipitation #: rainfall depth + PotSnowMelt=ifthenelse(self.Temperature > self.TT,self.CFMAX*(self.Temperature-self.TT),scalar(0.0)) #Potential snow melt, based on temperature + PotRefreezing=ifthenelse(self.Temperature < self.TT, self.CFMAX*self.CFR*(self.TT-self.Temperature),0.0) #Potential refreezing, based on temperature + + Refreezing=ifthenelse(self.Temperature < self.TT,min(PotRefreezing,self.FreeWater),0.0) #actual refreezing + self.SnowMelt=min(PotSnowMelt,self.DrySnow) #actual snow melt + self.DrySnow=self.DrySnow+SnowFall+Refreezing-self.SnowMelt #dry snow content + self.FreeWater=self.FreeWater-Refreezing #free water content in snow + MaxFreeWater=self.DrySnow*self.WHC + self.FreeWater=self.FreeWater+self.SnowMelt+RainFall + InSoil = max(self.FreeWater-MaxFreeWater,0.0) #abundant water in snow pack which goes into soil + self.FreeWater=self.FreeWater-InSoil + + + # Soil and evaporation + soil_wetness = (self.SoilMoisture/self.FC) ** self.BETA + soil_wetness = max(min(soil_wetness, 1.0),0.0) + recharge = (self.Precipitation+InSoil) * soil_wetness + self.SoilMoisture = self.SoilMoisture+self.Precipitation+InSoil-recharge + excess = self.SoilMoisture-self.FC + excess = max(excess,0.0) + self.SoilMoisture = self.SoilMoisture-excess + evapfactor = self.SoilMoisture / (self.LP*self.FC) + evapfactor = min(max(evapfactor,0.0), 1.0) + #---------------- + self.ActEvap = self.PotEvaporation*evapfactor + self.ActEvap = min(self.SoilMoisture, self.ActEvap) + self.SoilMoisture = self.SoilMoisture-self.ActEvap + + # Groundwater boxes + self.UpperZoneStorage = self.UpperZoneStorage+recharge+excess + self.actPERC = min(self.UpperZoneStorage, self.PERC) + self.UpperZoneStorage = self.UpperZoneStorage-self.actPERC + self.Q0 = self.K0 * max(self.UpperZoneStorage-self.UZL, 0.0) + self.UpperZoneStorage = self.UpperZoneStorage-self.Q0 + self.Q1 = self.K1*self.UpperZoneStorage + self.UpperZoneStorage = self.UpperZoneStorage-self.Q1 + self.LowerZoneStorage = self.LowerZoneStorage+self.actPERC + self.Q2 = self.K2*self.LowerZoneStorage + self.LowerZoneStorage = self.LowerZoneStorage-self.Q2 + + DirectRunoffStorage= self.Q0 + self.Q1 + self.Q2 + + self.InwaterMM=max(0.0,DirectRunoffStorage) + self.Inwater=self.InwaterMM * self.ToCubic + self.QuickFlowCubic = (self.Q0 + self.Q1) * self.ToCubic + self.BaseFlowCubic = self.Q2 * self.ToCubic + + + + + +# The main function is used to run the program from the command line + +def main(argv=None): + """ + Perform command line execution of the model. + """ + global multpars + global updateCols + caseName = "default_hbv" + runId = "run_default" + configfile="wflow_hbvl.ini" + LogFileName="wflow.log" + _lastTimeStep = 0 + _firstTimeStep = 1 + runinfoFile="runinfo.xml" + timestepsecs=86400 + wflow_cloneMap = 'wflow_subcatch.map' + NoOverWrite=1 + loglevel = logging.DEBUG + + if argv is None: + argv = sys.argv[1:] + if len(argv) == 0: + usage() + return + + ## Main model starts here + ######################################################################## + try: + opts, args = getopt.getopt(argv, 'c:QXS:hC:Ii:T:R:u:s:P:p:Xx:U:fl:L:') + except getopt.error as msg: + pcrut.usage(msg) + + for o, a in opts: + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-L': LogFileName = a + if o == '-l': exec("loglevel = logging." + a) + if o == '-c': configfile = a + if o == '-s': timestepsecs = int(a) + if o == '-T': _lastTimeStep=int(a) + if o == '-S': _firstTimeStep=int(a) + if o == '-h': usage() + if o == '-f': NoOverWrite = 0 + + + + + starttime = dt.datetime(1990,0o1,0o1) + + if _lastTimeStep < _firstTimeStep: + print("The starttimestep (" + str(_firstTimeStep) +") is smaller than the last timestep (" + str(_lastTimeStep) + ")") + usage() + + myModel = WflowModel(wflow_cloneMap, caseName,runId,configfile) + dynModelFw = wf_DynamicFramework(myModel, _lastTimeStep,firstTimestep=_firstTimeStep,datetimestart=starttime) + dynModelFw.createRunId(NoOverWrite=NoOverWrite,logfname=LogFileName,level=loglevel,doSetupFramework=False) + + for o, a in opts: + if o == '-P': + left = a.split('=')[0] + right = a.split('=')[1] + configset(myModel.config,'variable_change_once',left,right,overwrite=True) + if o == '-p': + left = a.split('=')[0] + right = a.split('=')[1] + configset(myModel.config,'variable_change_timestep',left,right,overwrite=True) + if o == '-X': configset(myModel.config,'model','OverWriteInit','1',overwrite=True) + if o == '-I': configset(myModel.config,'model','reinit','1',overwrite=True) + if o == '-i': configset(myModel.config,'model','intbl',a,overwrite=True) + if o == '-s': configset(myModel.config,'model','timestepsecs',a,overwrite=True) + if o == '-x': configset(myModel.config,'model','sCatch',a,overwrite=True) + if o == '-c': configset(myModel.config,'model','configfile', a,overwrite=True) + if o == '-M': configset(myModel.config,'model','MassWasting',"0",overwrite=True) + if o == '-Q': configset(myModel.config,'model','ExternalQbase','1',overwrite=True) + if o == '-U': + configset(myModel.config,'model','updateFile',a,overwrite=True) + configset(myModel.config,'model','updating',"1",overwrite=True) + if o == '-u': + exec("zz =" + a) + updateCols = zz + + dynModelFw.setupFramework() + dynModelFw._runInitial() + dynModelFw._runResume() + dynModelFw._runDynamic(_firstTimeStep,_lastTimeStep) + dynModelFw._runSuspend() + dynModelFw._wf_shutdown() + + + + os.chdir("../../") + + +if __name__ == "__main__": + main() Index: wflow-py/wflow/wflow_lib.py =================================================================== diff -u -r74c9106bc711c80b9496353805ce09ae7e90f317 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_lib.py (.../wflow_lib.py) (revision 74c9106bc711c80b9496353805ce09ae7e90f317) +++ wflow-py/wflow/wflow_lib.py (.../wflow_lib.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -39,7 +39,7 @@ import os.path import sys -import ConfigParser +import configparser import osgeo.gdal as gdal from osgeo.gdalconst import * from pcraster import * @@ -345,11 +345,11 @@ """ if os.path.exists(lddname) and not force: if Verbose: - print ("Returning existing ldd", lddname) + print(("Returning existing ldd", lddname)) return readmap(lddname) else: if Verbose: - print ("Creating ldd", lddname) + print(("Creating ldd", lddname)) LDD = lddcreate(dem, 10.0E35, outflowdepth, 10.0E35, 10.0E35) report(LDD, lddname) return LDD @@ -1262,7 +1262,7 @@ mapFormat.Register() ds = gdal.Open(fileName) if ds is None: - print "Could not open " + fileName + ". Something went wrong!! Shutting down" + print('Could not open ' + fileName + '. Something went wrong!! Shutting down') sys.exit(1) # Retrieve geoTransform info geotrans = ds.GetGeoTransform() @@ -1332,7 +1332,7 @@ # Processing if verbose: - print "Writing to temporary file " + fileName + ".tif" + print('Writing to temporary file ' + fileName + '.tif') # Create Output filename from (FEWS) product name and data and open for writing if data.dtype == np.int32: @@ -1355,13 +1355,14 @@ TempBand.SetNoDataValue(FillVal) # Create data to write to correct format (supported by 'CreateCopy') if verbose: - print "Writing to " + fileName + ".map" + print('Writing to ' + fileName + '.map') outDataset = driver2.CreateCopy(fileName, TempDataset, 0) TempDataset = None outDataset = None if verbose: - print "Removing temporary file " + fileName + ".tif" - os.remove(fileName + ".tif") + print('Removing temporary file ' + fileName + '.tif') + os.remove(fileName + '.tif'); if verbose: - print "Writing to " + fileName + " is done!" + print('Writing to ' + fileName + ' is done!') + Index: wflow-py/wflow/wflow_lintul.py =================================================================== diff -u -rba40a6612e674bbeaf3688a22ca91d7ebf9571f9 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_lintul.py (.../wflow_lintul.py) (revision ba40a6612e674bbeaf3688a22ca91d7ebf9571f9) +++ wflow-py/wflow/wflow_lintul.py (.../wflow_lintul.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -126,15 +126,15 @@ def __init__(self, name): self.data = name self.name = name[-1] - self.filename = self.name + ".tmp" - - temptablefile = open(self.filename, "w") - index = range(0, len(self.data) - 1) + self.filename = self.name + ".tmp" + + temptablefile = open(self.filename, 'w') + index = list(range(0, len(self.data)-1)) for i in index: if i < (len(self.data) - 1): if i >= i + 1: - print "x values of lookuplinear table not sorted in strictly ascending order..." - if i // 2. - i / 2. <> 0.: + print("x values of lookuplinear table not sorted in strictly ascending order...") + if i//2. - i/2. != 0.: string = str(self.data[i]) + " " else: string = "\n" + str(self.data[i]) + " " @@ -167,9 +167,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -542,7 +541,7 @@ if self.reinit == 1: self.logger.info("Setting initial conditions to default") for s in self.stateVariables(): - exec "self." + s + " = cover(0.0)" + exec("self." + s + " = cover(0.0)") else: self.wf_resume(self.Dir + "/instate/") @@ -624,28 +623,26 @@ if self.CropStartDOY > -1: if self.HarvestDAP > 0: - HarvNow = DOY >= (self.CropStartDOY + self.HarvestDAP) - print "Warning: harvest date read from ini file, not from Crop Profile map..." - elif self.HarvestDAP == 0: - HarvNow = Not_Finished == False - print "Harvest date not specified; crop harvest at crop maturity" - else: - print "Crop harvest not initialized, found strange values in ini file... CTRL + C to exit..." + HarvNow = DOY >= (self.CropStartDOY + self.HarvestDAP) + print("Warning: harvest date read from ini file, not from Crop Profile map...") + elif self.HarvestDAP == 0: + HarvNow = Not_Finished == False + print("Harvest date not specified; crop harvest at crop maturity") + else: + print("Crop harvest not initialized, found strange values in ini file... CTRL + C to exit...") time.sleep(100) - CropHarvNow = HarvNow & self.ricemask_BOOL - - # Initializing crop growth, optionally from a single start day (CropStartDOY in the ini file), - # but normally from a crop profile forcing variable. - StartNow = DOY == self.CropStartDOY - CropStartNow = StartNow & self.ricemask_BOOL - CropStartNow_scalar = scalar(CropStartNow) - Started = self.STARTED > 0 - CropStarted = Started & self.ricemask_BOOL - self.STARTED = ( - self.STARTED + CropStartNow_scalar + scalar(CropStarted) - ) * ifthenelse(CropHarvNow, scalar(0.), 1.) - print "Warning: using start date from ini file, not read from Crop Profile..." - + CropHarvNow = HarvNow & self.ricemask_BOOL + + # Initializing crop growth, optionally from a single start day (CropStartDOY in the ini file), + # but normally from a crop profile forcing variable. + StartNow = DOY == self.CropStartDOY + CropStartNow = StartNow & self.ricemask_BOOL + CropStartNow_scalar= scalar(CropStartNow) + Started = self.STARTED > 0 + CropStarted = Started & self.ricemask_BOOL + self.STARTED = (self.STARTED + CropStartNow_scalar + scalar(CropStarted)) * ifthenelse(CropHarvNow, scalar(0.), 1.) + print("Warning: using start date from ini file, not read from Crop Profile...") + elif self.CropStartDOY == -1: if self.AutoStartStop == False: @@ -654,11 +651,11 @@ crpprfl_eq_zero = self.CRPST == 0. CropHarvNow = Started & crpprfl_eq_zero & self.ricemask_BOOL elif self.HarvestDAP > 0: - HarvNow = self.STARTED == self.HarvestDAP - CropHarvNow = HarvNow & self.ricemask_BOOL - print "Start date read from Crop Profile..." - # Two auxilliary variables: - CRPST_gt_0 = self.CRPST > 0. + HarvNow = self.STARTED == self.HarvestDAP + CropHarvNow = HarvNow & self.ricemask_BOOL + print("Start date read from Crop Profile...") + # Two auxilliary variables: + CRPST_gt_0 = self.CRPST > 0. CRPST_eq_STARTED = self.CRPST == self.STARTED CropStartNow = CRPST_gt_0 & CRPST_eq_STARTED & self.ricemask_BOOL CropStarted = Started & self.ricemask_BOOL @@ -717,26 +714,19 @@ CropStarted = Started & self.ricemask_BOOL Season12Harvd = self.STARTED < 0 Season12Harvd_Scalar = scalar(Season12Harvd) - PrepareField_temp = scalar(self.Pausedays) - FirstorSecondSeason = FirstSeason | SecondSeason - PrepareField = ifthenelse( - FirstorSecondSeason, PrepareField_temp, 0. - ) - self.STARTED = ( - (self.STARTED + CropStartNow_scalar + scalar(CropStarted)) - * ifthenelse(CropHarvNow, scalar(0.), 1.) - - ifthenelse(HarvSeasonOneTwo, PrepareField, 0.) - + Season12Harvd_Scalar - ) - else: - print self.Sim3rdSeason + PrepareField_temp = scalar(self.Pausedays) + FirstorSecondSeason = FirstSeason | SecondSeason + PrepareField = ifthenelse(FirstorSecondSeason, PrepareField_temp, 0.) + self.STARTED = (self.STARTED + CropStartNow_scalar + scalar(CropStarted)) * ifthenelse(CropHarvNow, scalar(0.), 1.) - ifthenelse(HarvSeasonOneTwo, PrepareField, 0.) + Season12Harvd_Scalar + else: + print(self.Sim3rdSeason) time.sleep(10) else: - print "Strange value of variable AutoStartStop found... ctrl + c to exit..." + print("Strange value of variable AutoStartStop found... ctrl + c to exit...") time.sleep(100) else: - print "Strange (negative?) value of variable CropStartDOY found... ctrl + c to exit..." + print("Strange (negative?) value of variable CropStartDOY found... ctrl + c to exit...") time.sleep(100) if self.WATERLIMITED == "True": @@ -746,30 +736,30 @@ CropStartNow, True, self.WA > WAWP ) # timestep delay...! todo else: - print "Warning, run without water effects on crop growth..." - TRANRF = scalar(1.) - Enough_water = True + print("Warning, run without water effects on crop growth...") + TRANRF = scalar(1.) + Enough_water = True + + #self.T = (self.TMIN + self.TMAX)/2. # for testing with Wageningen weather files only - sdv + # Calculate thermal time (for TSUM and DVS): + Warm_Enough = self.T >= self.TBASE + DegreeDay = self.T - self.TBASE + DTEFF = ifthenelse(Warm_Enough, DegreeDay, 0.) + # Check if leaves are present: + Leaves_Present = self.LAI > 0. - # self.T = (self.TMIN + self.TMAX)/2. # for testing with Wageningen weather files only - sdv - # Calculate thermal time (for TSUM and DVS): - Warm_Enough = self.T >= self.TBASE - DegreeDay = self.T - self.TBASE - DTEFF = ifthenelse(Warm_Enough, DegreeDay, 0.) - # Check if leaves are present: - Leaves_Present = self.LAI > 0. + # Check whether certain critical moments, external circumstances or crop growth stages occur that influence crop growth and development: + BeforeAnthesis = self.TSUM < self.TSUMAN + UntilAnthesis = self.TSUM <= self.TSUMAN + AtAndAfterAnthesis = self.TSUM >= self.TSUMAN + AfterAnthesis = self.TSUM > self.TSUMAN + Roots_Dying = self.DVS >= self.DVSDR - # Check whether certain critical moments, external circumstances or crop growth stages occur that influence crop growth and development: - BeforeAnthesis = self.TSUM < self.TSUMAN - UntilAnthesis = self.TSUM <= self.TSUMAN - AtAndAfterAnthesis = self.TSUM >= self.TSUMAN - AfterAnthesis = self.TSUM > self.TSUMAN - Roots_Dying = self.DVS >= self.DVSDR - - Vegetative = CropStarted & UntilAnthesis - Generative = CropStarted & AfterAnthesis - EarlyStages = self.DVS < 0.2 - LaterStages = self.DVS >= 0.2 - SmallLeaves = self.LAI < 0.75 + Vegetative = CropStarted & UntilAnthesis + Generative = CropStarted & AfterAnthesis + EarlyStages = self.DVS < 0.2 + LaterStages = self.DVS >= 0.2 + SmallLeaves = self.LAI < 0.75 BiggerLeaves = self.LAI >= 0.75 Juvenile = EarlyStages & SmallLeaves Adult = LaterStages | BiggerLeaves @@ -990,29 +980,21 @@ ## Process command-line options # ######################################################################## try: - opts, args = getopt.getopt(argv, "F:C:S:T:c:s:R:l") - except getopt.error, msg: + opts, args = getopt.getopt(argv, 'F:C:S:T:c:s:R:l') + except getopt.error as msg: pcrut.usage(msg) for o, a in opts: - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-c": - configfile = a - if o == "-s": - timestepsecs = int(a) - if o == "-T": - _lastTimeStep = int(a) - if o == "-S": - _firstTimeStep = int(a) - if o == "-f": - _NoOverWrite = 0 - if o == "-l": - exec "loglevel = logging." + a + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-c': configfile = a + if o == '-s': timestepsecs = int(a) + if o == '-T': _lastTimeStep = int(a) + if o == '-S': _firstTimeStep = int(a) + if o == '-f': _NoOverWrite = 0 + if o == '-l': exec("loglevel = logging." + a) - if len(opts) <= 1: + if (len(opts) <= 1): usage() # starttime = dt.datetime(1990,01,01) Index: wflow-py/wflow/wflow_logging.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_logging.py (.../wflow_logging.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_logging.py (.../wflow_logging.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -39,5 +39,5 @@ logger.debug("File logging to " + logfilename) return logger except IOError: - print "ERROR: Failed to initialize logger with logfile: " + logfilename + print("ERROR: Failed to initialize logger with logfile: " + logfilename) return None Index: wflow-py/wflow/wflow_obsolete.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_obsolete.py (.../wflow_obsolete.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/wflow_obsolete.py (.../wflow_obsolete.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -1,4 +1,4 @@ -from wflow_hbv import * +from .wflow_hbv import * class wflow_model: Index: wflow-py/wflow/wflow_pcrglobwb.py =================================================================== diff -u -r6b5de2fc7f34f47c266d184869ed1d6a7342b16f -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_pcrglobwb.py (.../wflow_pcrglobwb.py) (revision 6b5de2fc7f34f47c266d184869ed1d6a7342b16f) +++ wflow-py/wflow/wflow_pcrglobwb.py (.../wflow_pcrglobwb.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -99,7 +99,7 @@ from wflow.wf_DynamicFramework import * from wflow.wflow_funcs import * from wflow.wflow_adapt import * -import ConfigParser +import configparser from wflow.pcrglobwb import landSurface from wflow.pcrglobwb import groundwater @@ -120,9 +120,8 @@ - *args: command line arguments given """ sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -668,36 +667,27 @@ ## Process command-line options # ######################################################################## try: - opts, args = getopt.getopt(argv, "XL:hC:Ii:v:S:T:WR:u:s:EP:p:Xx:U:fOc:l:d:") - except getopt.error, msg: + opts, args = getopt.getopt(argv, 'XL:hC:Ii:v:S:T:WR:u:s:EP:p:Xx:U:fOc:l:d:') + except getopt.error as msg: pcrut.usage(msg) for o, a in opts: - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-c": - configfile = a - if o == "-L": - LogFileName = a - if o == "-s": - timestepsecs = int(a) - if o == "-h": - usage() - if o == "-f": - _NoOverWrite = 0 - if o == "-l": - exec "loglevel = logging." + a - if o == "-d": - staticmaps = a + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-c': configfile = a + if o == '-L': LogFileName = a + if o == '-s': timestepsecs = int(a) + if o == '-h': usage() + if o == '-f': _NoOverWrite = 0 + if o == '-l': exec("loglevel = logging." + a) + if o == '-d': staticmaps = a - starttime = dt.datetime(1990, 01, 01) + starttime = dt.datetime(1990,0o1,0o1) + if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) + ") is smaller than the last timestep (" + str( + _lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile, staticmaps) @@ -746,7 +736,7 @@ configset(myModel.config, "model", "updating", "1", overwrite=True) if o == "-u": zz = [] - exec "zz =" + a + exec("zz =" + a) updateCols = zz if o == "-E": configset(myModel.config, "model", "reInfilt", "1", overwrite=True) Index: wflow-py/wflow/wflow_routing.py =================================================================== diff -u -r5bc2c6406fea89698faa5d0ca1488dc25760b5e3 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_routing.py (.../wflow_routing.py) (revision 5bc2c6406fea89698faa5d0ca1488dc25760b5e3) +++ wflow-py/wflow/wflow_routing.py (.../wflow_routing.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -69,7 +69,7 @@ from wflow.wf_DynamicFramework import * from wflow.wflow_funcs import * from wflow.wflow_adapt import * -import ConfigParser +import configparser wflow = "wflow_routing: " @@ -79,9 +79,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -1034,34 +1033,27 @@ ## Process command-line options # ######################################################################## try: - opts, args = getopt.getopt(argv, "F:L:hC:Ii:v:S:T:WR:u:s:EP:p:Xx:U:fOc:l:g:") - except getopt.error, msg: + opts, args = getopt.getopt(argv, 'F:L:hC:Ii:v:S:T:WR:u:s:EP:p:Xx:U:fOc:l:g:') + except getopt.error as msg: pcrut.usage(msg) for o, a in opts: - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-c": - configfile = a - if o == "-L": - LogFileName = a - if o == "-s": - timestepsecs = int(a) - if o == "-h": - usage() - if o == "-f": - _NoOverWrite = 0 - if o == "-l": - exec "loglevel = logging." + a + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-c': configfile = a + if o == '-L': LogFileName = a + if o == '-s': timestepsecs = int(a) + if o == '-h': usage() + if o == '-f': _NoOverWrite = 0 + if o == '-l': exec("loglevel = logging." + a) - starttime = dt.datetime(1990, 01, 01) + + starttime = dt.datetime(1990,0o1,0o1) + if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) + ") is smaller than the last timestep (" + str( + _lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) @@ -1076,26 +1068,19 @@ ) for o, a in opts: - if o == "-X": - configset(myModel.config, "model", "OverWriteInit", "1", overwrite=True) - if o == "-I": - configset(myModel.config, "run", "reinit", "1", overwrite=True) - if o == "-i": - configset(myModel.config, "model", "intbl", a, overwrite=True) - if o == "-s": - configset(myModel.config, "model", "timestepsecs", a, overwrite=True) - if o == "-x": - configset(myModel.config, "model", "sCatch", a, overwrite=True) - if o == "-c": - configset(myModel.config, "model", "configfile", a, overwrite=True) - if o == "-g": - configset(myModel.config, "model", "instate", a, overwrite=True) + if o == '-X': configset(myModel.config, 'model', 'OverWriteInit', '1', overwrite=True) + if o == '-I': configset(myModel.config, 'run', 'reinit', '1', overwrite=True) + if o == '-i': configset(myModel.config, 'model', 'intbl', a, overwrite=True) + if o == '-s': configset(myModel.config, 'model', 'timestepsecs', a, overwrite=True) + if o == '-x': configset(myModel.config, 'model', 'sCatch', a, overwrite=True) + if o == '-c': configset(myModel.config, 'model', 'configfile', a, overwrite=True) + if o == '-g': configset(myModel.config,'model','instate',a,overwrite=True) - if o == "-U": - configset(myModel.config, "model", "updateFile", a, overwrite=True) - configset(myModel.config, "model", "updating", "1", overwrite=True) - if o == "-u": - exec "zz =" + a + if o == '-U': + configset(myModel.config, 'model', 'updateFile', a, overwrite=True) + configset(myModel.config, 'model', 'updating', "1", overwrite=True) + if o == '-u': + exec("zz =" + a) updateCols = zz if o == "-P": left = a.split("=")[0] Index: wflow-py/wflow/wflow_sbm.py =================================================================== diff -u -rb6ba3d8e50ff32ef284800a790979b651cd83b69 -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_sbm.py (.../wflow_sbm.py) (revision b6ba3d8e50ff32ef284800a790979b651cd83b69) +++ wflow-py/wflow/wflow_sbm.py (.../wflow_sbm.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -96,7 +96,7 @@ from wflow.wf_DynamicFramework import * from wflow.wflow_funcs import * from wflow.wflow_adapt import * -import ConfigParser +import configparser wflow = "wflow_sbm: " @@ -107,9 +107,8 @@ def usage(*args): sys.stdout = sys.stderr """Way""" - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -3068,34 +3067,26 @@ ## Process command-line options # ######################################################################## try: - opts, args = getopt.getopt(argv, "XL:hC:Ii:v:S:T:WR:u:s:EP:p:Xx:U:fOc:l:") - except getopt.error, msg: + opts, args = getopt.getopt(argv, 'XL:hC:Ii:v:S:T:WR:u:s:EP:p:Xx:U:fOc:l:') + except getopt.error as msg: pcrut.usage(msg) for o, a in opts: - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-c": - configfile = a - if o == "-L": - LogFileName = a - if o == "-s": - timestepsecs = int(a) - if o == "-h": - usage() - if o == "-f": - _NoOverWrite = 0 - if o == "-l": - exec "loglevel = logging." + a + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-c': configfile = a + if o == '-L': LogFileName = a + if o == '-s': timestepsecs = int(a) + if o == '-h': usage() + if o == '-f': _NoOverWrite = 0 + if o == '-l': exec("loglevel = logging." + a) - starttime = dt.datetime(1990, 01, 01) + starttime = dt.datetime(1990,0o1,0o1) + if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) + ") is smaller than the last timestep (" + str( + _lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) @@ -3144,7 +3135,7 @@ configset(myModel.config, "model", "updating", "1", overwrite=True) if o == "-u": zz = [] - exec "zz =" + a + exec("zz =" + a) updateCols = zz if o == "-E": configset(myModel.config, "model", "reInfilt", "1", overwrite=True) Index: wflow-py/wflow/wflow_sbm_old.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_sbm_old.py (.../wflow_sbm_old.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_sbm_old.py (.../wflow_sbm_old.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -98,7 +98,7 @@ from wflow.wf_DynamicFramework import * from wflow.wflow_funcs import * from wflow.wflow_adapt import * -import ConfigParser +import configparser wflow = "wflow_sbm: " @@ -109,9 +109,8 @@ def usage(*args): sys.stdout = sys.stderr """Way""" - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -2161,38 +2160,28 @@ ## Process command-line options # ######################################################################## try: - opts, args = getopt.getopt(argv, "XF:L:hC:Ii:v:S:T:WR:u:s:EP:p:Xx:U:fOc:l:") - except getopt.error, msg: + opts, args = getopt.getopt(argv, 'XF:L:hC:Ii:v:S:T:WR:u:s:EP:p:Xx:U:fOc:l:') + except getopt.error as msg: pcrut.usage(msg) for o, a in opts: - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-c": - configfile = a - if o == "-L": - LogFileName = a - if o == "-s": - timestepsecs = int(a) - if o == "-T": - _lastTimeStep = int(a) - if o == "-S": - _firstTimeStep = int(a) - if o == "-h": - usage() - if o == "-f": - _NoOverWrite = 0 - if o == "-l": - exec "loglevel = logging." + a + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-c': configfile = a + if o == '-L': LogFileName = a + if o == '-s': timestepsecs = int(a) + if o == '-T': _lastTimeStep = int(a) + if o == '-S': _firstTimeStep = int(a) + if o == '-h': usage() + if o == '-f': _NoOverWrite = 0 + if o == '-l': exec("loglevel = logging." + a) - starttime = dt.datetime(1990, 01, 01) + starttime = dt.datetime(1990,0o1,0o1) + if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) + ") is smaller than the last timestep (" + str( + _lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) @@ -2241,7 +2230,7 @@ configset(myModel.config, "model", "updating", "1", overwrite=True) if o == "-u": zz = [] - exec "zz =" + a + exec("zz =" + a) updateCols = zz if o == "-E": configset(myModel.config, "model", "reInfilt", "1", overwrite=True) Index: wflow-py/wflow/wflow_sceleton.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_sceleton.py (.../wflow_sceleton.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_sceleton.py (.../wflow_sceleton.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -32,9 +32,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -193,24 +192,25 @@ setup needed. """ - self.logger.info("Reading initial conditions...") - #: It is advised to use the wf_resume() function - #: here which pick up the variable save by a call to wf_suspend() + self.logger.info("Reading initial conditions...") + #: It is advised to use the wf_resume() function + #: here which pick up the variable save by a call to wf_suspend() - if self.reinit: - self.logger.warn("Setting initial states to default") + if self.reinit: + self.logger.warn("Setting initial states to default") + for s in self.stateVariables(): + exec("self." + s + " = cover(1.0)") + else: + try: + self.wf_resume(self.Dir + "/instate/") + except: + self.logger.warn("Cannot load initial states, setting to default") for s in self.stateVariables(): - exec "self." + s + " = cover(1.0)" - else: - try: - self.wf_resume(self.Dir + "/instate/") - except: - self.logger.warn("Cannot load initial states, setting to default") - for s in self.stateVariables(): - exec "self." + s + " = cover(1.0)" + exec("self." + s + " = cover(1.0)") - def default_summarymaps(self): - """ + + def default_summarymaps(self): + """ *Optional* Return a default list of variables to report as summary maps in the outsum dir. Index: wflow-py/wflow/wflow_snow.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_snow.py (.../wflow_snow.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_snow.py (.../wflow_snow.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -89,9 +89,8 @@ """ sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -281,164 +280,97 @@ ) #: Map with locations of output gauge(s) # Temperature correction poer cell to add - self.TempCor = pcrut.readmapSave( - self.Dir + "/staticmaps/wflow_tempcor.map", 0.0 - ) + self.TempCor=pcrut.readmapSave(self.Dir + "/staticmaps/wflow_tempcor.map",0.0) + + + if self.scalarInput: + self.gaugesMap=readmap(self.Dir + "/staticmaps/wflow_mgauges.map") #: Map with locations of rainfall/evap/temp gauge(s). Only needed if the input to the model is not in maps + self.OutputId=readmap(self.Dir + "/staticmaps/wflow_subcatch.map") # location of subcatchment + + self.ZeroMap=0.0*scalar(subcatch) #map with only zero's + + # 3: Input time series ################################################### + self.Rain_=self.Dir + "/inmaps/P" #: timeseries for rainfall + self.Temp_=self.Dir + "/inmaps/TEMP" #: temperature - if self.scalarInput: - self.gaugesMap = readmap( - self.Dir + "/staticmaps/wflow_mgauges.map" - ) #: Map with locations of rainfall/evap/temp gauge(s). Only needed if the input to the model is not in maps - self.OutputId = readmap( - self.Dir + "/staticmaps/wflow_subcatch.map" - ) # location of subcatchment - self.ZeroMap = 0.0 * scalar(subcatch) # map with only zero's + # Set static initial values here ######################################### + + + self.Latitude = ycoordinate(boolean(self.Altitude)) + self.Longitude = xcoordinate(boolean(self.Altitude)) + + self.logger.info("Linking parameters to landuse, catchment and soil...") + + #HBV Soil params + self.CFR=self.readtblDefault(self.Dir + "/" + self.intbl + "/CFR.tbl",self.LandUse,subcatch,self.Soil, 0.05000) # refreezing efficiency constant in refreezing of freewater in snow + #self.FoCfmax=self.readtblDefault(self.Dir + "/" + self.intbl + "/FoCfmax.tbl",self.LandUse,subcatch,self.Soil, 0.6000) # correcton factor for snow melt/refreezing in forested and non-forested areas + self.Pcorr=self.readtblDefault(self.Dir + "/" + self.intbl + "/Pcorr.tbl",self.LandUse,subcatch,self.Soil, 1.0) # correction factor for precipitation + self.RFCF=self.readtblDefault(self.Dir + "/" + self.intbl + "/RFCF.tbl",self.LandUse,subcatch,self.Soil,1.0) # correction factor for rainfall + self.SFCF=self.readtblDefault(self.Dir + "/" + self.intbl + "/SFCF.tbl",self.LandUse,subcatch,self.Soil, 1.0) # correction factor for snowfall + self.Cflux= self.readtblDefault(self.Dir + "/" + self.intbl + "/Cflux.tbl",self.LandUse,subcatch,self.Soil, 2.0) # maximum capillary rise from runoff response routine to soil moisture routine + + + # HBV Snow parameters + # critical temperature for snowmelt and refreezing: TTI= 1.000 + self.TTI=self.readtblDefault(self.Dir + "/" + self.intbl + "/TTI.tbl" ,self.LandUse,subcatch,self.Soil,1.0) + # TT = -1.41934 # defines interval in which precipitation falls as rainfall and snowfall + self.TT=self.readtblDefault(self.Dir + "/" + self.intbl + "/TT.tbl" ,self.LandUse,subcatch,self.Soil,-1.41934) + #Cfmax = 3.75653 # meltconstant in temperature-index + self.Cfmax=self.readtblDefault(self.Dir + "/" + self.intbl + "/Cfmax.tbl" ,self.LandUse,subcatch,self.Soil,3.75653) + # WHC= 0.10000 # fraction of Snowvolume that can store water + self.WHC=self.readtblDefault(self.Dir + "/" + self.intbl + "/WHC.tbl" ,self.LandUse,subcatch,self.Soil,0.1) + + # Determine real slope and cell length + sizeinmetres = int(configget(self.config,"layout","sizeinmetres","0")) + self.xl,self.yl,self.reallength = pcrut.detRealCellLength(self.ZeroMap,sizeinmetres) + self.Slope= slope(self.Altitude) + self.Slope=ifthen(boolean(self.TopoId),max(0.001,self.Slope*celllength()/self.reallength)) + + # Multiply parameters with a factor (for calibration etc) -P option in command line + for k, v in multpars.items(): + estr = k + "=" + k + "*" + str(v) + self.logger.info("Parameter multiplication: " + estr) + exec(estr) - # 3: Input time series ################################################### - self.Rain_ = self.Dir + "/inmaps/P" #: timeseries for rainfall - self.Temp_ = self.Dir + "/inmaps/TEMP" #: temperature + self.SnowWater = self.ZeroMap + - # Set static initial values here ######################################### + # Initializing of variables + self.logger.info("Initializing of model variables..") + self.TopoLdd=lddmask(self.TopoLdd,boolean(self.TopoId)) + catchmentcells=maptotal(scalar(self.TopoId)) + + # Used to seperate output per LandUse/management classes + #OutZones = self.LandUse + #report(self.reallength,"rl.map") + #report(catchmentcells,"kk.map") + self.QMMConv = self.timestepsecs/(self.reallength * self.reallength * 0.001) #m3/s --> mm + + self.sumprecip=self.ZeroMap #: accumulated rainfall for water balance + self.sumtemp=self.ZeroMap #accumulated runoff for water balance - self.Latitude = ycoordinate(boolean(self.Altitude)) - self.Longitude = xcoordinate(boolean(self.Altitude)) + + self.logger.info("Create timeseries outputs...") + toprinttss = configsection(self.config,'outputtss') + - self.logger.info("Linking parameters to landuse, catchment and soil...") + # Save some summary maps + self.logger.info("Saving summary maps...") + report(self.Cfmax,self.Dir + "/" + self.runId + "/outsum/Cfmax.map") + report(self.TTI,self.Dir + "/" + self.runId + "/outsum/TTI.map") + report(self.TT,self.Dir + "/" + self.runId + "/outsum/TT.map") + report(self.WHC,self.Dir + "/" + self.runId + "/outsum/WHC.map") + report(self.xl,self.Dir + "/" + self.runId + "/outsum/xl.map") + report(self.yl,self.Dir + "/" + self.runId + "/outsum/yl.map") + report(self.reallength,self.Dir + "/" + self.runId + "/outsum/rl.map") + + - # HBV Soil params - self.CFR = self.readtblDefault( - self.Dir + "/" + self.intbl + "/CFR.tbl", - self.LandUse, - subcatch, - self.Soil, - 0.05000, - ) # refreezing efficiency constant in refreezing of freewater in snow - # self.FoCfmax=self.readtblDefault(self.Dir + "/" + self.intbl + "/FoCfmax.tbl",self.LandUse,subcatch,self.Soil, 0.6000) # correcton factor for snow melt/refreezing in forested and non-forested areas - self.Pcorr = self.readtblDefault( - self.Dir + "/" + self.intbl + "/Pcorr.tbl", - self.LandUse, - subcatch, - self.Soil, - 1.0, - ) # correction factor for precipitation - self.RFCF = self.readtblDefault( - self.Dir + "/" + self.intbl + "/RFCF.tbl", - self.LandUse, - subcatch, - self.Soil, - 1.0, - ) # correction factor for rainfall - self.SFCF = self.readtblDefault( - self.Dir + "/" + self.intbl + "/SFCF.tbl", - self.LandUse, - subcatch, - self.Soil, - 1.0, - ) # correction factor for snowfall - self.Cflux = self.readtblDefault( - self.Dir + "/" + self.intbl + "/Cflux.tbl", - self.LandUse, - subcatch, - self.Soil, - 2.0, - ) # maximum capillary rise from runoff response routine to soil moisture routine + self.SaveDir = self.Dir + "/" + self.runId + "/" + self.logger.info("Starting Dynamic run...") - # HBV Snow parameters - # critical temperature for snowmelt and refreezing: TTI= 1.000 - self.TTI = self.readtblDefault( - self.Dir + "/" + self.intbl + "/TTI.tbl", - self.LandUse, - subcatch, - self.Soil, - 1.0, - ) - # TT = -1.41934 # defines interval in which precipitation falls as rainfall and snowfall - self.TT = self.readtblDefault( - self.Dir + "/" + self.intbl + "/TT.tbl", - self.LandUse, - subcatch, - self.Soil, - -1.41934, - ) - # Cfmax = 3.75653 # meltconstant in temperature-index - self.Cfmax = self.readtblDefault( - self.Dir + "/" + self.intbl + "/Cfmax.tbl", - self.LandUse, - subcatch, - self.Soil, - 3.75653, - ) - # WHC= 0.10000 # fraction of Snowvolume that can store water - self.WHC = self.readtblDefault( - self.Dir + "/" + self.intbl + "/WHC.tbl", - self.LandUse, - subcatch, - self.Soil, - 0.1, - ) - # Determine real slope and cell length - sizeinmetres = int(configget(self.config, "layout", "sizeinmetres", "0")) - self.xl, self.yl, self.reallength = pcrut.detRealCellLength( - self.ZeroMap, sizeinmetres - ) - self.Slope = slope(self.Altitude) - self.Slope = ifthen( - boolean(self.TopoId), - max(0.001, self.Slope * celllength() / self.reallength), - ) - - # Multiply parameters with a factor (for calibration etc) -P option in command line - for k, v in multpars.iteritems(): - estr = k + "=" + k + "*" + str(v) - self.logger.info("Parameter multiplication: " + estr) - exec estr - - self.SnowWater = self.ZeroMap - - # Initializing of variables - self.logger.info("Initializing of model variables..") - self.TopoLdd = lddmask(self.TopoLdd, boolean(self.TopoId)) - catchmentcells = maptotal(scalar(self.TopoId)) - - # Used to seperate output per LandUse/management classes - # OutZones = self.LandUse - # report(self.reallength,"rl.map") - # report(catchmentcells,"kk.map") - self.QMMConv = self.timestepsecs / ( - self.reallength * self.reallength * 0.001 - ) # m3/s --> mm - - self.sumprecip = self.ZeroMap #: accumulated rainfall for water balance - self.sumtemp = self.ZeroMap # accumulated runoff for water balance - - self.logger.info("Create timeseries outputs...") - toprinttss = configsection(self.config, "outputtss") - - # Save some summary maps - self.logger.info("Saving summary maps...") - report(self.Cfmax, self.Dir + "/" + self.runId + "/outsum/Cfmax.map") - report(self.TTI, self.Dir + "/" + self.runId + "/outsum/TTI.map") - report(self.TT, self.Dir + "/" + self.runId + "/outsum/TT.map") - report(self.WHC, self.Dir + "/" + self.runId + "/outsum/WHC.map") - report(self.xl, self.Dir + "/" + self.runId + "/outsum/xl.map") - report(self.yl, self.Dir + "/" + self.runId + "/outsum/yl.map") - report(self.reallength, self.Dir + "/" + self.runId + "/outsum/rl.map") - - self.SaveDir = self.Dir + "/" + self.runId + "/" - self.logger.info("Starting Dynamic run...") - - def resume(self): - """ read initial state maps (they are output of a previous call to suspend()) """ - - if self.reinit == 1: - self.logger.info("Setting initial conditions to default (zero!)") - self.FreeWater = cover(0.0) #: Water on surface (state variable [mm]) - self.DrySnow = cover(0.0) #: Snow amount (state variable [mm]) - else: - self.wf_resume(self.Dir + "/instate/") - def dynamic(self): self.logger.debug( @@ -465,71 +397,58 @@ # These ar ALWAYS 0 at present!!! Temperature = self.readmap(self.Temp_, 0.0, self.TEMP_style) Temperature = Temperature + self.TempCor - # Inflow=spatial(scalar(0.0)) + #Inflow=spatial(scalar(0.0)) + + # Multiply input parameters with a factor (for calibration etc) -p option in command line + for k, v in multdynapars.items(): + estr = k + "=" + k + "*" + str(v) + self.logger.debug("Dynamic Parameter multiplication: " + estr) + exec(estr) + + # Snow pack modelling degree day methods + RainFrac=ifthenelse(1.0*self.TTI == 0.0,ifthenelse(Temperature <= self.TT,scalar(0.0),scalar(1.0)),min((Temperature-(self.TT-self.TTI/2.0))/self.TTI,scalar(1.0))) + RainFrac=max(RainFrac,scalar(0.0)) #fraction of precipitation which falls as rain + SnowFrac=1.0-RainFrac #fraction of precipitation which falls as snow + Precipitation=self.SFCF*SnowFrac*Precipitation+self.RFCF*RainFrac*Precipitation # different correction for rainfall and snowfall + + SnowFall=SnowFrac*Precipitation #: snowfall depth + RainFall=RainFrac*Precipitation #: rainfall depth + PotSnowMelt=ifthenelse(Temperature > self.TT,self.Cfmax*(Temperature-self.TT),scalar(0.0)) #Potential snow melt, based on temperature + PotRefreezing=ifthenelse(Temperature < self.TT, self.Cfmax*self.CFR*(self.TT-Temperature),0.0) #Potential refreezing, based on temperature + + + #PotSnowMelt=self.FoCfmax*PotSnowMelt #correction for forest zones 0.6) + #PotRefreezing=self.FoCfmax*PotRefreezing + Refreezing=ifthenelse(Temperature < self.TT,min(PotRefreezing,self.FreeWater),0.0) #actual refreezing + SnowMelt=min(PotSnowMelt,self.DrySnow) #actual snow melt + self.DrySnow=self.DrySnow+SnowFall+Refreezing-SnowMelt #dry snow content + self.FreeWater=self.FreeWater-Refreezing #free water content in snow + MaxFreeWater=self.DrySnow*self.WHC + self.FreeWater=self.FreeWater+SnowMelt+RainFall + InSoil = max(self.FreeWater-MaxFreeWater,0.0) #abundant water in snow pack which goes into soil + self.FreeWater=self.FreeWater-InSoil + self.Melt = InSoil + + MaxSnowPack = 10000.0 + if self.MassWasting: + # Masswasting of snow + # 5.67 = tan 80 graden + SnowFluxFrac = min(0.5,self.Slope/5.67) * min(1.0,self.DrySnow/MaxSnowPack) + MaxFlux = SnowFluxFrac * self.DrySnow + self.DrySnow = accucapacitystate(self.TopoLdd,self.DrySnow, MaxFlux) + self.FreeWater = accucapacitystate(self.TopoLdd,self.FreeWater,SnowFluxFrac * self.FreeWater ) + else: + SnowFluxFrac = self.ZeroMap + MaxFlux= self.ZeroMap - # Multiply input parameters with a factor (for calibration etc) -p option in command line - for k, v in multdynapars.iteritems(): - estr = k + "=" + k + "*" + str(v) - self.logger.debug("Dynamic Parameter multiplication: " + estr) - exec estr + + + self.sumprecip=self.sumprecip + Precipitation #accumulated rainfall for water balance + + + # Get rest from ini file + - # Snow pack modelling degree day methods - RainFrac = ifthenelse( - 1.0 * self.TTI == 0.0, - ifthenelse(Temperature <= self.TT, scalar(0.0), scalar(1.0)), - min((Temperature - (self.TT - self.TTI / 2.0)) / self.TTI, scalar(1.0)), - ) - RainFrac = max( - RainFrac, scalar(0.0) - ) # fraction of precipitation which falls as rain - SnowFrac = 1.0 - RainFrac # fraction of precipitation which falls as snow - Precipitation = ( - self.SFCF * SnowFrac * Precipitation + self.RFCF * RainFrac * Precipitation - ) # different correction for rainfall and snowfall - - SnowFall = SnowFrac * Precipitation #: snowfall depth - RainFall = RainFrac * Precipitation #: rainfall depth - PotSnowMelt = ifthenelse( - Temperature > self.TT, self.Cfmax * (Temperature - self.TT), scalar(0.0) - ) # Potential snow melt, based on temperature - PotRefreezing = ifthenelse( - Temperature < self.TT, self.Cfmax * self.CFR * (self.TT - Temperature), 0.0 - ) # Potential refreezing, based on temperature - - # PotSnowMelt=self.FoCfmax*PotSnowMelt #correction for forest zones 0.6) - # PotRefreezing=self.FoCfmax*PotRefreezing - Refreezing = ifthenelse( - Temperature < self.TT, min(PotRefreezing, self.FreeWater), 0.0 - ) # actual refreezing - SnowMelt = min(PotSnowMelt, self.DrySnow) # actual snow melt - self.DrySnow = ( - self.DrySnow + SnowFall + Refreezing - SnowMelt - ) # dry snow content - self.FreeWater = self.FreeWater - Refreezing # free water content in snow - MaxFreeWater = self.DrySnow * self.WHC - self.FreeWater = self.FreeWater + SnowMelt + RainFall - InSoil = max( - self.FreeWater - MaxFreeWater, 0.0 - ) # abundant water in snow pack which goes into soil - self.FreeWater = self.FreeWater - InSoil - self.Melt = InSoil - - MaxSnowPack = 10000.0 - if self.MassWasting: - # Masswasting of snow - # 5.67 = tan 80 graden - SnowFluxFrac = min(0.5, self.Slope / 5.67) * min( - 1.0, self.DrySnow / MaxSnowPack - ) - MaxFlux = SnowFluxFrac * self.DrySnow - self.DrySnow = accucapacitystate(self.TopoLdd, self.DrySnow, MaxFlux) - self.FreeWater = accucapacitystate( - self.TopoLdd, self.FreeWater, SnowFluxFrac * self.FreeWater - ) - else: - SnowFluxFrac = self.ZeroMap - MaxFlux = self.ZeroMap - self.sumprecip = ( self.sumprecip + Precipitation ) # accumulated rainfall for water balance @@ -557,38 +476,30 @@ ## Main model starts here ######################################################################## try: - opts, args = getopt.getopt(sys.argv[1:], "Mc:QXS:hC:Ii:T:NR:u:s:P:p:Xx:U:f") - except getopt.error, msg: + opts, args = getopt.getopt(sys.argv[1:], 'Mc:QXS:hC:Ii:T:NR:u:s:P:p:Xx:U:f') + except getopt.error as msg: pcrut.usage(msg) for o, a in opts: - if o == "-P": - exec "multpars =" + a - print "WARN: -P Does not work at the moment" - if o == "-p": - exec "multdynapars =" + a - print "WARN: -p Does not work at the moment" - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-c": - configfile = a - if o == "-s": - timestepsecs = int(a) - if o == "-T": - _lastTimeStep = int(a) - if o == "-S": - _firstTimeStep = int(a) - if o == "-h": - usage() - if o == "-f": - NoOverWrite = 1 + if o == '-P': + exec("multpars =" + a) + print("WARN: -P Does not work at the moment") + if o == '-p': + exec("multdynapars =" + a) + print("WARN: -p Does not work at the moment") + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-c': configfile = a + if o == '-s': timestepsecs = int(a) + if o == '-T': _lastTimeStep=int(a) + if o == '-S': _firstTimeStep=int(a) + if o == '-h': usage() + if o == '-f': NoOverWrite = 1 + - myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) - dynModelFw = wf_DynamicFramework( - myModel, _lastTimeStep, firstTimestep=_firstTimeStep - ) + + myModel = WflowModel(wflow_cloneMap, caseName,runId,configfile) + dynModelFw = wf_DynamicFramework(myModel, _lastTimeStep,firstTimestep=_firstTimeStep) dynModelFw.createRunId() for o, a in opts: Index: wflow-py/wflow/wflow_sphy.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_sphy.py (.../wflow_sphy.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_sphy.py (.../wflow_sphy.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -54,9 +54,8 @@ - *args: command line arguments given """ sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -249,1268 +248,766 @@ self.logger.info("running for " + str(self.nrTimeSteps()) + " timesteps") # Set and get defaults from ConfigFile here ################################### - # self.scalarInput = int(configget(self.config,"model","ScalarInput","0")) - # self.Tslice = int(configget(self.config,"model","Tslice","1")) - # self.interpolMethod = configget(self.config,"model","InterpolationMethod","inv") - self.reinit = int(configget(self.config, "run", "reinit", "0")) - self.fewsrun = int(configget(self.config, "run", "fewsrun", "0")) - self.OverWriteInit = int(configget(self.config, "model", "OverWriteInit", "0")) - # self.updating = int(configget(self.config,"model","updating","0")) - # self.updateFile = configget(self.config,"model","updateFile","no_set") + # self.scalarInput = int(configget(self.config,"model","ScalarInput","0")) + # self.Tslice = int(configget(self.config,"model","Tslice","1")) + # self.interpolMethod = configget(self.config,"model","InterpolationMethod","inv") + self.reinit = int(configget(self.config,"run","reinit","0")) + self.fewsrun = int(configget(self.config,"run","fewsrun","0")) + self.OverWriteInit = int(configget(self.config,"model","OverWriteInit","0")) + # self.updating = int(configget(self.config,"model","updating","0")) + # self.updateFile = configget(self.config,"model","updateFile","no_set") - # self.sCatch = int(configget(self.config,"model","sCatch","0")) - # self.intbl = configget(self.config,"model","intbl","intbl") - # self.P_style = int(configget(self.config,"model","P_style","1")) - # self.PET_style = int(configget(self.config,"model","PET_style","1")) - # self.TEMP_style = int(configget(self.config,"model","TEMP_style","1")) + # self.sCatch = int(configget(self.config,"model","sCatch","0")) + # self.intbl = configget(self.config,"model","intbl","intbl") + # self.P_style = int(configget(self.config,"model","P_style","1")) + # self.PET_style = int(configget(self.config,"model","PET_style","1")) + # self.TEMP_style = int(configget(self.config,"model","TEMP_style","1")) - # self.modelSnow = int(configget(self.config,"model","ModelSnow","1")) - # sizeinmetres = int(configget(self.config,"layout","sizeinmetres","0")) - # alf = float(configget(self.config,"model","Alpha","60")) - # Qmax = float(configget(self.config,"model","AnnualDischarge","300")) - # self.UpdMaxDist =float(configget(self.config,"model","UpdMaxDist","100")) - # self.MaxUpdMult =float(configget(self.config,"model","MaxUpdMult","1.3")) - # self.MinUpdMult =float(configget(self.config,"model","MinUpdMult","0.7")) - # self.UpFrac =float(configget(self.config,"model","UpFrac","0.8")) - # self.ExternalQbase=int(configget(self.config,'model','ExternalQbase','0')) - # self.SetKquickFlow=int(configget(self.config,'model','SetKquickFlow','0')) - # self.MassWasting = int(configget(self.config,"model","MassWasting","0")) - # self.SubCatchFlowOnly = int(configget(self.config, 'model', 'SubCatchFlowOnly', '0')) - # Print model info - print "The Spatial Processes in HYdrology (SPHY) model is " "developed and owned by FutureWater, Wageningen, The Netherlands" - print "Version 2.1" - print " " + # self.modelSnow = int(configget(self.config,"model","ModelSnow","1")) + # sizeinmetres = int(configget(self.config,"layout","sizeinmetres","0")) + # alf = float(configget(self.config,"model","Alpha","60")) + # Qmax = float(configget(self.config,"model","AnnualDischarge","300")) + # self.UpdMaxDist =float(configget(self.config,"model","UpdMaxDist","100")) + # self.MaxUpdMult =float(configget(self.config,"model","MaxUpdMult","1.3")) + # self.MinUpdMult =float(configget(self.config,"model","MinUpdMult","0.7")) + # self.UpFrac =float(configget(self.config,"model","UpFrac","0.8")) + # self.ExternalQbase=int(configget(self.config,'model','ExternalQbase','0')) + # self.SetKquickFlow=int(configget(self.config,'model','SetKquickFlow','0')) + # self.MassWasting = int(configget(self.config,"model","MassWasting","0")) + # self.SubCatchFlowOnly = int(configget(self.config, 'model', 'SubCatchFlowOnly', '0')) - # Read the modules to be used - self.GlacFLAG = int(configget(self.config, "MODULES", "GlacFLAG", "0")) - self.SnowFLAG = int(configget(self.config, "MODULES", "SnowFLAG", "0")) - self.RoutFLAG = int(configget(self.config, "MODULES", "RoutFLAG", "0")) - self.ResFLAG = int(configget(self.config, "MODULES", "ResFLAG", "0")) - self.LakeFLAG = int(configget(self.config, "MODULES", "LakeFLAG", "0")) - self.DynVegFLAG = int(configget(self.config, "MODULES", "DynVegFLAG", "0")) - self.GroundFLAG = int(configget(self.config, "MODULES", "GroundFLAG", "0")) + # Print model info + print('The Spatial Processes in HYdrology (SPHY) model is ' \ + 'developed and owned by FutureWater, Wageningen, The Netherlands') + print('Version 2.1') + print(' ') - # import the required modules - import datetime, calendar - from wflow.sphy import reporting as reporting - from wflow.sphy import timecalc as timecalc - from wflow.sphy import ET as ET - from wflow.sphy import rootzone as rootzone - from wflow.sphy import subzone as subzone + # Read the modules to be used + self.GlacFLAG = int(configget(self.config,'MODULES','GlacFLAG','0')) + self.SnowFLAG = int(configget(self.config,'MODULES','SnowFLAG','0')) + self.RoutFLAG = int(configget(self.config,'MODULES','RoutFLAG','0')) + self.ResFLAG = int(configget(self.config,'MODULES','ResFLAG','0')) + self.LakeFLAG = int(configget(self.config,'MODULES','LakeFLAG','0')) + self.DynVegFLAG = int(configget(self.config,'MODULES','DynVegFLAG','0')) + self.GroundFLAG = int(configget(self.config,'MODULES','GroundFLAG','0')) + + # import the required modules + import datetime, calendar + from wflow.sphy import reporting as reporting + from wflow.sphy import timecalc as timecalc + from wflow.sphy import ET as ET + from wflow.sphy import rootzone as rootzone + from wflow.sphy import subzone as subzone - # from wflow.wflow_lib import * - from math import pi + #from wflow.wflow_lib import * + from math import pi + #-standard python modules + self.datetime = datetime + self.calendar = calendar + self.pi = pi + #-FW defined modules + self.reporting = reporting + self.timecalc = timecalc + self.ET = ET + self.rootzone = rootzone + self.subzone = subzone + del datetime, calendar, pi, reporting, timecalc, ET, rootzone, subzone + #-import additional modules if required + if self.GlacFLAG == 1: + self.SnowFLAG = 1 + self.GroundFLAG = 1 + import wflow.sphy.glacier as glacier # glacier melting processes + self.glacier = glacier + del glacier + if self.SnowFLAG == 1: + import wflow.sphy.snow as snow # snow melt processes + self.snow = snow + del snow + if self.RoutFLAG == 1: + import wflow.sphy.routing as routing # simple routing scheme + self.routing = routing + del routing + if self.LakeFLAG == 1: + import lakes # import lake module + self.lakes = lakes + del lakes + if self.ResFLAG == 1: + import reservoirs # import reservoir module + self.reservoirs = reservoirs + del reservoirs + if self.LakeFLAG == 1 or self.ResFLAG == 1: + import advanced_routing # overwrite the simple routing scheme + self.routing = advanced_routing + del advanced_routing + self.RoutFLAG = 0 + if self.DynVegFLAG == 1: + import dynamic_veg # dynamic crop growth using ndvi or kc time-series + self.dynamic_veg = dynamic_veg + del dynamic_veg + if self.GroundFLAG == 1: + import wflow.sphy.groundwater as groundwater # groundwater storage as third storage layer. This is used instead of a fixed bottomflux + self.groundwater = groundwater + del groundwater + + #-read the input and output directories from the configuration file + # self.inpath = config.get('DIRS', 'inputdir') + # self.inpathforcingT = config.get('DIRS','inputforcingdirT') + # self.inpathforcingP = config.get('DIRS','inputforcingdirP') + # self.outpath = config.get('DIRS', 'outputdir') + + # self.starttime = configget(self.config,"run","starttime","0") + # ds = dt.datetime.strptime(self.starttime, '%Y-%m-%d %H:%M:%S %Z') + # self.endtime = configget(self.config,"run","endtime","0") + # de = dt.datetime.strptime(self.endtime, '%Y-%m-%d %H:%M:%S %Z') + + # #-set the timing criteria + # sy = ds.year + # sm = ds.month + # sd = ds.day + # ey = de.year + # em = de.month + # ed = de.day + # self.startdate = self.datetime.datetime(sy,sm,sd) + # self.enddate = self.datetime.datetime(ey,em,ed) + + # #-get start date of first forcing file in forcing directory + # syF = config.getint('TIMING', 'startyear_F') + # smF = config.getint('TIMING', 'startmonth_F') + # sdF = config.getint('TIMING', 'startday_F') + # self.startdateF = self.datetime.datetime(syF, smF, sdF) + + #-set the global options + setglobaloption('radians') + #-set the 2000 julian date number + self.julian_date_2000 = 2451545 + #-set the option to calculate the fluxes in mm for the upstream area + self.mm_rep_FLAG = int(configget(self.config,'REPORTING','mm_rep_FLAG','1')) + + # #-setting clone map + # clonemap = self.inpath + config.get('GENERAL','mask') ##->check + # setclone(clonemap) + # self.clone = readmap(clonemap) + + #-read general maps + self.DEM = readmap(os.path.join(self.Dir,"staticmaps", configget(self.config, 'GENERAL','dem','dem.map'))) #-> This has to be implemented for all readmap functions + self.Slope = readmap(os.path.join(self.Dir,"staticmaps", configget(self.config, 'GENERAL','Slope','slope.map'))) + self.Locations = readmap(os.path.join(self.Dir,"staticmaps", configget(self.config, 'GENERAL','locations','outlets.map'))) + + #-read soil maps + #self.Soil = readmap(self.inpath + config.get('SOIL','Soil')) + self.RootFieldMap = readmap(os.path.join(self.Dir,"staticmaps", configget(self.config,'SOIL','RootFieldMap','root_field.map'))) + self.RootSatMap = readmap(os.path.join(self.Dir,"staticmaps", configget(self.config,'SOIL','RootSatMap','root_sat.map'))) + self.RootDryMap = readmap(os.path.join(self.Dir,"staticmaps", configget(self.config,'SOIL','RootDryMap','root_dry.map'))) + self.RootWiltMap = readmap(os.path.join(self.Dir,"staticmaps", configget(self.config,'SOIL','RootWiltMap','root_wilt.map'))) + self.RootKsat = readmap(os.path.join(self.Dir,"staticmaps", configget(self.config,'SOIL','RootKsat','root_ksat.map'))) + self.SubSatMap = readmap(os.path.join(self.Dir,"staticmaps", configget(self.config,'SOIL','SubSatMap', 'sub_sat.map'))) + self.SubFieldMap = readmap(os.path.join(self.Dir,"staticmaps", configget(self.config,'SOIL','SubFieldMap','sub_field.map'))) + self.SubKsat = readmap(os.path.join(self.Dir,"staticmaps", configget(self.config,'SOIL','SubKsat','sub_ksat.map'))) + self.RootDrainVel = self.RootKsat * self.Slope + + #-Read and set the soil parameters + pars = ['CapRiseMax','RootDepthFlat','SubDepthFlat'] + for i in pars: + try: + #setattr(self, i, readmap(self.inpath + config.get('SOILPARS',i))) + setattr(self, i, readmap(os.path.join(self.Dir,"staticmaps", configget(self.config,'SOILPARS',i,i)))) + except: + #setattr(self, i, config.getfloat('SOILPARS',i)) + setattr(self, i, float(configget(self.config,'SOILPARS',i,i))) + if self.GroundFLAG == 0: # if groundwater module is not used, read seepage and gwl_base + self.SeepStatFLAG = config.getint('SOILPARS','SeepStatic') + if self.SeepStatFLAG == 0: # set the seepage map series + self.Seepmaps = self.inpath + config.get('SOILPARS', 'SeePage') + else: #-set a static map or value for seepage + try: + self.SeePage = readmap(self.inpath + config.get('SOILPARS','SeePage')) + except: + self.SeePage = config.getfloat('SOILPARS','SeePage') + try: + self.GWL_base = readmap(self.inpath + config.get('SOILPARS','GWL_base')) + except: + self.GWL_base = config.getfloat('SOILPARS','GWL_base') + + self.SubDrainVel = self.SubKsat * self.Slope + else: # if groundwater module is used, then read the groundwater soil parameters + pars = ['GwDepth','GwSat','deltaGw','BaseThresh','alphaGw','YieldGw'] + for i in pars: + try: + setattr(self, i, readmap(self.inpath + config.get('GROUNDW_PARS',i))) + except: + setattr(self, i, float(configget(self.config,'GROUNDW_PARS',i,i))) + + #-calculate soil properties + self.RootField = self.RootFieldMap * self.RootDepthFlat + self.RootSat = self.RootSatMap * self.RootDepthFlat + self.RootDry = self.RootDryMap * self.RootDepthFlat + self.RootWilt = self.RootWiltMap * self.RootDepthFlat + self.SubSat = self.SubSatMap * self.SubDepthFlat + self.SubField = self.SubFieldMap * self.SubDepthFlat + self.RootTT = (self.RootSat - self.RootField) / self.RootKsat + self.SubTT = (self.SubSat - self.SubField) / self.SubKsat + # soil max and soil min for scaling of gwl if groundwater module is not used + if self.GroundFLAG == 0: + self.SoilMax = self.RootSat + self.SubSat + self.SoilMin = self.RootDry + self.SubField + + #-read the crop coefficient table if the dynamic vegetation module is not used + if self.DynVegFLAG == 0: + self.KcStatFLAG = int(configget(self.config,'LANDUSE', 'KCstatic','kc.tbl')) + if self.KcStatFLAG == 1: + #-read land use map and kc table + self.LandUse = readmap(os.path.join(self.Dir,"staticmaps",configget(self.config,'LANDUSE','LandUse','landuse.map'))) + self.kc_table = os.path.join(self.Dir,"staticmaps",configget(self.config,'LANDUSE','CropFac','kc.tbl')) + self.Kc = lookupscalar(self.kc_table, self.LandUse) + else: + #-set the kc map series + self.Kcmaps = self.inpath + config.get('LANDUSE', 'KC') + #-Use the dynamic vegetation module + else: + #-set the ndvi map series to be read + self.ndvi = self.inpath + config.get('DYNVEG', 'NDVI') + #-read the vegetation parameters + pars = ['NDVImax','NDVImin','NDVIbase','KCmax','KCmin','LAImax','FPARmax','FPARmin'] + for i in pars: + try: + setattr(self, i, readmap(self.inpath + config.get('DYNVEG', i))) + except: + setattr(self, i, config.getfloat('DYNVEG', i)) + + #-read and set glacier maps and parameters if glacier module is used + if self.GlacFLAG == 1: + # self.GlacFracCI = readmap(self.inpath + config.get('GLACIER','GlacFracCI')) + # self.GlacFracDB = readmap(self.inpath + config.get('GLACIER','GlacFracDB')) + self.GlacFracCI = readmap(os.path.join(self.Dir,"staticmaps", configget(self.config,'GLACIER','GlacFracCI','glacier_clean.map'))) + self.GlacFracDB = readmap(os.path.join(self.Dir,"staticmaps", configget(self.config,'GLACIER','GlacFracDB','glacier_debris.map'))) + pars = ['DDFG','DDFDG','GlacF'] + for i in pars: + try: + setattr(self, i, readmap(self.inpath + config.get('GLACIER',i))) + except: + #setattr(self, i, config.getfloat('GLACIER',i)) + setattr(self, i, float(configget(self.config,'GLACIER',i,i))) + + #-read and set snow maps and parameters if snow modules are used + if self.SnowFLAG == 1: + pars = ['Tcrit','SnowSC','DDFS'] + for i in pars: + try: + setattr(self, i, readmap(self.inpath + config.get('SNOW',i))) + except: +# setattr(self, i, float(configget(self.config,'SNOW',i,i))) + setattr(self, i, float(configget(self.config,'SNOW',i,i))) + + #-read and set climate forcing and the calculation of etref + + self.Prec_mapstack = self.Dir + configget(self.config, "inputmapstacks", "Prec","/inmaps/Prec") # timeseries for rainfall + self.Tair_mapstack = self.Dir + configget(self.config, "inputmapstacks", "Tair","/inmaps/Tair") # timeseries for rainfall "/inmaps/TEMP" # global radiation + self.Tmax_mapstack = self.Dir + configget(self.config, "inputmapstacks", "Tmax","/inmaps/Tmax") # timeseries for rainfall "/inmaps/TEMP" # global radiation + self.Tmin_mapstack = self.Dir + configget(self.config, "inputmapstacks", "Tmin","/inmaps/Tmin") # timeseries for rainfall "/inmaps/TEMP" # global radiation + + + + + # self.Prec = self.inpathforcingP + config.get('CLIMATE','Prec') + # self.Tair = self.inpathforcingT + config.get('CLIMATE','Tair') + #self.ETREF_FLAG = config.getint('ETREF','ETREF_FLAG') ##-> for now should be zero. + self.ETREF_FLAG = int(configget(self.config,'ETREF','ETREF_FLAG',0)) ##-> for now should be zero. + #-determine the use of a given etref time-series or calculate etref using Hargreaves + if self.ETREF_FLAG == 1: + self.ETref = self.inpath + config.get('ETREF','ETref') + else: + #self.Lat = readmap(self.inpath + config.get('ETREF','Lat')) + self.Lat = readmap(os.path.join(self.Dir,"staticmaps",configget(self.config,'ETREF','Lat','latitude.map'))) + self.Tmax_mapstack = self.Dir + configget(self.config, "inputmapstacks", "Tmax","/inmaps/Tmax") # timeseries for rainfall "/inmaps/TEMP" # global radiation + self.Tmin_mapstack = self.Dir + configget(self.config, "inputmapstacks", "Tmin","/inmaps/Tmin") # timeseries for rainfall "/inmaps/TEMP" # global radiation + #self.Gsc = config.getfloat('ETREF', 'Gsc') + self.Gsc = float(configget(self.config,'ETREF','Gsc',0.0820)) + from wflow.sphy import hargreaves + self.Hargreaves = hargreaves + del hargreaves + + #-read and set routing maps and parameters + if self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1: + #self.FlowDir = readmap(self.inpath + config.get('ROUTING','flowdir')) + self.FlowDir = readmap(os.path.join(self.Dir,"staticmaps",configget(self.config,'ROUTING','flowdir','ldd.map'))) + try: + self.kx = readmap(self.inpath + config.get('ROUTING','kx')) + except: + #self.kx = config.getfloat('ROUTING','kx') + self.kx = float(configget(self.config,'ROUTING','kx',1)) + + setglobaloption('matrixtable') + #-read lake maps and parameters if lake module is used + if self.LakeFLAG == 1: + # nominal map with lake IDs + self.LakeID = cover(readmap(self.inpath + config.get('LAKE','LakeId')), 0) + # lookup table with function for each lake (exp, 1-order poly, 2-order poly, 3-order poly) + LakeFunc_Tab = self.inpath + config.get('LAKE', 'LakeFunc') + # lookup table with Qh-coeficients for each lake + LakeQH_Tab = self.inpath + config.get('LAKE', 'LakeQH') + # lookup table with Sh-coeficients for each lake + LakeSH_Tab = self.inpath + config.get('LAKE', 'LakeSH') + # lookup table with hS-coeficients for each lake + LakeHS_Tab = self.inpath + config.get('LAKE', 'LakeHS') + # create lake coefficient maps + self.LakeQH_Func = lookupnominal(LakeFunc_Tab, 1, self.LakeID) + self.LakeSH_Func = lookupnominal(LakeFunc_Tab, 2, self.LakeID) + self.LakeHS_Func = lookupnominal(LakeFunc_Tab, 3, self.LakeID) + # Read QH coefficients + self.LakeQH_exp_a = lookupscalar(LakeQH_Tab, 1, self.LakeID) + self.LakeQH_exp_b = lookupscalar(LakeQH_Tab, 2, self.LakeID) + self.LakeQH_pol_b = lookupscalar(LakeQH_Tab, 3, self.LakeID) + self.LakeQH_pol_a1 = lookupscalar(LakeQH_Tab, 4, self.LakeID) + self.LakeQH_pol_a2 = lookupscalar(LakeQH_Tab, 5, self.LakeID) + self.LakeQH_pol_a3 = lookupscalar(LakeQH_Tab, 6, self.LakeID) + # Read SH coefficients + self.LakeSH_exp_a = lookupscalar(LakeSH_Tab, 1, self.LakeID) + self.LakeSH_exp_b = lookupscalar(LakeSH_Tab, 2, self.LakeID) + self.LakeSH_pol_b = lookupscalar(LakeSH_Tab, 3, self.LakeID) + self.LakeSH_pol_a1 = lookupscalar(LakeSH_Tab, 4, self.LakeID) + self.LakeSH_pol_a2 = lookupscalar(LakeSH_Tab, 5, self.LakeID) + self.LakeSH_pol_a3 = lookupscalar(LakeSH_Tab, 6, self.LakeID) + # Read HS coefficients + self.LakeHS_exp_a = lookupscalar(LakeHS_Tab, 1, self.LakeID) + self.LakeHS_exp_b = lookupscalar(LakeHS_Tab, 2, self.LakeID) + self.LakeHS_pol_b = lookupscalar(LakeHS_Tab, 3, self.LakeID) + self.LakeHS_pol_a1 = lookupscalar(LakeHS_Tab, 4, self.LakeID) + self.LakeHS_pol_a2 = lookupscalar(LakeHS_Tab, 5, self.LakeID) + self.LakeHS_pol_a3 = lookupscalar(LakeHS_Tab, 6, self.LakeID) + #-read water level maps and parameters if available + try: + self.UpdateLakeLevel = readmap(self.inpath + config.get('LAKE','updatelakelevel')) + self.LLevel = self.inpath + config.get('LAKE','LakeFile') + print('measured lake levels will be used to update lake storage') + except: + pass + + #-read reservior maps and parameters if reservoir module is used + if self.ResFLAG == 1: + # nominal map with reservoir IDs + self.ResID = cover(readmap(self.inpath + config.get('RESERVOIR','ResId')), 0) + # lookup table with operational scheme to use (simple or advanced) + ResFunc_Tab = self.inpath + config.get('RESERVOIR', 'ResFuncStor') + # Reservoir function + self.ResFunc = cover(lookupscalar(ResFunc_Tab, 1, self.ResID), 0) + try: + # lookup table with coefficients for simple reservoirs + ResSimple_Tab = self.inpath + config.get('RESERVOIR', 'ResSimple') + # Read coefficients for simple reservoirs + self.ResKr = lookupscalar(ResSimple_Tab, 1, self.ResID) + self.ResSmax = lookupscalar(ResSimple_Tab, 2, self.ResID) * 10**6 # convert to m3 + self.ResSimple = True + except: + self.ResSimple = False + try: + # lookup table with coefficients for advanced reservoirs + ResAdvanced_Tab = self.inpath + config.get('RESERVOIR', 'ResAdv') + # Read coefficients for advanced reservoirs + self.ResEVOL = lookupscalar(ResAdvanced_Tab, 1, self.ResID) * 10**6 # convert to m3 + self.ResPVOL = lookupscalar(ResAdvanced_Tab, 2, self.ResID) * 10**6 # convert to m3 + self.ResMaxFl = lookupscalar(ResAdvanced_Tab, 3, self.ResID) * 10**6 # convert to m3/d + self.ResDemFl = lookupscalar(ResAdvanced_Tab, 4, self.ResID) * 10**6 # convert to m3/d + self.ResFlStart = lookupscalar(ResAdvanced_Tab, 5, self.ResID) + self.ResFlEnd = lookupscalar(ResAdvanced_Tab, 6, self.ResID) + self.ResAdvanced = True + except: + self.ResAdvanced = False + + #-below is original initial part from sphy + + + #-get the correct forcing file number, depending on the start date of your simulation + #-and the start date of the first forcing file in your forcing directory. + #self.counter = (self.startdate - self.startdateF).days + # #-initial date + # self.curdate = self.startdate + #self.curdate = configget(self.config,"run","starttime","0") + #print self.curdate + #-initial soil properties + #-initial rootwater content - # -standard python modules - self.datetime = datetime - self.calendar = calendar - self.pi = pi - # -FW defined modules - self.reporting = reporting - self.timecalc = timecalc - self.ET = ET - self.rootzone = rootzone - self.subzone = subzone - del datetime, calendar, pi, reporting, timecalc, ET, rootzone, subzone - # -import additional modules if required - if self.GlacFLAG == 1: - self.SnowFLAG = 1 - self.GroundFLAG = 1 - import wflow.sphy.glacier as glacier # glacier melting processes - self.glacier = glacier - del glacier - if self.SnowFLAG == 1: - import wflow.sphy.snow as snow # snow melt processes - - self.snow = snow - del snow - if self.RoutFLAG == 1: - import wflow.sphy.routing as routing # simple routing scheme - - self.routing = routing - del routing - if self.LakeFLAG == 1: - import lakes # import lake module - - self.lakes = lakes - del lakes - if self.ResFLAG == 1: - import reservoirs # import reservoir module - - self.reservoirs = reservoirs - del reservoirs - if self.LakeFLAG == 1 or self.ResFLAG == 1: - import advanced_routing # overwrite the simple routing scheme - - self.routing = advanced_routing - del advanced_routing - self.RoutFLAG = 0 - if self.DynVegFLAG == 1: - import dynamic_veg # dynamic crop growth using ndvi or kc time-series - - self.dynamic_veg = dynamic_veg - del dynamic_veg - if self.GroundFLAG == 1: - import wflow.sphy.groundwater as groundwater # groundwater storage as third storage layer. This is used instead of a fixed bottomflux - - self.groundwater = groundwater - del groundwater - - # -read the input and output directories from the configuration file - # self.inpath = config.get('DIRS', 'inputdir') - # self.inpathforcingT = config.get('DIRS','inputforcingdirT') - # self.inpathforcingP = config.get('DIRS','inputforcingdirP') - # self.outpath = config.get('DIRS', 'outputdir') - - # self.starttime = configget(self.config,"run","starttime","0") - # ds = dt.datetime.strptime(self.starttime, '%Y-%m-%d %H:%M:%S %Z') - # self.endtime = configget(self.config,"run","endtime","0") - # de = dt.datetime.strptime(self.endtime, '%Y-%m-%d %H:%M:%S %Z') - - # #-set the timing criteria - # sy = ds.year - # sm = ds.month - # sd = ds.day - # ey = de.year - # em = de.month - # ed = de.day - # self.startdate = self.datetime.datetime(sy,sm,sd) - # self.enddate = self.datetime.datetime(ey,em,ed) - - # #-get start date of first forcing file in forcing directory - # syF = config.getint('TIMING', 'startyear_F') - # smF = config.getint('TIMING', 'startmonth_F') - # sdF = config.getint('TIMING', 'startday_F') - # self.startdateF = self.datetime.datetime(syF, smF, sdF) - - # -set the global options - setglobaloption("radians") - # -set the 2000 julian date number - self.julian_date_2000 = 2451545 - # -set the option to calculate the fluxes in mm for the upstream area - self.mm_rep_FLAG = int(configget(self.config, "REPORTING", "mm_rep_FLAG", "1")) - - # #-setting clone map - # clonemap = self.inpath + config.get('GENERAL','mask') ##->check - # setclone(clonemap) - # self.clone = readmap(clonemap) - - # -read general maps - self.DEM = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "GENERAL", "dem", "dem.map"), - ) - ) # -> This has to be implemented for all readmap functions - self.Slope = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "GENERAL", "Slope", "slope.map"), - ) - ) - self.Locations = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "GENERAL", "locations", "outlets.map"), - ) - ) - - # -read soil maps - # self.Soil = readmap(self.inpath + config.get('SOIL','Soil')) - self.RootFieldMap = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "SOIL", "RootFieldMap", "root_field.map"), - ) - ) - self.RootSatMap = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "SOIL", "RootSatMap", "root_sat.map"), - ) - ) - self.RootDryMap = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "SOIL", "RootDryMap", "root_dry.map"), - ) - ) - self.RootWiltMap = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "SOIL", "RootWiltMap", "root_wilt.map"), - ) - ) - self.RootKsat = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "SOIL", "RootKsat", "root_ksat.map"), - ) - ) - self.SubSatMap = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "SOIL", "SubSatMap", "sub_sat.map"), - ) - ) - self.SubFieldMap = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "SOIL", "SubFieldMap", "sub_field.map"), - ) - ) - self.SubKsat = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "SOIL", "SubKsat", "sub_ksat.map"), - ) - ) - self.RootDrainVel = self.RootKsat * self.Slope - - # -Read and set the soil parameters - pars = ["CapRiseMax", "RootDepthFlat", "SubDepthFlat"] - for i in pars: - try: - # setattr(self, i, readmap(self.inpath + config.get('SOILPARS',i))) - setattr( - self, - i, - readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "SOILPARS", i, i), - ) - ), - ) - except: - # setattr(self, i, config.getfloat('SOILPARS',i)) - setattr(self, i, float(configget(self.config, "SOILPARS", i, i))) - if ( - self.GroundFLAG == 0 - ): # if groundwater module is not used, read seepage and gwl_base - self.SeepStatFLAG = config.getint("SOILPARS", "SeepStatic") - if self.SeepStatFLAG == 0: # set the seepage map series - self.Seepmaps = self.inpath + config.get("SOILPARS", "SeePage") - else: # -set a static map or value for seepage - try: - self.SeePage = readmap( - self.inpath + config.get("SOILPARS", "SeePage") - ) - except: - self.SeePage = config.getfloat("SOILPARS", "SeePage") - try: - self.GWL_base = readmap( - self.inpath + config.get("SOILPARS", "GWL_base") - ) - except: - self.GWL_base = config.getfloat("SOILPARS", "GWL_base") - - self.SubDrainVel = self.SubKsat * self.Slope - else: # if groundwater module is used, then read the groundwater soil parameters - pars = ["GwDepth", "GwSat", "deltaGw", "BaseThresh", "alphaGw", "YieldGw"] - for i in pars: - try: - setattr( - self, i, readmap(self.inpath + config.get("GROUNDW_PARS", i)) - ) - except: - setattr( - self, i, float(configget(self.config, "GROUNDW_PARS", i, i)) - ) - - # -calculate soil properties - self.RootField = self.RootFieldMap * self.RootDepthFlat - self.RootSat = self.RootSatMap * self.RootDepthFlat - self.RootDry = self.RootDryMap * self.RootDepthFlat - self.RootWilt = self.RootWiltMap * self.RootDepthFlat - self.SubSat = self.SubSatMap * self.SubDepthFlat - self.SubField = self.SubFieldMap * self.SubDepthFlat - self.RootTT = (self.RootSat - self.RootField) / self.RootKsat - self.SubTT = (self.SubSat - self.SubField) / self.SubKsat - # soil max and soil min for scaling of gwl if groundwater module is not used - if self.GroundFLAG == 0: - self.SoilMax = self.RootSat + self.SubSat - self.SoilMin = self.RootDry + self.SubField - - # -read the crop coefficient table if the dynamic vegetation module is not used - if self.DynVegFLAG == 0: - self.KcStatFLAG = int( - configget(self.config, "LANDUSE", "KCstatic", "kc.tbl") - ) - if self.KcStatFLAG == 1: - # -read land use map and kc table - self.LandUse = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "LANDUSE", "LandUse", "landuse.map"), - ) - ) - self.kc_table = os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "LANDUSE", "CropFac", "kc.tbl"), - ) - self.Kc = lookupscalar(self.kc_table, self.LandUse) - else: - # -set the kc map series - self.Kcmaps = self.inpath + config.get("LANDUSE", "KC") - # -Use the dynamic vegetation module - else: - # -set the ndvi map series to be read - self.ndvi = self.inpath + config.get("DYNVEG", "NDVI") - # -read the vegetation parameters - pars = [ - "NDVImax", - "NDVImin", - "NDVIbase", - "KCmax", - "KCmin", - "LAImax", - "FPARmax", - "FPARmin", - ] - for i in pars: - try: - setattr(self, i, readmap(self.inpath + config.get("DYNVEG", i))) - except: - setattr(self, i, config.getfloat("DYNVEG", i)) - - # -read and set glacier maps and parameters if glacier module is used - if self.GlacFLAG == 1: - # self.GlacFracCI = readmap(self.inpath + config.get('GLACIER','GlacFracCI')) - # self.GlacFracDB = readmap(self.inpath + config.get('GLACIER','GlacFracDB')) - self.GlacFracCI = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget( - self.config, "GLACIER", "GlacFracCI", "glacier_clean.map" - ), - ) - ) - self.GlacFracDB = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget( - self.config, "GLACIER", "GlacFracDB", "glacier_debris.map" - ), - ) - ) - pars = ["DDFG", "DDFDG", "GlacF"] - for i in pars: - try: - setattr(self, i, readmap(self.inpath + config.get("GLACIER", i))) - except: - # setattr(self, i, config.getfloat('GLACIER',i)) - setattr(self, i, float(configget(self.config, "GLACIER", i, i))) - - # -read and set snow maps and parameters if snow modules are used - if self.SnowFLAG == 1: - pars = ["Tcrit", "SnowSC", "DDFS"] - for i in pars: - try: - setattr(self, i, readmap(self.inpath + config.get("SNOW", i))) - except: - # setattr(self, i, float(configget(self.config,'SNOW',i,i))) - setattr(self, i, float(configget(self.config, "SNOW", i, i))) - - # -read and set climate forcing and the calculation of etref - - self.Prec_mapstack = self.Dir + configget( - self.config, "inputmapstacks", "Prec", "/inmaps/Prec" - ) # timeseries for rainfall - self.Tair_mapstack = self.Dir + configget( - self.config, "inputmapstacks", "Tair", "/inmaps/Tair" - ) # timeseries for rainfall "/inmaps/TEMP" # global radiation - self.Tmax_mapstack = self.Dir + configget( - self.config, "inputmapstacks", "Tmax", "/inmaps/Tmax" - ) # timeseries for rainfall "/inmaps/TEMP" # global radiation - self.Tmin_mapstack = self.Dir + configget( - self.config, "inputmapstacks", "Tmin", "/inmaps/Tmin" - ) # timeseries for rainfall "/inmaps/TEMP" # global radiation - - # self.Prec = self.inpathforcingP + config.get('CLIMATE','Prec') - # self.Tair = self.inpathforcingT + config.get('CLIMATE','Tair') - # self.ETREF_FLAG = config.getint('ETREF','ETREF_FLAG') ##-> for now should be zero. - self.ETREF_FLAG = int( - configget(self.config, "ETREF", "ETREF_FLAG", 0) - ) ##-> for now should be zero. - # -determine the use of a given etref time-series or calculate etref using Hargreaves - if self.ETREF_FLAG == 1: - self.ETref = self.inpath + config.get("ETREF", "ETref") - else: - # self.Lat = readmap(self.inpath + config.get('ETREF','Lat')) - self.Lat = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "ETREF", "Lat", "latitude.map"), - ) - ) - self.Tmax_mapstack = self.Dir + configget( - self.config, "inputmapstacks", "Tmax", "/inmaps/Tmax" - ) # timeseries for rainfall "/inmaps/TEMP" # global radiation - self.Tmin_mapstack = self.Dir + configget( - self.config, "inputmapstacks", "Tmin", "/inmaps/Tmin" - ) # timeseries for rainfall "/inmaps/TEMP" # global radiation - # self.Gsc = config.getfloat('ETREF', 'Gsc') - self.Gsc = float(configget(self.config, "ETREF", "Gsc", 0.0820)) - from wflow.sphy import hargreaves - - self.Hargreaves = hargreaves - del hargreaves - - # -read and set routing maps and parameters - if self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1: - # self.FlowDir = readmap(self.inpath + config.get('ROUTING','flowdir')) - self.FlowDir = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget(self.config, "ROUTING", "flowdir", "ldd.map"), - ) - ) - try: - self.kx = readmap(self.inpath + config.get("ROUTING", "kx")) - except: - # self.kx = config.getfloat('ROUTING','kx') - self.kx = float(configget(self.config, "ROUTING", "kx", 1)) - - setglobaloption("matrixtable") - # -read lake maps and parameters if lake module is used - if self.LakeFLAG == 1: - # nominal map with lake IDs - self.LakeID = cover(readmap(self.inpath + config.get("LAKE", "LakeId")), 0) - # lookup table with function for each lake (exp, 1-order poly, 2-order poly, 3-order poly) - LakeFunc_Tab = self.inpath + config.get("LAKE", "LakeFunc") - # lookup table with Qh-coeficients for each lake - LakeQH_Tab = self.inpath + config.get("LAKE", "LakeQH") - # lookup table with Sh-coeficients for each lake - LakeSH_Tab = self.inpath + config.get("LAKE", "LakeSH") - # lookup table with hS-coeficients for each lake - LakeHS_Tab = self.inpath + config.get("LAKE", "LakeHS") - # create lake coefficient maps - self.LakeQH_Func = lookupnominal(LakeFunc_Tab, 1, self.LakeID) - self.LakeSH_Func = lookupnominal(LakeFunc_Tab, 2, self.LakeID) - self.LakeHS_Func = lookupnominal(LakeFunc_Tab, 3, self.LakeID) - # Read QH coefficients - self.LakeQH_exp_a = lookupscalar(LakeQH_Tab, 1, self.LakeID) - self.LakeQH_exp_b = lookupscalar(LakeQH_Tab, 2, self.LakeID) - self.LakeQH_pol_b = lookupscalar(LakeQH_Tab, 3, self.LakeID) - self.LakeQH_pol_a1 = lookupscalar(LakeQH_Tab, 4, self.LakeID) - self.LakeQH_pol_a2 = lookupscalar(LakeQH_Tab, 5, self.LakeID) - self.LakeQH_pol_a3 = lookupscalar(LakeQH_Tab, 6, self.LakeID) - # Read SH coefficients - self.LakeSH_exp_a = lookupscalar(LakeSH_Tab, 1, self.LakeID) - self.LakeSH_exp_b = lookupscalar(LakeSH_Tab, 2, self.LakeID) - self.LakeSH_pol_b = lookupscalar(LakeSH_Tab, 3, self.LakeID) - self.LakeSH_pol_a1 = lookupscalar(LakeSH_Tab, 4, self.LakeID) - self.LakeSH_pol_a2 = lookupscalar(LakeSH_Tab, 5, self.LakeID) - self.LakeSH_pol_a3 = lookupscalar(LakeSH_Tab, 6, self.LakeID) - # Read HS coefficients - self.LakeHS_exp_a = lookupscalar(LakeHS_Tab, 1, self.LakeID) - self.LakeHS_exp_b = lookupscalar(LakeHS_Tab, 2, self.LakeID) - self.LakeHS_pol_b = lookupscalar(LakeHS_Tab, 3, self.LakeID) - self.LakeHS_pol_a1 = lookupscalar(LakeHS_Tab, 4, self.LakeID) - self.LakeHS_pol_a2 = lookupscalar(LakeHS_Tab, 5, self.LakeID) - self.LakeHS_pol_a3 = lookupscalar(LakeHS_Tab, 6, self.LakeID) - # -read water level maps and parameters if available - try: - self.UpdateLakeLevel = readmap( - self.inpath + config.get("LAKE", "updatelakelevel") - ) - self.LLevel = self.inpath + config.get("LAKE", "LakeFile") - print "measured lake levels will be used to update lake storage" - except: - pass - - # -read reservior maps and parameters if reservoir module is used - if self.ResFLAG == 1: - # nominal map with reservoir IDs - self.ResID = cover( - readmap(self.inpath + config.get("RESERVOIR", "ResId")), 0 - ) - # lookup table with operational scheme to use (simple or advanced) - ResFunc_Tab = self.inpath + config.get("RESERVOIR", "ResFuncStor") - # Reservoir function - self.ResFunc = cover(lookupscalar(ResFunc_Tab, 1, self.ResID), 0) - try: - # lookup table with coefficients for simple reservoirs - ResSimple_Tab = self.inpath + config.get("RESERVOIR", "ResSimple") - # Read coefficients for simple reservoirs - self.ResKr = lookupscalar(ResSimple_Tab, 1, self.ResID) - self.ResSmax = ( - lookupscalar(ResSimple_Tab, 2, self.ResID) * 10 ** 6 - ) # convert to m3 - self.ResSimple = True - except: - self.ResSimple = False - try: - # lookup table with coefficients for advanced reservoirs - ResAdvanced_Tab = self.inpath + config.get("RESERVOIR", "ResAdv") - # Read coefficients for advanced reservoirs - self.ResEVOL = ( - lookupscalar(ResAdvanced_Tab, 1, self.ResID) * 10 ** 6 - ) # convert to m3 - self.ResPVOL = ( - lookupscalar(ResAdvanced_Tab, 2, self.ResID) * 10 ** 6 - ) # convert to m3 - self.ResMaxFl = ( - lookupscalar(ResAdvanced_Tab, 3, self.ResID) * 10 ** 6 - ) # convert to m3/d - self.ResDemFl = ( - lookupscalar(ResAdvanced_Tab, 4, self.ResID) * 10 ** 6 - ) # convert to m3/d - self.ResFlStart = lookupscalar(ResAdvanced_Tab, 5, self.ResID) - self.ResFlEnd = lookupscalar(ResAdvanced_Tab, 6, self.ResID) - self.ResAdvanced = True - except: - self.ResAdvanced = False - - # -below is original initial part from sphy - - # -get the correct forcing file number, depending on the start date of your simulation - # -and the start date of the first forcing file in your forcing directory. - # self.counter = (self.startdate - self.startdateF).days - # #-initial date - # self.curdate = self.startdate - # self.curdate = configget(self.config,"run","starttime","0") - # print self.curdate - # -initial soil properties - # -initial rootwater content - - self.RootWater = self.RootField - self.SubWater = self.SubField - - # if not config.get('SOIL_INIT','RootWater'): - # self.RootWater = self.RootField - # else: + self.RootWater = self.RootField + self.SubWater = self.SubField + + # if not config.get('SOIL_INIT','RootWater'): + # self.RootWater = self.RootField + # else: + # try: + # self.RootWater = config.getfloat('SOIL_INIT','RootWater') + # except: + # self.RootWater = readmap(self.inpath + config.get('SOIL_INIT','RootWater')) + # #-initial water content in subsoil + # if not config.get('SOIL_INIT','SubWater'): + # self.SubWater = self.SubField + # else: + # try: + # self.SubWater = config.getfloat('SOIL_INIT','SubWater') + # except: + # self.SubWater = readmap(self.inpath + config.get('SOIL_INIT','SubWater')) + #-initial water storage in rootzone + subsoil + self.SoilWater = self.RootWater + self.SubWater + #-initial capillary rise + self.CapRise = configget(self.config,'SOIL_INIT','CapRise',3) + # try: + # self.CapRise = config.getfloat('SOIL_INIT','CapRise') + # except: + # self.CapRise = readmap(self.inpath + config.get('SOIL_INIT','CapRise')) + #-initial drainage from rootzone + self.RootDrain = configget(self.config,'SOIL_INIT','RootDrain',3) + # try: + # self.RootDrain = config.getfloat('SOIL_INIT','RootDrain') + # except: + # self.RootDrain = readmap(self.inpath + config.get('SOIL_INIT','RootDrain')) + + if self.DynVegFLAG == 1: + #-initial canopy storage + self.Scanopy = 0 + #-initial ndvi if first map is not provided + self.ndviOld = scalar((self.NDVImax + self.NDVImin)/2) + elif self.KcStatFLAG == 0: + #-set initial kc value to one, if kc map is not available for first timestep + self.KcOld = scalar(1) + + #-initial groundwater properties + if self.GroundFLAG == 1: + self.GwRecharge = float(configget(self.config,'GROUNDW_INIT','GwRecharge',0)) + self.BaseR = float(configget(self.config,'GROUNDW_INIT','BaseR',1)) + self.Gw = float(configget(self.config,'GROUNDW_INIT','Gw',1)) + self.H_gw = float(configget(self.config,'GROUNDW_INIT','H_gw',1)) + # #-initial groundwater recharge + # try: + # self.GwRecharge = config.getfloat('GROUNDW_INIT','GwRecharge') + # except: + # self.GwRecharge = readmap(self.inpath + config.get('GROUNDW_INIT','GwRecharge')) + # #-initial baseflow + # try: + # self.BaseR = config.getfloat('GROUNDW_INIT','BaseR') + # except: + # self.BaseR = readmap(self.inpath + config.get('GROUNDW_INIT','BaseR')) + # #-initial groundwater storage + # try: + # self.Gw = config.getfloat('GROUNDW_INIT','Gw') + # except: + # self.Gw = readmap(self.inpath + config.get('GROUNDW_INIT','Gw')) + # #-initial groundwater level + # try: + # self.H_gw = config.getfloat('GROUNDW_INIT','H_gw') + # except: + # self.H_gw = readmap(self.inpath + config.get('GROUNDW_INIT','H_gw')) + # self.H_gw = max((self.RootDepthFlat + self.SubDepthFlat + self.GwDepth)/1000 - self.H_gw, 0) + # else: + # #-initial drainage from subsoil + # try: + # self.SubDrain = config.getfloat('SOIL_INIT','SubDrain') + # except: + # self.SubDrain = readmap(self.inpath + config.get('SOIL_INIT','SubDrain')) + # #-initial seepage value if seepage map series is used + # if self.SeepStatFLAG == 0: + # self.SeepOld = scalar(0) + + #-initial snow properties + if self.SnowFLAG == 1: + try: + #self.SnowStore = config.getfloat('SNOW_INIT','SnowIni') + self.SnowStore = float(configget(self.config,'SNOW_INIT','SnowIni',0)) + except: + self.SnowStore = readmap(self.inpath + config.get('SNOW_INIT','SnowIni')) + #-initial water stored in snowpack + try: + self.SnowWatStore = float(configget(self.config,'SNOW_INIT','SnowWatStore',0)) + #self.SnowWatStore = config.getfloat('SNOW_INIT','SnowWatStore') + except: + self.SnowWatStore = readmap(self.inpath + config.get('SNOW_INIT','SnowWatStore')) + self.TotalSnowStore = self.SnowStore + self.SnowWatStore + + #-initial glacier properties + if self.GlacFLAG == 1: # try: - # self.RootWater = config.getfloat('SOIL_INIT','RootWater') - # except: - # self.RootWater = readmap(self.inpath + config.get('SOIL_INIT','RootWater')) - # #-initial water content in subsoil - # if not config.get('SOIL_INIT','SubWater'): - # self.SubWater = self.SubField - # else: - # try: - # self.SubWater = config.getfloat('SOIL_INIT','SubWater') - # except: - # self.SubWater = readmap(self.inpath + config.get('SOIL_INIT','SubWater')) - # -initial water storage in rootzone + subsoil - self.SoilWater = self.RootWater + self.SubWater - # -initial capillary rise - self.CapRise = configget(self.config, "SOIL_INIT", "CapRise", 3) - # try: - # self.CapRise = config.getfloat('SOIL_INIT','CapRise') - # except: - # self.CapRise = readmap(self.inpath + config.get('SOIL_INIT','CapRise')) - # -initial drainage from rootzone - self.RootDrain = configget(self.config, "SOIL_INIT", "RootDrain", 3) - # try: - # self.RootDrain = config.getfloat('SOIL_INIT','RootDrain') - # except: - # self.RootDrain = readmap(self.inpath + config.get('SOIL_INIT','RootDrain')) + # self.GlacFrac = config.getfloat('GLACIER_INIT','GlacFrac') + # except: + # self.GlacFrac = readmap(self.inpath + config.get('GLACIER_INIT','GlacFrac')) + self.GlacFrac = readmap(os.path.join(self.Dir,"staticmaps",configget(self.config,'GLACIER_INIT','GlacFrac','glacierfraction.map'))) + print(self.GlacFrac) + #-initial routed total runoff and of individual components + if self.RoutFLAG == 1 or self.LakeFLAG==1 or self.ResFLAG==1: + #-initial routed total runoff + try: + self.QRAold = config.getfloat('ROUT_INIT','QRA_init') + except: + try: + self.QRAold = readmap(self.inpath + config.get('ROUT_INIT','QRA_init')) + except: + self.QRAold = 0 + #-initial routed runoff for the individual components + pars = ['RainRA','SnowRA','GlacRA','BaseRA'] + self.RainRAold = 0 + self.SnowRAold = 0 + self.GlacRAold = 0 + self.BaseRAold = 0 + self.RainRA_FLAG = True + self.SnowRA_FLAG = True + self.GlacRA_FLAG = True + self.BaseRA_FLAG = True + # for i in pars: + # try: + # setattr(self, i + 'old', readmap(self.inpath + config.get('ROUT_INIT', i + '_init'))) + # setattr(self, i + '_FLAG', True) + # except: + # try: + # #setattr(self, i + 'old', config.getfloat('ROUT_INIT', i + '_init')) + # setattr(self, i + '_FLAG', True) + # print RainRA_init + # except: + # setattr(self, i + '_FLAG', False) + + #-initial storage in lakes and reservoirs + if self.LakeFLAG == 1 or self.ResFLAG == 1: + #-Read initial storages from table/reservoir file + if self.LakeFLAG == 1: + LakeStor_Tab = self.inpath + config.get('LAKE', 'LakeStor') + self.StorRES = cover(lookupscalar(LakeStor_Tab, 1, self.LakeID), 0) * 10**6 # convert to m3 + #-Qfrac for lake cells should be zero, else 1 + self.QFRAC = ifthenelse(self.LakeID != 0, scalar(0), 1) + if self.ResFLAG == 1: + ResStor_Tab = self.inpath + config.get('RESERVOIR', 'ResFuncStor') + ResStor = cover(lookupscalar(ResStor_Tab, 2, self.ResID), 0) * 10**6 # convert to m3 + try: + self.StorRES = self.StorRES + ResStor + #-Qfrac for reservoir cells should be zero, else 1 + self.QFRAC = ifthenelse(self.ResID != 0, scalar(0), self.QFRAC) + except: + self.StorRES = ResStor + #-Qfrac for reservoir cells should be zero, else 1 + self.QFRAC = ifthenelse(self.ResID != 0, scalar(0), 1) + + #-initial storage in lakes/reservoirs of individual flow components + pars = ['RainRA','SnowRA','GlacRA','BaseRA'] + for i in pars: + column = pars.index(i) # identify column to be read from lake or reservoir table + try: #-try to sum the storages read from the lake and reservoir tables if both thse modules are used + setattr(self, i + 'stor', (cover(lookupscalar(LakeStor_Tab, column + 2, self.LakeID), 0) + \ + cover(lookupscalar(ResStor_Tab, column + 3, self.ResID), 0)) * 10**6) + if eval('self.' + i + '_FLAG'): + setattr(self, i + '_FLAG', True) + else: + setattr(self, i + '_FLAG', False) + except: + try: #-try to read the storages from the lake table + setattr(self, i + 'stor', cover(lookupscalar(LakeStor_Tab, column + 2, self.LakeID), 0) * 10**6) + if eval('self.' + i + '_FLAG'): + setattr(self, i + '_FLAG', True) + else: + setattr(self, i + '_FLAG', False) + except: #-try to read the storages from the reservoir table + try: + setattr(self, i + 'stor', cover(lookupscalar(ResStor_Tab, column + 3, self.ResID), 0) * 10**6) + if eval('self.' + i + '_FLAG'): + setattr(self, i + '_FLAG', True) + else: + setattr(self, i + '_FLAG', False) + except: + setattr(self, i + '_FLAG', False) + + #-Initial values for reporting and setting of time-series + #-set time-series reporting for mm flux from upstream area for prec and eta + if self.mm_rep_FLAG == 1 and (self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1): + self.PrecSubBasinTSS = TimeoutputTimeseries("PrecSubBasinTSS", self, self.Locations, noHeader=False) + self.ETaSubBasinTSS = TimeoutputTimeseries("ETaSubBasinTSS", self, self.Locations, noHeader=False) + if self.GlacFLAG == 1: + pars = ['wbal','GWL','TotPrec','TotPrecF','TotPrecEF','TotIntF','TotRain','TotRainF','TotETpot','TotETpotF','TotETact','TotETactF','TotSnow','TotSnowF','TotSnowMelt','TotSnowMeltF','TotGlacMelt','TotGlacMeltF','TotRootRF','TotRootDF','TotRootPF',\ + 'TotSubPF','TotCapRF','TotGlacPercF','TotGwRechargeF','TotRainRF','TotBaseRF','TotSnowRF','TotGlacRF','TotRF','RainRAtot','SnowRAtot','GlacRAtot','BaseRAtot','QallRAtot'] + #-set time-series reporting for mm fluxes from upstream area if glacier and routing/reservoir modules are used + if self.mm_rep_FLAG == 1 and (self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1): + self.GMeltSubBasinTSS = TimeoutputTimeseries("GMeltSubBasinTSS", self, self.Locations, noHeader=False) + self.QSNOWSubBasinTSS = TimeoutputTimeseries("QSNOWSubBasinTSS", self, self.Locations, noHeader=False) + self.QRAINSubBasinTSS = TimeoutputTimeseries("QRAINSubBasinTSS", self, self.Locations, noHeader=False) + self.QGLACSubBasinTSS = TimeoutputTimeseries("QGLACSubBasinTSS", self, self.Locations, noHeader=False) + self.QBASFSubBasinTSS = TimeoutputTimeseries("QBASFSubBasinTSS", self, self.Locations, noHeader=False) + self.QTOTSubBasinTSS = TimeoutputTimeseries("QTOTSubBasinTSS", self, self.Locations, noHeader=False) + elif self.SnowFLAG == 1: + if self.GroundFLAG == 1: + pars = ['wbal','GWL','TotPrec','TotPrecF','TotPrecEF','TotIntF','TotRain','TotRainF','TotETpot','TotETpotF','TotETact','TotETactF','TotSnow','TotSnowF','TotSnowMelt','TotSnowMeltF','TotRootRF','TotRootDF','TotRootPF',\ + 'TotSubPF','TotCapRF','TotGwRechargeF','TotRainRF','TotBaseRF','TotSnowRF','TotRF','RainRAtot','SnowRAtot','BaseRAtot','QallRAtot'] + #-set time-series reporting for mm fluxes from upstream area if snow, groundwater and routing/reservoir modules are used + if self.mm_rep_FLAG == 1 and (self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1): + self.QSNOWSubBasinTSS = TimeoutputTimeseries("QSNOWSubBasinTSS", self, self.Locations, noHeader=False) + self.QRAINSubBasinTSS = TimeoutputTimeseries("QRAINSubBasinTSS", self, self.Locations, noHeader=False) + self.QBASFSubBasinTSS = TimeoutputTimeseries("QBASFSubBasinTSS", self, self.Locations, noHeader=False) + self.QTOTSubBasinTSS = TimeoutputTimeseries("QTOTSubBasinTSS", self, self.Locations, noHeader=False) + else: + pars = ['wbal','GWL','TotPrec','TotPrecF','TotPrecEF','TotIntF','TotRain','TotRainF','TotETpot','TotETpotF','TotETact','TotETactF','TotSnow','TotSnowF','TotSnowMelt','TotSnowMeltF','TotRootRF','TotRootDF','TotRootPF',\ + 'TotSubDF','TotCapRF','TotSeepF','TotRainRF','TotSnowRF','TotRF','RainRAtot','SnowRAtot','BaseRAtot','QallRAtot'] + #-set time-series reporting for mm fluxes from upstream area if snow and routing/reservoir modules are used + if self.mm_rep_FLAG == 1 and (self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1): + self.SeepSubBasinTSS = TimeoutputTimeseries("SeepSubBasinTSS", self, self.Locations, noHeader=False) + self.QSNOWSubBasinTSS = TimeoutputTimeseries("QSNOWSubBasinTSS", self, self.Locations, noHeader=False) + self.QRAINSubBasinTSS = TimeoutputTimeseries("QRAINSubBasinTSS", self, self.Locations, noHeader=False) + self.QBASFSubBasinTSS = TimeoutputTimeseries("QBASFSubBasinTSS", self, self.Locations, noHeader=False) + self.QTOTSubBasinTSS = TimeoutputTimeseries("QTOTSubBasinTSS", self, self.Locations, noHeader=False) + else: + if self.GroundFLAG == 1: + pars = ['wbal','GWL','TotPrec','TotPrecF','TotPrecEF','TotIntF','TotRain','TotRainF','TotETpot','TotETpotF','TotETact','TotETactF','TotRootRF','TotRootDF','TotRootPF',\ + 'TotSubPF','TotCapRF','TotGwRechargeF','TotRainRF','TotBaseRF','TotRF','RainRAtot','BaseRAtot','QallRAtot'] + #-set time-series reporting for mm fluxes from upstream area if groundwater and routing/reservoir modules are used + if self.mm_rep_FLAG == 1 and (self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1): + self.QRAINSubBasinTSS = TimeoutputTimeseries("QRAINSubBasinTSS", self, self.Locations, noHeader=False) + self.QBASFSubBasinTSS = TimeoutputTimeseries("QBASFSubBasinTSS", self, self.Locations, noHeader=False) + self.QTOTSubBasinTSS = TimeoutputTimeseries("QTOTSubBasinTSS", self, self.Locations, noHeader=False) + else: + pars = ['wbal','GWL','TotPrec','TotPrecF','TotPrecEF','TotIntF','TotRain','TotRainF','TotETpot','TotETpotF','TotETact','TotETactF','TotRootRF','TotRootDF','TotRootPF',\ + 'TotSubDF','TotCapRF','TotSeepF','TotRainRF','TotRF','RainRAtot','BaseRAtot','QallRAtot'] + #-set time-series reporting for mm fluxes from upstream area if routing/reservoir modules are used + if self.mm_rep_FLAG == 1 and (self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1): + self.SeepSubBasinTSS = TimeoutputTimeseries("SeepSubBasinTSS", self, self.Locations, noHeader=False) + self.QRAINSubBasinTSS = TimeoutputTimeseries("QRAINSubBasinTSS", self, self.Locations, noHeader=False) + self.QBASFSubBasinTSS = TimeoutputTimeseries("QBASFSubBasinTSS", self, self.Locations, noHeader=False) + self.QTOTSubBasinTSS = TimeoutputTimeseries("QTOTSubBasinTSS", self, self.Locations, noHeader=False) + #-remove routing output from reported list of parameters if these modules are not used + if self.RoutFLAG == 0 and self.ResFLAG == 0 and self.LakeFLAG == 0: + rpars = ['RainRAtot','SnowRAtot','GlacRAtot','BaseRAtot','QallRAtot'] + for i in rpars: + try: + j = pars.index(i) + del pars[j] + except: + pass + #-set reporting options and read initial values + for i in pars: + mapoutops = configget(self.config,'REPORTING',i+'_mapoutput',i+'_mapoutput') + #mapoutops = config.get('REPORTING', i+'_mapoutput') + TSoutops = configget(self.config,'REPORTING',i+'_TSoutput',i+'_TSoutput') + #TSoutops = config.get('REPORTING', i+'_TSoutput') + if mapoutops == 'NONE' and TSoutops == 'NONE': + print(i + ' will NOT be reported') + else: + print(i + ' will be reported') + fname = configget(self.config,'REPORTING', i+'_fname', i+'_fname') + #fname = config.get('REPORTING', i+'_fname') + setattr(self, i+'_fname', fname) + # try: + # setattr(self, i, readmap(self.inpath + config.get('INITTOT', i))) + # except: + # try: + # setattr(self, i, config.getfloat('INITTOT', i)) + # except: + # setattr(self, i, 0.) + setattr(self, i, 0.) # use this instead of the commented part above, because it is more logical to always zero as initial condition for reporting + if mapoutops != 'NONE': + mapoutops = mapoutops.split(",") + for j in mapoutops: + if j == 'D': + setattr(self, i+'_Day', eval('self.'+i)) + setattr(self, i+'_Day_map', 1) + elif j == 'M': + setattr(self, i+'_Month', eval('self.'+i)) + setattr(self, i+'_Month_map', 1) + elif j == 'Y': + setattr(self, i+'_Year', eval('self.'+i)) + setattr(self, i+'_Year_map', 1) + else: + setattr(self, i+'_Final', eval('self.'+i)) + setattr(self, i+'_Final_map', 1) + if TSoutops != 'NONE': + TSoutops = TSoutops.split(",") + for j in TSoutops: + if j == 'D': + setattr(self, i+'_Day', eval('self.'+i)) + setattr(self, i+'_DayTS', eval('TimeoutputTimeseries("'+fname+'DTS'+'", self, self.Locations, noHeader=False)')) + elif j == 'M': + setattr(self, i+'_Month', eval('self.'+i)) + setattr(self, i+'_MonthTS', eval('TimeoutputTimeseries("'+fname+'MTS'+'", self, self.Locations, noHeader=False)')) + elif j == 'Y': + setattr(self, i+'_Year', eval('self.'+i)) + setattr(self, i+'_YearTS', eval('TimeoutputTimeseries("'+fname+'YTS'+'", self, self.Locations, noHeader=False)')) + + #-set reporting of water balances for lakes + if self.LakeFLAG == 1 and config.getint('REPORTING', 'Lake_wbal') ==1: + self.LakeInTSS = pcrm.TimeoutputTimeseries("LakeInTSS", self, self.LakeID, noHeader=True) + self.LakeOutTSS = pcrm.TimeoutputTimeseries("LakeOutTSS", self, self.LakeID, noHeader=True) + self.LakeStorTSS = pcrm.TimeoutputTimeseries("LakeStorTSS", self, self.LakeID, noHeader=True) + if self.RainRA_FLAG==1: #-set reporting of water balances for individual components + self.LakeRainInTSS = pcrm.TimeoutputTimeseries("LakeRainInTSS", self, self.LakeID, noHeader=True) + self.LakeRainOutTSS = pcrm.TimeoutputTimeseries("LakeRainOutTSS", self, self.LakeID, noHeader=True) + self.LakeRainStorTSS = pcrm.TimeoutputTimeseries("LakeRainStorTSS", self, self.LakeID, noHeader=True) + if self.SnowRA_FLAG==1: + self.LakeSnowInTSS = pcrm.TimeoutputTimeseries("LakeSnowInTSS", self, self.LakeID, noHeader=True) + self.LakeSnowOutTSS = pcrm.TimeoutputTimeseries("LakeSnowOutTSS", self, self.LakeID, noHeader=True) + self.LakeSnowStorTSS = pcrm.TimeoutputTimeseries("LakeSnowStorTSS", self, self.LakeID, noHeader=True) + if self.GlacRA_FLAG==1: + self.LakeGlacInTSS = pcrm.TimeoutputTimeseries("LakeGlacInTSS", self, self.LakeID, noHeader=True) + self.LakeGlacOutTSS = pcrm.TimeoutputTimeseries("LakeGlacOutTSS", self, self.LakeID, noHeader=True) + self.LakeGlacStorTSS = pcrm.TimeoutputTimeseries("LakeGlacStorTSS", self, self.LakeID, noHeader=True) + if self.BaseRA_FLAG==1: + self.LakeBaseInTSS = pcrm.TimeoutputTimeseries("LakeBaseInTSS", self, self.LakeID, noHeader=True) + self.LakeBaseOutTSS = pcrm.TimeoutputTimeseries("LakeBaseOutTSS", self, self.LakeID, noHeader=True) + self.LakeBaseStorTSS = pcrm.TimeoutputTimeseries("LakeBaseStorTSS", self, self.LakeID, noHeader=True) + #-set reporting of water balances for reservoirs + if self.ResFLAG == 1 and config.getint('REPORTING', 'Res_wbal') == 1: + self.ResInTSS = pcrm.TimeoutputTimeseries("ResInTSS", self, self.ResID, noHeader=True) + self.ResOutTSS = pcrm.TimeoutputTimeseries("ResOutTSS", self, self.ResID, noHeader=True) + self.ResStorTSS = pcrm.TimeoutputTimeseries("ResStorTSS", self, self.ResID, noHeader=True) + if self.RainRA_FLAG==1: #-set reporting of water balances for individual components + self.ResRainInTSS = pcrm.TimeoutputTimeseries("ResRainInTSS", self, self.ResID, noHeader=True) + self.ResRainOutTSS = pcrm.TimeoutputTimeseries("ResRainOutTSS", self, self.ResID, noHeader=True) + self.ResRainStorTSS = pcrm.TimeoutputTimeseries("ResRainStorTSS", self, self.ResID, noHeader=True) + if self.SnowRA_FLAG==1: + self.ResSnowInTSS = pcrm.TimeoutputTimeseries("ResSnowInTSS", self, self.ResID, noHeader=True) + self.ResSnowOutTSS = pcrm.TimeoutputTimeseries("ResSnowOutTSS", self, self.ResID, noHeader=True) + self.ResSnowStorTSS = pcrm.TimeoutputTimeseries("ResSnowStorTSS", self, self.ResID, noHeader=True) + if self.GlacRA_FLAG==1: + self.ResGlacInTSS = pcrm.TimeoutputTimeseries("ResGlacInTSS", self, self.ResID, noHeader=True) + self.ResGlacOutTSS = pcrm.TimeoutputTimeseries("ResGlacOutTSS", self, self.ResID, noHeader=True) + self.ResGlacStorTSS = pcrm.TimeoutputTimeseries("ResGlacStorTSS", self, self.ResID, noHeader=True) + if self.BaseRA_FLAG==1: + self.ResBaseInTSS = pcrm.TimeoutputTimeseries("ResBaseInTSS", self, self.ResID, noHeader=True) + self.ResBaseOutTSS = pcrm.TimeoutputTimeseries("ResBaseOutTSS", self, self.ResID, noHeader=True) + self.ResBaseStorTSS = pcrm.TimeoutputTimeseries("ResBaseStorTSS", self, self.ResID, noHeader=True) + + + + + + + + + # if self.scalarInput: + # self.gaugesMap=self.wf_readmap(os.path.join(self.Dir , wflow_mgauges),0.0,fail=True) #: Map with locations of rainfall/evap/temp gauge(s). Only needed if the input to the model is not in maps + # self.OutputId=self.wf_readmap(os.path.join(self.Dir , wflow_subcatch),0.0,fail=True) # location of subcatchment + + self.ZeroMap=0.0*scalar(defined(self.DEM)) #map with only zero's + + + # For in memory override: + #self.Prec, self.Tair, self.Tmax, self.Tmin = self.ZeroMap + + + # Set static initial values here ######################################### + self.Latitude = ycoordinate(boolean(self.ZeroMap)) + self.Longitude = xcoordinate(boolean(self.ZeroMap)) + + # self.logger.info("Linking parameters to landuse, catchment and soil...") + + # self.Beta = scalar(0.6) # For sheetflow + # #self.M=lookupscalar(self.Dir + "/" + modelEnv['intbl'] + "/M.tbl" ,self.LandUse,subcatch,self.Soil) # Decay parameter in Topog_sbm + # self.N=lookupscalar(self.Dir + "/" + self.intbl + "/N.tbl",self.LandUse,subcatch,self.Soil) # Manning overland flow + # """ *Parameter:* Manning's N for all non-river cells """ + # self.NRiver=lookupscalar(self.Dir + "/" + self.intbl + "/N_River.tbl",self.LandUse,subcatch,self.Soil) # Manning river + # """ Manning's N for all cells that are marked as a river """ + + self.wf_updateparameters() + + + # Multiply parameters with a factor (for calibration etc) -P option in command line + + self.wf_multparameters() - if self.DynVegFLAG == 1: - # -initial canopy storage - self.Scanopy = 0 - # -initial ndvi if first map is not provided - self.ndviOld = scalar((self.NDVImax + self.NDVImin) / 2) - elif self.KcStatFLAG == 0: - # -set initial kc value to one, if kc map is not available for first timestep - self.KcOld = scalar(1) - # -initial groundwater properties - if self.GroundFLAG == 1: - self.GwRecharge = float( - configget(self.config, "GROUNDW_INIT", "GwRecharge", 0) - ) - self.BaseR = float(configget(self.config, "GROUNDW_INIT", "BaseR", 1)) - self.Gw = float(configget(self.config, "GROUNDW_INIT", "Gw", 1)) - self.H_gw = float(configget(self.config, "GROUNDW_INIT", "H_gw", 1)) - # #-initial groundwater recharge - # try: - # self.GwRecharge = config.getfloat('GROUNDW_INIT','GwRecharge') - # except: - # self.GwRecharge = readmap(self.inpath + config.get('GROUNDW_INIT','GwRecharge')) - # #-initial baseflow - # try: - # self.BaseR = config.getfloat('GROUNDW_INIT','BaseR') - # except: - # self.BaseR = readmap(self.inpath + config.get('GROUNDW_INIT','BaseR')) - # #-initial groundwater storage - # try: - # self.Gw = config.getfloat('GROUNDW_INIT','Gw') - # except: - # self.Gw = readmap(self.inpath + config.get('GROUNDW_INIT','Gw')) - # #-initial groundwater level - # try: - # self.H_gw = config.getfloat('GROUNDW_INIT','H_gw') - # except: - # self.H_gw = readmap(self.inpath + config.get('GROUNDW_INIT','H_gw')) - # self.H_gw = max((self.RootDepthFlat + self.SubDepthFlat + self.GwDepth)/1000 - self.H_gw, 0) - # else: - # #-initial drainage from subsoil - # try: - # self.SubDrain = config.getfloat('SOIL_INIT','SubDrain') - # except: - # self.SubDrain = readmap(self.inpath + config.get('SOIL_INIT','SubDrain')) - # #-initial seepage value if seepage map series is used - # if self.SeepStatFLAG == 0: - # self.SeepOld = scalar(0) - # -initial snow properties - if self.SnowFLAG == 1: - try: - # self.SnowStore = config.getfloat('SNOW_INIT','SnowIni') - self.SnowStore = float( - configget(self.config, "SNOW_INIT", "SnowIni", 0) - ) - except: - self.SnowStore = readmap( - self.inpath + config.get("SNOW_INIT", "SnowIni") - ) - # -initial water stored in snowpack - try: - self.SnowWatStore = float( - configget(self.config, "SNOW_INIT", "SnowWatStore", 0) - ) - # self.SnowWatStore = config.getfloat('SNOW_INIT','SnowWatStore') - except: - self.SnowWatStore = readmap( - self.inpath + config.get("SNOW_INIT", "SnowWatStore") - ) - self.TotalSnowStore = self.SnowStore + self.SnowWatStore - # -initial glacier properties - if self.GlacFLAG == 1: - # try: - # self.GlacFrac = config.getfloat('GLACIER_INIT','GlacFrac') - # except: - # self.GlacFrac = readmap(self.inpath + config.get('GLACIER_INIT','GlacFrac')) - self.GlacFrac = readmap( - os.path.join( - self.Dir, - "staticmaps", - configget( - self.config, "GLACIER_INIT", "GlacFrac", "glacierfraction.map" - ), - ) - ) - print self.GlacFrac - # -initial routed total runoff and of individual components - if self.RoutFLAG == 1 or self.LakeFLAG == 1 or self.ResFLAG == 1: - # -initial routed total runoff - try: - self.QRAold = config.getfloat("ROUT_INIT", "QRA_init") - except: - try: - self.QRAold = readmap( - self.inpath + config.get("ROUT_INIT", "QRA_init") - ) - except: - self.QRAold = 0 - # -initial routed runoff for the individual components - pars = ["RainRA", "SnowRA", "GlacRA", "BaseRA"] - self.RainRAold = 0 - self.SnowRAold = 0 - self.GlacRAold = 0 - self.BaseRAold = 0 - self.RainRA_FLAG = True - self.SnowRA_FLAG = True - self.GlacRA_FLAG = True - self.BaseRA_FLAG = True - # for i in pars: - # try: - # setattr(self, i + 'old', readmap(self.inpath + config.get('ROUT_INIT', i + '_init'))) - # setattr(self, i + '_FLAG', True) - # except: - # try: - # #setattr(self, i + 'old', config.getfloat('ROUT_INIT', i + '_init')) - # setattr(self, i + '_FLAG', True) - # print RainRA_init - # except: - # setattr(self, i + '_FLAG', False) - - # -initial storage in lakes and reservoirs - if self.LakeFLAG == 1 or self.ResFLAG == 1: - # -Read initial storages from table/reservoir file - if self.LakeFLAG == 1: - LakeStor_Tab = self.inpath + config.get("LAKE", "LakeStor") - self.StorRES = ( - cover(lookupscalar(LakeStor_Tab, 1, self.LakeID), 0) * 10 ** 6 - ) # convert to m3 - # -Qfrac for lake cells should be zero, else 1 - self.QFRAC = ifthenelse(self.LakeID != 0, scalar(0), 1) - if self.ResFLAG == 1: - ResStor_Tab = self.inpath + config.get("RESERVOIR", "ResFuncStor") - ResStor = ( - cover(lookupscalar(ResStor_Tab, 2, self.ResID), 0) * 10 ** 6 - ) # convert to m3 - try: - self.StorRES = self.StorRES + ResStor - # -Qfrac for reservoir cells should be zero, else 1 - self.QFRAC = ifthenelse(self.ResID != 0, scalar(0), self.QFRAC) - except: - self.StorRES = ResStor - # -Qfrac for reservoir cells should be zero, else 1 - self.QFRAC = ifthenelse(self.ResID != 0, scalar(0), 1) - - # -initial storage in lakes/reservoirs of individual flow components - pars = ["RainRA", "SnowRA", "GlacRA", "BaseRA"] - for i in pars: - column = pars.index( - i - ) # identify column to be read from lake or reservoir table - try: # -try to sum the storages read from the lake and reservoir tables if both thse modules are used - setattr( - self, - i + "stor", - ( - cover( - lookupscalar(LakeStor_Tab, column + 2, self.LakeID), 0 - ) - + cover( - lookupscalar(ResStor_Tab, column + 3, self.ResID), 0 - ) - ) - * 10 ** 6, - ) - if eval("self." + i + "_FLAG"): - setattr(self, i + "_FLAG", True) - else: - setattr(self, i + "_FLAG", False) - except: - try: # -try to read the storages from the lake table - setattr( - self, - i + "stor", - cover( - lookupscalar(LakeStor_Tab, column + 2, self.LakeID), 0 - ) - * 10 ** 6, - ) - if eval("self." + i + "_FLAG"): - setattr(self, i + "_FLAG", True) - else: - setattr(self, i + "_FLAG", False) - except: # -try to read the storages from the reservoir table - try: - setattr( - self, - i + "stor", - cover( - lookupscalar(ResStor_Tab, column + 3, self.ResID), 0 - ) - * 10 ** 6, - ) - if eval("self." + i + "_FLAG"): - setattr(self, i + "_FLAG", True) - else: - setattr(self, i + "_FLAG", False) - except: - setattr(self, i + "_FLAG", False) - - # -Initial values for reporting and setting of time-series - # -set time-series reporting for mm flux from upstream area for prec and eta - if self.mm_rep_FLAG == 1 and ( - self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1 - ): - self.PrecSubBasinTSS = TimeoutputTimeseries( - "PrecSubBasinTSS", self, self.Locations, noHeader=False - ) - self.ETaSubBasinTSS = TimeoutputTimeseries( - "ETaSubBasinTSS", self, self.Locations, noHeader=False - ) - if self.GlacFLAG == 1: - pars = [ - "wbal", - "GWL", - "TotPrec", - "TotPrecF", - "TotPrecEF", - "TotIntF", - "TotRain", - "TotRainF", - "TotETpot", - "TotETpotF", - "TotETact", - "TotETactF", - "TotSnow", - "TotSnowF", - "TotSnowMelt", - "TotSnowMeltF", - "TotGlacMelt", - "TotGlacMeltF", - "TotRootRF", - "TotRootDF", - "TotRootPF", - "TotSubPF", - "TotCapRF", - "TotGlacPercF", - "TotGwRechargeF", - "TotRainRF", - "TotBaseRF", - "TotSnowRF", - "TotGlacRF", - "TotRF", - "RainRAtot", - "SnowRAtot", - "GlacRAtot", - "BaseRAtot", - "QallRAtot", - ] - # -set time-series reporting for mm fluxes from upstream area if glacier and routing/reservoir modules are used - if self.mm_rep_FLAG == 1 and ( - self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1 - ): - self.GMeltSubBasinTSS = TimeoutputTimeseries( - "GMeltSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QSNOWSubBasinTSS = TimeoutputTimeseries( - "QSNOWSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QRAINSubBasinTSS = TimeoutputTimeseries( - "QRAINSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QGLACSubBasinTSS = TimeoutputTimeseries( - "QGLACSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QBASFSubBasinTSS = TimeoutputTimeseries( - "QBASFSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QTOTSubBasinTSS = TimeoutputTimeseries( - "QTOTSubBasinTSS", self, self.Locations, noHeader=False - ) - elif self.SnowFLAG == 1: - if self.GroundFLAG == 1: - pars = [ - "wbal", - "GWL", - "TotPrec", - "TotPrecF", - "TotPrecEF", - "TotIntF", - "TotRain", - "TotRainF", - "TotETpot", - "TotETpotF", - "TotETact", - "TotETactF", - "TotSnow", - "TotSnowF", - "TotSnowMelt", - "TotSnowMeltF", - "TotRootRF", - "TotRootDF", - "TotRootPF", - "TotSubPF", - "TotCapRF", - "TotGwRechargeF", - "TotRainRF", - "TotBaseRF", - "TotSnowRF", - "TotRF", - "RainRAtot", - "SnowRAtot", - "BaseRAtot", - "QallRAtot", - ] - # -set time-series reporting for mm fluxes from upstream area if snow, groundwater and routing/reservoir modules are used - if self.mm_rep_FLAG == 1 and ( - self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1 - ): - self.QSNOWSubBasinTSS = TimeoutputTimeseries( - "QSNOWSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QRAINSubBasinTSS = TimeoutputTimeseries( - "QRAINSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QBASFSubBasinTSS = TimeoutputTimeseries( - "QBASFSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QTOTSubBasinTSS = TimeoutputTimeseries( - "QTOTSubBasinTSS", self, self.Locations, noHeader=False - ) - else: - pars = [ - "wbal", - "GWL", - "TotPrec", - "TotPrecF", - "TotPrecEF", - "TotIntF", - "TotRain", - "TotRainF", - "TotETpot", - "TotETpotF", - "TotETact", - "TotETactF", - "TotSnow", - "TotSnowF", - "TotSnowMelt", - "TotSnowMeltF", - "TotRootRF", - "TotRootDF", - "TotRootPF", - "TotSubDF", - "TotCapRF", - "TotSeepF", - "TotRainRF", - "TotSnowRF", - "TotRF", - "RainRAtot", - "SnowRAtot", - "BaseRAtot", - "QallRAtot", - ] - # -set time-series reporting for mm fluxes from upstream area if snow and routing/reservoir modules are used - if self.mm_rep_FLAG == 1 and ( - self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1 - ): - self.SeepSubBasinTSS = TimeoutputTimeseries( - "SeepSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QSNOWSubBasinTSS = TimeoutputTimeseries( - "QSNOWSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QRAINSubBasinTSS = TimeoutputTimeseries( - "QRAINSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QBASFSubBasinTSS = TimeoutputTimeseries( - "QBASFSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QTOTSubBasinTSS = TimeoutputTimeseries( - "QTOTSubBasinTSS", self, self.Locations, noHeader=False - ) - else: - if self.GroundFLAG == 1: - pars = [ - "wbal", - "GWL", - "TotPrec", - "TotPrecF", - "TotPrecEF", - "TotIntF", - "TotRain", - "TotRainF", - "TotETpot", - "TotETpotF", - "TotETact", - "TotETactF", - "TotRootRF", - "TotRootDF", - "TotRootPF", - "TotSubPF", - "TotCapRF", - "TotGwRechargeF", - "TotRainRF", - "TotBaseRF", - "TotRF", - "RainRAtot", - "BaseRAtot", - "QallRAtot", - ] - # -set time-series reporting for mm fluxes from upstream area if groundwater and routing/reservoir modules are used - if self.mm_rep_FLAG == 1 and ( - self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1 - ): - self.QRAINSubBasinTSS = TimeoutputTimeseries( - "QRAINSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QBASFSubBasinTSS = TimeoutputTimeseries( - "QBASFSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QTOTSubBasinTSS = TimeoutputTimeseries( - "QTOTSubBasinTSS", self, self.Locations, noHeader=False - ) - else: - pars = [ - "wbal", - "GWL", - "TotPrec", - "TotPrecF", - "TotPrecEF", - "TotIntF", - "TotRain", - "TotRainF", - "TotETpot", - "TotETpotF", - "TotETact", - "TotETactF", - "TotRootRF", - "TotRootDF", - "TotRootPF", - "TotSubDF", - "TotCapRF", - "TotSeepF", - "TotRainRF", - "TotRF", - "RainRAtot", - "BaseRAtot", - "QallRAtot", - ] - # -set time-series reporting for mm fluxes from upstream area if routing/reservoir modules are used - if self.mm_rep_FLAG == 1 and ( - self.RoutFLAG == 1 or self.ResFLAG == 1 or self.LakeFLAG == 1 - ): - self.SeepSubBasinTSS = TimeoutputTimeseries( - "SeepSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QRAINSubBasinTSS = TimeoutputTimeseries( - "QRAINSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QBASFSubBasinTSS = TimeoutputTimeseries( - "QBASFSubBasinTSS", self, self.Locations, noHeader=False - ) - self.QTOTSubBasinTSS = TimeoutputTimeseries( - "QTOTSubBasinTSS", self, self.Locations, noHeader=False - ) - # -remove routing output from reported list of parameters if these modules are not used - if self.RoutFLAG == 0 and self.ResFLAG == 0 and self.LakeFLAG == 0: - rpars = ["RainRAtot", "SnowRAtot", "GlacRAtot", "BaseRAtot", "QallRAtot"] - for i in rpars: - try: - j = pars.index(i) - del pars[j] - except: - pass - # -set reporting options and read initial values - for i in pars: - mapoutops = configget( - self.config, "REPORTING", i + "_mapoutput", i + "_mapoutput" - ) - # mapoutops = config.get('REPORTING', i+'_mapoutput') - TSoutops = configget( - self.config, "REPORTING", i + "_TSoutput", i + "_TSoutput" - ) - # TSoutops = config.get('REPORTING', i+'_TSoutput') - if mapoutops == "NONE" and TSoutops == "NONE": - print i + " will NOT be reported" - else: - print i + " will be reported" - fname = configget(self.config, "REPORTING", i + "_fname", i + "_fname") - # fname = config.get('REPORTING', i+'_fname') - setattr(self, i + "_fname", fname) - # try: - # setattr(self, i, readmap(self.inpath + config.get('INITTOT', i))) - # except: - # try: - # setattr(self, i, config.getfloat('INITTOT', i)) - # except: - # setattr(self, i, 0.) - setattr( - self, i, 0. - ) # use this instead of the commented part above, because it is more logical to always zero as initial condition for reporting - if mapoutops != "NONE": - mapoutops = mapoutops.split(",") - for j in mapoutops: - if j == "D": - setattr(self, i + "_Day", eval("self." + i)) - setattr(self, i + "_Day_map", 1) - elif j == "M": - setattr(self, i + "_Month", eval("self." + i)) - setattr(self, i + "_Month_map", 1) - elif j == "Y": - setattr(self, i + "_Year", eval("self." + i)) - setattr(self, i + "_Year_map", 1) - else: - setattr(self, i + "_Final", eval("self." + i)) - setattr(self, i + "_Final_map", 1) - if TSoutops != "NONE": - TSoutops = TSoutops.split(",") - for j in TSoutops: - if j == "D": - setattr(self, i + "_Day", eval("self." + i)) - setattr( - self, - i + "_DayTS", - eval( - 'TimeoutputTimeseries("' - + fname - + "DTS" - + '", self, self.Locations, noHeader=False)' - ), - ) - elif j == "M": - setattr(self, i + "_Month", eval("self." + i)) - setattr( - self, - i + "_MonthTS", - eval( - 'TimeoutputTimeseries("' - + fname - + "MTS" - + '", self, self.Locations, noHeader=False)' - ), - ) - elif j == "Y": - setattr(self, i + "_Year", eval("self." + i)) - setattr( - self, - i + "_YearTS", - eval( - 'TimeoutputTimeseries("' - + fname - + "YTS" - + '", self, self.Locations, noHeader=False)' - ), - ) - - # -set reporting of water balances for lakes - if self.LakeFLAG == 1 and config.getint("REPORTING", "Lake_wbal") == 1: - self.LakeInTSS = pcrm.TimeoutputTimeseries( - "LakeInTSS", self, self.LakeID, noHeader=True - ) - self.LakeOutTSS = pcrm.TimeoutputTimeseries( - "LakeOutTSS", self, self.LakeID, noHeader=True - ) - self.LakeStorTSS = pcrm.TimeoutputTimeseries( - "LakeStorTSS", self, self.LakeID, noHeader=True - ) - if ( - self.RainRA_FLAG == 1 - ): # -set reporting of water balances for individual components - self.LakeRainInTSS = pcrm.TimeoutputTimeseries( - "LakeRainInTSS", self, self.LakeID, noHeader=True - ) - self.LakeRainOutTSS = pcrm.TimeoutputTimeseries( - "LakeRainOutTSS", self, self.LakeID, noHeader=True - ) - self.LakeRainStorTSS = pcrm.TimeoutputTimeseries( - "LakeRainStorTSS", self, self.LakeID, noHeader=True - ) - if self.SnowRA_FLAG == 1: - self.LakeSnowInTSS = pcrm.TimeoutputTimeseries( - "LakeSnowInTSS", self, self.LakeID, noHeader=True - ) - self.LakeSnowOutTSS = pcrm.TimeoutputTimeseries( - "LakeSnowOutTSS", self, self.LakeID, noHeader=True - ) - self.LakeSnowStorTSS = pcrm.TimeoutputTimeseries( - "LakeSnowStorTSS", self, self.LakeID, noHeader=True - ) - if self.GlacRA_FLAG == 1: - self.LakeGlacInTSS = pcrm.TimeoutputTimeseries( - "LakeGlacInTSS", self, self.LakeID, noHeader=True - ) - self.LakeGlacOutTSS = pcrm.TimeoutputTimeseries( - "LakeGlacOutTSS", self, self.LakeID, noHeader=True - ) - self.LakeGlacStorTSS = pcrm.TimeoutputTimeseries( - "LakeGlacStorTSS", self, self.LakeID, noHeader=True - ) - if self.BaseRA_FLAG == 1: - self.LakeBaseInTSS = pcrm.TimeoutputTimeseries( - "LakeBaseInTSS", self, self.LakeID, noHeader=True - ) - self.LakeBaseOutTSS = pcrm.TimeoutputTimeseries( - "LakeBaseOutTSS", self, self.LakeID, noHeader=True - ) - self.LakeBaseStorTSS = pcrm.TimeoutputTimeseries( - "LakeBaseStorTSS", self, self.LakeID, noHeader=True - ) - # -set reporting of water balances for reservoirs - if self.ResFLAG == 1 and config.getint("REPORTING", "Res_wbal") == 1: - self.ResInTSS = pcrm.TimeoutputTimeseries( - "ResInTSS", self, self.ResID, noHeader=True - ) - self.ResOutTSS = pcrm.TimeoutputTimeseries( - "ResOutTSS", self, self.ResID, noHeader=True - ) - self.ResStorTSS = pcrm.TimeoutputTimeseries( - "ResStorTSS", self, self.ResID, noHeader=True - ) - if ( - self.RainRA_FLAG == 1 - ): # -set reporting of water balances for individual components - self.ResRainInTSS = pcrm.TimeoutputTimeseries( - "ResRainInTSS", self, self.ResID, noHeader=True - ) - self.ResRainOutTSS = pcrm.TimeoutputTimeseries( - "ResRainOutTSS", self, self.ResID, noHeader=True - ) - self.ResRainStorTSS = pcrm.TimeoutputTimeseries( - "ResRainStorTSS", self, self.ResID, noHeader=True - ) - if self.SnowRA_FLAG == 1: - self.ResSnowInTSS = pcrm.TimeoutputTimeseries( - "ResSnowInTSS", self, self.ResID, noHeader=True - ) - self.ResSnowOutTSS = pcrm.TimeoutputTimeseries( - "ResSnowOutTSS", self, self.ResID, noHeader=True - ) - self.ResSnowStorTSS = pcrm.TimeoutputTimeseries( - "ResSnowStorTSS", self, self.ResID, noHeader=True - ) - if self.GlacRA_FLAG == 1: - self.ResGlacInTSS = pcrm.TimeoutputTimeseries( - "ResGlacInTSS", self, self.ResID, noHeader=True - ) - self.ResGlacOutTSS = pcrm.TimeoutputTimeseries( - "ResGlacOutTSS", self, self.ResID, noHeader=True - ) - self.ResGlacStorTSS = pcrm.TimeoutputTimeseries( - "ResGlacStorTSS", self, self.ResID, noHeader=True - ) - if self.BaseRA_FLAG == 1: - self.ResBaseInTSS = pcrm.TimeoutputTimeseries( - "ResBaseInTSS", self, self.ResID, noHeader=True - ) - self.ResBaseOutTSS = pcrm.TimeoutputTimeseries( - "ResBaseOutTSS", self, self.ResID, noHeader=True - ) - self.ResBaseStorTSS = pcrm.TimeoutputTimeseries( - "ResBaseStorTSS", self, self.ResID, noHeader=True - ) - - # if self.scalarInput: - # self.gaugesMap=self.wf_readmap(os.path.join(self.Dir , wflow_mgauges),0.0,fail=True) #: Map with locations of rainfall/evap/temp gauge(s). Only needed if the input to the model is not in maps - # self.OutputId=self.wf_readmap(os.path.join(self.Dir , wflow_subcatch),0.0,fail=True) # location of subcatchment - - self.ZeroMap = 0.0 * scalar(defined(self.DEM)) # map with only zero's - - # For in memory override: - # self.Prec, self.Tair, self.Tmax, self.Tmin = self.ZeroMap - - # Set static initial values here ######################################### - self.Latitude = ycoordinate(boolean(self.ZeroMap)) - self.Longitude = xcoordinate(boolean(self.ZeroMap)) - - # self.logger.info("Linking parameters to landuse, catchment and soil...") - - # self.Beta = scalar(0.6) # For sheetflow - # #self.M=lookupscalar(self.Dir + "/" + modelEnv['intbl'] + "/M.tbl" ,self.LandUse,subcatch,self.Soil) # Decay parameter in Topog_sbm - # self.N=lookupscalar(self.Dir + "/" + self.intbl + "/N.tbl",self.LandUse,subcatch,self.Soil) # Manning overland flow - # """ *Parameter:* Manning's N for all non-river cells """ - # self.NRiver=lookupscalar(self.Dir + "/" + self.intbl + "/N_River.tbl",self.LandUse,subcatch,self.Soil) # Manning river - # """ Manning's N for all cells that are marked as a river """ - - self.wf_updateparameters() - - # Multiply parameters with a factor (for calibration etc) -P option in command line - - self.wf_multparameters() - - def default_summarymaps(self): ##-maybe not needed. check later - """ + def default_summarymaps(self): ##-maybe not needed. check later + """ Returns a list of default summary-maps at the end of a run. This is model specific. You can also add them to the [summary]section of the ini file but stuff you think is crucial to the model should be listed here @@ -2258,48 +1755,40 @@ ## Main model starts here ######################################################################## try: - opts, args = getopt.getopt(argv, "c:QXS:F:hC:Ii:T:R:u:s:P:p:Xx:U:fl:L:") - except getopt.error, msg: + opts, args = getopt.getopt(argv, 'c:QXS:F:hC:Ii:T:R:u:s:P:p:Xx:U:fl:L:') + except getopt.error as msg: pcrut.usage(msg) for o, a in opts: if o == "-F": runinfoFile = a fewsrun = True - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-L": - LogFileName = a - if o == "-l": - exec "loglevel = logging." + a - if o == "-c": - configfile = a - if o == "-s": - timestepsecs = int(a) - if o == "-h": - usage() - if o == "-f": - NoOverWrite = 0 + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-L': LogFileName = a + if o == '-l': exec("loglevel = logging." + a) + if o == '-c': configfile = a + if o == '-s': timestepsecs = int(a) + if o == '-h': usage() + if o == '-f': NoOverWrite = 0 + + if fewsrun: ts = getTimeStepsfromRuninfo(runinfoFile, timestepsecs) starttime = getStartTimefromRuninfo(runinfoFile) if ts: _lastTimeStep = ts # * 86400/timestepsecs _firstTimeStep = 1 else: - print "Failed to get timesteps from runinfo file: " + runinfoFile + print("Failed to get timesteps from runinfo file: " + runinfoFile) sys.exit(2) else: - starttime = dt.datetime(1990, 01, 01) + starttime = dt.datetime(1990,0o1,0o1) if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) +") is smaller than the last timestep (" + str(_lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) @@ -2314,39 +1803,27 @@ ) for o, a in opts: - if o == "-P": - left = a.split("=")[0] - right = a.split("=")[1] - configset( - myModel.config, "variable_change_once", left, right, overwrite=True - ) - if o == "-p": - left = a.split("=")[0] - right = a.split("=")[1] - configset( - myModel.config, "variable_change_timestep", left, right, overwrite=True - ) - if o == "-X": - configset(myModel.config, "model", "OverWriteInit", "1", overwrite=True) - if o == "-I": - configset(myModel.config, "model", "reinit", "1", overwrite=True) - if o == "-i": - configset(myModel.config, "model", "intbl", a, overwrite=True) - if o == "-s": - configset(myModel.config, "model", "timestepsecs", a, overwrite=True) - if o == "-x": - configset(myModel.config, "model", "sCatch", a, overwrite=True) - if o == "-c": - configset(myModel.config, "model", "configfile", a, overwrite=True) - if o == "-M": - configset(myModel.config, "model", "MassWasting", "0", overwrite=True) - if o == "-Q": - configset(myModel.config, "model", "ExternalQbase", "1", overwrite=True) - if o == "-U": - configset(myModel.config, "model", "updateFile", a, overwrite=True) - configset(myModel.config, "model", "updating", "1", overwrite=True) - if o == "-u": - exec "zz =" + a + if o == '-P': + left = a.split('=')[0] + right = a.split('=')[1] + configset(myModel.config,'variable_change_once',left,right,overwrite=True) + if o == '-p': + left = a.split('=')[0] + right = a.split('=')[1] + configset(myModel.config,'variable_change_timestep',left,right,overwrite=True) + if o == '-X': configset(myModel.config,'model','OverWriteInit','1',overwrite=True) + if o == '-I': configset(myModel.config,'model','reinit','1',overwrite=True) + if o == '-i': configset(myModel.config,'model','intbl',a,overwrite=True) + if o == '-s': configset(myModel.config,'model','timestepsecs',a,overwrite=True) + if o == '-x': configset(myModel.config,'model','sCatch',a,overwrite=True) + if o == '-c': configset(myModel.config,'model','configfile', a,overwrite=True) + if o == '-M': configset(myModel.config,'model','MassWasting',"0",overwrite=True) + if o == '-Q': configset(myModel.config,'model','ExternalQbase','1',overwrite=True) + if o == '-U': + configset(myModel.config,'model','updateFile',a,overwrite=True) + configset(myModel.config,'model','updating',"1",overwrite=True) + if o == '-u': + exec("zz =" + a) updateCols = zz if o == "-T": configset(myModel.config, "run", "endtime", a, overwrite=True) Index: wflow-py/wflow/wflow_topoflex.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_topoflex.py (.../wflow_topoflex.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_topoflex.py (.../wflow_topoflex.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -48,9 +48,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -1604,43 +1603,33 @@ return try: - opts, args = getopt.getopt( - argv, "C:S:T:Ic:s:R:fl:L:P:p:i:" - ) # 'XF:L:hC:Ii:v:S:T:WR:u:s:EP:p:Xx:U:fOc:l:') - except getopt.error, msg: + opts, args = getopt.getopt(argv, 'C:S:T:Ic:s:R:fl:L:P:p:i:') #'XF:L:hC:Ii:v:S:T:WR:u:s:EP:p:Xx:U:fOc:l:') + except getopt.error as msg: pcrut.usage(msg) - print opts - for o, a in opts: - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-c": - configfile = a - print configfile - if o == "-s": - timestepsecs = int(a) - if o == "-T": - _lastTimeStep = int(a) - if o == "-S": - _firstTimeStep = int(a) - if o == "-f": - NoOverWrite = 0 - if o == "-L": - LogFileName = a - if o == "-l": - exec "loglevel = logging." + a - if len(argv) <= 1: + print(opts) + for o, a in opts: + if o == '-C': + caseName = a + if o == '-R': runId = a + if o == '-c': + configfile = a + print(configfile) + if o == '-s': timestepsecs = int(a) + if o == '-T': _lastTimeStep = int(a) + if o == '-S': _firstTimeStep = int(a) + if o == '-f': NoOverWrite = 0 + if o == '-L': LogFileName = a + if o == '-l': exec("loglevel = logging." + a) + + if (len(argv) <= 1): usage() - starttime = dt.datetime(1990, 01, 01) - + starttime = dt.datetime(1990,0o1,0o1) + if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) +") is smaller than the last timestep (" + str(_lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) @@ -1689,7 +1678,7 @@ configset(myModel.config, "model", "updating", "1", overwrite=True) if o == "-u": zz = [] - exec "zz =" + a + exec("zz =" + a) updateCols = zz if o == "-E": configset(myModel.config, "model", "reInfilt", "1", overwrite=True) Index: wflow-py/wflow/wflow_upscale.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_upscale.py (.../wflow_upscale.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_upscale.py (.../wflow_upscale.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -55,9 +55,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -81,7 +80,7 @@ # failed raise Exception("Command %s failed" % pollCmd) else: - print "Command %s completed successfully" % pollCmd + print("Command %s completed successfully" % pollCmd) return newProcs processes = [] @@ -100,14 +99,14 @@ while len(processes) > 0: time.sleep(0.5) processes = removeFinishedProcesses(processes) - print "All processes in que (" + str(len(commands)) + ") completed." + print("All processes in que (" + str(len(commands)) + ") completed.") def main(): try: - opts, args = getopt.getopt(sys.argv[1:], "fhC:N:Ir:M:") - except getopt.error, msg: + opts, args = getopt.getopt(sys.argv[1:], 'fhC:N:Ir:M:') + except getopt.error as msg: usage(msg) factor = 1 @@ -137,7 +136,7 @@ dirs = ["/intbl/", "/inmaps/", "/staticmaps/", "/intss/", "/instate/", "/outstate/"] ext_to_copy = ["*.tss", "*.tbl", "*.col", "*.xml"] if os.path.isdir(caseNameNew) and not force: - print "Refusing to write into an existing directory:" + caseNameNew + print("Refusing to write into an existing directory:" + caseNameNew) sys.exit() if not os.path.isdir(caseNameNew): @@ -179,8 +178,8 @@ allcmd.append(mstr) # os.system(mstr) else: - print "skipping " + mfile.replace(caseName, caseNameNew) - runCommands(allcmd, maxcpu) + print("skipping " + mfile.replace(caseName,caseNameNew)) + runCommands(allcmd,maxcpu) for ext in ext_to_copy: for mfile in glob.glob(caseName + ddir + ext): @@ -189,18 +188,16 @@ # Because the ldd cannot be resampled this way we have to recreate # in including the subcatchments that are derived from it - print "recreating static maps ..." + print("recreating static maps ...") # Create new ldd using old river network dem = readmap(caseNameNew + "/staticmaps/wflow_dem.map") # orig low res river riverburn = readmap(caseNameNew + "/staticmaps/wflow_river.map") # save it - report(riverburn, caseNameNew + "/staticmaps/wflow_riverburnin.map") - demburn = cover(ifthen(boolean(riverburn), dem - 600), dem) - print "Creating ldd..." - ldd = lddcreate_save( - caseNameNew + "/staticmaps/wflow_ldd.map", demburn, True, 10.0E35 - ) + report(riverburn,caseNameNew + "/staticmaps/wflow_riverburnin.map") + demburn = cover(ifthen(boolean(riverburn), dem - 600) ,dem) + print("Creating ldd...") + ldd = lddcreate_save(caseNameNew + "/staticmaps/wflow_ldd.map",demburn, True, 10.0E35) ## Find catchment (overall) outlet = find_outlet(ldd) sub = subcatch(ldd, outlet) Index: wflow-py/wflow/wflow_w3ra.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_w3ra.py (.../wflow_w3ra.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_w3ra.py (.../wflow_w3ra.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -51,9 +51,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -424,18 +423,19 @@ setup needed. """ - self.logger.info("Reading initial conditions...") - #: It is advised to use the wf_resume() function - #: here which pick up the variable save by a call to wf_suspend() - try: - self.wf_resume(self.Dir + "/instate/") - except: - self.logger.warn("Cannot load initial states, setting to default") - for s in self.stateVariables(): - exec "self." + s + " = cover(1.0)" + self.logger.info("Reading initial conditions...") + #: It is advised to use the wf_resume() function + #: here which pick up the variable save by a call to wf_suspend() + try: + self.wf_resume(self.Dir + "/instate/") + except: + self.logger.warn("Cannot load initial states, setting to default") + for s in self.stateVariables(): + exec("self." + s + " = cover(1.0)") - def default_summarymaps(self): - """ + + def default_summarymaps(self): + """ *Optional* Return a default list of variables to report as summary maps in the outsum dir. """ @@ -1025,12 +1025,12 @@ # if (len(opts) <=1): # usage() - starttime = dt.datetime(1990, 01, 01) + starttime = dt.datetime(1990,0o1,0o1) + if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) + ") is smaller than the last timestep (" + str( + _lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) Index: wflow-py/wflow/wflow_w3ra_new.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_w3ra_new.py (.../wflow_w3ra_new.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_w3ra_new.py (.../wflow_w3ra_new.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -47,9 +47,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -426,18 +425,19 @@ setup needed. """ - self.logger.info("Reading initial conditions...") - #: It is advised to use the wf_resume() function - #: here which pick up the variable save by a call to wf_suspend() - try: - self.wf_resume(self.Dir + "/instate/") - except: - self.logger.warn("Cannot load initial states, setting to default") - for s in self.stateVariables(): - exec "self." + s + " = cover(1.0)" + self.logger.info("Reading initial conditions...") + #: It is advised to use the wf_resume() function + #: here which pick up the variable save by a call to wf_suspend() + try: + self.wf_resume(self.Dir + "/instate/") + except: + self.logger.warn("Cannot load initial states, setting to default") + for s in self.stateVariables(): + exec("self." + s + " = cover(1.0)") - def default_summarymaps(self): - """ + + def default_summarymaps(self): + """ *Optional* Return a default list of variables to report as summary maps in the outsum dir. """ @@ -1025,12 +1025,12 @@ if len(opts) <= 1: usage() - starttime = dt.datetime(1990, 01, 01) + starttime = dt.datetime(1990,0o1,0o1) + if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) + ") is smaller than the last timestep (" + str( + _lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) Index: wflow-py/wflow/wflow_wave.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflow_wave.py (.../wflow_wave.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflow_wave.py (.../wflow_wave.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -112,9 +112,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: - print msg - print __doc__ + for msg in args: print(msg) + print(__doc__) sys.exit(0) @@ -570,31 +569,22 @@ opts, args = getopt.getopt(argv, "C:S:T:c:s:R:fIs:hl:") for o, a in opts: - if o == "-C": - caseName = a - if o == "-R": - runId = a - if o == "-c": - configfile = a - if o == "-s": - timestepsecs = int(a) - if o == "-T": - _lastTimeStep = int(a) - if o == "-S": - _firstTimeStep = int(a) - if o == "-l": - exec "loglevel = logging." + a - if o == "-h": + if o == '-C': caseName = a + if o == '-R': runId = a + if o == '-c': configfile = a + if o == '-s': timestepsecs = int(a) + if o == '-T': _lastTimeStep=int(a) + if o == '-S': _firstTimeStep=int(a) + if o == '-l': exec("loglevel = logging." + a) + if o == '-h': usage() return if len(opts) <= 1: usage() if _lastTimeStep < _firstTimeStep: - print "The starttimestep (" + str( - _firstTimeStep - ) + ") is smaller than the last timestep (" + str(_lastTimeStep) + ")" + print("The starttimestep (" + str(_firstTimeStep) +") is smaller than the last timestep (" + str(_lastTimeStep) + ")") usage() myModel = WflowModel(wflow_cloneMap, caseName, runId, configfile) Index: wflow-py/wflow/wflowtools_lib.py =================================================================== diff -u -r12ea40dc08628f654753679e0972e87b7bb12f7a -r4143969ebd6b276284ea6e4198ee693bd6ab506a --- wflow-py/wflow/wflowtools_lib.py (.../wflowtools_lib.py) (revision 12ea40dc08628f654753679e0972e87b7bb12f7a) +++ wflow-py/wflow/wflowtools_lib.py (.../wflowtools_lib.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) @@ -9,7 +9,7 @@ import copy import sys from subprocess import call -import ConfigParser +import configparser import logging import logging.handlers @@ -48,7 +48,7 @@ logger.debug("File logging to " + logfilename) return logger, ch except IOError: - print "ERROR: Failed to initialize logger with logfile: " + logfilename + print("ERROR: Failed to initialize logger with logfile: " + logfilename) sys.exit(1) @@ -67,13 +67,13 @@ def OpenConf(fn): - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.optionxform = str if os.path.exists(fn): config.read(fn) else: - print "Cannot open config file: " + fn + print("Cannot open config file: " + fn) sys.exit(1) return config @@ -192,7 +192,7 @@ for shape in shapelist: if os.path.exists(shape): Driver.DeleteDataSource(shape) - print "shapefile deleted: " + shape + print("shapefile deleted: " + shape) def MergeShapes(shapesin, Layer): @@ -221,7 +221,7 @@ mapFormat.Register() ds = gdal.Open(fileName) if ds is None: - print "Could not open " + fileName + ". Something went wrong!! Shutting down" + print('Could not open ' + fileName + '. Something went wrong!! Shutting down') sys.exit(1) # Retrieve geoTransform info geotrans = ds.GetGeoTransform() @@ -378,7 +378,7 @@ EndCoord.append([geometry.GetX(points - 1), geometry.GetY(points - 1)]) EndCoord_np = np.array(EndCoord) reaches = copy.deepcopy(i) + 1 - ReachIDs = range(reaches) + ReachIDs = list(range(reaches)) ReachOrders = np.array([None] * len(ReachIDs)) order = 1 @@ -426,7 +426,7 @@ order += 1 if None in list(ReachOrders): - print "Conversion of river to orders failed. Try to use a smaller tollerance" + print("Conversion of river to orders failed. Try to use a smaller tollerance") # sys.exit(1) LYR.ResetReading() @@ -484,14 +484,9 @@ ) for i in range(MAX + 1): if i > 0: - print i - REV_MAP = pcr.cover( - pcr.ifthen( - pcr.ordinal(MAP) == pcr.ordinal(i), - pcr.ordinal(pcr.scalar(MAX + 1) - pcr.scalar(i)), - ), - REV_MAP, - ) + print(i) + REV_MAP = pcr.cover(pcr.ifthen(pcr.ordinal(MAP) == pcr.ordinal( + i), pcr.ordinal(pcr.scalar(MAX + 1) - pcr.scalar(i))), REV_MAP) REV_MAP = pcr.cover(REV_MAP, pcr.ordinal(MAP)) return REV_MAP @@ -505,7 +500,7 @@ def Tiff2Point(TIFF): DS = gdal.Open(TIFF, GA_ReadOnly) if DS is None: - print "Could not open " + fn + print('Could not open ' + fn) sys.exit(1) cols = DS.RasterXSize @@ -564,7 +559,7 @@ def GridDef(TIFF, XML): DS = gdal.Open(TIFF, GA_ReadOnly) if DS is None: - print "Could not open " + fn + print('Could not open ' + fn) sys.exit(1) cols = DS.RasterXSize @@ -612,7 +607,7 @@ xi, yi = np.meshgrid(x, y) # mesh of surrounding pixels - xi_window, yi_window = np.meshgrid(range(-1, 2), range(-1, 2)) + xi_window, yi_window = np.meshgrid(list(range(-1, 2)), list(range(-1, 2))) # mesh of ldd grid values ldd_values = np.array([[7, 8, 9], [4, 5, 6], [1, 2, 3]]) [iiy, iix] = np.where(riversid > 0)