Index: examples/wflow_rhine_sbm/wflow_sbm.ini =================================================================== diff -u -r58fb95443da77451296cbca4d6ad8fd71ae8f4da -rd66a33f37991f6a5a18c063434f86b2153256a75 --- examples/wflow_rhine_sbm/wflow_sbm.ini (.../wflow_sbm.ini) (revision 58fb95443da77451296cbca4d6ad8fd71ae8f4da) +++ examples/wflow_rhine_sbm/wflow_sbm.ini (.../wflow_sbm.ini) (revision d66a33f37991f6a5a18c063434f86b2153256a75) @@ -26,7 +26,26 @@ areamap=staticmaps/wflow_subcatch.map areacode=[1,8,7] +[modelparameters] +# Format: +# name=stack,type,default +# example: +# RootingDepth=monthlyclim/ROOT,monthyclim,100 +# - 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 + +#Possible types are:: +# - static: Read at startup from map or tbl (not implmented yet) +# - 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) +#RootingDepth=monthlyclim/ROOTS,monthlyclim,75 + + [run] # either a runinfo file or a start and end-time are required #runinfo=runinfo.xml @@ -89,7 +108,8 @@ #self.TopoLdd=ldd self.InwaterMM=iwm #self.watbal=wat -#self.ActLeakage=lek +self.PotenEvap=PET +self.Precipitation=P [summary] self.MaxLeakage=MaxLeakage.map Index: wflow-py/Scripts/pcr2netcdf.py =================================================================== diff -u -r411e0cf110429b9b0d7bd95d741be5267ce9651e -rd66a33f37991f6a5a18c063434f86b2153256a75 --- wflow-py/Scripts/pcr2netcdf.py (.../pcr2netcdf.py) (revision 411e0cf110429b9b0d7bd95d741be5267ce9651e) +++ wflow-py/Scripts/pcr2netcdf.py (.../pcr2netcdf.py) (revision d66a33f37991f6a5a18c063434f86b2153256a75) @@ -147,9 +147,9 @@ - return x, y, data, FillVal + def getnetcdfmetafromini(inifile): """ Gets a netcdf mete data dictionary from an ini file Index: wflow-py/setup.py =================================================================== diff -u -r45538220e92828b746de290e67509131e9a61373 -rd66a33f37991f6a5a18c063434f86b2153256a75 --- wflow-py/setup.py (.../setup.py) (revision 45538220e92828b746de290e67509131e9a61373) +++ wflow-py/setup.py (.../setup.py) (revision d66a33f37991f6a5a18c063434f86b2153256a75) @@ -1,16 +1,35 @@ -from distutils.core import setup - -from _version import * - -# Source dist -setup(name='wflow', - version= MVERSION, - packages=['wflow'], - package_dir={'wflow': 'wflow'}, - author='J. Schellekens', - author_email='jaap.schellekens@deltares.nl', - url='http://www.openstreams.nl', - license = "GPL", - scripts=['Scripts/pcr2netcdf.py','Scripts/tss2xml.py','wflow/wflow_extract.py','wflow/wflow_sceleton.py','wflow/wflow_gr4.py','wflow/plottss.py','wflow/wflow_wave.py','wflow/wflow_cqf.py','wflow/wflow_floodmap.py','wflow/wflow_upscale.py','wflow/wflow_fit.py','wflow/wflow_adapt.py','wflow/wflow_delwaq.py','Scripts/wflow_prepare_step1.py','Scripts/wflow_prepare_step2.py','wflow/wflow_sbm.py','wflow/wflow_hbv.py','wflow/wflow_W3RA.py','wflow/wflow_upscale.py','wflow/wflow_routing.py'], - description='the wflow hydrological models (part of OpenStreams)', - ) +import os +from _version import * + +try: + from setuptools import setup +except ImportError: + from distutils.core import setup +from setuptools import find_packages +here = os.path.abspath(os.path.dirname(__file__)) + +README = open(os.path.join(here, 'README.txt')).read() +TODO = open(os.path.join(here, 'TODO.txt')).read() + +requires = [ + 'netCDF4', + 'numpy', + 'matplotlib', + 'pcraster'] + + +#setup(**config) + +# Source dist +setup(name='wflow', + version= MVERSION, + packages=['wflow'], + package_dir={'wflow': 'wflow'}, + author='J. Schellekens', + author_email='jaap.schellekens@deltares.nl', + url='http://www.openstreams.nl', + license = "GPL", + scripts=['Scripts/pcr2netcdf.py','Scripts/tss2xml.py','wflow/wflow_extract.py','wflow/wflow_sceleton.py','wflow/wflow_gr4.py','wflow/plottss.py','wflow/wflow_wave.py','wflow/wflow_cqf.py','wflow/wflow_floodmap.py','wflow/wflow_upscale.py','wflow/wflow_fit.py','wflow/wflow_adapt.py','wflow/wflow_delwaq.py','Scripts/wflow_prepare_step1.py','Scripts/wflow_prepare_step2.py','wflow/wflow_sbm.py','wflow/wflow_hbv.py','wflow/wflow_W3RA.py','wflow/wflow_upscale.py','wflow/wflow_routing.py'], + description='the wflow hydrological models (part of OpenStreams)', + ) + Index: wflow-py/wflow/wf_DynamicFramework.py =================================================================== diff -u -r58fb95443da77451296cbca4d6ad8fd71ae8f4da -rd66a33f37991f6a5a18c063434f86b2153256a75 --- wflow-py/wflow/wf_DynamicFramework.py (.../wf_DynamicFramework.py) (revision 58fb95443da77451296cbca4d6ad8fd71ae8f4da) +++ wflow-py/wflow/wf_DynamicFramework.py (.../wf_DynamicFramework.py) (revision d66a33f37991f6a5a18c063434f86b2153256a75) @@ -24,25 +24,20 @@ #TODO: Remove command-line options from models such as -F that is now in the ini #TODO: Fix timestep not forewarding in BMI runs (for reading writing maps) -import osgeo.gdal as gdal -from wflow.wf_netcdfio import * - -import numpy import datetime - import ConfigParser + +from wflow.wf_netcdfio import * #from wf_Timeoutput import * import pcrut -import shutil, glob -import sys +import glob import traceback from wflow_adapt import getStartTimefromRuninfo, getEndTimefromRuninfo +from collections import namedtuple - logging = None -from pcraster import * from pcraster.framework import * from wflow_lib import * #import scipy.io @@ -109,6 +104,12 @@ return 1 + + + + + + class wf_sumavg(): def __init__(self,varname,mode='sum',filename=None): @@ -245,7 +246,9 @@ # def __init__(self, userModel, lastTimeStep=0, firstTimestep=1,datetimestart=dt.datetime(1990,01,01),timestepsecs=86400): frameworkBase.FrameworkBase.__init__(self) - + + self.ParamType = namedtuple("ParamType", "name stack type default") + self.modelparameters = [] # list of model parameters self.exchnageitems = wf_exchnageVariables() self.setQuiet(True) self.reinit=0 @@ -270,7 +273,10 @@ self._addMethodToClass(self.readtblDefault) self._addMethodToClass(self.wf_supplyVariableNamesAndRoles) self._addMethodToClass(self.wf_supplyVariableNamesAndRoles) + self._addMethodToClass(self.wf_updateparameters) + self._addAttributeToClass("ParamType",self.ParamType) + self._userModel()._setNrTimeSteps(lastTimeStep - firstTimestep + 1) if firstTimestep == 0: self._d_firstTimestep = 1 @@ -284,7 +290,71 @@ - + def wf_updateparameters(self): + """ + Update the model [arameters + + input:: + + - pname - Name of the parameter (internal variable) + - pstack - Name of the mapstack (representation on disk or in mem) + - ptype - Type of parameter (default = static) + + Possible parameter types are:: + + - static: Read at startup from map or tbl + - 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) + + :return nothing: + """ + + for par in self.modelparameters: + if self._userModel()._inInitial(): + if par.type == 'static': + if hasattr(self._userModel(),par.name): + tblname = os.path.join(self._userModel().Dir, self._userModel().intbl, par.stack) + theparmap = self.readtblDefault(tblname, + self._userModel().LandUse, self._userModel().TopoId, self._userModel().Soil, + par.default) + setattr(self._userModel(),par.name,theparmap) + else: + print "cannot find " + par.name + par.stack + if self._userModel()._inDynamic(): + if par.type == 'timeseries': + if not hasattr(self._userModel(),par.name): + self._userModel().logger.info("Adding " + par.name + " to model.") + theparmap = self.wf_readmap(os.path.join(self._userModel().caseName,"inmaps",par.stack), par.default) + theparmap = cover(theparmap,par.default) + setattr(self._userModel(),par.name,theparmap) + + if par.type == 'monthlyclim': + if not hasattr(self._userModel(),par.name): + self._userModel().logger.info("Adding " + par.name + " to model.") + theparmap = self.wf_readmapClimatology(os.path.join(self._userModel().caseName,"monthlyclim",par.stack) ,kind=1, default=par.default, verbose=True) + theparmap = cover(theparmap,par.default) + setattr(self._userModel(),par.name,theparmap) + + if par.type == 'hourlyclim': + if not hasattr(self._userModel(),par.name): + self._userModel().logger.info("Adding " + par.name + " to model.") + print "hourlyclim has " + par.name + par.stack + print "Not implemented yet" + + if par.type == 'dailyclim': + if not hasattr(self._userModel(),par.name): + self._userModel().logger.info(par.name + " is not defined yet, adding anyway.") + theparmap = self.wf_readmapClimatology(os.path.join(self._userModel().caseName,"dailyclim",par.stack) ,kind=2, default=par.default, verbose=True) + setattr(self._userModel(),par.name,theparmap) + + + + + + + def _wf_shutdown(self): """ Makes sure the logging closed @@ -476,6 +546,19 @@ thismap = thismap.split('self.')[1] self.statslst.append(wf_sumavg(thismap,mode=sttype,filename=thismapname)) + + # Get model parameters from model object + self.modelparameters = self._userModel().parameters() + # Read extra model parameters from ini file + modpars = configsection(self._userModel().config,"modelparameters") + for par in modpars: + aline = self._userModel().config.get("modelparameters",par) + vals = aline.split(',') + if len(vals) == 3: + self.modelparameters.append(self.ParamType(name=par,stack=vals[0],type=vals[1],default=float(vals[2]))) + else: + logging.error("Parameter line in ini not valid: " + aline) + # Add the summary/statistics variable to the class # self._addAttributeToClass("summap",self._userModel().clone) Index: wflow-py/wflow/wflow_W3RA.py =================================================================== diff -u -ra6bc28d9526c813a31a70905459a892e620af680 -rd66a33f37991f6a5a18c063434f86b2153256a75 --- wflow-py/wflow/wflow_W3RA.py (.../wflow_W3RA.py) (revision a6bc28d9526c813a31a70905459a892e620af680) +++ wflow-py/wflow/wflow_W3RA.py (.../wflow_W3RA.py) (revision d66a33f37991f6a5a18c063434f86b2153256a75) @@ -160,8 +160,8 @@ self.TMIN_mapstack=self.Dir + configget(self.config,"inputmapstacks","TMIN","/inmaps/TMIN") self.PRECIP_mapstack=self.Dir + configget(self.config,"inputmapstacks","PRECIP","/inmaps/PRECIP") self.RAD_mapstack=self.Dir + configget(self.config,"inputmapstacks","RAD","/inmaps/RAD") - self.WINDSPEED_mapstack=self.Dir + configget(self.config,"inputmapstacks","WINDSPEED","/inmaps/WINDSPEED") - self.AIRPRESS_mapstack=self.Dir + configget(self.config,"inputmapstacks","AIRPRESS","/inmaps/AIRPRESS") + self.WINDSPEED_mapstack=self.Dir + configget(self.config,"inputmapstacks","WIND","/inmaps/WIND") + self.AIRPRESS_mapstack=self.Dir + configget(self.config,"inputmapstacks","PRES","/inmaps/PRES") self.ALBEDO_mapstack=self.Dir + configget(self.config,"inputmapstacks","ALBEDO","/inmaps/ALBEDO") self.Altitude=readmap(self.Dir + "/staticmaps/wflow_dem") @@ -282,12 +282,14 @@ #Put the W3RA here. Stuff from W3RA_timestep_model.m #read meteo from file self.logger.debug("Running for: " + str(self.currentdatetime)) - self.TMAX=cover(self.wf_readmap(self.TMAX_mapstack, 10.0), scalar(10.0)) - self.TMIN=cover(self.wf_readmap(self.TMIN_mapstack, 10.0), scalar(10.0)) - self.PRECIP=cover(self.wf_readmap(self.PRECIP_mapstack, 0.0), scalar(0.0)) - self.RAD=cover(self.wf_readmap(self.RAD_mapstack, 10.0), scalar(10.0)) - self.WINDSPEED=cover(self.wf_readmapClimatology(self.WINDSPEED_mapstack, default=1.0), scalar(1.0)) - self.AIRPRESS=cover(self.wf_readmapClimatology(self.AIRPRESS_mapstack, default=980.0), scalar(980.0)) + self.TMAX=cover(self.wf_readmap(self.TMAX_mapstack, 10.0), scalar(10.0))# T in degC + self.TMIN=cover(self.wf_readmap(self.TMIN_mapstack, 10.0), scalar(10.0))# T in degC + self.PRECIP=cover(self.wf_readmap(self.PRECIP_mapstack, 0.0), scalar(0.0)) #mm + self.RAD=cover(self.wf_readmap(self.RAD_mapstack, 10.0), scalar(10.0))# W m-2 s-1 + self.AIRPRESS=cover(self.wf_readmap(self.AIRPRESS_mapstack, 10.0), scalar(10.0))# Pa + self.WINDSPEED=cover(self.wf_readmap(self.WINDSPEED_mapstack, 10.0), scalar(10.0))# ms-1 + #self.WINDSPEED=cover(self.wf_readmapClimatology(self.WINDSPEED_mapstack, default=1.0), scalar(1.0)) + #self.AIRPRESS=cover(self.wf_readmapClimatology(self.AIRPRESS_mapstack, default=980.0), scalar(980.0)) self.ALBEDO=cover(self.wf_readmapClimatology(self.ALBEDO_mapstack, default=0.1), scalar(0.1)) doy=self.currentdatetime.timetuple().tm_yday @@ -300,15 +302,15 @@ # Assign forcing and estimate effective meteorological variables - Pg = self.PRECIP*24*60*60 # from kg m-2 s-1 to mm d-1 + Pg = self.PRECIP # mm Rg = max(self.RAD,scalar(0.0001)) # already in W m-2 s-1; set minimum of 0.01 to avoid numerical problems - Ta = (self.TMIN+scalar(0.75)*(self.TMAX-self.TMIN))-273.15 # from K to degC - T24 = (self.TMIN+scalar(0.5)*(self.TMAX-self.TMIN))-273.15 # from K to degC - pex = min(scalar(17.27)*(self.TMIN-scalar(273.15))/(scalar(237.3)+self.TMIN-scalar(273.15)),scalar(10)) + Ta = self.TMIN+scalar(0.75)*(self.TMAX-self.TMIN)# T in degC + T24 = self.TMIN+scalar(0.5)*(self.TMAX-self.TMIN)# T in degC + pex = min(scalar(17.27)*(self.TMIN)/(scalar(237.3)+self.TMIN),scalar(10)) # T in degC pe = min(scalar(610.8)*(exp(pex)),scalar(10000.0)) - # rescale factor because windspeed climatology is at 50ms - WindFactor = 0.59904 + # rescale factor because windspeed climatology is at 2m + WindFactor = 1.0 u2 = scalar(WindFactor)*self.WINDSPEED*(scalar(1)-(scalar(1)-self.fday)*scalar(0.25))/self.fday self.u2 = scalar(WindFactor)*self.WINDSPEED*(scalar(1)-(scalar(1)-self.fday)*scalar(0.25))/self.fday pair = self.AIRPRESS # already in Pa Index: wflow-py/wflow/wflow_prepare_rad.py =================================================================== diff -u -ra0e4a61f20e152818153dbdf0433e63311443d90 -rd66a33f37991f6a5a18c063434f86b2153256a75 --- wflow-py/wflow/wflow_prepare_rad.py (.../wflow_prepare_rad.py) (revision a0e4a61f20e152818153dbdf0433e63311443d90) +++ wflow-py/wflow/wflow_prepare_rad.py (.../wflow_prepare_rad.py) (revision d66a33f37991f6a5a18c063434f86b2153256a75) @@ -25,12 +25,14 @@ """ Usage: - wflow_prepare_rad -D DEM [-S start day][-E end day][-M][-x lon][-y lat][-h][-l loglevel][-T minutes] + wflow_prepare_rad -D DEM [-O outputdir][-S start day][-E end day] + [-M][-x lon][-y lat][-h][-l loglevel][-T minutes] -D DEM Filename of the digital elevation model + -O outputdir (default is . ) -S Startday - Start day of the simulation (1 Jan is 1) -E EndDay - End day of the simulation - -T minuts - timeresolution in minutss (60 default is 1 hour) + -T minutes - timeresolution in minutes (60 default is 1 hour) -M The DEM xy units are in metres (instead of lat/lon) -x longitute of the map left (if map xy in metres) -y lattitude of the map bottom (if map xy in metres) @@ -39,6 +41,15 @@ -e end hour (per day) of the calculations (default = 23) -h This information + The program produces the following map stacks, one for each day of + the year: + + COR00000.??? - Total clear sky radiation on DEM + SUN00000.??? - Nr of time intervals a pixel was in the sun + FLAT0000.??? - Total clear sky radiation on a flat surface + CORDIR00.??? - Direct clear sky radiation on DEM + FLATDIR0.??? - Direct clear sky radiation on a flat surface + """ @@ -167,7 +178,7 @@ - return Stot, StotCor, StotFlat, Shade, + return StotCor, StotFlat, Shade, SdirCor, SdirFlat def GenRadMaps(SaveDir,Lat,Lon,Slope,Aspect,Altitude,DegreeDem,logje,start=1,end=2,interval=60,shour=1,ehour=23): @@ -185,30 +196,36 @@ for Day in range(start,end+1): avgrad = 0.0 * Altitude - _avgrad = 0.0 * Altitude + _flat = 0.0 * Altitude avshade = 0.0 * Altitude + + cordir = 0.0 * Altitude + flatdir = 0.0 * Altitude id = 1 logje.info("Calulations for day: " + str(Day)) for Hour in calchours: logje.info("Hour: " + str(Hour)) - cradnodem, crad, flat, shade = correctrad(Day,float(Hour),Lat,Lon,Slope,Aspect,Altitude,DegreeDem) + crad, flat, shade, craddir, craddirflat = correctrad(Day,float(Hour),Lat,Lon,Slope,Aspect,Altitude,DegreeDem) avgrad=avgrad + crad _flat = _flat + flat - _avgrad=_avgrad + cradnodem avshade=avshade + scalar(shade) + cordir = cordir + craddir + flatdir = flatdir + craddirflat + nrr = "%03d" % id #report(crad,"tt000000." + nrr) #report(shade,"sh000000." + nrr) #report(cradnodem,"ttr00000." + nrr) id = id + 1 nr = "%0.3d" % Day - report(avgrad/Calcsteps,SaveDir + "/RAD00000." + nr) - report(_avgrad/Calcsteps,SaveDir + "/_RAD0000." + nr) + report(avgrad/Calcsteps,SaveDir + "/COR00000." + nr) report(avshade,SaveDir + "/SHADE000." + nr) report(_flat/Calcsteps,SaveDir + "/FLAT0000." + nr) - report(ifthen((Altitude + 300) > 0.0, cover(avgrad/_flat,1.0)),SaveDir + "/RATI0000." + nr) + report(cordir/Calcsteps,SaveDir + "/CORDIR00." + nr) + report(flatdir/Calcsteps,SaveDir + "/FLATDIR0." + nr) + #report(ifthen((Altitude + 300) > 0.0, cover(avgrad/_flat,1.0)),SaveDir + "/RATI0000." + nr) def usage(*args): sys.stdout = sys.stderr Index: wflow-py/wflow/wflow_sbm.py =================================================================== diff -u -r58fb95443da77451296cbca4d6ad8fd71ae8f4da -rd66a33f37991f6a5a18c063434f86b2153256a75 --- wflow-py/wflow/wflow_sbm.py (.../wflow_sbm.py) (revision 58fb95443da77451296cbca4d6ad8fd71ae8f4da) +++ wflow-py/wflow/wflow_sbm.py (.../wflow_sbm.py) (revision d66a33f37991f6a5a18c063434f86b2153256a75) @@ -313,6 +313,29 @@ report(self.CumExfiltWater, self.SaveDir + "/outsum/CumExfiltWater.map") report(self.watbal, self.SaveDir + "/outsum/watbal.map") + def parameters(self): + """ + Define all model parameters here that the framework should handle for the model + See wf_updateparameters and the parameters section of the ini file + If you use this make sure to all wf_updateparameters at the start of the dynamic section + and at the start/end of the initial section + """ + modelparameters = [] + + #Static model parameters + modelparameters.append(self.ParamType(name="RunoffGeneratingGWPerc",stack="RunoffGeneratingGWPerc.tbl",type="static",default=0.1)) + + # Meteo and other forcing + modelparameters.append(self.ParamType(name="Precipitation",stack="P",type="timeseries",default=0.0)) + modelparameters.append(self.ParamType(name="PotenEvap",stack="PET",type="timeseries",default=0.0)) + modelparameters.append(self.ParamType(name="Temperature",stack="TEMP",type="timeseries",default=10.0)) + modelparameters.append(self.ParamType(name="Inflow",stack="IF",type="timeseries",default=0.0)) + + #etc... + return modelparameters + + + def initial(self): """ Initial part of the model, executed only once. Reads all static data from disk @@ -381,7 +404,7 @@ # Set and get defaults from ConfigFile here ################################### - self.scalarInput = int(configget(self.config, "model", "ScalarInput", "0")) + self.Tslice = int(configget(self.config, "model", "Tslice", "1")) self.interpolMethod = configget(self.config, "model", "InterpolationMethod", "inv") self.reinit = int(configget(self.config, "model", "reinit", "0")) @@ -463,8 +486,6 @@ self.SubCatchFlowOnly = int(configget(self.config, 'model', 'SubCatchFlowOnly', '0')) self.RunoffGeneratingGWPerc = float(configget(self.config, 'defaultfortbl', 'RunoffGeneratingGWPerc', '0.1')) - if self.scalarInput: - self.gaugesMap = readmap(os.path.join(self.Dir, wflow_mgauges)) # location of rainfall/evap/temp gauge(s) self.OutputId = readmap(os.path.join(self.Dir,wflow_subcatch)) # location of subcatchment # Temperature correction poer cell to add @@ -493,7 +514,13 @@ self.Latitude = ycoordinate(boolean(self.Altitude)) self.Longitude = xcoordinate(boolean(self.Altitude)) + + # Read parameters NEW Method + self.logger.info("Linking parameters to landuse, catchment and soil...") + + self.wf_updateparameters() + self.RunoffGeneratingGWPerc = self.readtblDefault(self.Dir + "/" + self.intbl + "/RunoffGeneratingGWPerc.tbl", self.LandUse, subcatch, self.Soil, self.RunoffGeneratingGWPerc) @@ -903,55 +930,19 @@ :var self.ToCubic: Mutiplier to convert mm to m^3/s for fluxes """ + + self.logger.debug( "Step: " + str(int(self.thestep + self._d_firstTimeStep)) + "/" + str(int(self._d_nrTimeSteps))) self.thestep = self.thestep + 1 - if self.scalarInput: - # gaugesmap not yet finished. Should be a map with cells that - # hold the gauges with an unique id - self.Precipitation = timeinputscalar(self.caseName + self.precipTss, self.gaugesMap) - if (os.path.exists(self.caseName + self.inflowTss)): - self.Inflow = cover(timeinputscalar(self.caseName + self.inflowTss, nominal(self.InflowLoc)), 0) - else: - self.Inflow = self.ZeroMap - self.Precipitation = pcrut.interpolategauges(self.Precipitation, self.interpolMethod) - self.PotenEvap = timeinputscalar(self.caseName + self.evapTss, self.gaugesMap) - self.PotenEvap = pcrut.interpolategauges(self.PotenEvap, self.interpolMethod) * self.et_RefToPot - if self.modelSnow: - self.Temperature = timeinputscalar(self.caseName + self.tempTss, self.gaugesMap) - self.Temperature = pcrut.interpolategauges(self.Temperature, self.interpolMethod) - self.Temperature = self.Temperature + self.TempCor - else: - self.Precipitation = cover(self.wf_readmap(self.P_mapstack, 0.0), scalar(0.0)) - self.PotenEvap = cover(self.wf_readmap(self.PET_mapstack, 0.0), scalar(0.0)) * self.et_RefToPot - #self.Inflow=cover(self.wf_readmap(self.Inflow),0) - if (os.path.exists(self.caseName + self.inflowTss)): - self.Inflow = cover(timeinputscalar(self.caseName + self.inflowTss, nominal(self.InflowLoc)), 0) - else: - self.Inflow = cover(self.wf_readmap(self.Inflow_mapstack, 0.0,verbose=False),0) + # Read forcing data and dynamic parameters + self.wf_updateparameters() + #Apply forcing data corrections + self.PotenEvap = self.PotenEvap * self.et_RefToPot + if self.modelSnow: + self.Temperature = self.Temperature + self.TempCor - if self.modelSnow: - self.Temperature = cover(self.wf_readmap(self.TEMP_mapstack, 10.0), scalar(10.0)) - self.Temperature = self.Temperature + self.TempCor - - # Read dynamic vegetationmaps - not tested at all.... - # Fixed parameter for now, these should become maps - if self.DynamicVegetation: - self.LAI = self.wf_readmapClimatology(os.path.join(self.Dir,self.runId,"LAI") ,kind=1, default=self.LAI, verbose=True) - self.Cmax = self.LAI * 0.467 - self.CanopyGapFraction = exp(-1.457 * self.LAI) - """ - Pitman, Rainfall interception by bracken in open habitats 1989 - throughfall coefficient - p = exp[-1.457( _+ 0.063)LAI], - (short vegetation) - Cmax - 0.467( _+ O.O04)LAI - - (Talll vegetation) - Cmax = K *LAI (K == 0.2, Dickinson, 1984] - """ - # Multiply input parameters with a factor (for calibration etc) -p option in command line for k, v in multdynapars.iteritems(): estr = k + "=" + k + "*" + str(v) @@ -965,7 +956,8 @@ """ .. todo:: - Snow modelling if enabled _ needs to be moved as it breaks the scalar input + Snow modelling if enabled _ needs to be moved as it breaks the scalar input + """ if self.modelSnow: self.TSoil = self.TSoil + self.w_soil * (self.Temperature - self.TSoil)