Index: examples/wflow_orientale_topoflex/wflow_orientale_topoflexHCW.ini =================================================================== diff -u -r7009a9b1afac296365ebef623478dab8a3e2de5e -r12805abd62063cd121fe69ba66c7568a3e7466f7 --- examples/wflow_orientale_topoflex/wflow_orientale_topoflexHCW.ini (.../wflow_orientale_topoflexHCW.ini) (revision 7009a9b1afac296365ebef623478dab8a3e2de5e) +++ examples/wflow_orientale_topoflex/wflow_orientale_topoflexHCW.ini (.../wflow_orientale_topoflexHCW.ini) (revision 12805abd62063cd121fe69ba66c7568a3e7466f7) @@ -36,6 +36,7 @@ selectSr=None,None #input time series +# J.S., deze kunnen weg, zie [modelparameters] sectie Pfile_1 = intss\1_P.tss Efile_1 = intss\1_PET.tss Tfile_1 = intss\1_T.tss @@ -102,6 +103,7 @@ Kr =[0,0] + [layout] # if set to zero the cell-size is given in lat/long (the default) sizeinmetres = 0 @@ -120,39 +122,61 @@ #self.Su_diff=sudiff -# List all timeseries in tss format to save in this section. Timeseries are -# produced per subcatchment. -[outputtss] + + +[modelparameters] +# Format: +# name=stack,type,default,verbose[lookupmap_1],[lookupmap_2],lookupmap_n] +# example: +# RootingDepth=monthlyclim/ROOT,monthyclim,100,1 + +# - name - Name of the parameter (internal variable) +# - stack - Name of the mapstack (representation on disk or in mem) relative to case +# - type - Type of parameter (default = static) +# - default - Default value if map/tbl is not present +# - set to 1 to be verbose if a map is missing +# - lookupmap - maps to be used in the lookuptable in the case the type is statictbl + +#Possible types are:: +# - staticmap: Read at startup from map +# - statictbl: Read at startup from tbl +# - tbl: Read each timestep from tbl and at startup +# - timeseries: read map for each timestep +# - monthlyclim: read a map corresponding to the current month (12 maps in total) +# - dailyclim: read a map corresponding to the current day of the year +# - hourlyclim: read a map corresponding to the current hour of the day (24 in total) (not implemented yet) +# - tss: read a tss file and link to lookupmap (only one allowed) a map using timeinputscalar +Temperature=intss/1_T.tss,tss,0.0,1,staticmaps/wflow_mgauges.map +Precipitation=intss/1_P.tss,tss,0.0,1,staticmaps/wflow_mgauges.map +PotEvaporation=intss/1_PET.tss,tss,0.0,1,staticmaps/wflow_mgauges.map + + +[outputtss_0] +samplemap=staticmaps/wflow_mgauges.map #stages -self.Si[0]=SiW -self.Si[1]=SiH -self.Sf[1]=SfH -self.Sf[0]=SfW -self.Su[1]=SuH -self.Su[0]=SuW +self.Si[0]=SiW.tss +self.Si[1]=SiH.tss +self.Sf[1]=SfH.tss +self.Sf[0]=SfW.tss +self.Su[1]=SuH.tss +self.Su[0]=SuW.tss #fluxen -self.Precipitation=Prec -self.Qu_[0]=QuW -self.Qu_[1]=QuH -self.Ei_[0]=EiW -self.Ei_[1]=EiH -self.Eu_[0]=EuW -self.Eu_[1]=EuH -self.Pe_[0]=peW -self.Pe_[1]=peH -self.Perc_[1]=PercH -self.Cap_[0]=CapW -self.Qf_[1] = QfH -self.Qf_[0] = QfW -self.Qfcub = Qfcub -self.Qtlag = Qtlag +self.Precipitation=Prec.tss +self.Qu_[0]=QuW.tss +self.Qu_[1]=QuH.tss +#self.Ei_[1]=EiH.tss +self.Eu_[0]=EuW.tss +self.Eu_[1]=EuH.tss +self.Pe_[0]=peW.tss +self.Pe_[1]=peH.tss +self.Perc_[1]=PercH.tss +self.Cap_[0]=CapW.tss +self.Qf_[1] = QfH.tss +self.Qf_[0] = QfW.tss +self.Qfcub = Qfcub.tss +self.Qtlag = Qtlag.tss #waterbalance -# Variables to determine basic statistics for (and save to disk at the -# and of the run. Note that the statistics are only calculated if -# the -S command-line option is given. -# THIS DOES NOT WORK YET. -[statvariables] -#self.FirstZoneDepth=fir + Index: wflow-py/Sandbox/wflow_topoflex/wflow_topoflex.py =================================================================== diff -u -rfe4d512b48102b1a6eb3cf75d9d695569a73db74 -r12805abd62063cd121fe69ba66c7568a3e7466f7 --- wflow-py/Sandbox/wflow_topoflex/wflow_topoflex.py (.../wflow_topoflex.py) (revision fe4d512b48102b1a6eb3cf75d9d695569a73db74) +++ wflow-py/Sandbox/wflow_topoflex/wflow_topoflex.py (.../wflow_topoflex.py) (revision 12805abd62063cd121fe69ba66c7568a3e7466f7) @@ -43,14 +43,14 @@ # TODO: see below """ +Configuratie file aanpassen (reservoir-naam gebruiken ipv nummer) Inlezen tijdseries (grids) Nieuwe manier van wegschrijven tijdseries Nieuwe lezen parameters Lijstjes reservoirs en fluxen Reservoir nul een doorgeefreservoir maken Multiplication with cell surface aanpassen Verwijderen IRURFR_L statements? -Documentatie updaten! """ @@ -263,31 +263,17 @@ self.Classes = [x for x in range(len(self.NamesClasses))] # numbering of classes # selection of reservoir conceputalisatie - codes are described in reservoir files - self.selectSi = configget(self.config, "model", - "selectSi", "0, 0, 0").replace( - ' ', '').replace('[', '').replace( - ']', '').replace( - 'None', '').split(',') - self.selectSu = configget(self.config, "model", - "selectSu", "0, 0, 0").replace( - ' ', '').replace('[', '').replace( - ']', '').replace( - 'None', '').split(',') - self.selectSus = configget(self.config, "model", - "selectSus", "0, 0, 0").replace( - ' ', '').replace('[', '').replace( - ']', '').replace( - 'None', '').split(',') - self.selectSf = configget(self.config, "model", - "selectSf", "0, 0, 0").replace( - ' ', '').replace('[', '').replace( - ']', '').replace( - 'None', '').split(',') - self.selectSr = configget(self.config, "model", - "selectSr", "0, 0, 0").replace( - ' ', '').replace('[', '').replace( - ']', '').replace( - 'None', '').split(',') + self.selectSi = eval(str(configget(self.config, + "model", "selectSi", "[0,0,0]"))) + self.selectSu = eval(str(configget(self.config, + "model", "selectSu", "[0,0,0]"))) + self.selectSus = eval(str(configget(self.config, + "model", "selectSus", "[0,0,0]"))) + self.selectSf = eval(str(configget(self.config, + "model", "selectSf", "[0,0,0]"))) + self.selectSr = eval(str(configget(self.config, + "model", "selectSr", "[0,0,0]"))) + # static maps to use (normally default) wflow_subcatch = configget(self.config, "model", "wflow_subcatch", "staticmaps/wflow_subcatch.map") @@ -403,8 +389,47 @@ self.Q = self.ZeroMap self.sumwb = self.ZeroMap + # Define timeseries outputs There seems to be a bug and the .tss files are # saved in the current dir... + tssName = os.path.join(self.Dir, "outtss", "exf") + self.logger.info("Create timeseries outputs...") + toprinttss = configsection(self.config,'outputtss') + + tssName = self.Dir + "/" + self.runId + "/runLag" + estr = "self.runLagTss=wf_TimeoutputTimeseries('" + tssName + "', self, self.OutputIdRunoff,noHeader=False)" + exec estr + tssName = self.Dir + "/" + self.runId + "/Ss" + estr = "self.SsTss=wf_TimeoutputTimeseries('" + tssName + "', self, self.OutputIdRunoff,noHeader=False)" + exec estr + tssName = self.Dir + "/" + self.runId + "/Qs" + estr = "self.QsTss=wf_TimeoutputTimeseries('" + tssName + "', self, self.OutputIdRunoff,noHeader=False)" + exec estr + tssName = self.Dir + "/" + self.runId + "/WB" + estr = "self.WBTss=wf_TimeoutputTimeseries('" + tssName + "', self, self.OutputIdRunoff,noHeader=False)" + exec estr + + if self.IRURFR_L: + self.check=nominal(i*scalar(self.TopoId)) + self.OutputGaugeId=boolean(ifthenelse(self.gaugesMap == self.check,1*scalar(self.TopoId),0*scalar(self.TopoId))) + for a in toprinttss: + tssName = self.Dir + "/" + self.runId + "/" + self.config.get("outputtss", a) + estr = "self." + self.config.get("outputtss", a) + "Tss=wf_TimeoutputTimeseries('" + tssName + "', self, self.OutputIdRunoff,noHeader=False)" + self.logger.info("Creating tss output: " + a + "(" + self.config.get('outputtss', a) + ")") + exec estr + else: + self.allGaugeId = [] + for i in range(1,self.maxGaugeId+1): + self.check=nominal(i*scalar(self.TopoId)) + self.OutputGaugeId=boolean(ifthenelse(self.gaugesMap == self.check,1*scalar(self.TopoId),0*scalar(self.TopoId))) + if any(pcr2numpy(self.OutputGaugeId,nan) > 0): + self.allGaugeId.append(i) + for a in toprinttss: + tssName = self.Dir + "/" + self.runId + "/" + self.config.get("outputtss",a) + str(i) + estr = "self." + self.config.get("outputtss",a) + str(i) + "Tss=wf_TimeoutputTimeseries('" + tssName + "', self, self.OutputGaugeId,noHeader=False)" + self.logger.info("Creating tss output: " + a + "(" + self.config.get('outputtss',a) + ")") + exec estr + self.SaveDir = os.path.join(self.Dir, self.runId) self.logger.info("Starting Dynamic run...") @@ -510,32 +535,32 @@ if self.scalarInput: if self.InputSeries == 1: - self.Precipitation = timeinputscalar(self.precipTss, self.gaugesMap) - self.PotEvaporation = timeinputscalar(self.evapTss, self.gaugesMap) - self.Temperature = timeinputscalar(self.tempTss, self.gaugesMap) + self.Precipitation = timeinputscalar(self.precipTss,self.gaugesMap) + self.PotEvaporation = timeinputscalar(self.evapTss,self.gaugesMap) + self.Temperature = timeinputscalar(self.tempTss,self.gaugesMap) elif self.InputSeries == 2: - self.Precipitation = timeinputscalar(self.precipTss2, self.gaugesMap) - self.EpDay = timeinputscalar(self.evapTss2, self.gaugesMap) - self.Tmean = timeinputscalar(self.tempDMTss, self.gaugesMap) - self.Rn = timeinputscalar(self.radnTss, self.gaugesMap) - self.rad_si = timeinputscalar(self.radsTss, self.gaugesMap) - self.sgamma = timeinputscalar(self.sgammaTss, self.gaugesMap) - self.vpd = timeinputscalar(self.vpdTss, self.gaugesMap) - self.wind2m = timeinputscalar(self.windTss, self.gaugesMap) - self.DS = timeinputscalar(self.daySTss, self.gaugesMap) - self.DE = timeinputscalar(self.dayETss, self.gaugesMap) + self.Precipitation = timeinputscalar(self.precipTss2,self.gaugesMap) + self.EpDay = timeinputscalar(self.evapTss2,self.gaugesMap) + self.Tmean = timeinputscalar(self.tempDMTss,self.gaugesMap) + self.Rn = timeinputscalar(self.radnTss,self.gaugesMap) + self.rad_si = timeinputscalar(self.radsTss,self.gaugesMap) + self.sgamma = timeinputscalar(self.sgammaTss,self.gaugesMap) + self.vpd = timeinputscalar(self.vpdTss,self.gaugesMap) + self.wind2m = timeinputscalar(self.windTss,self.gaugesMap) + self.DS = timeinputscalar(self.daySTss,self.gaugesMap) + self.DE = timeinputscalar(self.dayETss,self.gaugesMap) # self.LAI = timeinputscalar(self.laiTss,self.gaugesMap) - self.rst_lai = [timeinputscalar(self.rst_laiTss[i], self.gaugesMap) for i in self.Classes] + self.rst_lai = [timeinputscalar(self.rst_laiTss[i],self.gaugesMap) for i in self.Classes] else: - self.Precipitation=cover(self.wf_readmap(self.P_mapstack, 0.0), 0.0) - self.PotEvaporation=cover(self.wf_readmap(self.PET_mapstack, 0.0), 0.0) - self.Inflow=pcrut.readmapSave(self.Inflow_mapstack, 0.0) + self.Precipitation=cover(self.wf_readmap(self.P_mapstack,0.0),0.0) + self.PotEvaporation=cover(self.wf_readmap(self.PET_mapstack,0.0),0.0) + self.Inflow=pcrut.readmapSave(self.Inflow_mapstack,0.0) if self.ExternalQbase: - self.Seepage = cover(self.wf_readmap(self.Seepage_mapstack, 0.0), 0.0) + self.Seepage = cover(self.wf_readmap(self.Seepage_mapstack,0.0),0.0) else: self.Seepage=cover(0.0) - self.Temperature=self.wf_readmap(self.TEMP_mapstack, 0.0) + self.Temperature=self.wf_readmap(self.TEMP_mapstack,0.0) if self.IRURFR_L: self.PotEvaporation = areatotal(self.PotEvaporation * self.percentArea, nominal(self.TopoId)) @@ -552,29 +577,31 @@ #INTERCEPTION ========================================================================================= - if self.selectSi[k]: - eval_str = 'reservoir_Si.{:s}(self, k)'.format(self.selectSi[k]) - eval(eval_str) + if self.selectSi[k] > 0: + version = reservoir_Si.selectSiR(self.selectSi[k]) + eval('reservoir_Si.' + version + '(self,k)') + #UNSATURATED ZONE ====================================================================================== - if self.selectSu[k]: - eval_str = 'reservoir_Su.{:s}(self, k)'.format(self.selectSu[k]) - eval(eval_str) + if self.selectSu[k] > 0: + version = reservoir_Su.selectSuR(self.selectSu[k]) + eval('reservoir_Su.' + version + '(self,k)') #COMBINED SATURATED AND UNSATURATED ZONE ======================================================================== - if self.selectSus[k]: - eval_str = 'reservoir_Sus.{:s}(self, k)'.format(self.selectSus[k]) - eval(eval_str) + if self.selectSus[k] > 0: + version = reservoir_Sus.selectSusR(self.selectSus[k]) + eval('reservoir_Sus.' + version + '(self,k)') #FAST RUNOFF RESERVOIR =================================================================================== - if self.selectSf[k]: - eval_str = 'reservoir_Sf.{:s}(self, k)'.format(self.selectSf[k]) - eval(eval_str) + if self.selectSf[k] > 0: + version = reservoir_Sf.selectSfR(self.selectSf[k]) + eval('reservoir_Sf.' + version + '(self,k)') #RIPARIAN ZONE RESERVOIR ================================================================================== - if self.selectSr[k]: - eval_str = 'reservoir_Sr.{:s}(self, k)'.format(self.selectSr[k]) - eval(eval_str) + if self.selectSr[k] > 0: + version = reservoir_Sr.selectSrR(self.selectSr[k]) + eval('reservoir_Sr.' + version + '(self,k)') + #SLOW RUNOFF RESERVOIR =========================================================================== @@ -640,7 +667,32 @@ self.sumwb=self.sumwb + self.WB self.sumE = sum(multiply(self.Ei_,self.percent)) + sum(multiply(self.Eu_,self.percent)) + sum(multiply(self.Er_,self.percent)) + # EXPORTING TSS ========================================================================================== + + if self.teller > self.Ctime: + estr = "self.runLagTss.sample(self.QLagTot)" + eval(estr) + estr = "self.SsTss.sample(self.Ss)" + eval(estr) + estr = "self.QsTss.sample(self.Qs)" + eval(estr) + estr = "self.WBTss.sample(self.WBtot)" + eval(estr) + if self.IRURFR_L: + toprinttss = configsection(self.config,'outputtss') + for a in toprinttss: + estr = "self." + self.config.get("outputtss",a) + "Tss.sample(" + a +")" + eval(estr) + else: + for i in range(1,self.maxGaugeId+1): + if i in self.allGaugeId: + toprinttss = configsection(self.config,'outputtss') + for a in toprinttss: + estr = "self." + self.config.get("outputtss",a) + str(i) + "Tss.sample(" + a +")" + eval(estr) + + # The main function is used to run the program from the command line def main(argv=None):