Index: wflow-py/Sandbox/wflow_mswat.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Sandbox/wflow_mswat.py (.../wflow_mswat.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/Sandbox/wflow_mswat.py (.../wflow_mswat.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -380,7 +380,7 @@ self.xl, self.yl, self.reallength = pcrut.detRealCellLength( self.ZeroMap, sizeinmetres ) - self.hru_km = (self.reallength / 1000.) ** 2 + self.hru_km = (self.reallength / 1000.0) ** 2 # Calulate slope taking into account that x,y may be in lat,lon self.Slope = slope(self.Altitude) @@ -390,59 +390,61 @@ self.percent_sand = 100 - (self.percent_clay + self.percent_silt) self.erod_k = ifthenelse( pcrand( - self.percent_clay >= 40., - pcrand(self.percent_sand >= 20., self.percent_sand <= 45.), + self.percent_clay >= 40.0, + pcrand(self.percent_sand >= 20.0, self.percent_sand <= 45.0), ), 2.0, ifthenelse( pcrand( - self.percent_clay >= 27., - pcrand(self.percent_sand >= 20., self.percent_sand <= 45.), + self.percent_clay >= 27.0, + pcrand(self.percent_sand >= 20.0, self.percent_sand <= 45.0), ), 1.7, ifthenelse( - pcrand(self.percent_silt <= 40., self.percent_sand <= 20.), + pcrand(self.percent_silt <= 40.0, self.percent_sand <= 20.0), 2.0, ifthenelse( - pcrand(self.percent_silt > 40., self.percent_clay >= 40.), + pcrand(self.percent_silt > 40.0, self.percent_clay >= 40.0), 1.6, ifthenelse( - pcrand(self.percent_clay >= 35., self.percent_sand >= 45.), + pcrand( + self.percent_clay >= 35.0, self.percent_sand >= 45.0 + ), 1.9, ifthenelse( pcrand( - self.percent_clay >= 27., self.percent_sand < 20. + self.percent_clay >= 27.0, self.percent_sand < 20.0 ), 1.6, ifthenelse( pcrand( - self.percent_clay <= 10., - self.percent_silt >= 80., + self.percent_clay <= 10.0, + self.percent_silt >= 80.0, ), 1.2, ifthenelse( self.percent_silt >= 50, 1.5, ifthenelse( pcrand( - self.percent_clay >= 7., + self.percent_clay >= 7.0, pcrand( - self.percent_sand <= 52., - self.percent_silt >= 28., + self.percent_sand <= 52.0, + self.percent_silt >= 28.0, ), ), 2.0, ifthenelse( - self.percent_clay >= 20., + self.percent_clay >= 20.0, 2.1, ifthenelse( self.percent_clay - >= self.percent_sand - 70., + >= self.percent_sand - 70.0, 2.6, ifthenelse( self.percent_clay - >= (2. * self.percent_sand) - - 170., + >= (2.0 * self.percent_sand) + - 170.0, 3, scalar(1.9), ), @@ -558,12 +560,12 @@ # JS PAthFrac (Fimp) is already impervious fraction so this (sedspl) is the pervious? # So we multiply sedspl with pervious area fraction # DT Yes we do, it is erosion from pervious area. Splash erosion from impervious area (I think they call it 'wash') is not included. - self.sedspl = self.sedspl * (1. - self.PathFrac) + self.sedspl = self.sedspl * (1.0 - self.PathFrac) """ maximum water depth that allows splash erosion """ self.sedspl = ifthenelse( - pcror(self.RunDepthMM >= 3. * rain_d50, self.RunDepthMM <= 1.e-6), - 0., + pcror(self.RunDepthMM >= 3.0 * rain_d50, self.RunDepthMM <= 1.0e-6), + 0.0, self.sedspl, ) @@ -590,12 +592,12 @@ """ Impervious area of HRU """ # DT, again it is only erosion from pervious area - self.sedov = self.sedov * (1. - self.PathFrac) + self.sedov = self.sedov * (1.0 - self.PathFrac) """ Report sediment yield """ self.hhsedy = self.dratio * (self.sedspl + self.sedov) self.hhsedy = cover( - ifthenelse(self.hhsedy < 1.e-10, 0, self.hhsedy), scalar(0.0) + ifthenelse(self.hhsedy < 1.0e-10, 0, self.hhsedy), scalar(0.0) ) # We could use accucapacityflux and link the capacity to runoff of speed self.SedRunoff = accuflux(self.TopoLdd, self.hhsedy) Index: wflow-py/Sandbox/wflow_musle.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Sandbox/wflow_musle.py (.../wflow_musle.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/Sandbox/wflow_musle.py (.../wflow_musle.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -393,7 +393,7 @@ self.xl, self.yl, self.reallength = pcrut.detRealCellLength( self.ZeroMap, sizeinmetres ) - self.hru_km = (self.reallength / 1000.) ** 2 + self.hru_km = (self.reallength / 1000.0) ** 2 # Calulate slope taking into account that x,y may be in lat,lon self.Slope = slope(self.Altitude) @@ -403,59 +403,61 @@ self.percent_sand = 100 - self.percent_clay - self.percent_silt self.erod_k = ifthenelse( pcrand( - self.percent_clay >= 40., - pcrand(self.percent_sand >= 20., self.percent_sand <= 45.), + self.percent_clay >= 40.0, + pcrand(self.percent_sand >= 20.0, self.percent_sand <= 45.0), ), 2.0, ifthenelse( pcrand( - self.percent_clay >= 27., - pcrand(self.percent_sand >= 20., self.percent_sand <= 45.), + self.percent_clay >= 27.0, + pcrand(self.percent_sand >= 20.0, self.percent_sand <= 45.0), ), 1.7, ifthenelse( - pcrand(self.percent_silt <= 40., self.percent_sand <= 20.), + pcrand(self.percent_silt <= 40.0, self.percent_sand <= 20.0), 2.0, ifthenelse( - pcrand(self.percent_silt > 40., self.percent_clay >= 40.), + pcrand(self.percent_silt > 40.0, self.percent_clay >= 40.0), 1.6, ifthenelse( - pcrand(self.percent_clay >= 35., self.percent_sand >= 45.), + pcrand( + self.percent_clay >= 35.0, self.percent_sand >= 45.0 + ), 1.9, ifthenelse( pcrand( - self.percent_clay >= 27., self.percent_sand < 20. + self.percent_clay >= 27.0, self.percent_sand < 20.0 ), 1.6, ifthenelse( pcrand( - self.percent_clay <= 10., - self.percent_silt >= 80., + self.percent_clay <= 10.0, + self.percent_silt >= 80.0, ), 1.2, ifthenelse( self.percent_silt >= 50, 1.5, ifthenelse( pcrand( - self.percent_clay >= 7., + self.percent_clay >= 7.0, pcrand( - self.percent_sand <= 52., - self.percent_silt >= 28., + self.percent_sand <= 52.0, + self.percent_silt >= 28.0, ), ), 2.0, ifthenelse( - self.percent_clay >= 20., + self.percent_clay >= 20.0, 2.1, ifthenelse( self.percent_clay - >= self.percent_sand - 70., + >= self.percent_sand - 70.0, 2.6, ifthenelse( self.percent_clay - >= (2. * self.percent_sand) - - 170., + >= (2.0 * self.percent_sand) + - 170.0, 3, scalar(1.9), ), @@ -546,28 +548,30 @@ self.sedspl = ( self.erod_k * ke_total - * exp(-self.eros_spl * self.Runoff / 1000.) + * exp(-self.eros_spl * self.Runoff / 1000.0) * self.hru_km ) # tons per cell """ Impervious area of HRU """ # JS PAthFrac (Fimp) is already impervious fraction so this (sedspl) is the pervious? # So we multiply sedspl with pervious area fraction - self.sedspl = self.sedspl * (1. - self.PathFrac) + self.sedspl = self.sedspl * (1.0 - self.PathFrac) """ maximum water depth that allows splash erosion """ self.sedspl = ifthenelse( - pcror(self.Runoff >= 3. * rain_d50, self.Runoff <= 1.e-6), 0., self.sedspl + pcror(self.Runoff >= 3.0 * rain_d50, self.Runoff <= 1.0e-6), + 0.0, + self.sedspl, ) """ Overland flow erosion """ """ cover and management factor used in usle equation (ysed.f) """ c = exp( - (-.2231 - self.idplt_cvm) * exp(-.00115 * self.soil_cov + self.idplt_cvm) + (-0.2231 - self.idplt_cvm) * exp(-0.00115 * self.soil_cov + self.idplt_cvm) ) """ calculate shear stress (N/m2) """ - bed_shear = 9807 * (self.Runoff / 1000.) * self.Slope + bed_shear = 9807 * (self.Runoff / 1000.0) * self.Slope """ sediment yield by overland flow (kg/hour/m2) """ self.sedov = ( @@ -583,12 +587,12 @@ self.sedov = 16.667 * self.sedov * self.hru_km * self.timestepsecs / 60.0 """ Impervious area of HRU """ - self.sedov = self.sedov * (1. - self.PathFrac) + self.sedov = self.sedov * (1.0 - self.PathFrac) """ Report sediment yield """ self.hhsedy = self.dratio * (self.sedspl + self.sedov) self.hhsedy = cover( - ifthenelse(self.hhsedy < 1.e-10, 0, self.hhsedy), scalar(0.0) + ifthenelse(self.hhsedy < 1.0e-10, 0, self.hhsedy), scalar(0.0) ) # We could use accucapacityflux and link the capacity to runoff of speed self.SedRunoff = accuflux(self.TopoLdd, self.hhsedy) Index: wflow-py/Sandbox/wflow_prepare_rad.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Sandbox/wflow_prepare_rad.py (.../wflow_prepare_rad.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/Sandbox/wflow_prepare_rad.py (.../wflow_prepare_rad.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -225,7 +225,7 @@ steps and averaging this per day. """ - Intperday = 1440. / interval + Intperday = 1440.0 / interval Starthour = shour EndHour = ehour Calcsteps = Intperday / 24 * 24 Index: wflow-py/Sandbox/wflow_w3.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Sandbox/wflow_w3.py (.../wflow_w3.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/Sandbox/wflow_w3.py (.../wflow_w3.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -503,7 +503,7 @@ self.Sg = cover(0) self.Sr = cover(0) - self.Mleaf = 2. / self.SLA + self.Mleaf = 2.0 / self.SLA self.S0 = 0.2 * self.w0limE * self.S0max self.Ss = 0.2 * self.wslimU * self.Ssmax self.Sd = 0.2 * self.wdlimU * self.Sdmax @@ -708,7 +708,7 @@ if self.UseETPdata == 1: self.E0 = max(self.EPOT, 0) keps = ( - 0.655E-3 * pair / pes + 0.655e-3 * pair / pes ) # See Appendix A3 (http://www.clw.csiro.au/publications/waterforahealthycountry/2010/wfhc-aus-water-resources-assessment-system.pdf) -------------------------------- check! self.Ept = self.E0 Index: wflow-py/Sandbox/wflow_w3ra_v2.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Sandbox/wflow_w3ra_v2.py (.../wflow_w3ra_v2.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/Sandbox/wflow_w3ra_v2.py (.../wflow_w3ra_v2.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -358,7 +358,7 @@ self.wf_multparameters() # Static, for the computation of Aerodynamic conductance (3.7) - self.fh = ln(813. / max(self.hveg, 0.25) - 5.45) + self.fh = ln(813.0 / max(self.hveg, 0.25) - 5.45) self.ku1 = 0.305 / (self.fh * (self.fh + 2.3)) self.logger.info("Starting Dynamic run...") @@ -549,7 +549,7 @@ if self.UseETPdata == 1: self.E0 = max(self.EPOT, 0) keps = ( - 0.655E-3 * pair / pes + 0.655e-3 * pair / pes ) # See Appendix A3 (http://www.clw.csiro.au/publications/waterforahealthycountry/2010/wfhc-aus-water-resources-assessment-system.pdf) -------------------------------- check! elif self.UseETPdata == 0: Index: wflow-py/Scripts/bmi2runner.py =================================================================== diff -u -r59cffa03cc52cdb4dc62a0ead1aafb6bc039b430 -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Scripts/bmi2runner.py (.../bmi2runner.py) (revision 59cffa03cc52cdb4dc62a0ead1aafb6bc039b430) +++ wflow-py/Scripts/bmi2runner.py (.../bmi2runner.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -30,10 +30,12 @@ import getopt import logging + def usage(*args): sys.stdout = sys.stderr """Way""" - for msg in args: print(msg) + for msg in args: + print(msg) print(__doc__) sys.exit(0) @@ -45,7 +47,6 @@ configfile = "bmirunner.ini" - if argv is None: argv = sys.argv[1:] if len(argv) == 0: @@ -55,52 +56,51 @@ ## Process command-line options # ######################################################################## try: - opts, args = getopt.getopt(argv, 'c:l:') + opts, args = getopt.getopt(argv, "c:l:") except getopt.error as msg: usage(msg) - loglevel=logging.WARN + loglevel = logging.WARN for o, a in opts: - if o == '-c': configfile = a - if o == '-l': exec("loglevel = logging." + a) + if o == "-c": + configfile = a + if o == "-l": + exec("loglevel = logging." + a) + combilogger = pcrut.setlogger( + "bmi2runner.log", "bmi2runner_logging", thelevel=loglevel + ) - - 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) - + cts = bmiobj.currenttimestep # Loop over the time duration while cts < steps: combilogger.info("time is: " + str(bmiobj.get_current_time())) bmiobj.update() cts = bmiobj.currenttimestep - - + bmiobj.finalize() combilogger.info("Finishing run") if __name__ == "__main__": main() - - Index: wflow-py/Scripts/e2o-getfromwci.py =================================================================== diff -u -r90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Scripts/e2o-getfromwci.py (.../e2o-getfromwci.py) (revision 90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a) +++ wflow-py/Scripts/e2o-getfromwci.py (.../e2o-getfromwci.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -19,9 +19,7 @@ """ -baseurl = ( - "http://wci.earth2observe.eu/thredds/dodsC/ecmwf/met_forcing_v0/%d/Rainf_daily_E2OBS_%d%02d.nc" -) +baseurl = "http://wci.earth2observe.eu/thredds/dodsC/ecmwf/met_forcing_v0/%d/Rainf_daily_E2OBS_%d%02d.nc" # baseurl = 'http://wci.earth2observe.eu/thredds/dodsC/ecmwf/met_forcing_v0/%d/Tair_daily_E2OBS_%d%02d.nc' months = arange(1, 13, 1) Index: wflow-py/Scripts/pcr2netcdf.py =================================================================== diff -u -r90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Scripts/pcr2netcdf.py (.../pcr2netcdf.py) (revision 90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a) +++ wflow-py/Scripts/pcr2netcdf.py (.../pcr2netcdf.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -169,7 +169,7 @@ :, 0 ] - FillVal = float(1E31) + FillVal = float(1e31) data = _pcrut.pcr2numpy(pcrdata, FillVal) if unzipped: # Delete uncompressed file if compressed exsists @@ -280,7 +280,7 @@ least_significant_digit=None, startidx=0, EPSG="EPSG:4326", - FillVal=1E31, + FillVal=1e31, ): """ Write pcraster mapstack to netcdf file. Taken from GLOFRIS_Utils.py @@ -513,7 +513,7 @@ mbuf = 600 timestepsecs = 86400 - outputFillVal = 1E31 + outputFillVal = 1e31 clonemap = None OFormat = "NETCDF4" IFormat = "PCRaster" Index: wflow-py/Scripts/read_arcinfo_files.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Scripts/read_arcinfo_files.py (.../read_arcinfo_files.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/Scripts/read_arcinfo_files.py (.../read_arcinfo_files.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -92,7 +92,7 @@ lat = ( fileTable["yllcorner"] + (fileTable["nrows"] - i) * fileTable["cellsize"] - - fileTable["cellsize"] / 2. + - fileTable["cellsize"] / 2.0 ) if lat >= Extent["South"] and lat <= Extent["North"]: tmprcnt = tmprcnt + 1 @@ -111,7 +111,7 @@ lng = ( fileTable["xllcorner"] + (j) * fileTable["cellsize"] - + fileTable["cellsize"] / 2. + + fileTable["cellsize"] / 2.0 ) if lng >= Extent["West"] and lng <= Extent["East"]: if tmprcnt == 1: @@ -184,19 +184,19 @@ lat = ( gridTable["yllcorner"] + (gridTable["nrows"] - i) * gridTable["cellsize"] - - gridTable["cellsize"] / 2. + - gridTable["cellsize"] / 2.0 ) tmpstr = "" for j in range(gridTable["ncols"]): lng = ( gridTable["xllcorner"] + (j) * gridTable["cellsize"] - + gridTable["cellsize"] / 2. + + gridTable["cellsize"] / 2.0 ) if idx < gridTable["Ncells"] and ( - abs(lat - gridTable["cell"][idx]["lat"]) <= gridTable["cellsize"] / 2. + abs(lat - gridTable["cell"][idx]["lat"]) <= gridTable["cellsize"] / 2.0 and abs(lng - gridTable["cell"][idx]["lng"]) - <= gridTable["cellsize"] / 2. + <= gridTable["cellsize"] / 2.0 ): if ( INTflag Index: wflow-py/Scripts/shptoraster.py =================================================================== diff -u -r4143969ebd6b276284ea6e4198ee693bd6ab506a -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Scripts/shptoraster.py (.../shptoraster.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) +++ wflow-py/Scripts/shptoraster.py (.../shptoraster.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -1,4 +1,3 @@ - import os import os.path import getopt Index: wflow-py/Scripts/wflow_flood.py =================================================================== diff -u -r90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Scripts/wflow_flood.py (.../wflow_flood.py) (revision 90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a) +++ wflow-py/Scripts/wflow_flood.py (.../wflow_flood.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -401,7 +401,7 @@ config, "inundation", "iterations", 20, datatype="int" ) options.initial_level = inun_lib.configget( - config, "inundation", "initial_level", 32., datatype="float" + config, "inundation", "initial_level", 32.0, datatype="float" ) options.flood_volume_type = inun_lib.configget( config, "inundation", "flood_volume_type", 0, datatype="int" @@ -595,7 +595,7 @@ np.arange(0, terrain.shape[1]), np.arange(0, terrain.shape[0]), terrain, - -9999., + -9999.0, gdal_type=gdal.GDT_Float32, logging=logger, ) @@ -661,7 +661,7 @@ neg_HAND=options.neg_HAND, ) # convert to numpy - hand = pcr.pcr2numpy(hand_pcr, -9999.) + hand = pcr.pcr2numpy(hand_pcr, -9999.0) # cut relevant part if y_overlap_max == 0: y_overlap_max = -hand.shape[0] @@ -680,7 +680,7 @@ ds_dem = None ds_ldd = None ds_stream = None - band_hand.SetNoDataValue(-9999.) + band_hand.SetNoDataValue(-9999.0) ds_hand = None logger.info("Finalizing {:s}".format(hand_file)) # rename temporary file to final hand file @@ -789,7 +789,7 @@ options.time = "20000101000000" time = [dt.datetime.strptime(options.time, "%Y%m%d%H%M%S")] - flood[flood == flood_fill_value] = 0. + flood[flood == flood_fill_value] = 0.0 # load the bankfull depths if options.bankfull_map == "": bankfull = np.zeros(flood.shape) @@ -834,7 +834,7 @@ else: flood_vol_m = flood_vol / cell_surface_wflow flood_vol_m_data = flood_vol_m.data - flood_vol_m_data[flood_vol_m.mask] = -999. + flood_vol_m_data[flood_vol_m.mask] = -999.0 logger.info("Saving water layer map to {:s}".format(flood_vol_map)) # write to a tiff file inun_lib.gdal_writemap( @@ -843,7 +843,7 @@ xax, yax, np.maximum(flood_vol_m_data, 0), - -999., + -999.0, logging=logger, ) # this is placed later in the hand loop @@ -1027,7 +1027,7 @@ drainage_pcr, subcatch ), # to make sure backwater effects can occur from higher order rivers to lower order rivers flood_vol_strahler, - volume_thres=0., + volume_thres=0.0, iterations=options.iterations, cell_surface=pcr.numpy2pcr(pcr.Scalar, cell_surface_tile, -9999), logging=logger, @@ -1036,7 +1036,7 @@ ) # 1166400000. # use maximum value of inundation_pcr_step and new inundation for higher strahler order inundation_pcr = pcr.max(inundation_pcr, inundation_pcr_step) - inundation = pcr.pcr2numpy(inundation_pcr, -9999.) + inundation = pcr.pcr2numpy(inundation_pcr, -9999.0) # cut relevant part if y_overlap_max == 0: y_overlap_max = -inundation.shape[0] Index: wflow-py/Scripts/wflow_flood_lib.py =================================================================== diff -u -r90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Scripts/wflow_flood_lib.py (.../wflow_flood_lib.py) (revision 90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a) +++ wflow-py/Scripts/wflow_flood_lib.py (.../wflow_flood_lib.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -292,7 +292,7 @@ ds.SetProjection(srs.ExportToWkt()) # get rasterband entry band = ds.GetRasterBand(1) - band.SetNoDataValue(-9999.) + band.SetNoDataValue(-9999.0) ds.SetMetadata(metadata) band.SetMetadata(metadata_var) @@ -454,7 +454,7 @@ if up_area is None: up_area = pcr.accuflux(ldd, 1) up_area = pcr.ifthen(stream, up_area) # mask areas outside streams - friction = 1. / pcr.scalar( + friction = 1.0 / pcr.scalar( pcr.spreadzone(pcr.cover(pcr.ordinal(up_area), 0), 0, 0) ) # if basin, use nearest river within subcatchment, if outside basin, use weighted-nearest river @@ -558,7 +558,7 @@ ) riverid = pcr.ifthen(pcr.boolean(pcr.cover(stream_ge, 0)), subcatch) - friction = 1. / pcr.scalar( + friction = 1.0 / pcr.scalar( pcr.spreadzone(pcr.cover(pcr.ordinal(up_area), 0), 0, 0) ) # *(pcr.scalar(ldd)*0+1) delta = pcr.ifthen( @@ -585,8 +585,8 @@ hand, subcatch, volume, - volume_thres=0., - cell_surface=1., + volume_thres=0.0, + cell_surface=1.0, iterations=15, logging=logging, order=0, @@ -622,14 +622,14 @@ # pcr.report(volume, 'volume_{:02d}.map'.format(order)) if neg_HAND == 1: dem_max = pcr.ifthenelse( - volume_catch > volume_thres, pcr.scalar(32.), pcr.scalar(-32.) + volume_catch > volume_thres, pcr.scalar(32.0), pcr.scalar(-32.0) ) # bizarre high inundation depth☻ - dem_min = pcr.scalar(-32.) + dem_min = pcr.scalar(-32.0) else: dem_max = pcr.ifthenelse( - volume_catch > volume_thres, pcr.scalar(32.), pcr.scalar(0.) + volume_catch > volume_thres, pcr.scalar(32.0), pcr.scalar(0.0) ) # bizarre high inundation depth☻ - dem_min = pcr.scalar(0.) + dem_min = pcr.scalar(0.0) for n in range(iterations): logging.debug("Iteration: {:02d}".format(n + 1)) #####while np.logical_and(error_abs > error_thres, dem_min < dem_max): Index: wflow-py/Scripts/wflow_sbm_rtc.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Scripts/wflow_sbm_rtc.py (.../wflow_sbm_rtc.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/Scripts/wflow_sbm_rtc.py (.../wflow_sbm_rtc.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -1,4 +1,3 @@ - # coding: utf-8 #

Basic test of the wflow BMI interface + reservoir Index: wflow-py/Scripts/wflow_subcatch.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Scripts/wflow_subcatch.py (.../wflow_subcatch.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/Scripts/wflow_subcatch.py (.../wflow_subcatch.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -86,7 +86,7 @@ procTuple = (command, proc) processes.append(procTuple) while len(processes) >= maxCpu: - time.sleep(.2) + time.sleep(0.2) processes = removeFinishedProcesses(processes) # wait for all processes Index: wflow-py/UnitTests/Test_w3ra_BMI.py =================================================================== diff -u -r4143969ebd6b276284ea6e4198ee693bd6ab506a -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/UnitTests/Test_w3ra_BMI.py (.../Test_w3ra_BMI.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) +++ wflow-py/UnitTests/Test_w3ra_BMI.py (.../Test_w3ra_BMI.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -60,8 +60,8 @@ tmax = np.ma.masked_invalid(data.astype(np.float64)).max() tmin = np.ma.masked_invalid(data.astype(np.float64)).min() self.assertAlmostEqual(266.18075561523438, tmax) - self.assertAlmostEqual(-7.8522729383405979e+37, tmean) - self.assertAlmostEqual(-3.4028234663852886e+38, tmin) + self.assertAlmostEqual(-7.8522729383405979e37, tmean) + self.assertAlmostEqual(-3.4028234663852886e38, tmin) if __name__ == "__main__": Index: wflow-py/UnitTests/Testwflow_sbm_example.py =================================================================== diff -u -r96b2c5912f681ce0acb20172da7a9114d502b818 -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/UnitTests/Testwflow_sbm_example.py (.../Testwflow_sbm_example.py) (revision 96b2c5912f681ce0acb20172da7a9114d502b818) +++ wflow-py/UnitTests/Testwflow_sbm_example.py (.../Testwflow_sbm_example.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -45,7 +45,7 @@ my_data = wf.genfromtxt( os.path.join(caseName, runId, "specrun.csv"), delimiter="," ) - + os.chdir(orgdir) print("Checking specific runoff ....") Index: wflow-py/_version.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/_version.py (.../_version.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/_version.py (.../_version.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -1,4 +1,3 @@ - # This file helps to compute a version number in source trees obtained from # git-archive tarball (such as those provided by githubs download-from-tag # feature). Distribution tarballs (built by setup.py sdist) and build Index: wflow-py/versioneer.py =================================================================== diff -u -r684a68f61a81e3a2074f63392168cbbd3e858910 -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/versioneer.py (.../versioneer.py) (revision 684a68f61a81e3a2074f63392168cbbd3e858910) +++ wflow-py/versioneer.py (.../versioneer.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -1,4 +1,3 @@ - # Version: 0.18 """The Versioneer - like a rocketeer, but for versions. Index: wflow-py/wflow/_version.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/_version.py (.../_version.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/_version.py (.../_version.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -1,4 +1,3 @@ - # This file was generated by 'versioneer.py' (0.18) from # revision-control system data, or from the parent directory name of an # unpacked source archive. Distribution tarballs contain a pre-generated copy Index: wflow-py/wflow/create_grid.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/create_grid.py (.../create_grid.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/create_grid.py (.../create_grid.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -238,7 +238,7 @@ # create clone raster print(("rows: {0} cols: {1}".format(rows, cols))) - dummy_raster = np.zeros((rows, cols)) - 9999. + dummy_raster = np.zeros((rows, cols)) - 9999.0 clone_file_map = os.path.abspath(os.path.join(destination, "mask.map")) clone_file_tif = os.path.abspath(os.path.join(destination, "mask.tif")) logger.info("Writing PCRaster clone to {:s}".format(clone_file_map)) @@ -248,7 +248,7 @@ xorg, yorg, dummy_raster, - -9999., + -9999.0, resolution=cellsize, srs=srs, ) @@ -259,7 +259,7 @@ xorg, yorg, dummy_raster, - -9999., + -9999.0, resolution=cellsize, zlib=True, srs=srs, Index: wflow-py/wflow/pcrglobwb/groundwater.py =================================================================== diff -u -r7a07bfcf366e6f498e2e0d4036a15240c3260476 -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/pcrglobwb/groundwater.py (.../groundwater.py) (revision 7a07bfcf366e6f498e2e0d4036a15240c3260476) +++ wflow-py/wflow/pcrglobwb/groundwater.py (.../groundwater.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -76,9 +76,7 @@ self.inputDir = os.path.join( os.path.abspath(Dir), staticmaps ) # iniItems.globalOptions['inputDir'] - self.stateDir = os.path.join( - os.path.abspath(Dir), 'instate' - ) + self.stateDir = os.path.join(os.path.abspath(Dir), "instate") self.landmask = landmask # configuration from the ini file @@ -234,9 +232,7 @@ and "recessionCoeff" not in iniItems._sections["groundwaterOptions"] ): - msg = ( - "Calculating the groundwater linear reccesion coefficient based on the given parameters." - ) + msg = "Calculating the groundwater linear reccesion coefficient based on the given parameters." logger.info(msg) # reading the 'aquiferWidth' value from the landSurfaceOptions (slopeLength) @@ -272,9 +268,9 @@ # calculate recessionCoeff (unit; day-1) self.recessionCoeff = ( - (math.pi ** 2.) + (math.pi ** 2.0) * aquiferThicknessForRecessionCoeff - / (4. * self.specificYield * (aquiferWidth ** 2.)) + / (4.0 * self.specificYield * (aquiferWidth ** 2.0)) ) # assign the reccession coefficient based on the given pcraster file @@ -885,31 +881,33 @@ # make sure that active storGroundwater, avgAbstraction and avgNonFossilAllocation cannot be negative # self.storGroundwater = pcr.cover(self.storGroundwater, 0.0) - self.storGroundwater = pcr.max(0., self.storGroundwater) + self.storGroundwater = pcr.max(0.0, self.storGroundwater) self.storGroundwater = pcr.ifthen(self.landmask, self.storGroundwater) # self.avgAbstraction = pcr.cover(self.avgAbstraction, 0.0) - self.avgAbstraction = pcr.max(0., self.avgAbstraction) + self.avgAbstraction = pcr.max(0.0, self.avgAbstraction) self.avgAbstraction = pcr.ifthen(self.landmask, self.avgAbstraction) # self.avgAllocation = pcr.cover(self.avgAllocation, 0.0) - self.avgAllocation = pcr.max(0., self.avgAllocation) + self.avgAllocation = pcr.max(0.0, self.avgAllocation) self.avgAllocation = pcr.ifthen(self.landmask, self.avgAllocation) # self.avgAllocationShort = pcr.cover(self.avgAllocationShort, 0.0) - self.avgAllocationShort = pcr.max(0., self.avgAllocationShort) + self.avgAllocationShort = pcr.max(0.0, self.avgAllocationShort) self.avgAllocationShort = pcr.ifthen(self.landmask, self.avgAllocationShort) # self.avgNonFossilAllocation = pcr.cover(self.avgNonFossilAllocation, 0.0) - self.avgNonFossilAllocation = pcr.max(0., self.avgNonFossilAllocation) + self.avgNonFossilAllocation = pcr.max(0.0, self.avgNonFossilAllocation) self.avgNonFossilAllocation = pcr.ifthen( self.landmask, self.avgNonFossilAllocation ) # self.avgNonFossilAllocationShort = pcr.cover( self.avgNonFossilAllocationShort, 0.0 ) - self.avgNonFossilAllocationShort = pcr.max(0., self.avgNonFossilAllocationShort) + self.avgNonFossilAllocationShort = pcr.max( + 0.0, self.avgNonFossilAllocationShort + ) self.avgNonFossilAllocationShort = pcr.ifthen( self.landmask, self.avgNonFossilAllocationShort ) @@ -936,7 +934,7 @@ self.storGroundwater = self.storGroundwater * ( mapnormal() * parameters["standard_deviation"] + 1 ) - self.storGroundwater = pcr.max(0., self.storGroundwater) + self.storGroundwater = pcr.max(0.0, self.storGroundwater) else: print("Error: only groundwater may be updated at this time") @@ -1035,21 +1033,21 @@ # get net recharge (percolation-capRise) and update storage: self.storGroundwater = pcr.max( - 0., self.storGroundwater + landSurface.gwRecharge + 0.0, self.storGroundwater + landSurface.gwRecharge ) # non fossil groundwater abstraction self.nonFossilGroundwaterAbs = landSurface.nonFossilGroundwaterAbs self.storGroundwater = pcr.max( - 0., self.storGroundwater - self.nonFossilGroundwaterAbs + 0.0, self.storGroundwater - self.nonFossilGroundwaterAbs ) # baseflow self.baseflow = pcr.max( - 0., + 0.0, pcr.min(self.storGroundwater, self.recessionCoeff * self.storGroundwater), ) - self.storGroundwater = pcr.max(0., self.storGroundwater - self.baseflow) + self.storGroundwater = pcr.max(0.0, self.storGroundwater - self.baseflow) # PS: baseflow must be calculated at the end (to ensure the availability of storGroundwater to support nonFossilGroundwaterAbs) # fossil groundwater abstraction: @@ -1105,8 +1103,8 @@ landSurface.allocSurfaceWaterAbstract, ], [landSurface.totalPotentialGrossDemand], - [pcr.scalar(0.)], - [pcr.scalar(0.)], + [pcr.scalar(0.0)], + [pcr.scalar(0.0)], "demand allocation (desalination, surface water, groundwater & unmetDemand. Error here may be due to rounding error.", True, currTimeStep.fulldate, @@ -1119,7 +1117,7 @@ totalAbstraction = self.fossilGroundwaterAbstr + self.nonFossilGroundwaterAbs deltaAbstraction = totalAbstraction - self.avgAbstraction self.avgAbstraction = self.avgAbstraction + deltaAbstraction / pcr.min( - 365., pcr.max(1.0, routing.timestepsToAvgDischarge) + 365.0, pcr.max(1.0, routing.timestepsToAvgDischarge) ) self.avgAbstraction = pcr.max(0.0, self.avgAbstraction) @@ -1129,7 +1127,7 @@ self.avgNonFossilAllocation = ( self.avgNonFossilAllocation + deltaAllocation - / pcr.min(365., pcr.max(1.0, routing.timestepsToAvgDischarge)) + / pcr.min(365.0, pcr.max(1.0, routing.timestepsToAvgDischarge)) ) self.avgNonFossilAllocation = pcr.max(0.0, self.avgNonFossilAllocation) # - from the last 7 days: @@ -1139,7 +1137,7 @@ self.avgNonFossilAllocationShort = ( self.avgNonFossilAllocationShort + deltaAllocationShort - / pcr.min(7., pcr.max(1.0, routing.timestepsToAvgDischarge)) + / pcr.min(7.0, pcr.max(1.0, routing.timestepsToAvgDischarge)) ) self.avgNonFossilAllocationShort = pcr.max( 0.0, self.avgNonFossilAllocationShort @@ -1152,15 +1150,15 @@ # - from the last 365 days: deltaAllocation = totalGroundwaterAllocation - self.avgAllocation self.avgAllocation = self.avgAllocation + deltaAllocation / pcr.min( - 365., pcr.max(1.0, routing.timestepsToAvgDischarge) + 365.0, pcr.max(1.0, routing.timestepsToAvgDischarge) ) self.avgAllocation = pcr.max(0.0, self.avgAllocation) # - from the last 7 days: deltaAllocationShort = totalGroundwaterAllocation - self.avgAllocationShort self.avgAllocationShort = ( self.avgAllocationShort + deltaAllocationShort - / pcr.min(7., pcr.max(1.0, routing.timestepsToAvgDischarge)) + / pcr.min(7.0, pcr.max(1.0, routing.timestepsToAvgDischarge)) ) self.avgAllocationShort = pcr.max(0.0, self.avgAllocationShort) Index: wflow-py/wflow/pcrglobwb/landCover.py =================================================================== diff -u -r7a07bfcf366e6f498e2e0d4036a15240c3260476 -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/pcrglobwb/landCover.py (.../landCover.py) (revision 7a07bfcf366e6f498e2e0d4036a15240c3260476) +++ wflow-py/wflow/pcrglobwb/landCover.py (.../landCover.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -106,9 +106,7 @@ self.interceptionModuleType = "Original" 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).' - ) + 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" else: @@ -127,9 +125,7 @@ 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".' - ) + 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": self.minInterceptCap = vos.readPCRmapClone( @@ -167,9 +163,7 @@ "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 = "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." ) @@ -187,12 +181,8 @@ ] == "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)." - ) + 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 @@ -351,9 +341,7 @@ + self.name + " " ) # '\n' - msg = ( - "This run assumes zero canopy interception capacity for this run, UNLESS minInterceptCap (minimum interception capacity) is bigger than zero." - ) # + '\n' + msg = "This run assumes zero canopy interception capacity for this run, UNLESS minInterceptCap (minimum interception capacity) is bigger than zero." # + '\n' logger.warning(msg) self.coverFractionNC = None self.interceptCapNC = None @@ -471,9 +459,7 @@ # get parameters that are fixed for the entire simulation: if date_in_string == None: - msg = ( - "Obtaining the land cover parameters that are fixed for the entire simulation." - ) + msg = "Obtaining the land cover parameters that are fixed for the entire simulation." logger.debug(msg) if self.iniItemsLC["landCoverMapsNC"] == str(None): @@ -562,8 +548,8 @@ # estimating arnoBeta from the values of maxSoilDepthFrac and minSoilDepthFrac. lc_parameters["arnoBeta"] = pcr.max( 0.001, - (lc_parameters["maxSoilDepthFrac"] - 1.) - / (1. - lc_parameters["minSoilDepthFrac"]) + (lc_parameters["maxSoilDepthFrac"] - 1.0) + / (1.0 - lc_parameters["minSoilDepthFrac"]) + self.parameters.orographyBeta - 0.01, ) # Rens's line: BCF[TYPE]= max(0.001,(MAXFRAC[TYPE]-1)/(1-MINFRAC[TYPE])+B_ORO-0.01) @@ -638,8 +624,8 @@ # estimating arnoBeta from the values of maxSoilDepthFrac and minSoilDepthFrac lc_parameters["arnoBeta"] = pcr.max( 0.001, - (lc_parameters["maxSoilDepthFrac"] - 1.) - / (1. - lc_parameters["minSoilDepthFrac"]) + (lc_parameters["maxSoilDepthFrac"] - 1.0) + / (1.0 - lc_parameters["minSoilDepthFrac"]) + self.parameters.orographyBeta - 0.01, ) # Rens's line: BCF[TYPE]= max(0.001,(MAXFRAC[TYPE]-1)/(1-MINFRAC[TYPE])+B_ORO-0.01) @@ -718,9 +704,11 @@ # Due to compaction infiltration/percolation loss rate can be much smaller than original soil saturated conductivity # - Wada et al. (2014) assume it will be 10 times smaller if self.numberOfLayers == 2: - design_percolation_loss = self.parameters.kSatUpp / 10. # unit: m/day + design_percolation_loss = self.parameters.kSatUpp / 10.0 # unit: m/day if self.numberOfLayers == 3: - design_percolation_loss = self.parameters.kSatUpp000005 / 10. # unit: m/day + design_percolation_loss = ( + self.parameters.kSatUpp000005 / 10.0 + ) # unit: m/day # However, it can also be much smaller especially in well-puddled paddy fields and should avoid salinization problems. # - Default minimum and maximum percolation loss values based on FAO values Reference: http://www.fao.org/docrep/s2022e/s2022e08.htm @@ -978,14 +966,14 @@ self.parameters.matricSuction50 / self.parameters.airEntryValueUpp ) - ** (-1. / self.parameters.poreSizeBetaUpp) + ** (-1.0 / self.parameters.poreSizeBetaUpp) + self.parameters.storCapLow * self.adjRootFrLow * ( self.parameters.matricSuction50 / self.parameters.airEntryValueLow ) - ** (-1. / self.parameters.poreSizeBetaLow) + ** (-1.0 / self.parameters.poreSizeBetaLow) ) / ( self.parameters.storCapUpp * self.adjRootFrUpp @@ -1058,21 +1046,21 @@ self.parameters.matricSuction50 / self.parameters.airEntryValueUpp000005 ) - ** (-1. / self.parameters.poreSizeBetaUpp000005) + ** (-1.0 / self.parameters.poreSizeBetaUpp000005) + self.parameters.storCapUpp005030 * self.adjRootFrUpp005030 * ( self.parameters.matricSuction50 / self.parameters.airEntryValueUpp000005 ) - ** (-1. / self.parameters.poreSizeBetaUpp000005) + ** (-1.0 / self.parameters.poreSizeBetaUpp000005) + self.parameters.storCapLow030150 * self.adjRootFrLow030150 * ( self.parameters.matricSuction50 / self.parameters.airEntryValueLow030150 ) - ** (-1. / self.parameters.poreSizeBetaLow030150) + ** (-1.0 / self.parameters.poreSizeBetaLow030150) / ( self.parameters.storCapUpp000005 * self.adjRootFrUpp000005 + self.parameters.storCapUpp005030 * self.adjRootFrUpp005030 @@ -1146,7 +1134,7 @@ self.totAvlWater = ( pcr.max( - 0., + 0.0, self.parameters.effSatAtFieldCapUpp - self.parameters.effSatAtWiltPointUpp, ) @@ -1156,15 +1144,15 @@ self.parameters.thickUpp, self.maxRootDepth ) + ( pcr.max( - 0., + 0.0, self.parameters.effSatAtFieldCapLow - self.parameters.effSatAtWiltPointLow, ) ) * ( self.parameters.satVolMoistContLow - self.parameters.resVolMoistContLow ) * pcr.min( self.parameters.thickLow, - pcr.max(self.maxRootDepth - self.parameters.thickUpp, 0.), + pcr.max(self.maxRootDepth - self.parameters.thickUpp, 0.0), ) # Edwin modified this line. Edwin uses soil thickness thickUpp and thickLow (instead of storCapUpp and storCapLow). # And Rens support this. self.totAvlWater = pcr.min( @@ -1177,7 +1165,7 @@ self.totAvlWater = ( ( pcr.max( - 0., + 0.0, self.parameters.effSatAtFieldCapUpp000005 - self.parameters.effSatAtWiltPointUpp000005, ) @@ -1189,7 +1177,7 @@ * pcr.min(self.parameters.thickUpp000005, self.maxRootDepth) + ( pcr.max( - 0., + 0.0, self.parameters.effSatAtFieldCapUpp005030 - self.parameters.effSatAtWiltPointUpp005030, ) @@ -1204,7 +1192,7 @@ ) + ( pcr.max( - 0., + 0.0, self.parameters.effSatAtFieldCapLow030150 - self.parameters.effSatAtWiltPointLow030150, ) @@ -1215,7 +1203,7 @@ ) * pcr.min( self.parameters.thickLow030150, - pcr.max(self.maxRootDepth - self.parameters.thickUpp005030, 0.), + pcr.max(self.maxRootDepth - self.parameters.thickUpp005030, 0.0), ) ) # @@ -1335,11 +1323,11 @@ # saturation degrees (needed only for reporting): if self.numberOfSoilLayers == 2: self.satDegUpp = vos.getValDivZero( - self.storUpp, self.parameters.storCapUpp, vos.smallNumber, 0. + self.storUpp, self.parameters.storCapUpp, vos.smallNumber, 0.0 ) self.satDegUpp = pcr.ifthen(self.landmask, self.satDegUpp) self.satDegLow = vos.getValDivZero( - self.storLow, self.parameters.storCapLow, vos.smallNumber, 0. + self.storLow, self.parameters.storCapLow, vos.smallNumber, 0.0 ) self.satDegLow = pcr.ifthen(self.landmask, self.satDegLow) @@ -1351,29 +1339,29 @@ self.storUpp000005, self.parameters.storCapUpp000005, vos.smallNumber, - 0., + 0.0, ) self.satDegUpp000005 = pcr.ifthen(self.landmask, self.satDegUpp000005) self.satDegUpp005030 = vos.getValDivZero( self.storUpp005030, self.parameters.storCapUpp005030, vos.smallNumber, - 0., + 0.0, ) self.satDegUpp005030 = pcr.ifthen(self.landmask, self.satDegUpp005030) self.satDegLow030150 = vos.getValDivZero( self.storLow030150, self.parameters.storCapLow030150, vos.smallNumber, - 0., + 0.0, ) self.satDegLow030150 = pcr.ifthen(self.landmask, self.satDegLow030150) self.satDegUppTotal = vos.getValDivZero( self.storUpp000005 + self.storUpp005030, self.parameters.storCapUpp000005 + self.parameters.storCapUpp005030, vos.smallNumber, - 0., + 0.0, ) self.satDegUppTotal = pcr.ifthen(self.landmask, self.satDegUppTotal) self.satDegLowTotal = self.satDegLow030150 @@ -1591,7 +1579,7 @@ self.potInterceptionFlux * ( vos.getValDivZero( - self.interceptStor, self.interceptCap, vos.smallNumber, 0. + self.interceptStor, self.interceptCap, vos.smallNumber, 0.0 ) ** (2.00 / 3.00) ), @@ -1635,7 +1623,7 @@ ) # update actual evaporation (after interceptEvap) - self.actualET = 0. # interceptEvap is the first flux in ET + self.actualET = 0.0 # interceptEvap is the first flux in ET self.actualET += self.interceptEvap if self.debugWaterBalance: @@ -1806,12 +1794,12 @@ # netLqWaterToSoil = net liquid transferred to soil self.netLqWaterToSoil = pcr.max( - 0., self.snowFreeWater - self.snowWaterHoldingCap * self.snowCoverSWE + 0.0, self.snowFreeWater - self.snowWaterHoldingCap * self.snowCoverSWE ) # Pn = max(0,SCF_L[TYPE]-CWH*SC_L[TYPE]) # update snowFreeWater (after netLqWaterToSoil) self.snowFreeWater = pcr.max( - 0., self.snowFreeWater - self.netLqWaterToSoil + 0.0, self.snowFreeWater - self.netLqWaterToSoil ) # SCF_L[TYPE] = max(0,SCF_L[TYPE]-Pn) # evaporation from snowFreeWater (based on potBareSoilEvap) @@ -1871,17 +1859,17 @@ if self.numberOfLayers == 2: # initial total soilWaterStorage - self.soilWaterStorage = pcr.max(0., self.storUpp + self.storLow) + self.soilWaterStorage = pcr.max(0.0, self.storUpp + self.storLow) # effective degree of saturation (-) self.effSatUpp = pcr.max( - 0., self.storUpp / self.parameters.storCapUpp + 0.0, self.storUpp / self.parameters.storCapUpp ) # THEFF1= max(0,S1_L[TYPE]/SC1[TYPE]); self.effSatLow = pcr.max( - 0., self.storLow / self.parameters.storCapLow + 0.0, self.storLow / self.parameters.storCapLow ) # THEFF2= max(0,S2_L[TYPE]/SC2[TYPE]); - self.effSatUpp = pcr.min(1., self.effSatUpp) - self.effSatLow = pcr.min(1., self.effSatLow) + self.effSatUpp = pcr.min(1.0, self.effSatUpp) + self.effSatLow = pcr.min(1.0, self.effSatLow) self.effSatUpp = pcr.cover(self.effSatUpp, 1.0) self.effSatLow = pcr.cover(self.effSatLow, 1.0) @@ -1903,12 +1891,12 @@ # ~ self.parameters.campbellBeta2*self.parameters.KSat2) # DW's code # self.kUnsatUpp = pcr.max( - 0., + 0.0, (self.effSatUpp ** self.parameters.campbellBetaUpp) * self.parameters.kSatUpp, ) # original Rens's code: KTHEFF1= max(0,THEFF1**BCB1[TYPE]*KS1[TYPE]) self.kUnsatLow = pcr.max( - 0., + 0.0, (self.effSatLow ** self.parameters.campbellBetaLow) * self.parameters.kSatLow, ) # original Rens's code: KTHEFF2= max(0,THEFF2**BCB2[TYPE]*KS2[TYPE]) @@ -1933,7 +1921,7 @@ self.gradientUppLow = pcr.max( 0.0, (self.matricSuctionUpp - self.matricSuctionLow) - * 2. + * 2.0 / (self.parameters.thickUpp + self.parameters.thickLow) - pcr.scalar(1.0), ) @@ -1953,41 +1941,41 @@ # ~ pcr.max(self.maxRootDepth-self.parameters.storCapUpp,0.)) # DW's code (using storCapUpp and storCapLow). Edwin does not agree with this. # self.readAvlWater = ( - pcr.max(0., self.effSatUpp - self.parameters.effSatAtWiltPointUpp) + pcr.max(0.0, self.effSatUpp - self.parameters.effSatAtWiltPointUpp) ) * ( self.parameters.satVolMoistContUpp - self.parameters.resVolMoistContUpp ) * pcr.min( self.parameters.thickUpp, self.maxRootDepth ) + ( - pcr.max(0., self.effSatLow - self.parameters.effSatAtWiltPointLow) + pcr.max(0.0, self.effSatLow - self.parameters.effSatAtWiltPointLow) ) * ( self.parameters.satVolMoistContLow - self.parameters.resVolMoistContLow ) * pcr.min( self.parameters.thickLow, - pcr.max(self.maxRootDepth - self.parameters.thickUpp, 0.), + pcr.max(self.maxRootDepth - self.parameters.thickUpp, 0.0), ) # Edwin modified this line. Edwin uses soil thickness thickUpp & thickLow (instead of storCapUpp & storCapLow). # And Rens support this. if self.numberOfLayers == 3: # initial total soilWaterStorage self.soilWaterStorage = pcr.max( - 0., self.storUpp000005 + self.storUpp005030 + self.storLow030150 + 0.0, self.storUpp000005 + self.storUpp005030 + self.storLow030150 ) # effective degree of saturation (-) self.effSatUpp000005 = pcr.max( - 0., self.storUpp000005 / self.parameters.storCapUpp000005 + 0.0, self.storUpp000005 / self.parameters.storCapUpp000005 ) self.effSatUpp005030 = pcr.max( - 0., self.storUpp005030 / self.parameters.storCapUpp005030 + 0.0, self.storUpp005030 / self.parameters.storCapUpp005030 ) self.effSatLow030150 = pcr.max( - 0., self.storLow030150 / self.parameters.storCapLow030150 + 0.0, self.storLow030150 / self.parameters.storCapLow030150 ) - self.effSatUpp000005 = pcr.min(1., self.effSatUpp000005) - self.effSatUpp005030 = pcr.min(1., self.effSatUpp005030) - self.effSatLow030150 = pcr.min(1., self.effSatLow030150) + self.effSatUpp000005 = pcr.min(1.0, self.effSatUpp000005) + self.effSatUpp005030 = pcr.min(1.0, self.effSatUpp005030) + self.effSatLow030150 = pcr.min(1.0, self.effSatLow030150) # matricSuction (m) self.matricSuctionUpp000005 = self.parameters.airEntryValueUpp000005 * ( @@ -2005,17 +1993,17 @@ # kUnsat (m.day-1): unsaturated hydraulic conductivity self.kUnsatUpp000005 = pcr.max( - 0., + 0.0, (self.effSatUpp000005 ** self.parameters.campbellBetaUpp000005) * self.parameters.kSatUpp000005, ) self.kUnsatUpp005030 = pcr.max( - 0., + 0.0, (self.effSatUpp005030 ** self.parameters.campbellBetaUpp005030) * self.parameters.kSatUpp005030, ) self.kUnsatLow030150 = pcr.max( - 0., + 0.0, (self.effSatLow030150 ** self.parameters.campbellBetaLow030150) * self.parameters.kSatLow030150, ) @@ -2058,26 +2046,26 @@ # gradient for capillary rise (index indicating target store to its underlying store) # between Upp000005Upp005030 self.gradientUpp000005Upp005030 = pcr.max( - 0., - 2. + 0.0, + 2.0 * (self.matricSuctionUpp000005 - self.matricSuctionUpp005030) / (self.parameters.thickUpp000005 + self.parameters.thickUpp005030) - - 1., + - 1.0, ) # between Upp005030Low030150 self.gradientUpp005030Low030150 = pcr.max( - 0., - 2. + 0.0, + 2.0 * (self.matricSuctionUpp005030 - self.matricSuctionLow030150) / (self.parameters.thickUpp005030 + self.parameters.thickLow030150) - - 1., + - 1.0, ) # readily available water in the root zone (upper soil layers) self.readAvlWater = ( ( pcr.max( - 0., + 0.0, self.effSatUpp000005 - self.parameters.effSatAtWiltPointUpp000005, ) @@ -2089,7 +2077,7 @@ * pcr.min(self.parameters.thickUpp000005, self.maxRootDepth) + ( pcr.max( - 0., + 0.0, self.effSatUpp005030 - self.parameters.effSatAtWiltPointUpp005030, ) @@ -2104,7 +2092,7 @@ ) + ( pcr.max( - 0., + 0.0, self.effSatLow030150 - self.parameters.effSatAtWiltPointLow030150, ) @@ -2115,7 +2103,7 @@ ) * pcr.min( self.parameters.thickLow030150, - pcr.max(self.maxRootDepth - self.parameters.thickUpp005030, 0.), + pcr.max(self.maxRootDepth - self.parameters.thickUpp005030, 0.0), ) ) @@ -2136,14 +2124,14 @@ ): # irrigation water demand (unit: m/day) for paddy and non-paddy - self.irrGrossDemand = pcr.scalar(0.) + self.irrGrossDemand = pcr.scalar(0.0) if ( self.name == "irrPaddy" or self.name == "irr_paddy" ) and self.includeIrrigation: self.irrGrossDemand = pcr.ifthenelse( self.cropKC > 0.75, pcr.max(0.0, self.minTopWaterLayer - (self.topWaterLayer)), - 0., + 0.0, ) # a function of cropKC (evaporation and transpiration), # topWaterLayer (water available in the irrigation field) @@ -2160,7 +2148,7 @@ adjDeplFactor = pcr.max( 0.1, pcr.min( - 0.8, (self.cropDeplFactor + 0.04 * (5. - self.totalPotET * 1000.)) + 0.8, (self.cropDeplFactor + 0.04 * (5.0 - self.totalPotET * 1000.0)) ), ) # original formula based on Allen et al. (1998) # see: http://www.fao.org/docrep/x0490e/x0490e0e.htm# @@ -2188,9 +2176,9 @@ 0.0, self.totAvlWater * self.irrigation_factor - self.readAvlWater, ), - 0., + 0.0, ), - 0., + 0.0, ) # irrigation demand is implemented only if there is deficit in transpiration and/or evaporation @@ -2307,7 +2295,7 @@ self.irrGrossDemand = pcr.min(maximum_demand, self.irrGrossDemand) # ignore small irrigation demand (less than 1 mm) - self.irrGrossDemand = pcr.rounddown(self.irrGrossDemand * 1000.) / 1000. + self.irrGrossDemand = pcr.rounddown(self.irrGrossDemand * 1000.0) / 1000.0 # irrigation demand is only calculated for areas with fracVegCover > 0 # DO WE NEED THIS ? self.irrGrossDemand = pcr.ifthenelse( @@ -2383,7 +2371,7 @@ ), allocation_zones=allocSegments, zone_area=self.segmentArea, - high_volume_treshold=1000000., + high_volume_treshold=1000000.0, debug_water_balance=True, extra_info_for_water_balance_reporting=str(currTimeStep.fulldate), landmask=self.landmask, @@ -2552,7 +2540,7 @@ available_water_volume=pcr.max(0.00, routing.readAvlChannelStorage), allocation_zones=allocSegments, zone_area=self.segmentArea, - high_volume_treshold=1000000., + high_volume_treshold=1000000.0, debug_water_balance=True, extra_info_for_water_balance_reporting=str(currTimeStep.fulldate), landmask=self.landmask, @@ -2703,7 +2691,7 @@ ) # estimate of total groundwater abstraction (m3) from the last 365 days: - tolerating_days = 0. + tolerating_days = 0.0 annualGroundwaterAbstraction = ( groundwater.avgAbstraction * routing.cellArea @@ -2819,7 +2807,7 @@ ), allocation_zones=groundwater.allocSegments, zone_area=groundwater.segmentArea, - high_volume_treshold=1000000., + high_volume_treshold=1000000.0, debug_water_balance=True, extra_info_for_water_balance_reporting=str(currTimeStep.fulldate), landmask=self.landmask, @@ -3026,7 +3014,7 @@ ) # - ignore small irrigation demand (less than 1 mm) correctedRemainingIrrigation = ( - pcr.rounddown(correctedRemainingIrrigation * 1000.) / 1000. + pcr.rounddown(correctedRemainingIrrigation * 1000.0) / 1000.0 ) # the (corrected) remaining total demand (limited to self.potFossilGroundwaterAbstract) @@ -3123,15 +3111,9 @@ # Note: If limitFossilGroundwaterAbstraction == False, # allocation of fossil groundwater abstraction is not needed. - msg = ( - "Fossil groundwater abstractions are without limit for satisfying local demand. " - ) - msg = ( - "Allocation for fossil groundwater abstraction is NOT needed/implemented. " - ) - msg += ( - "However, the fossil groundwater abstraction rate still consider the maximumDailyGroundwaterAbstraction." - ) + msg = "Fossil groundwater abstractions are without limit for satisfying local demand. " + msg = "Allocation for fossil groundwater abstraction is NOT needed/implemented. " + msg += "However, the fossil groundwater abstraction rate still consider the maximumDailyGroundwaterAbstraction." logger.debug(msg) # fossil groundwater abstraction (unit: m/day) @@ -3194,7 +3176,7 @@ ), allocation_zones=groundwater.allocSegments, zone_area=groundwater.segmentArea, - high_volume_treshold=1000000., + high_volume_treshold=1000000.0, debug_water_balance=True, extra_info_for_water_balance_reporting=str( currTimeStep.fulldate @@ -3368,7 +3350,7 @@ * self.livestockWaterWithdrawal ) # - ignore very small return flow (less than 0.1 mm) - self.nonIrrReturnFlow = pcr.rounddown(self.nonIrrReturnFlow * 10000.) / 10000. + self.nonIrrReturnFlow = pcr.rounddown(self.nonIrrReturnFlow * 10000.0) / 10000.0 self.nonIrrReturnFlow = pcr.min(self.nonIrrReturnFlow, self.nonIrrGrossDemand) if self.debugWaterBalance: @@ -3457,11 +3439,11 @@ self.rootZoneWaterStorageMin, iniWaterStorage ) # Pn = Pn-max(WMIN[TYPE],W[TYPE]); soilWaterStorage = pcr.ifthenelse( - Pn < 0., + Pn < 0.0, self.rootZoneWaterStorageMin + Pn, pcr.max(iniWaterStorage, self.rootZoneWaterStorageMin), ) # W[TYPE]= if(Pn<0,WMIN[TYPE]+Pn,max(W[TYPE],WMIN[TYPE])); - Pn = pcr.max(0., Pn) # Pn = max(0,Pn); + Pn = pcr.max(0.0, Pn) # Pn = max(0,Pn); # DW = pcr.max( 0.0, self.parameters.rootZoneWaterStorageCap - soilWaterStorage @@ -3476,11 +3458,11 @@ ) self.WFRACB = WFRAC ** ( - 1. / (1. + self.arnoBeta) + 1.0 / (1.0 + self.arnoBeta) ) # WFRACB = WFRAC**(1/(1+BCF[TYPE])); # self.satAreaFrac = pcr.ifthenelse( - self.WFRACB > 0., 1. - self.WFRACB ** self.arnoBeta, 1. + self.WFRACB > 0.0, 1.0 - self.WFRACB ** self.arnoBeta, 1.0 ) # SATFRAC_L = if(WFRACB>0,1-WFRACB**BCF[TYPE],1); # make sure that 0.0 <= satAreaFrac <= 1.0 self.satAreaFrac = pcr.min(self.satAreaFrac, 1.0) @@ -3544,7 +3526,7 @@ # directRunoff condition = ( - (self.arnoBeta + pcr.scalar(1.)) + (self.arnoBeta + pcr.scalar(1.0)) * self.rootZoneWaterStorageRange * self.WFRACB ) @@ -3562,9 +3544,9 @@ self.rootZoneWaterStorageRange * ( self.WFRACB - - Pn / ((self.arnoBeta + 1.) * self.rootZoneWaterStorageRange) + - Pn / ((self.arnoBeta + 1.0) * self.rootZoneWaterStorageRange) ) - ** (self.arnoBeta + 1.), + ** (self.arnoBeta + 1.0), ), ) # Q1_L[TYPE]= max(0,Pn-(WMAX[TYPE]+P2_L[TYPE]-W[TYPE])+ @@ -3579,7 +3561,7 @@ # update topWaterLayer (above soil) # - with netLqWaterToSoil and irrGrossDemand - self.topWaterLayer += pcr.max(0., self.netLqWaterToSoil + self.irrGrossDemand) + self.topWaterLayer += pcr.max(0.0, self.netLqWaterToSoil + self.irrGrossDemand) # potential evaporation for openWaterEvap remainingPotETP = ( @@ -3588,13 +3570,13 @@ # remainingPotETP = self.totalPotET # DW, RvB, and YW use self.totalPotETP # openWaterEvap is ONLY for evaporation from paddy field areas - self.openWaterEvap = pcr.spatial(pcr.scalar(0.)) + self.openWaterEvap = pcr.spatial(pcr.scalar(0.0)) if ( self.name == "irrPaddy" or self.name == "irr_paddy" ): # only open water evaporation from the paddy field self.openWaterEvap = pcr.min( - pcr.max(0., self.topWaterLayer), remainingPotETP + pcr.max(0.0, self.topWaterLayer), remainingPotETP ) # update potBareSoilEvap & potTranspiration (after openWaterEvap) @@ -3619,7 +3601,7 @@ ) # update top water layer after openWaterEvap - self.topWaterLayer = pcr.max(0., self.topWaterLayer - self.openWaterEvap) + self.topWaterLayer = pcr.max(0.0, self.topWaterLayer - self.openWaterEvap) def calculateInfiltration(self): @@ -3640,7 +3622,7 @@ ) and self.includeIrrigation: infiltration_loss = pcr.max( self.design_percolation_loss, - ((1. / self.irrigationEfficiencyUsed) - 1.) * self.topWaterLayer, + ((1.0 / self.irrigationEfficiencyUsed) - 1.0) * self.topWaterLayer, ) self.infiltration = pcr.min(infiltration_loss, self.infiltration) @@ -3667,12 +3649,12 @@ self.adjRootFrUpp * self.storUpp + self.adjRootFrLow * self.storLow, ) transpFracUpp = pcr.ifthenelse( - (self.storUpp + self.storLow) > 0., + (self.storUpp + self.storLow) > 0.0, self.adjRootFrUpp * self.storUpp / dividerTranspFracs, self.adjRootFrUpp, ) transpFracLow = pcr.ifthenelse( - (self.storUpp + self.storLow) > 0., + (self.storUpp + self.storLow) > 0.0, self.adjRootFrLow * self.storLow / dividerTranspFracs, self.adjRootFrLow, ) # WF1= if((S1_L[TYPE]+S2_L[TYPE])>0,RFW1[TYPE]*S1_L[TYPE]/ @@ -3687,17 +3669,17 @@ + self.adjRootFrLow030150 * self.storLow030150, ) transpFracUpp000005 = pcr.ifthenelse( - (self.storUpp000005 + self.storUpp005030 + self.storLow030150) > 0., + (self.storUpp000005 + self.storUpp005030 + self.storLow030150) > 0.0, self.adjRootFrUpp000005 * self.storUpp000005 / dividerTranspFracs, self.adjRootFrUpp000005, ) transpFracUpp005030 = pcr.ifthenelse( - (self.storUpp000005 + self.storUpp005030 + self.storLow030150) > 0., + (self.storUpp000005 + self.storUpp005030 + self.storLow030150) > 0.0, self.adjRootFrUpp005030 * self.storUpp005030 / dividerTranspFracs, self.adjRootFrUpp005030, ) transpFracLow030150 = pcr.ifthenelse( - (self.storUpp000005 + self.storUpp005030 + self.storLow030150) > 0., + (self.storUpp000005 + self.storUpp005030 + self.storLow030150) > 0.0, self.adjRootFrLow030150 * self.storLow030150 / dividerTranspFracs, self.adjRootFrLow030150, ) @@ -3713,15 +3695,15 @@ self.parameters.rootZoneWaterStorageCap + self.arnoBeta * self.rootZoneWaterStorageRange - * (1. - (1. + self.arnoBeta) / self.arnoBeta * self.WFRACB) + * (1.0 - (1.0 + self.arnoBeta) / self.arnoBeta * self.WFRACB) ) / ( self.parameters.rootZoneWaterStorageCap - + self.arnoBeta * self.rootZoneWaterStorageRange * (1. - self.WFRACB) + + self.arnoBeta * self.rootZoneWaterStorageRange * (1.0 - self.WFRACB) ) # original Rens's line: # FRACTA[TYPE] = (WMAX[TYPE]+BCF[TYPE]*WRANGE[TYPE]*(1-(1+BCF[TYPE])/BCF[TYPE]*WFRACB))/ # (WMAX[TYPE]+BCF[TYPE]*WRANGE[TYPE]*(1-WFRACB)); - relActTranspiration = (1. - self.satAreaFrac) / ( - 1. + relActTranspiration = (1.0 - self.satAreaFrac) / ( + 1.0 + (pcr.max(0.01, relActTranspiration) / self.effSatAt50) ** (self.effPoreSizeBetaAt50 * pcr.scalar(-3.0)) ) # original Rens's line: @@ -3794,14 +3776,14 @@ if self.numberOfLayers == 2 and returnTotalEstimation == False: actBareSoilEvap = self.satAreaFrac * pcr.min( self.potBareSoilEvap, self.parameters.kSatUpp - ) + (1. - self.satAreaFrac) * pcr.min( + ) + (1.0 - self.satAreaFrac) * pcr.min( self.potBareSoilEvap, self.kUnsatUpp ) # ES_a[TYPE] = SATFRAC_L *min(ES_p[TYPE],KS1[TYPE]*Duration*timeslice())+ # (1-SATFRAC_L)*min(ES_p[TYPE],KTHEFF1*Duration*timeslice()); if self.numberOfLayers == 3 and returnTotalEstimation == False: actBareSoilEvap = self.satAreaFrac * pcr.min( self.potBareSoilEvap, self.parameters.kSatUpp000005 - ) + (1. - self.satAreaFrac) * pcr.min( + ) + (1.0 - self.satAreaFrac) * pcr.min( self.potBareSoilEvap, self.kUnsatUpp000005 ) actBareSoilEvap = pcr.max(0.0, actBareSoilEvap) @@ -3857,17 +3839,17 @@ if self.numberOfLayers == 2: # - percolation from storUpp to storLow - self.percUpp = self.kThVertUppLow * 1. + self.percUpp = self.kThVertUppLow * 1.0 self.percUpp = pcr.ifthenelse( self.effSatUpp > self.parameters.effSatAtFieldCapUpp, pcr.min( - pcr.max(0., self.effSatUpp - self.parameters.effSatAtFieldCapUpp) + pcr.max(0.0, self.effSatUpp - self.parameters.effSatAtFieldCapUpp) * self.parameters.storCapUpp, self.percUpp, ), self.percUpp, ) + pcr.max( - 0., self.infiltration - (self.parameters.storCapUpp - self.storUpp) + 0.0, self.infiltration - (self.parameters.storCapUpp - self.storUpp) ) # original Rens's line: # P1_L[TYPE] = KTHVERT*Duration*timeslice(); # P1_L[TYPE] = if(THEFF1 > THEFF1_FC[TYPE],min(max(0,THEFF1-THEFF1_FC[TYPE])*SC1[TYPE], @@ -3882,7 +3864,7 @@ # - capillary rise to storUpp from storLow self.capRiseUpp = pcr.min( - pcr.max(0., self.parameters.effSatAtFieldCapUpp - self.effSatUpp) + pcr.max(0.0, self.parameters.effSatAtFieldCapUpp - self.effSatUpp) * self.parameters.storCapUpp, self.kThVertUppLow * self.gradientUppLow, ) # original Rens's line: @@ -3893,7 +3875,7 @@ 0.5 * (self.satAreaFrac + capRiseFrac) * pcr.min( - (1. - self.effSatLow) + (1.0 - self.effSatLow) * pcr.sqrt(self.parameters.kSatLow * self.kUnsatLow), pcr.max(0.0, self.parameters.effSatAtFieldCapLow - self.effSatLow) * self.parameters.storCapLow, @@ -3913,19 +3895,20 @@ ) self.interflow = pcr.max( self.parameters.interflowConcTime * percToInterflow - + (pcr.scalar(1.) - self.parameters.interflowConcTime) * self.interflow, + + (pcr.scalar(1.0) - self.parameters.interflowConcTime) + * self.interflow, 0.0, ) if self.numberOfLayers == 3: # - percolation from storUpp000005 to storUpp005030 (m) - self.percUpp000005 = self.kThVertUpp000005Upp005030 * 1. + self.percUpp000005 = self.kThVertUpp000005Upp005030 * 1.0 self.percUpp000005 = pcr.ifthenelse( self.effSatUpp000005 > self.parameters.effSatAtFieldCapUpp000005, pcr.min( pcr.max( - 0., + 0.0, self.effSatUpp000005 - self.parameters.effSatAtFieldCapUpp000005, ) @@ -3934,18 +3917,18 @@ ), self.percUpp000005, ) + pcr.max( - 0., + 0.0, self.infiltration - (self.parameters.storCapUpp000005 - self.storUpp000005), ) # - percolation from storUpp005030 to storLow030150 (m) - self.percUpp005030 = self.kThVertUpp005030Low030150 * 1. + self.percUpp005030 = self.kThVertUpp005030Low030150 * 1.0 self.percUpp005030 = pcr.ifthenelse( self.effSatUpp005030 > self.parameters.effSatAtFieldCapUpp005030, pcr.min( pcr.max( - 0., + 0.0, self.effSatUpp005030 - self.parameters.effSatAtFieldCapUpp005030, ) @@ -3954,7 +3937,7 @@ ), self.percUpp005030, ) + pcr.max( - 0., + 0.0, self.percUpp000005 - (self.parameters.storCapUpp005030 - self.storUpp005030), ) @@ -3970,7 +3953,8 @@ # - capillary rise to storUpp000005 from storUpp005030 (m) self.capRiseUpp000005 = pcr.min( pcr.max( - 0., self.parameters.effSatAtFieldCapUpp000005 - self.effSatUpp000005 + 0.0, + self.parameters.effSatAtFieldCapUpp000005 - self.effSatUpp000005, ) * self.parameters.storCapUpp000005, self.kThVertUpp000005Upp005030 * self.gradientUpp000005Upp005030, @@ -3979,7 +3963,8 @@ # - capillary rise to storUpp005030 from storLow030150 (m) self.capRiseUpp005030 = pcr.min( pcr.max( - 0., self.parameters.effSatAtFieldCapUpp005030 - self.effSatUpp005030 + 0.0, + self.parameters.effSatAtFieldCapUpp005030 - self.effSatUpp005030, ) * self.parameters.storCapUpp005030, self.kThVertUpp005030Low030150 * self.gradientUpp005030Low030150, @@ -3990,7 +3975,7 @@ 0.5 * (self.satAreaFrac + capRiseFrac) * pcr.min( - (1. - self.effSatLow030150) + (1.0 - self.effSatLow030150) * pcr.sqrt(self.parameters.kSatLow030150 * self.kUnsatLow030150), pcr.max( 0.0, @@ -4014,7 +3999,8 @@ ) self.interflow = pcr.max( self.parameters.interflowConcTime * percToInterflow - + (pcr.scalar(1.) - self.parameters.interflowConcTime) * self.interflow, + + (pcr.scalar(1.0) - self.parameters.interflowConcTime) + * self.interflow, 0.0, ) @@ -4031,7 +4017,7 @@ ADJUST = pcr.ifthenelse( ADJUST > 0.0, pcr.min(1.0, pcr.max(0.0, self.storUpp + self.infiltration) / ADJUST), - 0., + 0.0, ) ADJUST = pcr.cover(ADJUST, 0.0) self.actBareSoilEvap = ADJUST * self.actBareSoilEvap @@ -4049,7 +4035,7 @@ ADJUST = pcr.ifthenelse( ADJUST > 0.0, pcr.min(1.0, pcr.max(0.0, self.storLow + self.percUpp) / ADJUST), - 0., + 0.0, ) ADJUST = pcr.cover(ADJUST, 0.0) self.percLow = ADJUST * self.percLow @@ -4079,9 +4065,9 @@ # also limited with reducedCapRise # self.capRiseLow = pcr.max( - 0., + 0.0, pcr.min( - pcr.max(0., groundwater.storGroundwater - self.reducedCapRise), + pcr.max(0.0, groundwater.storGroundwater - self.reducedCapRise), self.capRiseLow, ), ) @@ -4110,7 +4096,7 @@ pcr.min( 1.0, pcr.max(0.0, self.storUpp000005 + self.infiltration) / ADJUST ), - 0., + 0.0, ) self.actBareSoilEvap = ADJUST * self.actBareSoilEvap self.percUpp000005 = ADJUST * self.percUpp000005 @@ -4123,7 +4109,7 @@ pcr.min( 1.0, pcr.max(0.0, self.storUpp005030 + self.percUpp000005) / ADJUST ), - 0., + 0.0, ) self.percUpp005030 = ADJUST * self.percUpp005030 self.actTranspiUpp005030 = ADJUST * self.actTranspiUpp005030 @@ -4135,7 +4121,7 @@ pcr.min( 1.0, pcr.max(0.0, self.storLow030150 + self.percUpp005030) / ADJUST ), - 0., + 0.0, ) self.percLow030150 = ADJUST * self.percLow030150 self.actTranspiLow030150 = ADJUST * self.actTranspiLow030150 @@ -4145,9 +4131,9 @@ # and also limited with reducedCapRise # self.capRiseLow030150 = pcr.max( - 0., + 0.0, pcr.min( - pcr.max(0., groundwater.storGroundwater - self.reducedCapRise), + pcr.max(0.0, groundwater.storGroundwater - self.reducedCapRise), self.capRiseLow030150, ), ) @@ -4180,7 +4166,7 @@ # for irrigation areas: interflow will be minimized if self.name.startswith("irr"): - self.interflow = 0. + self.interflow = 0.0 # ~ # deep percolation should consider losses during application in non paddy areas # ~ if self.name == 'irrNonPaddy': @@ -4235,7 +4221,7 @@ deep_percolation_loss = pcr.max( deep_percolation_loss, pcr.max(0.0, self.storLow) - * ((1. / self.irrigationEfficiencyUsed) - 1.), + * ((1.0 / self.irrigationEfficiencyUsed) - 1.0), ) self.percLow = pcr.ifthenelse( self.cropKC > startingKC, deep_percolation_loss, self.percLow @@ -4246,7 +4232,7 @@ deep_percolation_loss = pcr.max( deep_percolation_loss, pcr.max(0.0, self.storLow030150) - * ((1. / self.irrigationEfficiencyUsed) - 1.), + * ((1.0 / self.irrigationEfficiencyUsed) - 1.0), ) self.percLow030150 = pcr.ifthenelse( self.cropKC > startingKC, deep_percolation_loss, self.percLow030150 @@ -4338,7 +4324,7 @@ ADJUST = pcr.ifthenelse( ADJUST > 0.0, pcr.min(1.0, pcr.max(0.0, self.storUpp + self.infiltration) / ADJUST), - 0., + 0.0, ) self.actBareSoilEvap = ADJUST * self.actBareSoilEvap self.actTranspiUpp = ADJUST * self.potTranspiration @@ -4378,7 +4364,7 @@ ADJUST = pcr.ifthenelse( ADJUST > 0.0, pcr.min(1.0, pcr.max(0.0, self.storLow + self.percUpp) / ADJUST), - 0., + 0.0, ) self.actTranspiLow = ADJUST * remainingPotET # - percolation and interflow fluxes depend on the remaining water @@ -4390,17 +4376,17 @@ pcr.max(0.0, self.storLow + self.percUpp - self.actTranspiLow) / ADJUST, ), - 0., + 0.0, ) self.percLow = ADJUST * self.percLow self.interflow = ADJUST * self.interflow # capillary rise to storLow is limited to available storGroundwater # - also limited with reducedCapRise self.capRiseLow = pcr.max( - 0., + 0.0, pcr.min( - pcr.max(0., groundwater.storGroundwater - self.reducedCapRise), + pcr.max(0.0, groundwater.storGroundwater - self.reducedCapRise), self.capRiseLow, ), ) @@ -4427,7 +4413,7 @@ pcr.min( 1.0, pcr.max(0.0, self.storUpp000005 + self.infiltration) / ADJUST ), - 0., + 0.0, ) self.actBareSoilEvap = ADJUST * self.actBareSoilEvap self.actTranspiUpp000005 = ADJUST * self.potTranspiration @@ -4469,7 +4455,7 @@ pcr.min( 1.0, pcr.max(0.0, self.storUpp005030 + self.percUpp000005) / ADJUST ), - 0., + 0.0, ) self.actTranspiUpp005030 = ADJUST * remainingPotET # - percolation fluxes depend on the remaining water @@ -4490,7 +4476,7 @@ pcr.min( 1.0, pcr.max(0.0, self.storLow030150 + self.percUpp005030) / ADJUST ), - 0., + 0.0, ) self.actTranspiLow030150 = ADJUST * remainingPotET # - percolation and interflow fluxes depend on the remaining water @@ -4507,7 +4493,7 @@ ) / ADJUST, ), - 0., + 0.0, ) self.percLow030150 = ADJUST * self.percLow030150 self.interflow = ADJUST * self.interflow @@ -4516,9 +4502,9 @@ # - also limited with reducedCapRise # self.capRiseLow030150 = pcr.max( - 0., + 0.0, pcr.min( - pcr.max(0., groundwater.storGroundwater - self.reducedCapRise), + pcr.max(0.0, groundwater.storGroundwater - self.reducedCapRise), self.capRiseLow030150, ), ) @@ -4559,7 +4545,7 @@ # for irrigation areas: interflow will be minimized if self.name.startswith("irr"): - self.interflow = 0. + self.interflow = 0.0 # an idea: deep percolation should consider losses during application in non paddy areas # @@ -4576,11 +4562,11 @@ ) ADJUST = self.percLow + self.interflow ADJUST = pcr.ifthenelse( - ADJUST > 0., + ADJUST > 0.0, pcr.min(maxADJUST, pcr.max(0.0, deep_percolation) / ADJUST), - 0., + 0.0, ) - ADJUST = pcr.ifthenelse(self.cropKC > startingCropKC, ADJUST, 1.) + ADJUST = pcr.ifthenelse(self.cropKC > startingCropKC, ADJUST, 1.0) self.percLow = ADJUST * self.percLow self.interflow = ADJUST * self.interflow if self.numberOfLayers == 3: @@ -4589,11 +4575,11 @@ ) ADJUST = self.percLow030150 + self.interflow ADJUST = pcr.ifthenelse( - ADJUST > 0., + ADJUST > 0.0, pcr.min(maxADJUST, pcr.max(0.0, deep_percolation) / ADJUST), - 0., + 0.0, ) - ADJUST = pcr.ifthenelse(self.cropKC > startingCropKC, ADJUST, 1.) + ADJUST = pcr.ifthenelse(self.cropKC > startingCropKC, ADJUST, 1.0) self.percLow030150 = ADJUST * self.percLow030150 self.interflow = ADJUST * self.interflow @@ -4607,7 +4593,7 @@ ADJUST = pcr.ifthenelse( ADJUST > 0.0, pcr.min(1.0, pcr.max(0.0, self.storUpp + self.infiltration) / ADJUST), - 0., + 0.0, ) self.actBareSoilEvap = ADJUST * self.actBareSoilEvap self.actTranspiUpp = ADJUST * self.potTranspiration @@ -4647,7 +4633,7 @@ ADJUST = pcr.ifthenelse( ADJUST > 0.0, pcr.min(1.0, pcr.max(0.0, self.storLow + self.percUpp) / ADJUST), - 0., + 0.0, ) self.actTranspiLow = ADJUST * remainingPotET # - percolation and interflow fluxes depend on the remaining water @@ -4659,17 +4645,17 @@ pcr.max(0.0, self.storLow + self.percUpp - self.actTranspiLow) / ADJUST, ), - 0., + 0.0, ) self.percLow = ADJUST * self.percLow self.interflow = ADJUST * self.interflow # capillary rise to storLow is limited to available storGroundwater # - also limited with reducedCapRise self.capRiseLow = pcr.max( - 0., + 0.0, pcr.min( - pcr.max(0., groundwater.storGroundwater - self.reducedCapRise), + pcr.max(0.0, groundwater.storGroundwater - self.reducedCapRise), self.capRiseLow, ), ) @@ -4696,7 +4682,7 @@ pcr.min( 1.0, pcr.max(0.0, self.storUpp000005 + self.infiltration) / ADJUST ), - 0., + 0.0, ) self.actBareSoilEvap = ADJUST * self.actBareSoilEvap self.actTranspiUpp000005 = ADJUST * self.potTranspiration @@ -4738,7 +4724,7 @@ pcr.min( 1.0, pcr.max(0.0, self.storUpp005030 + self.percUpp000005) / ADJUST ), - 0., + 0.0, ) self.actTranspiUpp005030 = ADJUST * remainingPotET # - percolation fluxes depend on the remaining water @@ -4759,7 +4745,7 @@ pcr.min( 1.0, pcr.max(0.0, self.storLow030150 + self.percUpp005030) / ADJUST ), - 0., + 0.0, ) self.actTranspiLow030150 = ADJUST * remainingPotET # - percolation and interflow fluxes depend on the remaining water @@ -4776,7 +4762,7 @@ ) / ADJUST, ), - 0., + 0.0, ) self.percLow030150 = ADJUST * self.percLow030150 self.interflow = ADJUST * self.interflow @@ -4785,9 +4771,9 @@ # - also limited with reducedCapRise # self.capRiseLow030150 = pcr.max( - 0., + 0.0, pcr.min( - pcr.max(0., groundwater.storGroundwater - self.reducedCapRise), + pcr.max(0.0, groundwater.storGroundwater - self.reducedCapRise), self.capRiseLow030150, ), ) @@ -4832,7 +4818,7 @@ # - capRiseUpp # self.storLow = pcr.max( - 0., + 0.0, self.storLow + self.percUpp + self.capRiseLow @@ -4848,25 +4834,27 @@ if self.allowNegativePercolation: # this is as defined in the original oldcalc script of Rens self.percUpp = percUpp - pcr.max( - 0., self.storLow - self.parameters.storCapLow + 0.0, self.storLow - self.parameters.storCapLow ) # Rens's line: P1_L[TYPE] = P1_L[TYPE]-max(0,S2_L[TYPE]-SC2[TYPE]); # PS: In the original Rens's code, P1 can be negative. else: # alternative, proposed by Edwin: avoid negative percolation self.percUpp = pcr.max( - 0., percUpp - pcr.max(0., self.storLow - self.parameters.storCapLow) + 0.0, + percUpp - pcr.max(0.0, self.storLow - self.parameters.storCapLow), ) self.storLow = self.storLow - percUpp + self.percUpp # If necessary, reduce capRise input: capRiseLow = self.capRiseLow self.capRiseLow = pcr.max( - 0., - capRiseLow - pcr.max(0., self.storLow - self.parameters.storCapLow), + 0.0, + capRiseLow + - pcr.max(0.0, self.storLow - self.parameters.storCapLow), ) self.storLow = self.storLow - capRiseLow + self.capRiseLow # If necessary, increase interflow outflow: - addInterflow = pcr.max(0., self.storLow - self.parameters.storCapLow) + addInterflow = pcr.max(0.0, self.storLow - self.parameters.storCapLow) self.interflow += addInterflow self.storLow -= addInterflow # @@ -4881,7 +4869,7 @@ # - actBareSoilEvap # self.storUpp = pcr.max( - 0., + 0.0, self.storUpp + self.infiltration + self.capRiseUpp @@ -4890,12 +4878,12 @@ # (P1_L[TYPE]+T_a1[TYPE]+ES_a[TYPE])); #* # # any excess above storCapUpp is handed to topWaterLayer - self.satExcess = pcr.max(0., self.storUpp - self.parameters.storCapUpp) + self.satExcess = pcr.max(0.0, self.storUpp - self.parameters.storCapUpp) self.topWaterLayer = self.topWaterLayer + self.satExcess # any excess above minTopWaterLayer is released as directRunoff self.directRunoff = self.directRunoff + pcr.max( - 0., self.topWaterLayer - self.minTopWaterLayer + 0.0, self.topWaterLayer - self.minTopWaterLayer ) # make sure that storage capacities are not exceeded @@ -4938,7 +4926,7 @@ # - capRiseUpp005030 # self.storLow030150 = pcr.max( - 0., + 0.0, self.storLow030150 + self.percUpp005030 + self.capRiseLow030150 @@ -4953,26 +4941,26 @@ # If necessary, reduce percolation input: percUpp005030 = self.percUpp005030 self.percUpp005030 = pcr.max( - 0., + 0.0, percUpp005030 - - pcr.max(0., self.storLow030150 - self.parameters.storCapLow030150), + - pcr.max(0.0, self.storLow030150 - self.parameters.storCapLow030150), ) self.storLow030150 = self.storLow030150 - percUpp005030 + self.percUpp005030 # # If necessary, reduce capRise input: capRiseLow030150 = self.capRiseLow030150 self.capRiseLow030150 = pcr.max( - 0., + 0.0, capRiseLow030150 - - pcr.max(0., self.storLow030150 - self.parameters.storCapLow030150), + - pcr.max(0.0, self.storLow030150 - self.parameters.storCapLow030150), ) self.storLow030150 = ( self.storLow030150 - capRiseLow030150 + self.capRiseLow030150 ) # # If necessary, increase interflow outflow: addInterflow = pcr.max( - 0., self.storLow030150 - self.parameters.storCapLow030150 + 0.0, self.storLow030150 - self.parameters.storCapLow030150 ) self.interflow += addInterflow self.storLow030150 -= addInterflow @@ -4989,7 +4977,7 @@ # - capRiseUpp000005 # self.storUpp005030 = pcr.max( - 0., + 0.0, self.storUpp005030 + self.percUpp000005 + self.capRiseUpp005030 @@ -5003,26 +4991,26 @@ # If necessary, reduce percolation input: percUpp000005 = self.percUpp000005 self.percUpp000005 = pcr.max( - 0., + 0.0, percUpp000005 - - pcr.max(0., self.storUpp005030 - self.parameters.storCapUpp005030), + - pcr.max(0.0, self.storUpp005030 - self.parameters.storCapUpp005030), ) self.storUpp005030 = self.storUpp005030 - percUpp000005 + self.percUpp000005 # # If necessary, reduce capRise input: capRiseUpp005030 = self.capRiseUpp005030 self.capRiseUpp005030 = pcr.max( - 0., + 0.0, capRiseUpp005030 - - pcr.max(0., self.storUpp005030 - self.parameters.storCapUpp005030), + - pcr.max(0.0, self.storUpp005030 - self.parameters.storCapUpp005030), ) self.storUpp005030 = ( self.storUpp005030 - capRiseUpp005030 + self.capRiseUpp005030 ) # # If necessary, introduce interflow outflow: self.interflowUpp005030 = pcr.max( - 0., self.storUpp005030 - self.parameters.storCapUpp005030 + 0.0, self.storUpp005030 - self.parameters.storCapUpp005030 ) self.storUpp005030 = self.storUpp005030 - self.interflowUpp005030 @@ -5034,7 +5022,7 @@ # - actBareSoilEvap # self.storUpp000005 = pcr.max( - 0., + 0.0, self.storUpp000005 + self.infiltration + self.capRiseUpp000005 @@ -5045,13 +5033,13 @@ # # any excess above storCapUpp is handed to topWaterLayer self.satExcess = pcr.max( - 0., self.storUpp000005 - self.parameters.storCapUpp000005 + 0.0, self.storUpp000005 - self.parameters.storCapUpp000005 ) self.topWaterLayer = self.topWaterLayer + self.satExcess # any excess above minTopWaterLayer is released as directRunoff self.directRunoff = self.directRunoff + pcr.max( - 0., self.topWaterLayer - self.minTopWaterLayer + 0.0, self.topWaterLayer - self.minTopWaterLayer ) # make sure that storage capacities are not exceeded Index: wflow-py/wflow/pcrglobwb/landSurface.py =================================================================== diff -u -r7a07bfcf366e6f498e2e0d4036a15240c3260476 -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/pcrglobwb/landSurface.py (.../landSurface.py) (revision 7a07bfcf366e6f498e2e0d4036a15240c3260476) +++ wflow-py/wflow/pcrglobwb/landSurface.py (.../landSurface.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -131,9 +131,7 @@ self.inputDir = os.path.join( os.path.abspath(Dir), staticmaps ) # iniItems.globalOptions['inputDir'] - self.stateDir = os.path.join( - os.path.abspath(Dir), 'instate' - ) + self.stateDir = os.path.join(os.path.abspath(Dir), "instate") self.landmask = landmask self.startTime = startTime @@ -470,9 +468,7 @@ else: msg = "Using the default set of soil and topo parameters " - msg += ( - "as defined in the landSurfaceOptions of the ini/configuration file." - ) + msg += "as defined in the landSurfaceOptions of the ini/configuration file." self.soil_topo_parameters[coverType] = self.soil_topo_parameters[ "default" @@ -546,9 +542,7 @@ and self.noLandCoverFractionCorrection == False ): self.noLandCoverFractionCorrection = True - msg = ( - "WARNING! No land cover fraction correction will be performed. Please make sure that the 'total' of all fracVegCover adds to one." - ) + msg = "WARNING! No land cover fraction correction will be performed. Please make sure that the 'total' of all fracVegCover adds to one." logger.warning(msg) logger.warning(msg) logger.warning(msg) @@ -1537,15 +1531,21 @@ ] = self.livestockGrossDemand nonIrrigationWaterDemandDict["return_flow_fraction"] = {} nonIrrigationWaterDemandDict["return_flow_fraction"]["domestic"] = pcr.cover( - pcr.min(1.0, pcr.roundup(self.domesticReturnFlowFraction * 1000.) / 1000.), + pcr.min( + 1.0, pcr.roundup(self.domesticReturnFlowFraction * 1000.0) / 1000.0 + ), 1.0, ) nonIrrigationWaterDemandDict["return_flow_fraction"]["industry"] = pcr.cover( - pcr.min(1.0, pcr.roundup(self.industryReturnFlowFraction * 1000.) / 1000.), + pcr.min( + 1.0, pcr.roundup(self.industryReturnFlowFraction * 1000.0) / 1000.0 + ), 1.0, ) nonIrrigationWaterDemandDict["return_flow_fraction"]["livestock"] = pcr.cover( - pcr.min(1.0, pcr.roundup(self.livestockReturnFlowFraction * 1000.) / 1000.), + pcr.min( + 1.0, pcr.roundup(self.livestockReturnFlowFraction * 1000.0) / 1000.0 + ), 1.0, ) @@ -1807,7 +1807,7 @@ averageUpstreamInput + averageBaseflowInput, vos.smallNumber, ) - swAbstractionFraction = pcr.roundup(swAbstractionFraction * 100.) / 100. + swAbstractionFraction = pcr.roundup(swAbstractionFraction * 100.0) / 100.0 swAbstractionFraction = pcr.max(0.0, swAbstractionFraction) swAbstractionFraction = pcr.min(1.0, swAbstractionFraction) @@ -1879,7 +1879,7 @@ ) # using this factor, the minimum value for the following 'data_weight_value' is 0.75 (for swAbstractionFractionDataQuality == 5) data_weight_value = ( pcr.scalar(1.0) - - (pcr.min(5., pcr.max(0.0, swAbstractionFractionDataQuality)) / 10.0) + - (pcr.min(5.0, pcr.max(0.0, swAbstractionFractionDataQuality)) / 10.0) * factor ) @@ -1918,7 +1918,7 @@ # read historical irrigation areas if self.dynamicIrrigationAreaFile.endswith((".nc4", ".nc")): fulldateInString = yearInString + "-01" + "-01" - self.irrigationArea = 10000. * pcr.cover( + self.irrigationArea = 10000.0 * pcr.cover( vos.netcdf2PCRobjClone( self.dynamicIrrigationAreaFile, "irrigationArea", @@ -1935,7 +1935,7 @@ logger.debug( "reading irrigation area map from : " + irrigation_pcraster_file ) - self.irrigationArea = 10000. * pcr.cover( + self.irrigationArea = 10000.0 * pcr.cover( vos.readPCRmapClone( irrigation_pcraster_file, self.cloneMap, self.tmpDir ), @@ -1966,8 +1966,8 @@ # avoid small values self.landCoverObj[coverType].fracVegCover = ( - pcr.rounddown(self.landCoverObj[coverType].fracVegCover * 1000.) - / 1000. + pcr.rounddown(self.landCoverObj[coverType].fracVegCover * 1000.0) + / 1000.0 ) # rescale land cover fractions (for all land cover types): @@ -1990,7 +1990,7 @@ ) other_ids = ( pcr.mapmaximum(self.groundwater_pumping_region_ids) - + pcr.scalar(1000.) + + pcr.scalar(1000.0) + pcr.uniqueid(self.landmask) ) self.groundwater_pumping_region_ids = pcr.cover( @@ -2020,13 +2020,13 @@ ) self.regionalAnnualGroundwaterAbstractionLimit *= ( - 1000. * 1000. * 1000. + 1000.0 * 1000.0 * 1000.0 ) # unit: m3/year self.regionalAnnualGroundwaterAbstractionLimit = pcr.ifthen( self.landmask, self.regionalAnnualGroundwaterAbstractionLimit ) # minimum value (unit: m3/year at the regional scale) - minimum_value = 1000. + minimum_value = 1000.0 self.regionalAnnualGroundwaterAbstractionLimit = pcr.max( minimum_value, self.regionalAnnualGroundwaterAbstractionLimit ) Index: wflow-py/wflow/pcrglobwb/ncConverter.py =================================================================== diff -u -r90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/pcrglobwb/ncConverter.py (.../ncConverter.py) (revision 90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a) +++ wflow-py/wflow/pcrglobwb/ncConverter.py (.../ncConverter.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -59,9 +59,7 @@ and iniItems.reportingOptions["netcdf_y_orientation_follow_cf_convention"] == "True" ): - msg = ( - "Latitude (y) orientation for output netcdf files start from the bottom to top." - ) + 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)) @@ -214,7 +212,9 @@ date_time = rootgrp.variables["time"] if posCnt == None: posCnt = len(date_time) - date_time[posCnt] = cftime.date2num(timeStamp, date_time.units, date_time.calendar) + date_time[posCnt] = cftime.date2num( + timeStamp, date_time.units, date_time.calendar + ) # flip variable if necessary (to follow cf_convention) if self.netcdf_y_orientation_follow_cf_convention: Index: wflow-py/wflow/pcrglobwb/parameterSoilAndTopo.py =================================================================== diff -u -r4143969ebd6b276284ea6e4198ee693bd6ab506a -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/pcrglobwb/parameterSoilAndTopo.py (.../parameterSoilAndTopo.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) +++ wflow-py/wflow/pcrglobwb/parameterSoilAndTopo.py (.../parameterSoilAndTopo.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -416,10 +416,10 @@ self.effSatAtFieldCapLow = pcr.cover(self.effSatAtFieldCapLow, 1.0) self.kUnsatAtFieldCapUpp = pcr.max( - 0., (self.effSatAtFieldCapUpp ** self.campbellBetaUpp) * self.kSatUpp + 0.0, (self.effSatAtFieldCapUpp ** self.campbellBetaUpp) * self.kSatUpp ) # unsaturated conductivity at field capacity: KTHEFF_FC = max(0,THEFF_FC[TYPE]**BCB*KS1) self.kUnsatAtFieldCapLow = pcr.max( - 0., (self.effSatAtFieldCapLow ** self.campbellBetaLow) * self.kSatLow + 0.0, (self.effSatAtFieldCapLow ** self.campbellBetaLow) * self.kSatLow ) # if self.numberOfLayers == 3: @@ -445,17 +445,17 @@ ) ** (-1.0 / self.poreSizeBetaLow030150) self.kUnsatAtFieldCapUpp000005 = pcr.max( - 0., + 0.0, (self.effSatAtFieldCapUpp000005 ** self.campbellBetaUpp000005) * self.kSatUpp000005, ) self.kUnsatAtFieldCapUpp005030 = pcr.max( - 0., + 0.0, (self.effSatAtFieldCapUpp005030 ** self.campbellBetaUpp005030) * self.kSatUpp005030, ) self.kUnsatAtFieldCapLow030150 = pcr.max( - 0., + 0.0, (self.effSatAtFieldCapLow030150 ** self.campbellBetaLow030150) * self.kSatLow030150, ) @@ -507,14 +507,14 @@ if self.numberOfLayers == 2: self.interflowConcTime = (self.kSatLow * self.tanslope * 2.0) / ( self.slopeLength - * (1. - self.effSatAtFieldCapLow) + * (1.0 - self.effSatAtFieldCapLow) * (self.satVolMoistContLow - self.resVolMoistContLow) ) # TCL = Duration*(2*KS2*TANSLOPE)/(LSLOPE*(1-THEFF2_FC)*(THETASAT2-THETARES2)) # if self.numberOfLayers == 3: self.interflowConcTime = (self.kSatLow030150 * self.tanslope * 2.0) / ( self.slopeLength - * (1. - self.effSatAtFieldCapLow030150) + * (1.0 - self.effSatAtFieldCapLow030150) * (self.satVolMoistContLow030150 - self.resVolMoistContLow030150) ) Index: wflow-py/wflow/pcrglobwb/routing.py =================================================================== diff -u -r7a07bfcf366e6f498e2e0d4036a15240c3260476 -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/pcrglobwb/routing.py (.../routing.py) (revision 7a07bfcf366e6f498e2e0d4036a15240c3260476) +++ wflow-py/wflow/pcrglobwb/routing.py (.../routing.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -124,9 +124,7 @@ self.inputDir = os.path.join( os.path.abspath(Dir), staticmaps ) # iniItems.globalOptions['inputDir'] - self.stateDir = os.path.join( - os.path.abspath(Dir), 'instate' - ) + self.stateDir = os.path.join(os.path.abspath(Dir), "instate") # option to activate water balance check self.debugWaterBalance = True @@ -185,14 +183,14 @@ ) # model resolution in arc-degree unit - #self.cellSizeInArcDeg = vos.getMapAttributes(self.cloneMap, "cellsize") - self.cellSizeInArcDeg = round(getgridparams()[2] * 360000.) / 360000. + # self.cellSizeInArcDeg = vos.getMapAttributes(self.cloneMap, "cellsize") + self.cellSizeInArcDeg = round(getgridparams()[2] * 360000.0) / 360000.0 # maximum number of days (timesteps) to calculate long term average flow values (default: 5 years = 5 * 365 days = 1825) - self.maxTimestepsToAvgDischargeLong = 1825. + self.maxTimestepsToAvgDischargeLong = 1825.0 # maximum number of days (timesteps) to calculate short term average values (default: 1 month = 1 * 30 days = 30) - self.maxTimestepsToAvgDischargeShort = 30. + self.maxTimestepsToAvgDischargeShort = 30.0 routingParameters = ["gradient", "manningsN"] for var in routingParameters: @@ -264,8 +262,8 @@ # channelLength = approximation of channel length (unit: m) # This is approximated by cell diagonal. - cellSizeInArcMin = self.cellSizeInArcDeg * 60. - verticalSizeInMeter = cellSizeInArcMin * 1852. + cellSizeInArcMin = self.cellSizeInArcDeg * 60.0 + verticalSizeInMeter = cellSizeInArcMin * 1852.0 # self.cellLengthFD = ( (self.cellArea / verticalSizeInMeter) ** (2) + (verticalSizeInMeter) ** (2) @@ -286,7 +284,7 @@ ) # dist2celllength in m/arcDegree (needed in the accuTravelTime function): - nrCellsDownstream = pcr.ldddist(self.lddMap, self.lddMap == 5, 1.) + nrCellsDownstream = pcr.ldddist(self.lddMap, self.lddMap == 5, 1.0) distanceDownstream = pcr.ldddist( self.lddMap, self.lddMap == 5, self.channelLength ) @@ -412,23 +410,17 @@ self.inputDir, ) else: - msg = ( - "The bankfull channel storage capacity is NOT defined in the configuration file. " - ) + msg = "The bankfull channel storage capacity is NOT defined in the configuration file. " 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)." - ) + msg += "The bankfull capacity is estimated from average discharge (5 year long term average)." else: - msg += ( - "The bankfull capacity is estimated from the given channel depth and channel width." - ) + msg += "The bankfull capacity is estimated from the given channel depth and channel width." self.usingFixedBankfullCapacity = True self.predefinedBankfullCapacity = self.estimateBankfullCapacity( self.predefinedChannelWidth, self.predefinedChannelDepth @@ -697,7 +689,7 @@ # using local distances deltaX per increment upto z[N] and the sum over sills # - fill all lists (including smoothing interval and slopes) - relZ = [0.] * nrZLevels + relZ = [0.0] * nrZLevels for iCnt in range(0, nrZLevels): if relativeElevationFileNC == None: @@ -739,12 +731,12 @@ minSlope, ) # - the maximum value for the floodplain slope is channel gradient (flow velocity is slower in the floodplain) - minSlope = pcr.min(self.gradient, 0.5 * pcr.max(deltaX[1], minSlope) ** -1.) + minSlope = pcr.min(self.gradient, 0.5 * pcr.max(deltaX[1], minSlope) ** -1.0) # - add small increment to elevations to each sill (except in the case of lakes, #TODO: verify this) for iCnt in range(nrZLevels): relZ[iCnt] = relZ[iCnt] + sumX[iCnt] * pcr.ifthenelse( - relZ[nrZLevels - 1] > 0., minSlope, 0.0 + relZ[nrZLevels - 1] > 0.0, minSlope, 0.0 ) # make sure that relZ[iCnt] >= relZ[iCnt-1] (added by Edwin) if iCnt > 0: @@ -756,9 +748,9 @@ # - set slope and smoothing interval between dy= y(i+1)-y(i) and dx= x(i+1)-x(i) # on the basis of volume # - floodVolume = [0.] * (nrZLevels) # volume (unit: m3) - mInterval = [0.] * (nrZLevels) # smoothing interval (unit: m3) - kSlope = [0.] * (nrZLevels) # slope (dimensionless) + floodVolume = [0.0] * (nrZLevels) # volume (unit: m3) + mInterval = [0.0] * (nrZLevels) # smoothing interval (unit: m3) + kSlope = [0.0] * (nrZLevels) # slope (dimensionless) # for iCnt in range(1, nrZLevels): floodVolume[iCnt] = ( @@ -852,7 +844,7 @@ * self.manningsN ** (1.5) + (flood_only_wetted_perimeter / channel_wetted_perimeter) * self.floodplainManN ** (1.5) - ) ** (2. / 3.) + ) ** (2.0 / 3.0) # characteristicDistance (dimensionless) # - This will be used for accutraveltimeflux & accutraveltimestate @@ -861,7 +853,7 @@ # - storage = the amount of material which is deposited in the cell (m3) # characteristicDistance = ( - ((yMean * wMean) / (wMean + 2 * yMean)) ** (2. / 3.) + ((yMean * wMean) / (wMean + 2 * yMean)) ** (2.0 / 3.0) * ((self.gradient) ** (0.5)) / usedManningsN * vos.secondsPerDay() @@ -874,7 +866,7 @@ # charateristicDistance for each lake/reservoir: lakeReservoirCharacteristicDistance = pcr.ifthen( - pcr.scalar(self.WaterBodies.waterBodyIds) > 0., + pcr.scalar(self.WaterBodies.waterBodyIds) > 0.0, pcr.areaaverage(characteristicDistance, self.WaterBodies.waterBodyIds), ) # @@ -884,13 +876,13 @@ pcr.boolean(0), ) distance_to_outlets = pcr.ifthen( - pcr.scalar(self.WaterBodies.waterBodyIds) > 0., + pcr.scalar(self.WaterBodies.waterBodyIds) > 0.0, pcr.ldddist(self.lddMap, outlets, pcr.scalar(1.0)), ) # ~ lakeReservoirCharacteristicDistance = pcr.ifthen(pcr.scalar(self.WaterBodies.waterBodyIds) > 0., # ~ pcr.max(distance_to_outlets + pcr.downstreamdist(self.lddMap)*1.50, lakeReservoirCharacteristicDistance)) lakeReservoirCharacteristicDistance = pcr.ifthen( - pcr.scalar(self.WaterBodies.waterBodyIds) > 0., + pcr.scalar(self.WaterBodies.waterBodyIds) > 0.0, pcr.max( distance_to_outlets + pcr.downstreamdist(self.lddMap) * 2.50, lakeReservoirCharacteristicDistance, @@ -916,7 +908,7 @@ # current solution: using the function "roundup" to ignore # zero and very small values characteristicDistance = ( - pcr.roundup(characteristicDistance * 100.) / 100. + pcr.roundup(characteristicDistance * 100.0) / 100.0 ) # arcDeg/day # and set minimum value of characteristicDistance: @@ -1426,7 +1418,7 @@ def simple_update(self, landSurface, groundwater, currTimeStep, meteo): # updating timesteps to calculate long and short term statistics values of avgDischarge, avgInflow, avgOutflow, etc. - self.timestepsToAvgDischarge += 1. + self.timestepsToAvgDischarge += 1.0 if self.debugWaterBalance: preStorage = self.channelStorage # unit: m3 @@ -1489,7 +1481,7 @@ # at cells where lakes and/or reservoirs defined, move channelStorage to waterBodyStorage # storageAtLakeAndReservoirs = pcr.ifthen( - pcr.scalar(self.WaterBodies.waterBodyIds) > 0., self.channelStorage + pcr.scalar(self.WaterBodies.waterBodyIds) > 0.0, self.channelStorage ) storageAtLakeAndReservoirs = pcr.cover(storageAtLakeAndReservoirs, 0.0) # @@ -1568,19 +1560,19 @@ # self.discharge = self.Q / vos.secondsPerDay() self.discharge = pcr.max( - 0., self.discharge + 0.0, self.discharge ) # reported channel discharge cannot be negative self.discharge = pcr.ifthen(self.landmask, self.discharge) # self.disChanWaterBody = pcr.ifthen( - pcr.scalar(self.WaterBodies.waterBodyIds) > 0., + pcr.scalar(self.WaterBodies.waterBodyIds) > 0.0, pcr.areamaximum(self.discharge, self.WaterBodies.waterBodyIds), ) self.disChanWaterBody = pcr.cover(self.disChanWaterBody, self.discharge) self.disChanWaterBody = pcr.ifthen(self.landmask, self.disChanWaterBody) # self.disChanWaterBody = pcr.max( - 0., self.disChanWaterBody + 0.0, self.disChanWaterBody ) # reported channel discharge cannot be negative # # @@ -1641,15 +1633,15 @@ * self.manningsN ** (1.5) + (flood_only_wetted_perimeter / channel_wetted_perimeter) * self.floodplainManN ** (1.5) - ) ** (2. / 3.) + ) ** (2.0 / 3.0) else: usedManningsN = self.manningsN # alpha (dimensionless) and initial estimate of channel discharge (m3/s) # alpha = ( usedManningsN - * channel_wetted_perimeter ** (2. / 3.) + * channel_wetted_perimeter ** (2.0 / 3.0) * self.gradient ** (-0.5) ) ** self.beta # dimensionless dischargeInitial = pcr.ifthenelse( @@ -1714,13 +1706,13 @@ * self.manningsN ** (1.5) + (flood_only_wetted_perimeter / channel_wetted_perimeter) * self.floodplainManN ** (1.5) - ) ** (2. / 3.) + ) ** (2.0 / 3.0) # alpha (dimensionless) and estimate of channel discharge (m3/s) # alpha = ( usedManningsN - * channel_wetted_perimeter ** (2. / 3.) + * channel_wetted_perimeter ** (2.0 / 3.0) * self.gradient ** (-0.5) ) ** self.beta # dimensionless dischargeInitial = pcr.ifthenelse( @@ -1747,9 +1739,7 @@ if self.floodPlain: - msg = ( - "Calculate channel inundated fraction and flood inundation depth above the floodplain." - ) + msg = "Calculate channel inundated fraction and flood inundation depth above the floodplain." logger.info(msg) # given the flood channel volume: channelStorage @@ -1781,9 +1771,9 @@ # on the basis of the integrated logistic functions PHI(x) and 1-PHI(x) # deltaX = deltaXMin - deltaXScaled = pcr.ifthenelse(deltaX < 0., pcr.scalar(-1.), 1.) * pcr.min( - self.criterionKK, pcr.abs(deltaX / pcr.max(1., mInt)) - ) + deltaXScaled = pcr.ifthenelse( + deltaX < 0.0, pcr.scalar(-1.0), 1.0 + ) * pcr.min(self.criterionKK, pcr.abs(deltaX / pcr.max(1.0, mInt))) logInt = self.integralLogisticFunction(deltaXScaled) # compute fractional inundated/flooded area @@ -1792,27 +1782,27 @@ pcr.ifthenelse( pcr.abs(deltaXScaled) < self.criterionKK, y_i - k[0] * mInt * logInt[0] + k[1] * mInt * logInt[1], - y_i + pcr.ifthenelse(deltaX < 0., k[0], k[1]) * deltaX, + y_i + pcr.ifthenelse(deltaX < 0.0, k[0], k[1]) * deltaX, ), 0.0, ) # - minimum value is channelFraction inundatedFraction = pcr.max(self.channelFraction, inundatedFraction) # - maximum value is 1.0 inundatedFraction = pcr.max( - 0., pcr.min(1.0, inundatedFraction) + 0.0, pcr.min(1.0, inundatedFraction) ) # dimensionless # calculate flooded/inundated depth (unit: m) above the floodplain # _- it will be zero if excessVolume == 0 floodDepth = pcr.ifthenelse( - inundatedFraction > 0., + inundatedFraction > 0.0, excessVolume / ( pcr.max(self.min_fracwat_for_water_height, inundatedFraction) * self.cellArea ), - 0., + 0.0, ) # unit: m # - maximum flood depth max_flood_depth = 25.0 @@ -1825,7 +1815,7 @@ # return waterBodyStorage to channelStorage # waterBodyStorageTotal = pcr.ifthen( - pcr.scalar(self.WaterBodies.waterBodyIds) > 0., + pcr.scalar(self.WaterBodies.waterBodyIds) > 0.0, pcr.areaaverage( pcr.ifthen(self.landmask, self.WaterBodies.waterBodyStorage), pcr.ifthen(self.landmask, self.WaterBodies.waterBodyIds), @@ -1844,7 +1834,7 @@ ) ) waterBodyStoragePerCell = pcr.ifthen( - pcr.scalar(self.WaterBodies.waterBodyIds) > 0., waterBodyStoragePerCell + pcr.scalar(self.WaterBodies.waterBodyIds) > 0.0, waterBodyStoragePerCell ) # unit: m3 # channelStorage = pcr.cover(waterBodyStoragePerCell, channelStorage) # unit: m3 @@ -1857,7 +1847,7 @@ # updating timesteps to calculate long and short term statistics # values of avgDischarge, avgInflow, avgOutflow, etc. - self.timestepsToAvgDischarge += 1. + self.timestepsToAvgDischarge += 1.0 # the following variable defines total local change (input) to surface water storage bodies # unit: m3 # - only local processes; therefore not considering any routing processes @@ -1897,7 +1887,7 @@ # # at cells where lakes and/or reservoirs defined, move channelStorage to waterBodyStorage storageAtLakeAndReservoirs = pcr.ifthen( - pcr.scalar(self.WaterBodies.waterBodyIds) > 0., self.channelStorage + pcr.scalar(self.WaterBodies.waterBodyIds) > 0.0, self.channelStorage ) storageAtLakeAndReservoirs = pcr.cover(storageAtLakeAndReservoirs, 0.0) # - move only non negative values and use rounddown values @@ -2175,19 +2165,19 @@ # self.discharge = self.Q / vos.secondsPerDay() self.discharge = pcr.max( - 0., self.discharge + 0.0, self.discharge ) # reported channel discharge cannot be negative self.discharge = pcr.ifthen(self.landmask, self.discharge) # self.disChanWaterBody = pcr.ifthen( - pcr.scalar(self.WaterBodies.waterBodyIds) > 0., + pcr.scalar(self.WaterBodies.waterBodyIds) > 0.0, pcr.areamaximum(self.discharge, self.WaterBodies.waterBodyIds), ) self.disChanWaterBody = pcr.cover(self.disChanWaterBody, self.discharge) self.disChanWaterBody = pcr.ifthen(self.landmask, self.disChanWaterBody) # self.disChanWaterBody = pcr.max( - 0., self.disChanWaterBody + 0.0, self.disChanWaterBody ) # reported channel discharge cannot be negative # calculate the statistics of long and short term flow values @@ -2251,9 +2241,9 @@ # long term variance and standard deviation of discharge values varDischarge = self.m2tDischarge / pcr.max( - 1., + 1.0, pcr.min(self.maxTimestepsToAvgDischargeLong, self.timestepsToAvgDischarge) - - 1., + - 1.0, ) # see: online algorithm on http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance stdDischarge = pcr.max(varDischarge ** 0.5, 0.0) @@ -2314,7 +2304,7 @@ readAvlChannelStorage = pcr.max(0.0, readAvlChannelStorage) # ignore small volume values - less than 0.1 m3 - readAvlChannelStorage = pcr.rounddown(readAvlChannelStorage * 10.) / 10. + readAvlChannelStorage = pcr.rounddown(readAvlChannelStorage * 10.0) / 10.0 readAvlChannelStorage = pcr.ifthen(self.landmask, readAvlChannelStorage) return readAvlChannelStorage # unit: m3 Index: wflow-py/wflow/pcrglobwb/virtualOS.py =================================================================== diff -u -r90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/pcrglobwb/virtualOS.py (.../virtualOS.py) (revision 90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a) +++ wflow-py/wflow/pcrglobwb/virtualOS.py (.../virtualOS.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -56,7 +56,7 @@ # Global variables: MV = 1e20 -smallNumber = 1E-39 +smallNumber = 1e-39 # tuple of netcdf file suffixes (extensions) that can be used: netcdf_suffixes = (".nc4", ".nc") @@ -1154,11 +1154,11 @@ # read from temporary file and delete the temporary file: PCRmap = pcr.readmap(output) if isLddMap == True: - PCRmap = pcr.ifthen(pcr.scalar(PCRmap) < 10., PCRmap) + PCRmap = pcr.ifthen(pcr.scalar(PCRmap) < 10.0, PCRmap) if isLddMap == True: PCRmap = pcr.ldd(PCRmap) if isNomMap == True: - PCRmap = pcr.ifthen(pcr.scalar(PCRmap) > 0., PCRmap) + PCRmap = pcr.ifthen(pcr.scalar(PCRmap) > 0.0, PCRmap) if isNomMap == True: PCRmap = pcr.nominal(PCRmap) if os.path.isdir(tmpDir): @@ -1435,7 +1435,7 @@ sys.exit() cellsize = float(cOut.split()[7]) if arcDegree == True: - cellsize = round(cellsize * 360000.) / 360000. + cellsize = round(cellsize * 360000.0) / 360000.0 mapAttr = { "cellsize": float(cellsize), "rows": float(cOut.split()[3]), @@ -1481,7 +1481,7 @@ if attribute == "cellsize": cellsize = float(cOut.split()[7]) if arcDegree == True: - cellsize = round(cellsize * 360000.) / 360000. + cellsize = round(cellsize * 360000.0) / 360000.0 return cellsize if attribute == "rows": return int(cOut.split()[3]) @@ -1519,8 +1519,8 @@ # cell value in this loop currentCellValue = pcr.rounddown( - remainingMapValue * pcr.scalar(10. ** (power_number)) - ) / pcr.scalar(10. ** (power_number)) + remainingMapValue * pcr.scalar(10.0 ** (power_number)) + ) / pcr.scalar(10.0 ** (power_number)) if power_number == min_power_number: currentCellValue = remainingMapValue @@ -1580,7 +1580,7 @@ return float(3600 * 24) -def getValDivZero(x, y, y_lim=smallNumber, z_def=0.): +def getValDivZero(x, y, y_lim=smallNumber, z_def=0.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, @@ -1589,7 +1589,7 @@ return pcr.ifthenelse(y > y_lim, x / pcr.max(y_lim, y), z_def) -def getValFloatDivZero(x, y, y_lim, z_def=0.): +def getValFloatDivZero(x, y, y_lim, z_def=0.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, @@ -1632,7 +1632,7 @@ def getQAtBasinMouths(discharge, basinMouth): - temp = pcr.ifthenelse(basinMouth != 0, discharge * secondsPerDay(), 0.) + temp = pcr.ifthenelse(basinMouth != 0, discharge * secondsPerDay(), 0.0) pcr.report(temp, "temp.map") return getMapTotal(temp) / 1e9 @@ -1738,19 +1738,15 @@ msg += "\n" msg = "\n" msg += "\n" - msg += ( - "##############################################################################################################################################\n" - ) + msg += "##############################################################################################################################################\n" msg += "WARNING !!!!!!!! Water Balance Error %s Min %f Max %f Mean %f" % ( processName, a, b, c, ) msg += "\n" - msg += ( - "##############################################################################################################################################\n" - ) + msg += "##############################################################################################################################################\n" msg += "\n" msg += "\n" msg += "\n" @@ -1887,8 +1883,8 @@ # cell available water in this loop cellAvlWater = pcr.rounddown( - remainingCellAvlWater * pcr.scalar(10. ** (power_number)) - ) / pcr.scalar(10. ** (power_number)) + remainingCellAvlWater * pcr.scalar(10.0 ** (power_number)) + ) / pcr.scalar(10.0 ** (power_number)) if power_number == min_power_number: cellAvlWater = pcr.max(0.0, remainingCellAvlWater) @@ -1979,7 +1975,7 @@ available_water_volume, allocation_zones, zone_area=None, - high_volume_treshold=1000000., + high_volume_treshold=1000000.0, debug_water_balance=True, extra_info_for_water_balance_reporting="", landmask=None, Index: wflow-py/wflow/pcrglobwb/waterBodies.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/pcrglobwb/waterBodies.py (.../waterBodies.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/pcrglobwb/waterBodies.py (.../waterBodies.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -99,7 +99,7 @@ ) # minimum width (m) used in the weir formula # TODO: define minWeirWidth based on the GLWD, GRanD database and/or bankfull discharge formula - self.minWeirWidth = 10. + self.minWeirWidth = 10.0 # lower and upper limits at which reservoir release is terminated and # at which reservoir release is equal to long-term average outflow @@ -153,7 +153,7 @@ self.waterBodyIds = pcr.nominal(0) # waterBody ids self.waterBodyOut = pcr.boolean(0) # waterBody outlets - self.waterBodyArea = pcr.scalar(0.) # waterBody surface areas + self.waterBodyArea = pcr.scalar(0.0) # waterBody surface areas # water body ids if self.useNetCDF: @@ -176,7 +176,7 @@ ) # self.waterBodyIds = pcr.ifthen( - pcr.scalar(self.waterBodyIds) > 0., pcr.nominal(self.waterBodyIds) + pcr.scalar(self.waterBodyIds) > 0.0, pcr.nominal(self.waterBodyIds) ) # water body outlets (correcting outlet positions) @@ -186,25 +186,26 @@ self.waterBodyIds, ) # = outlet ids self.waterBodyOut = pcr.ifthen( - pcr.scalar(self.waterBodyIds) > 0., self.waterBodyOut + pcr.scalar(self.waterBodyIds) > 0.0, self.waterBodyOut ) # TODO: Please also consider endorheic lakes! # correcting water body ids self.waterBodyIds = pcr.ifthen( - pcr.scalar(self.waterBodyIds) > 0., pcr.subcatchment(ldd, self.waterBodyOut) + pcr.scalar(self.waterBodyIds) > 0.0, + pcr.subcatchment(ldd, self.waterBodyOut), ) # boolean map for water body outlets: self.waterBodyOut = pcr.ifthen( - pcr.scalar(self.waterBodyOut) > 0., pcr.boolean(1) + pcr.scalar(self.waterBodyOut) > 0.0, pcr.boolean(1) ) # reservoir surface area (m2): if self.useNetCDF: resSfArea = ( - 1000. - * 1000. + 1000.0 + * 1000.0 * vos.netcdf2PCRobjClone( self.ncFileInp, "resSfAreaInp", @@ -215,8 +216,8 @@ ) else: resSfArea = ( - 1000. - * 1000. + 1000.0 + * 1000.0 * vos.readPCRmapClone( self.resSfAreaInp + str(year_used) + ".map", self.cloneMap, @@ -225,7 +226,7 @@ ) ) resSfArea = pcr.areaaverage(resSfArea, self.waterBodyIds) - resSfArea = pcr.cover(resSfArea, 0.) + resSfArea = pcr.cover(resSfArea, 0.0) # water body surface area (m2): (lakes and reservoirs) self.waterBodyArea = pcr.max( @@ -234,10 +235,10 @@ ), pcr.areaaverage(pcr.cover(resSfArea, 0.0), self.waterBodyIds), ) - self.waterBodyArea = pcr.ifthen(self.waterBodyArea > 0., self.waterBodyArea) + self.waterBodyArea = pcr.ifthen(self.waterBodyArea > 0.0, self.waterBodyArea) # correcting water body ids and outlets (exclude all water bodies with surfaceArea = 0) - self.waterBodyIds = pcr.ifthen(self.waterBodyArea > 0., self.waterBodyIds) + self.waterBodyIds = pcr.ifthen(self.waterBodyArea > 0.0, self.waterBodyIds) self.waterBodyOut = pcr.ifthen( pcr.boolean(self.waterBodyIds), self.waterBodyOut ) @@ -299,8 +300,8 @@ if self.useNetCDF: self.resMaxCap = ( - 1000. - * 1000. + 1000.0 + * 1000.0 * vos.netcdf2PCRobjClone( self.ncFileInp, "resMaxCapInp", @@ -311,8 +312,8 @@ ) else: self.resMaxCap = ( - 1000. - * 1000. + 1000.0 + * 1000.0 * vos.readPCRmapClone( self.resMaxCapInp + str(year_used) + ".map", self.cloneMap, @@ -334,10 +335,10 @@ # correcting water body types: # Reservoirs that have zero capacities will be assumed as lakes. self.waterBodyTyp = pcr.ifthen( - pcr.scalar(self.waterBodyTyp) > 0., self.waterBodyTyp + pcr.scalar(self.waterBodyTyp) > 0.0, self.waterBodyTyp ) self.waterBodyTyp = pcr.ifthenelse( - self.waterBodyCap > 0., + self.waterBodyCap > 0.0, self.waterBodyTyp, pcr.ifthenelse( pcr.scalar(self.waterBodyTyp) == 2, pcr.nominal(1), self.waterBodyTyp @@ -346,16 +347,16 @@ # final corrections: self.waterBodyTyp = pcr.ifthen( - self.waterBodyArea > 0., self.waterBodyTyp + self.waterBodyArea > 0.0, self.waterBodyTyp ) # make sure that all lakes and/or reservoirs have surface areas self.waterBodyTyp = pcr.ifthen( - pcr.scalar(self.waterBodyTyp) > 0., self.waterBodyTyp + pcr.scalar(self.waterBodyTyp) > 0.0, self.waterBodyTyp ) # make sure that only types 1 and 2 will be considered in lake/reservoir functions self.waterBodyIds = pcr.ifthen( - pcr.scalar(self.waterBodyTyp) > 0., self.waterBodyIds + pcr.scalar(self.waterBodyTyp) > 0.0, self.waterBodyIds ) # make sure that all lakes and/or reservoirs have ids self.waterBodyOut = pcr.ifthen( - pcr.scalar(self.waterBodyIds) > 0., self.waterBodyOut + pcr.scalar(self.waterBodyIds) > 0.0, self.waterBodyOut ) # make sure that all lakes and/or reservoirs have outlets # for a natural run (self.onlyNaturalWaterBodies == True) @@ -368,7 +369,7 @@ "Using only natural water bodies identified in the year 1900. All reservoirs in 1900 are assumed as lakes." ) self.waterBodyTyp = pcr.ifthen( - pcr.scalar(self.waterBodyTyp) > 0., pcr.nominal(1) + pcr.scalar(self.waterBodyTyp) > 0.0, pcr.nominal(1) ) # check that all lakes and/or reservoirs have types, ids, surface areas and outlets: @@ -422,7 +423,7 @@ # storageAtLakeAndReservoirs = pcr.cover( pcr.ifthen( - pcr.scalar(self.waterBodyIds) > 0., + pcr.scalar(self.waterBodyIds) > 0.0, initial_condition["channelStorage"], ), 0.0, @@ -435,7 +436,7 @@ # # lake and reservoir storages = waterBodyStorage (m3) ; values are given for the entire lake / reservoir cells waterBodyStorage = pcr.ifthen( - pcr.scalar(self.waterBodyIds) > 0., + pcr.scalar(self.waterBodyIds) > 0.0, pcr.areatotal(storageAtLakeAndReservoirs, self.waterBodyIds), ) @@ -557,7 +558,7 @@ self.waterBodyOutflow = pcr.cover(reservoirOutflow, lakeOutflow) # make sure that all water bodies have outflow: - self.waterBodyOutflow = pcr.max(0., pcr.cover(self.waterBodyOutflow, 0.0)) + self.waterBodyOutflow = pcr.max(0.0, pcr.cover(self.waterBodyOutflow, 0.0)) # limit outflow to available storage factor = 0.25 # to avoid flip flop @@ -566,7 +567,7 @@ ) # unit: m3 # use round values self.waterBodyOutflow = ( - pcr.rounddown(self.waterBodyOutflow / 1.) * 1. + pcr.rounddown(self.waterBodyOutflow / 1.0) * 1.0 ) # unit: m3 # outflow rate in m3 per sec @@ -620,27 +621,27 @@ (self.waterBodyStorage - pcr.cover(self.waterBodyCap, 0.0)) / self.waterBodyArea, ), - 0., + 0.0, ) # weirWidth (m) : # - estimated from avgOutflow (m3/s) using the bankfull discharge formula # avgOutflow = self.avgOutflow avgOutflow = pcr.ifthenelse( - avgOutflow > 0., + avgOutflow > 0.0, avgOutflow, pcr.max(avgChannelDischarge, self.avgInflow, 0.001), ) # This is needed when new lakes/reservoirs introduced (its avgOutflow is still zero). avgOutflow = pcr.areamaximum(avgOutflow, self.waterBodyIds) # - bankfullWidth = pcr.cover(pcr.scalar(4.8) * ((avgOutflow) ** (0.5)), 0.) + bankfullWidth = pcr.cover(pcr.scalar(4.8) * ((avgOutflow) ** (0.5)), 0.0) weirWidthUsed = bankfullWidth weirWidthUsed = pcr.max( weirWidthUsed, self.minWeirWidth ) # TODO: minWeirWidth based on the GRanD database weirWidthUsed = pcr.cover( - pcr.ifthen(pcr.scalar(self.waterBodyIds) > 0., weirWidthUsed), 0.0 + pcr.ifthen(pcr.scalar(self.waterBodyIds) > 0.0, weirWidthUsed), 0.0 ) # avgInflow <= lakeOutflow (weirFormula) <= waterBodyStorage @@ -652,7 +653,7 @@ lakeOutflow = lakeOutflowInM3PerSec * length_of_time_step # unit: m3 lakeOutflow = pcr.min(self.waterBodyStorage, lakeOutflow) # - lakeOutflow = pcr.ifthen(pcr.scalar(self.waterBodyIds) > 0., lakeOutflow) + lakeOutflow = pcr.ifthen(pcr.scalar(self.waterBodyIds) > 0.0, lakeOutflow) lakeOutflow = pcr.ifthen(pcr.scalar(self.waterBodyTyp) == 1, lakeOutflow) # TODO: Consider endorheic lake/basin. No outflow for endorheic lake/basin! @@ -673,10 +674,10 @@ # ~ pcr.max(avgChannelDischarge, self.avgInflow, 0.001)) # - alternative 2 avgOutflow = pcr.ifthenelse( - avgOutflow > 0., avgOutflow, pcr.max(avgChannelDischarge, self.avgInflow) + avgOutflow > 0.0, avgOutflow, pcr.max(avgChannelDischarge, self.avgInflow) ) avgOutflow = pcr.ifthenelse( - avgOutflow > 0., avgOutflow, pcr.downstream(self.lddMap, avgOutflow) + avgOutflow > 0.0, avgOutflow, pcr.downstream(self.lddMap, avgOutflow) ) avgOutflow = pcr.areamaximum(avgOutflow, self.waterBodyIds) @@ -686,9 +687,9 @@ # - if relativeCapacity > maxResvrFrac : longterm average reductionFactor = pcr.cover( pcr.min( - 1., + 1.0, pcr.max( - 0., self.waterBodyStorage - self.minResvrFrac * self.waterBodyCap + 0.0, self.waterBodyStorage - self.minResvrFrac * self.waterBodyCap ) / (self.maxResvrFrac - self.minResvrFrac) * self.waterBodyCap, @@ -717,10 +718,10 @@ # floodOutflow: additional release if storage > upper limit ratioQBankfull = 2.3 - estmStorage = pcr.max(0., self.waterBodyStorage - resvOutflow) + estmStorage = pcr.max(0.0, self.waterBodyStorage - resvOutflow) floodOutflow = pcr.max(0.0, estmStorage - self.waterBodyCap) + pcr.cover( pcr.max(0.0, estmStorage - self.maxResvrFrac * self.waterBodyCap) - / ((1. - self.maxResvrFrac) * self.waterBodyCap), + / ((1.0 - self.maxResvrFrac) * self.waterBodyCap), 0.0, ) * pcr.max( 0.0, ratioQBankfull * avgOutflow * vos.secondsPerDay() - resvOutflow @@ -759,6 +760,6 @@ # resvOutflow < waterBodyStorage resvOutflow = pcr.min(self.waterBodyStorage, resvOutflow) - resvOutflow = pcr.ifthen(pcr.scalar(self.waterBodyIds) > 0., resvOutflow) + resvOutflow = pcr.ifthen(pcr.scalar(self.waterBodyIds) > 0.0, resvOutflow) resvOutflow = pcr.ifthen(pcr.scalar(self.waterBodyTyp) == 2, resvOutflow) return resvOutflow # unit: m3 Index: wflow-py/wflow/pcrut.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/pcrut.py (.../pcrut.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/pcrut.py (.../pcrut.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -150,7 +150,7 @@ ifile.close() mat = numpy.loadtxt(nname, skiprows=toskip) - mis = mat == 1e+31 + mis = mat == 1e31 mat[mis] = numpy.nan if len(mat.shape) > 1: Index: wflow-py/wflow/reservoir_Sa.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/reservoir_Sa.py (.../reservoir_Sa.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/reservoir_Sa.py (.../reservoir_Sa.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -70,9 +70,9 @@ self.Fa_[k] = Pe Storage in unsaturated zone = 0. """ - self.Qa_[k] = 0. - self.Ea_[k] = 0. - self.Sa[k] = 0. + self.Qa_[k] = 0.0 + self.Ea_[k] = 0.0 + self.Sa[k] = 0.0 self.Fa_[k] = max(self.Pe_[k], 0) self.wbSa_[k] = ( self.Pe_[k] Index: wflow-py/wflow/reservoir_Sf.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/reservoir_Sf.py (.../reservoir_Sf.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/reservoir_Sf.py (.../reservoir_Sf.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -39,7 +39,7 @@ """ self.Qfin_[k] = self.Qu * (1 - self.D) self.Qf_[k] = self.Qfin_[k] - self.Sf_[k] = 0. + self.Sf_[k] = 0.0 self.wbSf_[k] = self.Qfin_[k] - self.Qf_[k] - self.Sf[k] + self.Sf_t[k] @@ -52,7 +52,7 @@ """ self.Qfa_[k] = self.Qa_[k] - self.Sfa[k] = 0. + self.Sfa[k] = 0.0 self.wbSfa_[k] = ( self.Qfa_[k] - self.Qfa_[k] Index: wflow-py/wflow/reservoir_Si.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/reservoir_Si.py (.../reservoir_Si.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/reservoir_Si.py (.../reservoir_Si.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -38,8 +38,8 @@ Storage in interception = 0. """ self.Pe_[k] = max(self.Precipitation, 0) - self.Ei_[k] = 0. - self.Si_[k] = 0. + self.Ei_[k] = 0.0 + self.Si_[k] = 0.0 self.wbSi_[k] = ( self.Precipitation - self.Ei_[k] - self.Pe_[k] - self.Si[k] + self.Si_t[k] ) Index: wflow-py/wflow/reservoir_Ss.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/reservoir_Ss.py (.../reservoir_Ss.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/reservoir_Ss.py (.../reservoir_Ss.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -41,7 +41,7 @@ ) # areatotal is taken, according to area percentage of cell self.Qs = self.Qsin - self.Ss = 0. + self.Ss = 0.0 self.wbSs = self.Qsin - self.Qs - self.Ss + self.Ss_t Index: wflow-py/wflow/reservoir_Su.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/reservoir_Su.py (.../reservoir_Su.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/reservoir_Su.py (.../reservoir_Su.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -78,10 +78,10 @@ Storage in unsaturated zone = 0. """ self.Qu_[k] = max(self.Pe_[k], 0) - self.Eu_[k] = 0. - self.Perc_[k] = 0. - self.Su[k] = 0. - self.Cap_[k] = 0. + self.Eu_[k] = 0.0 + self.Perc_[k] = 0.0 + self.Su[k] = 0.0 + self.Cap_[k] = 0.0 self.wbSu_[k] = ( self.Pe - self.Eu - self.Qu - self.Perc + self.Cap - self.Su[k] + self.Su_t[k] ) Index: wflow-py/wflow/reservoir_Sw.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/reservoir_Sw.py (.../reservoir_Sw.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/reservoir_Sw.py (.../reservoir_Sw.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -51,8 +51,8 @@ self.PotEvaporation = cover(ifthenelse(self.EpHour > 0, self.EpHour, 0), 0) self.Qw_[k] = max(self.PrecipitationSnow, 0) - self.Ew_[k] = 0. - self.Sw[k] = 0. + self.Ew_[k] = 0.0 + self.Sw[k] = 0.0 self.wbSw_[k] = ( self.Precipitation - self.Ew_[k] - self.Qw_[k] - self.Sw[k] + self.Sw_t[k] ) Index: wflow-py/wflow/rtc_wflow_bmi.py =================================================================== diff -u -r36b469410a4a5af24c3902cbebb595e9da83c7bb -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/rtc_wflow_bmi.py (.../rtc_wflow_bmi.py) (revision 36b469410a4a5af24c3902cbebb595e9da83c7bb) +++ wflow-py/wflow/rtc_wflow_bmi.py (.../rtc_wflow_bmi.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -1,4 +1,3 @@ - from wflow.wrappers.rtc.wrapperExtended import BMIWrapperExtended Index: wflow-py/wflow/sphy/timecalc.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/sphy/timecalc.py (.../timecalc.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/sphy/timecalc.py (.../timecalc.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -1,4 +1,3 @@ - # -Function to return the julian day of the year def julian(self): y = self.curdate.year Index: wflow-py/wflow/static_maps.py =================================================================== diff -u -raa6c405805092ee6ab8ddbf970ccb84a4e7f2c99 -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/static_maps.py (.../static_maps.py) (revision aa6c405805092ee6ab8ddbf970ccb84a4e7f2c99) +++ wflow-py/wflow/static_maps.py (.../static_maps.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -512,7 +512,7 @@ demburn_hr = dem_hr + burn_hr demburn_hr[np.isnan(demburn_hr)] = -9999 wt.gdal_writemap( - demburn_hr_file, "PCRaster", xax_hr, yax_hr, demburn_hr, -9999. + demburn_hr_file, "PCRaster", xax_hr, yax_hr, demburn_hr, -9999.0 ) pcr.setclone(demburn_hr_file) demburn_hr = pcr.readmap(demburn_hr_file) Index: wflow-py/wflow/stats.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/stats.py (.../stats.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/stats.py (.../stats.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -45,7 +45,7 @@ from numpy import isnan NoDataVal = -999 -SmallValue = 1.e-10 +SmallValue = 1.0e-10 def get_mean(values, N="", NoData=NoDataVal, Skip=""): @@ -93,7 +93,7 @@ if Nact > 0: new_value.sort() if Nact % 2 == 0: - median = (new_value[int(Nact / 2)] + new_value[int(Nact / 2)]) / 2. + median = (new_value[int(Nact / 2)] + new_value[int(Nact / 2)]) / 2.0 else: median = new_value[int(Nact / 2)] else: @@ -720,7 +720,7 @@ SubSetVals = [0] * 2 if Nact > 0: if Nact % 2 == 0: - median = (tmpvalues[int(Nact / 2)] + tmpvalues[int(Nact / 2)]) / 2. + median = (tmpvalues[int(Nact / 2)] + tmpvalues[int(Nact / 2)]) / 2.0 SubSetVals[0] = tmpvalues[: int(Nact / 2) + 1] SubSetVals[1] = tmpvalues[int(Nact / 2) + 1 :] else: @@ -753,7 +753,7 @@ quartiles[subset] = ( SubSetVals[subset][int(Nact / 2)] + SubSetVals[subset][int(Nact / 2)] - ) / 2. + ) / 2.0 else: quartiles[subset] = SubSetVals[subset][int(Nact / 2)] else: @@ -767,8 +767,8 @@ MildOutliers = [] for idx in range(Nact - 1, -1, -1): if ( - tmpvalues[idx] < quartiles[0] - 3. * IQR - or tmpvalues[idx] > quartiles[1] + 3. * IQR + tmpvalues[idx] < quartiles[0] - 3.0 * IQR + or tmpvalues[idx] > quartiles[1] + 3.0 * IQR ): ExtremeOutliers = ExtremeOutliers + [tmpvalues[idx]] del tmpvalues[idx] Index: wflow-py/wflow/wf_DynamicFramework.py =================================================================== diff -u -r59cffa03cc52cdb4dc62a0ead1aafb6bc039b430 -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wf_DynamicFramework.py (.../wf_DynamicFramework.py) (revision 59cffa03cc52cdb4dc62a0ead1aafb6bc039b430) +++ wflow-py/wflow/wf_DynamicFramework.py (.../wf_DynamicFramework.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -475,7 +475,7 @@ print("Not implemented yet") self.steps = self.steps + 1 - + tmpvar = spatial(scalar(variable)) if self.areafunction == "average": self.resmap = areaaverage(tmpvar, nominal(self.area)) @@ -839,7 +839,6 @@ """ return cover(timeinputscalar(tssfile, nominal(areamap)), default) - def _wf_shutdown(self): """ Makes sure the logging closed @@ -854,7 +853,7 @@ "w", ) self._userModel().config.write(fp) - + fp.close() for key, value in self.oscv.items(): @@ -2912,7 +2911,7 @@ path = name if self.outputFormat == 1: - + if not hasattr(self, "NcOutputStatic"): report(variable, path) if gzipit: Index: wflow-py/wflow/wf_netcdfio.py =================================================================== diff -u -r90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wf_netcdfio.py (.../wf_netcdfio.py) (revision 90a4ee3dd8724fb9dfe52fa5b7364aca4a4bd36a) +++ wflow-py/wflow/wf_netcdfio.py (.../wf_netcdfio.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -64,7 +64,7 @@ complevel=9, zlib=True, least_significant_digit=None, - FillValue=1E31, + FillValue=1e31, ): """ This function prepares a NetCDF file with given metadata, for a certain year, daily basis data @@ -325,10 +325,9 @@ # timeObj = cftime.num2date(time[:], units=time.units, calendar=time.calendar) idx = timestep - 1 - + buffreset = int((idx + 1) % self.maxbuf) bufpos = int((idx) % self.maxbuf) - try: nc_var = self.nc_trg.variables[var] Index: wflow-py/wflow/wflow_bmi_combined.py =================================================================== diff -u -r7698db683368c0c3ce99aeee53281bfbb5b8241e -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_bmi_combined.py (.../wflow_bmi_combined.py) (revision 7698db683368c0c3ce99aeee53281bfbb5b8241e) +++ wflow-py/wflow/wflow_bmi_combined.py (.../wflow_bmi_combined.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -1,4 +1,3 @@ - import wflow.bmi import wflow.wflow_bmi as wfbmi @@ -122,7 +121,11 @@ # mappingdir = self.datadir + '\\bmi_mapping\\' mappingdir = ( - os.path.join(self.datadir, wfbmi.configget(self.config,"IdMapping", "folder", "bmi_mapping")[0]) + "\\" + os.path.join( + self.datadir, + wfbmi.configget(self.config, "IdMapping", "folder", "bmi_mapping")[0], + ) + + "\\" ) self.models = configsection(self.config, "models") Index: wflow-py/wflow/wflow_bmi_combined_mp.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_bmi_combined_mp.py (.../wflow_bmi_combined_mp.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/wflow_bmi_combined_mp.py (.../wflow_bmi_combined_mp.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -1,4 +1,3 @@ - import wflow.bmi as bmi import wflow.wflow_bmi as wfbmi import wflow Index: wflow-py/wflow/wflow_cqf.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_cqf.py (.../wflow_cqf.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/wflow_cqf.py (.../wflow_cqf.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -1309,7 +1309,7 @@ if self.waterdem: waterDem = self.Altitude - (self.zi * 0.001) - waterLdd = lddcreate(waterDem, 1E35, 1E35, 1E35, 1E35) + waterLdd = lddcreate(waterDem, 1e35, 1e35, 1e35, 1e35) # waterLdd = lddcreate(waterDem,1,1,1,1) waterSlope = max(0.00001, slope(waterDem) * celllength() / self.reallength) Index: wflow-py/wflow/wflow_delwaq.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_delwaq.py (.../wflow_delwaq.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/wflow_delwaq.py (.../wflow_delwaq.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -868,7 +868,7 @@ # v_pcs.name = "Unknown projected" v_pcs.epsg = 4326 v_pcs.grid_mapping_name = "Unknown projected" - v_pcs.longitude_of_prime_meridian = 0. + v_pcs.longitude_of_prime_meridian = 0.0 # v_pcs.semi_major_axis = 6378137. # v_pcs.semi_minor_axis = 6356752.314245 v_pcs.inverse_flattening = 298.257223563 Index: wflow-py/wflow/wflow_extract.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_extract.py (.../wflow_extract.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/wflow_extract.py (.../wflow_extract.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -140,7 +140,7 @@ demburn = cover(ifthen(boolean(riverburn), dem - 600), dem) print("Creating ldd...") ldd = lddcreate_save( - caseNameNew + "/staticmaps/wflow_ldd.map", demburn, True, 10.0E35 + caseNameNew + "/staticmaps/wflow_ldd.map", demburn, True, 10.0e35 ) # ## Find catchment (overall) Index: wflow-py/wflow/wflow_hbv.py =================================================================== diff -u -r010aceeb0fc4449d7a2241c3e8fded25138981b9 -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_hbv.py (.../wflow_hbv.py) (revision 010aceeb0fc4449d7a2241c3e8fded25138981b9) +++ wflow-py/wflow/wflow_hbv.py (.../wflow_hbv.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -1301,7 +1301,7 @@ self.QuickFlow = self.KQuickFlow * self.UpperZoneStorage self.RealQuickFlow = max(0, self.K0 * (self.UpperZoneStorage - self.SUZ)) self.UpperZoneStorage = ( - self.UpperZoneStorage - self.QuickFlow - self.RealQuickFlow + self.UpperZoneStorage - self.QuickFlow - self.RealQuickFlow ) """Quickflow volume in mm/timestep""" # self.UpperZoneStorage=self.UpperZoneStorage-self.QuickFlow-self.RealQuickFlow Index: wflow-py/wflow/wflow_lib.py =================================================================== diff -u -r57a9b56c975e8af24d4db5882fbb7b44232f7a9e -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_lib.py (.../wflow_lib.py) (revision 57a9b56c975e8af24d4db5882fbb7b44232f7a9e) +++ wflow-py/wflow/wflow_lib.py (.../wflow_lib.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -321,10 +321,10 @@ lddname, dem, force, - corevolume=1E35, - catchmentprecipitation=1E35, - corearea=1E35, - outflowdepth=1E35, + corevolume=1e35, + catchmentprecipitation=1e35, + corearea=1e35, + outflowdepth=1e35, ): """ Creates an ldd if a file does not exists or if the force flag is used @@ -346,7 +346,7 @@ else: if Verbose: print(("Creating ldd", lddname)) - LDD = lddcreate(dem, 10.0E35, outflowdepth, 10.0E35, 10.0E35) + LDD = lddcreate(dem, 10.0e35, outflowdepth, 10.0e35, 10.0e35) report(LDD, lddname) return LDD @@ -798,7 +798,7 @@ up_area = ifthen(boolean(cover(stream_ge, 0)), accuflux(ldd, 1)) riverid = ifthen(boolean(cover(stream_ge, 0)), subcatch) - friction = 1. / scalar( + friction = 1.0 / scalar( spreadzone(cover(ordinal(up_area), 0), 0, 0) ) # *(scalar(ldd)*0+1) delta = ifthen( @@ -1002,8 +1002,8 @@ print (n) diffx = x - xcor[n] diffy = y - ycor[n] - col_ = numpy.absolute(diffx) <= (cell_length * tolerance) # cellsize - row_ = numpy.absolute(diffy) <= (cell_length * tolerance) # cellsize + col_ = numpy.absolute(diffx) <= (cell_length * tolerance) # cellsize + row_ = numpy.absolute(diffy) <= (cell_length * tolerance) # cellsize point = point + numpy2pcr(Scalar, ((col_ * row_) * (n + 1)), numpy.nan) return ordinal(point) @@ -1114,7 +1114,7 @@ up_elevation = scalar(subcatchment(ldd, height_river)) else: drainage_surf = ifthen(rivers, accuflux(ldd, 1)) - weight = 1. / scalar(spreadzone(cover(ordinal(drainage_surf), 0), 0, 0)) + weight = 1.0 / scalar(spreadzone(cover(ordinal(drainage_surf), 0), 0, 0)) up_elevation = ifthenelse( basin, scalar(subcatchment(ldd, height_river)), Index: wflow-py/wflow/wflow_lintul.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_lintul.py (.../wflow_lintul.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/wflow_lintul.py (.../wflow_lintul.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -39,7 +39,7 @@ # np_One = numpy.ones((219, 286)) # Some last remaining hardcoded (& partly non-functional) parameters: -DELT = 1. # Time step (delta T) = 1 day; changing it is not recommended. +DELT = 1.0 # Time step (delta T) = 1 day; changing it is not recommended. TINY = 1e-6 # A tiny number (from the original LINTUL code:) WCWP = ( 0.21 @@ -50,7 +50,7 @@ WCST = ( 0.55 ) # Volumetric soil water content at saturation (normal condition for irrigated rice soil) ... how soil specific is this for puddled soils...? todo -NNI = 1. # Nitrogen Nutrition Index (non-functional, for future development) +NNI = 1.0 # Nitrogen Nutrition Index (non-functional, for future development) NPART = ( 1.0 ) # Coefficient for the effect of N stress on leaf biomass reduction (presently non-functional, for future development) @@ -69,7 +69,7 @@ just return the value as is. If it equals zero: NOTNUL will return a value of 1 instead. Sander de Vries, March 2018 """ - checkzeros = pcr_map == 0. + checkzeros = pcr_map == 0.0 checkzeros_scalar = scalar(checkzeros) pcr_map += checkzeros_scalar return pcr_map @@ -88,27 +88,27 @@ """ # SINE AND COSINE OF LATITUDE - sinLAT = math.sin(pi * LAT / 180.) - cosLAT = math.cos(pi * LAT / 180.) + sinLAT = math.sin(pi * LAT / 180.0) + cosLAT = math.cos(pi * LAT / 180.0) # MAXIMAL SINE OF DECLINATION - sinDCM = math.sin(math.pi * 23.45 / 180.) + sinDCM = math.sin(math.pi * 23.45 / 180.0) # SINE AND COSINE OF DECLINATION (EQUATIONS 3.4, 3.5) # SINDEC = -SINDCM * cos(2.* PI * (DAY+10.)/365.) # The '9' below (instead of 10) keeps things in sync with FST... # Todo: try to understand this at a certain point... for now it works perfectly. - sinDEC = -sinDCM * math.cos(2. * pi * (DAY + 11.) / 365.) - cosDEC = math.sqrt(1. - sinDEC * sinDEC) + sinDEC = -sinDCM * math.cos(2.0 * pi * (DAY + 11.0) / 365.0) + cosDEC = math.sqrt(1.0 - sinDEC * sinDEC) # THE TERMS A AND B ACCORDING TO EQUATION 3.3 A = sinLAT * sinDEC B = cosLAT * cosDEC # DAYLENGTH ACCORDING TO EQUATION 3.6. - DAYL = 12. * (1. + (2. / pi) * math.asin(A / B)) + DAYL = 12.0 * (1.0 + (2.0 / pi) * math.asin(A / B)) return DAYL @@ -136,7 +136,7 @@ print( "x values of lookuplinear table not sorted in strictly ascending order..." ) - if i // 2. - i / 2. != 0.: + if i // 2.0 - i / 2.0 != 0.0: string = str(self.data[i]) + " " else: string = "\n" + str(self.data[i]) + " " @@ -383,7 +383,7 @@ name="RAIN", stack="inmaps/P", type="timeseries", - default=0., + default=0.0, verbose=False, lookupmaps=[], ) @@ -601,7 +601,7 @@ Calc_RainSum = False # Check whether the precipitation sum is positive - WeveGotRain = self.PSUM > 0. + WeveGotRain = self.PSUM > 0.0 # Check whether the precipitation sum is still below the threshhold for crop establishment (and hence calculation of the sum should still proceed): NotEnoughRainYet = self.PSUM <= self.RainSumReq EnoughRain = self.PSUM >= self.RainSumReq @@ -614,12 +614,12 @@ SecondSeason = self.Season == 2 ThirdSeason = self.Season == 3 self.Season += ifthenelse( - EnoughRain, self.ricemask, 0. + EnoughRain, self.ricemask, 0.0 ) # beware, this variable is also modified in another equation # Add rain when the precipitation sum is positive but still below the threshold for crop establishment, reset to 0. when this is no longer the case. self.PSUM = ( - self.PSUM + ifthenelse(KeepAddingRain, self.RAIN, 0.) - ) * ifthenelse(KeepAddingRain, scalar(1.), 0.) + self.PSUM + ifthenelse(KeepAddingRain, self.RAIN, 0.0) + ) * ifthenelse(KeepAddingRain, scalar(1.0), 0.0) # Initializing crop harvest: # If a fixed planting and a fixed harvest date are forced for the whole catchment: @@ -649,29 +649,29 @@ CropStarted = Started & self.ricemask_BOOL self.STARTED = ( self.STARTED + CropStartNow_scalar + scalar(CropStarted) - ) * ifthenelse(CropHarvNow, scalar(0.), 1.) + ) * ifthenelse(CropHarvNow, scalar(0.0), 1.0) print( "Warning: using start date from ini file, not read from Crop Profile..." ) elif self.CropStartDOY == -1: if self.AutoStartStop == False: - Started = self.STARTED > 0. + Started = self.STARTED > 0.0 if self.HarvestDAP == 0: - crpprfl_eq_zero = self.CRPST == 0. + crpprfl_eq_zero = self.CRPST == 0.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. + CRPST_gt_0 = self.CRPST > 0.0 CRPST_eq_STARTED = self.CRPST == self.STARTED CropStartNow = CRPST_gt_0 & CRPST_eq_STARTED & self.ricemask_BOOL CropStarted = Started & self.ricemask_BOOL self.STARTED = (self.STARTED + self.CRPST) * ifthenelse( - CropHarvNow, scalar(0.), 1. + CropHarvNow, scalar(0.0), 1.0 ) # - ifthenelse(CropHarvNow, self.STARTED, 0.) elif self.AutoStartStop == True: @@ -695,19 +695,19 @@ HarvSeasonTwo = HarvSeason2_temp & self.ricemask_BOOL self.Season = ( self.Season - + ifthenelse(HarvSeasonOne, self.ricemask, 0.) - - ifthenelse(HarvSeasonTwo, self.ricemask * 2., 0.) + + ifthenelse(HarvSeasonOne, self.ricemask, 0.0) + - ifthenelse(HarvSeasonTwo, self.ricemask * 2.0, 0.0) ) # beware, this variable is also modified in another equation Started = self.STARTED > 0 CropStarted = Started & self.ricemask_BOOL SeasonOneHarvd = self.STARTED < 0 SeasonOneHarvd_Scalar = scalar(SeasonOneHarvd) PrepareField_temp = scalar(self.Pausedays) - PrepareField = ifthenelse(FirstSeason, PrepareField_temp, 0.) + PrepareField = ifthenelse(FirstSeason, PrepareField_temp, 0.0) self.STARTED = ( (self.STARTED + CropStartNow_scalar + scalar(CropStarted)) - * ifthenelse(CropHarvNow, scalar(0.), 1.) - - ifthenelse(HarvSeasonOne, PrepareField, 0.) + * ifthenelse(CropHarvNow, scalar(0.0), 1.0) + - ifthenelse(HarvSeasonOne, PrepareField, 0.0) + SeasonOneHarvd_Scalar ) elif self.Sim3rdSeason == True: @@ -718,8 +718,8 @@ ) self.Season = ( self.Season - + ifthenelse(HarvSeasonOneTwo, scalar(1.), 0.) - - ifthenelse(HarvSeasonThree, scalar(3.), 0.) + + ifthenelse(HarvSeasonOneTwo, scalar(1.0), 0.0) + - ifthenelse(HarvSeasonThree, scalar(3.0), 0.0) ) # beware, this variable is also modified in another equation Started = self.STARTED > 0 CropStarted = Started & self.ricemask_BOOL @@ -728,12 +728,12 @@ PrepareField_temp = scalar(self.Pausedays) FirstorSecondSeason = FirstSeason | SecondSeason PrepareField = ifthenelse( - FirstorSecondSeason, PrepareField_temp, 0. + FirstorSecondSeason, PrepareField_temp, 0.0 ) self.STARTED = ( (self.STARTED + CropStartNow_scalar + scalar(CropStarted)) - * ifthenelse(CropHarvNow, scalar(0.), 1.) - - ifthenelse(HarvSeasonOneTwo, PrepareField, 0.) + * ifthenelse(CropHarvNow, scalar(0.0), 1.0) + - ifthenelse(HarvSeasonOneTwo, PrepareField, 0.0) + Season12Harvd_Scalar ) else: @@ -759,16 +759,16 @@ ) # timestep delay...! todo else: print("Warning, run without water effects on crop growth...") - TRANRF = scalar(1.) + TRANRF = scalar(1.0) 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.) + DTEFF = ifthenelse(Warm_Enough, DegreeDay, 0.0) # Check if leaves are present: - Leaves_Present = self.LAI > 0. + Leaves_Present = self.LAI > 0.0 # Check whether certain critical moments, external circumstances or crop growth stages occur that influence crop growth and development: BeforeAnthesis = self.TSUM < self.TSUMAN @@ -806,44 +806,44 @@ # Determine the influence of astronomical daylength on crop development (via thermal time - TSUM) by interpolation in the PHOTTB table PHOTT = self.PHOTTB.lookup_linear(DAYL) # Daylength only potentially has a modifying influence on crop development (via thermal time, TSUM) before anthesis: - PHOTPF = ifthenelse(BeforeAnthesis, PHOTT, scalar(1.)) + PHOTPF = ifthenelse(BeforeAnthesis, PHOTT, scalar(1.0)) # Influence (if any) of daylength results in a modified daily change in thermal time (TSUM). RTSUMP = DTEFF * PHOTPF # TSUM (state): at crop establishment TSUMI is added (the TSUM that was accumulated in the nursery in the case of transplanted rice); # during crop growth, the daily rate of change RTSUMP is added if EMERG = TRUE. Upon crop harvest, TSUM is reset (i.e. multiplied with 0.). self.TSUM = ( self.TSUM - + ifthenelse(CropStartNow, scalar(self.TSUMI), 0.) - + ifthenelse(EMERG, RTSUMP, 0.) - ) * ifthenelse(CropHarvNow, scalar(0.), 1.) + + ifthenelse(CropStartNow, scalar(self.TSUMI), 0.0) + + ifthenelse(EMERG, RTSUMP, 0.0) + ) * ifthenelse(CropHarvNow, scalar(0.0), 1.0) # Calculation of DVS (state). # In LINTUL1 and LINTUL2, TSUM directly steered all processes influenced by crop phenological development. # However, Shibu et al. (2010) derived some code from ORYZA_2000 (Bouman et al., 2001), including the use DVS instead of TSUM. # Hence in LINTUL3, some processes are still controlled directly by TSUM and some are controlled by its derived variable DVS # – a somewhat confusing situation that offers scope for future improvement. # After anthesis DVS proceeds at a different rate (DVS_gen) than before (DVS_veg). Throughout crop development DVS is calculated as the DVS_veg + DVS_gen. - DVS_veg = self.TSUM / self.TSUMAN * ifthenelse(CropHarvNow, scalar(0.), 1.) - DVS_gen = (1. + (self.TSUM - self.TSUMAN) / self.TSUMMT) * ifthenelse( - CropHarvNow, scalar(0.), 1. + DVS_veg = self.TSUM / self.TSUMAN * ifthenelse(CropHarvNow, scalar(0.0), 1.0) + DVS_gen = (1.0 + (self.TSUM - self.TSUMAN) / self.TSUMMT) * ifthenelse( + CropHarvNow, scalar(0.0), 1.0 ) - self.DVS = ifthenelse(Vegetative, DVS_veg, 0.) + ifthenelse( - Generative, DVS_gen, 0. + self.DVS = ifthenelse(Vegetative, DVS_veg, 0.0) + ifthenelse( + Generative, DVS_gen, 0.0 ) # Root depth growth can occur as long as the maximum rooting depth has not yet been achieved: CanGrowDownward = self.ROOTD_mm <= self.ROOTDM_mm # Root growth occurs before anthesis if there is crop growth (EMERG = TRUE), enough water (already in EMERG - todo) and the maximum rooting depth has not yet been reached. RootGrowth = Enough_water & BeforeAnthesis & EMERG & CanGrowDownward # If root growth occurs, it occurs at a fixed pace (mm/day): - RROOTD_mm = ifthenelse(RootGrowth, self.RRDMAX_mm, scalar(0.)) + RROOTD_mm = ifthenelse(RootGrowth, self.RRDMAX_mm, scalar(0.0)) # Rooting depth (state): at crop establishment ROOTDI_mm is added (the rooting depth at transplanting); during crop growth, the daily rate of change # self.ROOTDI_mm is added. Upon crop harvest, rooting depth is reset (i.e. multiplied with 0.). self.ROOTD_mm = ( self.ROOTD_mm - + ifthenelse(CropStartNow, self.ROOTDI_mm, scalar(0.)) + + ifthenelse(CropStartNow, self.ROOTDI_mm, scalar(0.0)) + RROOTD_mm - ) * ifthenelse(CropHarvNow, scalar(0.), 1.) + ) * ifthenelse(CropHarvNow, scalar(0.0), 1.0) # By depth growth, roots explore deeper layers of soil that contain previously untapped water supplies, the assumption is. # In the case of irrigated rice, it seems reasonable to assume that those layers are saturated with water (WCST = volumetric soil water content at saturation). # The volume of additional water that becomes available to the crop is then equal to EXPLOR: @@ -852,10 +852,10 @@ ############################################################################################################# # Water Limitation: effects on partitioning # If TRANRF falls below 0.5, root growth is accelerated: - FRTMOD = max(1., 1. / (TRANRF + 0.5)) + FRTMOD = max(1.0, 1.0 / (TRANRF + 0.5)) FRT = FRTWET * FRTMOD # ... and shoot growth (i.e. growth of all aboveground parts) diminshed: - FSHMOD = (1. - FRT) / (1 - FRT / FRTMOD) + FSHMOD = (1.0 - FRT) / (1 - FRT / FRTMOD) FLV = FLVT * FSHMOD FST = FSTT * FSHMOD FSO = FSOT * FSHMOD @@ -864,97 +864,99 @@ # The factor 0.5 accounts for the fact that about 50% (in terms of energy) of the frequency spectrum of incident solar radiation # can be utilized for photosynthesis by green plants. PARINT = ifthenelse( - Not_Finished, 0.5 * self.IRRAD * 0.001 * (1. - exp(-self.K * self.LAI)), 0. + Not_Finished, + 0.5 * self.IRRAD * 0.001 * (1.0 - exp(-self.K * self.LAI)), + 0.0, ) # The total growth rate is proportional to the intercepted PAR with a fixed Light Use Efficiency (LUE) - the core of the LINTUL apporach. GTOTAL = self.LUE * PARINT * TRANRF # Leaf dying due to ageing occurs from anthesis on (actually that is already arranged in the interpolation table - double!), with a relative death rate RDRTMP: - RDRDV = ifthenelse(AtAndAfterAnthesis, RDRTMP, scalar(0.)) + RDRDV = ifthenelse(AtAndAfterAnthesis, RDRTMP, scalar(0.0)) # Leaf dying due to mutual shading occurs when LAI > LAICR: - RDRSH = max(0., self.RDRSHM * (self.LAI - self.LAICR) / self.LAICR) + RDRSH = max(0.0, self.RDRSHM * (self.LAI - self.LAICR) / self.LAICR) # The largest of the two effects determines the relative death rate of foliage: RDR = max(RDRDV, RDRSH) # Impact of leaf dying on leaf weight - N limitation stuff not (yet) implemented - N_Limitation = NNI < 1. - DLVNS = ifthenelse(CropStarted, scalar(1.), 0.) * ifthenelse( - N_Limitation, self.WLVG * self.RDRNS * (1. - NNI), 0. + N_Limitation = NNI < 1.0 + DLVNS = ifthenelse(CropStarted, scalar(1.0), 0.0) * ifthenelse( + N_Limitation, self.WLVG * self.RDRNS * (1.0 - NNI), 0.0 ) DLVS = self.WLVG * RDR DLV = (DLVS + DLVNS) * scalar(Not_Finished) - RWLVG = ifthenelse(EMERG, GTOTAL * FLV - DLV, scalar(0.)) + RWLVG = ifthenelse(EMERG, GTOTAL * FLV - DLV, scalar(0.0)) self.WLVG = ( - self.WLVG + ifthenelse(CropStartNow, self.WLVGI, scalar(0.)) + RWLVG - ) * (1. - scalar(CropHarvNow)) - self.WLVD = (self.WLVD + DLV) * (1. - scalar(CropHarvNow)) + self.WLVG + ifthenelse(CropStartNow, self.WLVGI, scalar(0.0)) + RWLVG + ) * (1.0 - scalar(CropHarvNow)) + self.WLVD = (self.WLVD + DLV) * (1.0 - scalar(CropHarvNow)) # Growth of leaves in terms of mass (GLV) and in terms of LAI (GLAI). GLV = FLV * GTOTAL Adt_or_Harv = pcror(Adult, CropHarvNow) Juv_or_Harv = pcror(Juvenile, CropHarvNow) - NoLeavesYet = self.LAI == 0. + NoLeavesYet = self.LAI == 0.0 LetsGo = pcrand(Enough_water, CropStartNow) LetsGro = pcrand(NoLeavesYet, LetsGo) GLAI = ( - ifthenelse(Adt_or_Harv, SLA * GLV, scalar(0.)) + ifthenelse(Adt_or_Harv, SLA * GLV, scalar(0.0)) + ifthenelse( Juv_or_Harv, self.LAI - * (exp(self.RGRL * DTEFF * DELT) - 1.) + * (exp(self.RGRL * DTEFF * DELT) - 1.0) / DELT * TRANRF * exp(-self.LAI * (1.0 - NNI)), - 0., + 0.0, ) - + ifthenelse(LetsGro, self.LAII / DELT, scalar(0.)) + + ifthenelse(LetsGro, self.LAII / DELT, scalar(0.0)) ) # (Abs.) impact of leaf dying on LAI # Daily decrease in LAI due to dying of leaves (if any), due to aging and/or mutual shading: DLAIS = self.LAI * RDR # Daily decrease in LAI due to nitrogen shortage (presently non-functional): - DLAINS = ifthenelse(CropStarted, scalar(1.), 0.) * ifthenelse( - N_Limitation, DLVNS * SLA, 0. + DLAINS = ifthenelse(CropStarted, scalar(1.0), 0.0) * ifthenelse( + N_Limitation, DLVNS * SLA, 0.0 ) # Total daily decrease in LAI due to leaf death (aging, mutual shading, N shortage): DLAI = (DLAIS + DLAINS) * scalar(Not_Finished) # The initial LAI (LAII, transplanted rice) is added to GLAI at crop establishment, not in below state equation as done by Shibu et al. (2010). - self.LAI = (self.LAI + GLAI - DLAI) * ifthenelse(CropHarvNow, scalar(0.), 1.) + self.LAI = (self.LAI + GLAI - DLAI) * ifthenelse(CropHarvNow, scalar(0.0), 1.0) # Daily death rate of roots: if self.DVS >= self.DVSDR, a fraction self.DRRT of the roots is dying every day: - DRRT = ifthenelse(Roots_Dying, self.WRT * self.RDRRT, scalar(0.)) + DRRT = ifthenelse(Roots_Dying, self.WRT * self.RDRRT, scalar(0.0)) # Net daily change in root weight: if there is crop growth, this is equal to daily weight increase (GTOTAL * FRT) minus the daily decrease due to dying roots (if any). - RWRT = ifthenelse(EMERG, GTOTAL * FRT - DRRT, scalar(0.)) + RWRT = ifthenelse(EMERG, GTOTAL * FRT - DRRT, scalar(0.0)) # Calculation of the root weight (state): when the crop is planted, the initial root weight WRTLI is added. After that, the net (daily) rate of change RWRT is added. # Upon crop harvest, RWRT is reset (i.e. multiplied with 0.) self.WRT = ( - self.WRT + ifthenelse(CropStartNow, self.WRTLI, scalar(0.)) + RWRT - ) * (1. - scalar(CropHarvNow)) + self.WRT + ifthenelse(CropStartNow, self.WRTLI, scalar(0.0)) + RWRT + ) * (1.0 - scalar(CropHarvNow)) # WDRT (state) is the total quantity of leaves that has died (mostly relevant for mass balance checking purposes). Simply calculated by adding the daily dying roots (if any); # (the variable is reset upon crop harvest). - self.WDRT = (self.WDRT + DRRT) * (1. - scalar(CropHarvNow)) + self.WDRT = (self.WDRT + DRRT) * (1.0 - scalar(CropHarvNow)) # Daily change in the weight of the storage organs (rice grains) is fraction FSO of the total growth rate (GTOTAL). FSO is determined by phenology and moisture stress # (which can modify the root/shoort ratio) - RWSO = ifthenelse(EMERG, GTOTAL * FSO, scalar(0.)) + RWSO = ifthenelse(EMERG, GTOTAL * FSO, scalar(0.0)) # Weight of storage organs (state) is simply calculated by accumulating the daily growth RWSO. At crop harvest, it is reset to 0. self.WSO = ( - self.WSO + ifthenelse(CropStartNow, self.WSOI, scalar(0.)) + RWSO - ) * (1. - scalar(CropHarvNow)) + self.WSO + ifthenelse(CropStartNow, self.WSOI, scalar(0.0)) + RWSO + ) * (1.0 - scalar(CropHarvNow)) # WSO in tons/ha: - WSOTHA = self.WSO / 100. + WSOTHA = self.WSO / 100.0 # Daily change in the weight of the stems is a fraction FST of the total growth rate (GTOTAL). FST is determined by phenology and moisture stress - RWST = ifthenelse(EMERG, GTOTAL * FST, scalar(0.)) + RWST = ifthenelse(EMERG, GTOTAL * FST, scalar(0.0)) # Weight of storage organs (state) is simply calculated by accumulating the daily growth RWSO. At crop harvest, it is reset to 0. self.WST = ( - self.WST + ifthenelse(CropHarvNow, self.WSTI, scalar(0.)) + RWST - ) * (1. - scalar(CropHarvNow)) + self.WST + ifthenelse(CropHarvNow, self.WSTI, scalar(0.0)) + RWST + ) * (1.0 - scalar(CropHarvNow)) # An additional state, handy for testing purposes: - self.Test += 1. + self.Test += 1.0 # For quickly getting point output (sdv). Works only with a wf_supplyEndTime() implemented in wf_dynamicframework... todo? # Point_Output = open('Point_Output.csv', 'w') Index: wflow-py/wflow/wflow_pcrglobwb.py =================================================================== diff -u -r8b4b66867d08bce928dc65bef574dfcfd400d9c3 -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_pcrglobwb.py (.../wflow_pcrglobwb.py) (revision 8b4b66867d08bce928dc65bef574dfcfd400d9c3) +++ wflow-py/wflow/wflow_pcrglobwb.py (.../wflow_pcrglobwb.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -765,7 +765,7 @@ dynModelFw.setupFramework() dynModelFw._runInitial() - #dynModelFw._runResume() + # dynModelFw._runResume() # dynModelFw._runDynamic(0, 0) dynModelFw._runDynamic(_firstTimeStep, _lastTimeStep) dynModelFw._runSuspend() Index: wflow-py/wflow/wflow_routing.py =================================================================== diff -u -r7698db683368c0c3ce99aeee53281bfbb5b8241e -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_routing.py (.../wflow_routing.py) (revision 7698db683368c0c3ce99aeee53281bfbb5b8241e) +++ wflow-py/wflow/wflow_routing.py (.../wflow_routing.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -180,7 +180,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) @@ -206,7 +206,7 @@ :var self.WaterLevel: Water level in the kin-wave resrvoir [m] """ states = ["SurfaceRunoff", "WaterLevelCH", "WaterLevelFP"] - + if hasattr(self, "ReserVoirSimpleLocs"): states.append("ReservoirVolume") @@ -412,7 +412,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) @@ -423,7 +425,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) @@ -623,11 +627,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 @@ -732,7 +736,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) @@ -790,7 +794,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 Index: wflow-py/wflow/wflow_sbm.py =================================================================== diff -u -r7511bfaac7399429ff6c484cf952474bd2648cba -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_sbm.py (.../wflow_sbm.py) (revision 7511bfaac7399429ff6c484cf952474bd2648cba) +++ wflow-py/wflow/wflow_sbm.py (.../wflow_sbm.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -834,7 +834,8 @@ # Temperature correction poer cell to add self.TempCor = self.wf_readmap( - self.Dir + "\\" + self.Dir + + "\\" + configget( self.config, "model", @@ -1823,7 +1824,7 @@ If below that a max amount of 2mm/day can be converted to glacier-ice """ # TODO: document glacier module - self.snowdist = sCurve(self.Snow, a=8300., c=0.06) + self.snowdist = sCurve(self.Snow, a=8300.0, c=0.06) self.Snow2Glacier = ifthenelse( self.Snow > 8300, self.snowdist * (self.Snow - 8300), self.ZeroMap ) @@ -1973,16 +1974,15 @@ # Limit rootingdepth (if set externally) self.ActRootingDepth = min(self.SoilThickness * 0.99, self.ActRootingDepth) - # Determine Open Water EVAP based on waterfrac. Later subtract this from water that # enters the Kinematic wave self.ActEvapOpenWater = min( - self.WaterLevel * 1000.0 * self.WaterFrac, self.WaterFrac * self.PotTransSoil + self.WaterLevel * 1000.0 * self.WaterFrac, + self.WaterFrac * self.PotTransSoil, ) - + self.RestEvap = self.PotTransSoil - self.ActEvapOpenWater - self.ActEvapPond = self.ZeroMap if self.nrpaddyirri > 0: self.ActEvapPond = min(self.PondingDepth, self.RestEvap) @@ -2002,7 +2002,7 @@ self.SumThickness = self.UStoreLayerThickness[n] + self.SumThickness self.SaturationDeficit = self.SoilWaterCapacity - self.SatWaterDepth - + # evap available for soil evaporation self.RestEvap = self.RestEvap * self.CanopyGapFraction @@ -2021,7 +2021,9 @@ # Height of unsat zone in layer n self.L = ifthenelse( self.ZiLayer == float(n), - ifthenelse(self.ZeroMap + float(n) > 0, self.zi - l_Thickness[n - 1], self.zi), + ifthenelse( + self.ZeroMap + float(n) > 0, self.zi - l_Thickness[n - 1], self.zi + ), self.UStoreLayerThickness[n], ) # Depth for calculation of vertical fluxes (bottom layer or zi) @@ -2054,8 +2056,8 @@ self.soilevap = min(self.soilevap, self.UStoreLayerDepth[n]) self.UStoreLayerDepth[n] = self.UStoreLayerDepth[n] - self.soilevap - - #evap available for transpiration + + # evap available for transpiration self.PotTrans = ( self.PotTransSoil - self.soilevap - self.ActEvapOpenWater ) @@ -2224,7 +2226,9 @@ self.L = ifthen( self.ZiLayer == float(n), ifthenelse( - self.ZeroMap + float(n) > 0, self.zi - l_Thickness[n - 1], self.zi + self.ZeroMap + float(n) > 0, + self.zi - l_Thickness[n - 1], + self.zi, ), ) self.Transfer = self.Transfer + ifthenelse( @@ -2336,7 +2340,9 @@ L = ifthenelse( self.ZiLayer == float(n), - ifthenelse(self.ZeroMap + float(n) > 0, self.zi - l_Thickness[n - 1], self.zi), + ifthenelse( + self.ZeroMap + float(n) > 0, self.zi - l_Thickness[n - 1], self.zi + ), self.UStoreLayerThickness[n], ) thisLayer = ifthenelse( @@ -2406,7 +2412,7 @@ 0.000001, slope(self.WaterDem) * celllength() / self.reallength ) if self.waterdem: - self.waterLdd = lddcreate(self.WaterDem, 1E35, 1E35, 1E35, 1E35) + self.waterLdd = lddcreate(self.WaterDem, 1e35, 1e35, 1e35, 1e35) # waterLdd = lddcreate(waterDem,1,1,1,1) # TODO: We should make a couple of itterations here... @@ -2517,7 +2523,9 @@ ifthenelse( self.ZiLayer == float(n), ifthenelse( - self.ZeroMap + float(n) > 0, self.zi - l_Thickness[n - 1], self.zi + self.ZeroMap + float(n) > 0, + self.zi - l_Thickness[n - 1], + self.zi, ), self.UStoreLayerThickness[n], ) Index: wflow-py/wflow/wflow_sbm_old.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_sbm_old.py (.../wflow_sbm_old.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/wflow_sbm_old.py (.../wflow_sbm_old.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -1447,7 +1447,7 @@ If below that a max amount of 2mm/day can be converted to glacier-ice """ # TODO: document glacier module - self.snowdist = sCurve(self.Snow, a=8300., c=0.06) + self.snowdist = sCurve(self.Snow, a=8300.0, c=0.06) self.Snow2Glacier = ifthenelse( self.Snow > 8300, self.snowdist * (self.Snow - 8300), self.ZeroMap ) @@ -1746,7 +1746,7 @@ 0.000001, slope(self.WaterDem) * celllength() / self.reallength ) if self.waterdem: - self.waterLdd = lddcreate(self.WaterDem, 1E35, 1E35, 1E35, 1E35) + self.waterLdd = lddcreate(self.WaterDem, 1e35, 1e35, 1e35, 1e35) # TODO: We should make a couple ot iterations here... if self.waterdem: Index: wflow-py/wflow/wflow_snow.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_snow.py (.../wflow_snow.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/wflow_snow.py (.../wflow_snow.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -77,8 +77,12 @@ updateCols = [] #: columns used in updating -multpars = {} #: Dictionary with parameters and multipliers (static) (used in calibration) -multdynapars = {} #: Dictionary with parameters and multipliers (dynamic) (used in calibration) +multpars = ( + {} +) #: Dictionary with parameters and multipliers (static) (used in calibration) +multdynapars = ( + {} +) #: Dictionary with parameters and multipliers (dynamic) (used in calibration) def usage(*args): Index: wflow-py/wflow/wflow_sphy.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_sphy.py (.../wflow_sphy.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/wflow_sphy.py (.../wflow_sphy.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -1320,7 +1320,7 @@ # except: # setattr(self, i, 0.) setattr( - self, i, 0. + self, i, 0.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(",") Index: wflow-py/wflow/wflow_upscale.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_upscale.py (.../wflow_upscale.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/wflow_upscale.py (.../wflow_upscale.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -93,7 +93,7 @@ procTuple = (command, proc) processes.append(procTuple) while len(processes) >= maxCpu: - time.sleep(.2) + time.sleep(0.2) processes = removeFinishedProcesses(processes) # wait for all processes @@ -199,7 +199,7 @@ demburn = cover(ifthen(boolean(riverburn), dem - 600), dem) print("Creating ldd...") ldd = lddcreate_save( - caseNameNew + "/staticmaps/wflow_ldd.map", demburn, True, 10.0E35 + caseNameNew + "/staticmaps/wflow_ldd.map", demburn, True, 10.0e35 ) ## Find catchment (overall) outlet = find_outlet(ldd) Index: wflow-py/wflow/wflow_w3ra.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_w3ra.py (.../wflow_w3ra.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/wflow_w3ra.py (.../wflow_w3ra.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -409,8 +409,8 @@ self.wf_multparameters() # Static, for the computation of Aerodynamic conductance (3.7) - self.fh1 = ln(813. / self.hveg1 - 5.45) - self.fh2 = ln(813. / self.hveg2 - 5.45) + self.fh1 = ln(813.0 / self.hveg1 - 5.45) + self.fh2 = ln(813.0 / self.hveg2 - 5.45) self.ku2_1 = 0.305 / (self.fh1 * (self.fh1 + 2.3)) self.ku2_2 = 0.305 / (self.fh2 * (self.fh2 + 2.3)) @@ -619,7 +619,7 @@ self.E01 = max(self.EPOT, 0) self.E02 = max(self.EPOT, 0) keps = ( - 0.655E-3 * pair / pes + 0.655e-3 * pair / pes ) # See Appendix A3 (http://www.clw.csiro.au/publications/waterforahealthycountry/2010/wfhc-aus-water-resources-assessment-system.pdf) -------------------------------- check! elif self.UseETPdata == 0: Index: wflow-py/wflow/wflow_w3ra_new.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflow_w3ra_new.py (.../wflow_w3ra_new.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/wflow_w3ra_new.py (.../wflow_w3ra_new.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -411,8 +411,8 @@ self.wf_multparameters() # Static, for the computation of Aerodynamic conductance (3.7) - self.fh1 = ln(813. / self.hveg1 - 5.45) - self.fh2 = ln(813. / self.hveg2 - 5.45) + self.fh1 = ln(813.0 / self.hveg1 - 5.45) + self.fh2 = ln(813.0 / self.hveg2 - 5.45) self.ku2_1 = 0.305 / (self.fh1 * (self.fh1 + 2.3)) self.ku2_2 = 0.305 / (self.fh2 * (self.fh2 + 2.3)) @@ -621,7 +621,7 @@ self.E01 = max(self.EPOT, 0) self.E02 = max(self.EPOT, 0) keps = ( - 0.655E-3 * pair / pes + 0.655e-3 * pair / pes ) # See Appendix A3 (http://www.clw.csiro.au/publications/waterforahealthycountry/2010/wfhc-aus-water-resources-assessment-system.pdf) -------------------------------- check! elif self.UseETPdata == 0: Index: wflow-py/wflow/wflowtools_lib.py =================================================================== diff -u -rf33154035afcaa101c5a30594b9c86a4fe9f61ef -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/wflow/wflowtools_lib.py (.../wflowtools_lib.py) (revision f33154035afcaa101c5a30594b9c86a4fe9f61ef) +++ wflow-py/wflow/wflowtools_lib.py (.../wflowtools_lib.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -597,8 +597,8 @@ # ordermap = streamorder_map # lddmap = ldd_map # SHP_FILENAME = rivshp - counter = 0. - percentage = 0. + counter = 0.0 + percentage = 0.0 file_att = os.path.splitext(os.path.basename(SHP_FILENAME))[0] x, y, riversid, FillVal = readMap(rivermap, "PCRaster") riversid[riversid == FillVal] = -1 @@ -676,9 +676,9 @@ feature.SetField("ORDER", int(strahlerorder_select[0])) feature.SetField("CATCHMENT", int(catchment_select[0])) counter = counter + 1 - if (float(id) / float(maxRiverId)) * 100. > percentage: + if (float(id) / float(maxRiverId)) * 100.0 > percentage: # logger.info(' ' + str(int(percentage)) + '% completed') - percentage = percentage + 10. + percentage = percentage + 10.0 # print 'Writing polyline ' + str(id) + ' of ' + str(maxRiverId) layer_line.CreateFeature(feature) # Cleanup @@ -792,14 +792,14 @@ array_out = np.ones((t_rows, t_columns, len(stat)), dtype=np.float) * nodata blocks = t_rows * t_columns counter = 0 - percentage = 0. + percentage = 0.0 for row in range(t_rows): # print 'doing row ' + str(row + 1) + '/' + str(t_rows) for col in range(t_columns): counter = counter + 1 - if (float(counter) / float(blocks)) * 100. > percentage: + if (float(counter) / float(blocks)) * 100.0 > percentage: logger.info(" " + str(int(percentage)) + "% completed") - percentage = percentage + 10. + percentage = percentage + 10.0 # determine window boundaries xl = xorg + (col * cellsize_out) xr = xorg + ((col + 1) * cellsize_out)