Index: wflow-py/wflow/wflow_routing.py =================================================================== diff -u -r58f139b2afc2424fc9f8796934878bd6e49c31de -r8ef02b08296007c41963099d8d2c6854e1582d9b --- wflow-py/wflow/wflow_routing.py (.../wflow_routing.py) (revision 58f139b2afc2424fc9f8796934878bd6e49c31de) +++ wflow-py/wflow/wflow_routing.py (.../wflow_routing.py) (revision 8ef02b08296007c41963099d8d2c6854e1582d9b) @@ -62,14 +62,12 @@ import numpy import os import os.path -import shutil, glob import getopt from wflow.wf_DynamicFramework import * from wflow.wflow_funcs import * from wflow.wflow_adapt import * -import configparser wflow = "wflow_routing: " @@ -79,7 +77,8 @@ def usage(*args): sys.stdout = sys.stderr - for msg in args: print(msg) + for msg in args: + print(msg) print(__doc__) sys.exit(0) @@ -179,7 +178,7 @@ self.Ncombined = ( self.Pch / self.WetPComb * self.N ** 1.5 + self.Pfp / self.WetPComb * self.NFloodPlain ** 1.5 - ) ** (2. / 3.) + ) ** (2.0 / 3.0) self.AlpTermFP = pow((self.NFloodPlain / (sqrt(self.SlopeDCL))), self.Beta) self.AlpTermComb = pow((self.Ncombined / (sqrt(self.SlopeDCL))), self.Beta) self.AlphaFP = self.AlpTermFP * pow(self.Pfp, self.AlpPow) @@ -205,7 +204,7 @@ :var self.WaterLevel: Water level in the kin-wave resrvoir [m] """ states = ["SurfaceRunoff", "WaterLevelCH", "WaterLevelFP"] - + if hasattr(self, "ReserVoirSimpleLocs"): states.append("ReservoirVolume") @@ -411,7 +410,9 @@ if hasattr(self, "ReserVoirSimpleLocs"): tt = pcr2numpy(self.ReserVoirSimpleLocs, 0.0) self.nrresSimple = tt.max() - self.logger.info("A total of " + str(self.nrresSimple) + " reservoirs found.") + self.logger.info( + "A total of " + str(self.nrresSimple) + " reservoirs found." + ) areamap = self.reallength * self.reallength res_area = areatotal(spatial(areamap), self.ReservoirSimpleAreas) @@ -422,7 +423,9 @@ cover(resarea_pnt, scalar(0.0)), ) - self.ReserVoirDownstreamLocs = downstream(self.TopoLdd, self.ReserVoirSimpleLocs) + self.ReserVoirDownstreamLocs = downstream( + self.TopoLdd, self.ReserVoirSimpleLocs + ) self.TopoLddOrg = self.TopoLdd self.TopoLdd = lddrepair( cover(ifthen(boolean(self.ReserVoirSimpleLocs), ldd(5)), self.TopoLdd) @@ -622,11 +625,11 @@ self.Inflow_mapstack = self.Dir + configget( self.config, "inputmapstacks", "Inflow", "/inmaps/IF" ) # timeseries for rainfall "/inmaps/IF" # in/outflow locations (abstractions) - + 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 @@ -731,7 +734,7 @@ self.Ncombined = ( self.Pch / self.WetPComb * self.N ** 1.5 + self.Pfp / self.WetPComb * self.NFloodPlain ** 1.5 - ) ** (2. / 3.) + ) ** (2.0 / 3.0) self.AlpTermFP = pow((self.NFloodPlain / (sqrt(self.SlopeDCL))), self.Beta) self.AlpTermComb = pow((self.Ncombined / (sqrt(self.SlopeDCL))), self.Beta) @@ -789,7 +792,7 @@ # The MAx here may lead to watbal error. However, if inwaterMMM becomes < 0, the kinematic wave becomes very slow...... self.InwaterMM = max(0.0, self.InwaterForcing) self.Inwater = self.InwaterMM * self.ToCubic # m3/s - + self.Precipitation = max(0.0, self.Precipitation) # only run the reservoir module if needed @@ -1033,27 +1036,38 @@ ## 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:') + 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, 1, 1) - - 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) @@ -1068,18 +1082,25 @@ ) 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': + 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":