def __init__(self, begin, end):
        """Initializes the model and build the core setup"""
        # tr_soil_GW = Residence time of the water in the soil to the GW
        self.params = [
            param("tr_soil_out", 0., 200.),
            # tr_GW_out = Residence time in the groundwater to
            #  the outlet
            param('V0_soil', 0., 300.),
            # beta_soil_out = exponent that changes the form of the
            # flux from the soil to the outlet
            param("beta_soil_out", 0.3, 8.0),
            # ETV1 = the Volume that defines that the evaporation
            # is lowered because of not enough water in the soil
            param('ETV1', 0., 300.),
            # fETV0 = factor the ET is multiplied by, when water is
            #  low
            param('fETV0', 0., 0.9),
            # Rate of snow melt
            param('meltrate', 0.01, 15.),
            # Snow_melt_temp = Temperature at which the snow melts
            # (needed because of averaged temp
            param('snow_melt_temp', -3.0, 3.0)
        ]
        self.begin = begin
        self.end = end

        # load the weather data and discharge data
        prec, temp, temp_min, temp_max, Q = self.loadPETQ()
        self.Q = Q

        # use only one core (faster when model is small
        cmf.set_parallel_threads(1)

        # Generate a cmf project with one cell for a lumped model
        self.project = cmf.project()
        p = self.project

        # Create a cell in the project
        c = p.NewCell(0, 0, 0, 1000)

        # Add snow storage
        c.add_storage("Snow", "S")
        cmf.Snowfall(c.snow, c)

        # Add the soil and groundwater layers
        soil = c.add_layer(2.0)

        # Give the storages a initial volume
        c.layers[0].volume = 15

        # Install a calculation of the evaporation
        cmf.HargreaveET(soil, c.transpiration)

        # Create an outlet
        self.outlet = p.NewOutlet("outlet", 10, 0, 0)

        # Create the meteo stations
        self.make_stations(prec, temp, temp_min, temp_max)
        self.project = p
Ejemplo n.º 2
0
    def __init__(self):
        self.Params = [
            Param("tr_first_out", 0., 300),
            Param("tr_first_river", 0., 300),
            Param("tr_first_second", 0., 300),
            Param("tr_second_third", 0., 300),
            Param("tr_second_river", 0., 300),
            Param("tr_third_river", 0., 300),
            Param("tr_river_out", 0., 300),
            Param("beta_first_out", 0., 4),
            Param("beta_first_river", 0., 4),
            Param("beta_first_second", 0., 4),
            Param("beta_second_river", 0., 4),
            Param("beta_second_third", 0., 4),
            Param("beta_third_river", 0., 4),
            Param("beta_river_out", 0., 4),
            Param("canopy_lai", 1., 10),
            Param("canopy_closure", 0., 1.0),
            Param("snow_meltrate", 0.1, 15.),
            Param("snow_melt_temp", -5.0, 5.0),
            Param("V0_first_out", 0., 200),
            Param("V0_first_river", 0., 200),
            Param("V0_first_second", 0., 200),
            Param("ETV0", 0, 200),
            Param("fETV0", 0., 0.85)
        ]

        precipitation, temperature_avg, temperature_min, \
            temperature_max, discharge = utils.load_data(
                "observed_discharge.txt",
                "temperature_max_min_avg.txt",
                "precipitation.txt",
                2976.41
            )
        self.Q = discharge
        cmf.set_parallel_threads(1)
        self.project = cmf.project()
        project = self.project
        cell = project.NewCell(0, 0, 0, 1000)

        cell.add_storage("Snow", "S")
        cmf.Snowfall(cell.snow, cell)

        cell.add_layer(2.0)
        cell.add_layer(5.0)
        cell.add_layer(10.0)

        cmf.HargreaveET(cell.layers[0], cell.transpiration)

        self.outlet = project.NewOutlet("outlet", 10, 0, 0)

        self.make_stations(precipitation, temperature_avg, temperature_min,
                           temperature_max)

        self.river = cell.add_storage("River", "R")
        self.canopy = cell.add_storage("Canopy", "C")

        self.begin = datetime.datetime(1979, 1, 1)
        self.end = datetime.datetime(1986, 12, 31)
Ejemplo n.º 3
0
    def __init__(self, begin, end):
        """
        Initialisiert das Modell und baut das Grundsetup zusammen
        
        MP111 - Änderungsbedarf: Sehr groß, hier wird es Euer Modell definiert
        Verständlichkeit: mittel

        """

        # TODO: Parameterliste erweitern und anpassen.
        # Wichtig: Die Namen müssen genau die gleichen sein,
        # wie die Argumente in der Funktion setparameters.
        #
        # Parameter werden wie folgt definiert:
        # param(<Name>,<Minimum>,<Maximum>)
        self.params = [
            param('tr', 0., 1000.),
            param('ETV1', 0., 1000.),
            param('Vr', 0., 1000.),
            param('fETV0', 0., 1.),
            param('beta', 0.3, 5.0)
        ]

        # Lädt die Treiber Daten
        P, T, Tmin, Tmax, Q = self.loadPETQ()
        self.Q = Q
        # Nutze nur einen Kern - für unser Modell ist das schneller
        cmf.set_parallel_threads(1)

        # Erzeuge ein Projekt mit einer Zelle für lumped Modell
        self.project = cmf.project()
        p = self.project
        c = p.NewCell(0, 0, 0, 1000)

        # Füge Speicher zur Zelle
        l = c.add_layer(1.0)
        # TODO: Weitere Layer / Speicher zur Zelle hinzufügen

        # Verdunstung
        cmf.HargreaveET(l, c.transpiration)

        # Outlet
        self.outlet = p.NewOutlet('outlet', 10, 0, 0)

        # Regen
        self.makestations(P, T, Tmin, Tmax)
        self.project = p
        self.begin = begin
        self.end = end
Ejemplo n.º 4
0
 def basic_set_up(self):
     """
     Creates the basic storages, that are to be connected in set_parameters.
     :return:
     """
     # Add layers
     self.cell.add_layer(2.0)
     self.cell.add_layer(4.0)
     # Install a connection for the ET
     cmf.HargreaveET(self.cell.layers[0], self.cell.transpiration)
     # Add Snow
     self.cell.add_storage("Snow", "S")
     cmf.Snowfall(self.cell.snow, self.cell)
     # Create a storage for Interception
     self.cell.add_storage("Canopy", "C")
Ejemplo n.º 5
0
    def create_project(self):
        """
        Creates the cmf project with its basic elements
        """
        # Use only a single thread, that is better for a calibration run and for small models
        cmf.set_parallel_threads(1)

        # make the project
        p = cmf.project()

        # make a new cell
        c = p.NewCell(0, 0, 0, 1000)

        # Add a storage
        layer = c.add_layer(1.0)
        # ET
        cmf.HargreaveET(layer, c.transpiration)
        # Outlet
        outlet = p.NewOutlet('outlet', 10, 0, 0)
        return p, outlet
Ejemplo n.º 6
0
    def basic_set_up(self):
        """
        Creates all cmf structures which are the same for all cells.

        :param: cell: cmf.project.NewCell()
        :return: None (cell is changed though)
        """
        # Add Snow
        self.cell.add_storage("Snow", "S")
        cmf.Snowfall(self.cell.snow, self.cell)

        # Add layers and give them some water to start with
        self.cell.add_layer(2.0)
        self.cell.layers[0].volume = 10
        self.cell.add_layer(5.0)
        self.cell.layers[1].volume = 40

        # Create a storage for Interception
        I = self.cell.add_storage("Canopy", "C")

        # Install a connection for the ET
        cmf.HargreaveET(self.cell.layers[0], self.cell.transpiration)
Ejemplo n.º 7
0
        def basic_model_setup():
            """
            Creates the basic layout needed for every model structure.

            :return: None
            """
            # Basic Layout, same for all possible models
            prec = data["prec"]
            obs_discharge = data["discharge"]
            t_mean = data["t_mean"]
            t_min = data["t_min"]
            t_max = data["t_max"]
            self.obs_discharge = obs_discharge

            # Use only one core (quicker for smaller models)
            cmf.set_parallel_threads(1)

            # Generate a project with one cell for a lumped model
            self.project = cmf.project()
            project = self.project

            # Add one cell, which will include all other parts. The area is set
            # to 1000 m², so the units are easier to understand
            cell = project.NewCell(0, 0, 0, 1000)

            # Add a first layer, this one is always present, as a model with no
            # layers makes no sense
            first_layer = cell.add_layer(2.0)

            # Add an evapotranspiration
            cmf.HargreaveET(first_layer, cell.transpiration)

            # Create the CMF meteo and rain stations
            weather_stations.make_stations(self.project, prec, t_mean, t_min,
                                           t_max)

            # Create an outlet
            self.outlet = project.NewOutlet("outlet", 10, 0, 0)
    def __init__(self,begin,end, with_valid_data = False, shift_one_day = False):
        """
        Initializes the model and builds the core setup  
        begin: begin of the calibration period
        eng: end of the calibration period
        with_calib_data: save also the data from the validation period
                        the calibration is still only done form 'begin' to 'end'
        """     
               # tr_S = Residence time of the water in the soil to the GW
        self.params = [param('tr_soil_GW',0.5,150.),
                       # tr_soil_river = residence time from soil to river
                       param("tr_soil_fulda", 0.5,55.),
                        # tr_surf = Residence time from surface 
                       param('tr_surf',0.001,30),
                       # tr_GW_l = residence time in the lower groundwate
                       param('tr_GW_l',1.,1000.),
                       # tr_GW_u = Residence time in the upper groundwater to the river
                       param('tr_GW_u_fulda',1.,750.),
                       # tr_GW_u_GW_l = residencete time to GW_l from GW_u
                       param("tr_GW_u_GW_l", 10., 750.),
                       # tr_fulda = Residence time in the river (in days)
                       param('tr_fulda', 0., 3.5),  

                       # V0_soil = field capacity for the soil
                       param('V0_soil',15.,350.),

                        # beta_P_soil = Exponent that changes the form of the flux from the soil
                       param('beta_soil_GW',0.5,3.2),

                       # beta_fulda = exponent that changes the form of the flux from the soil 
                       param("beta_fulda", 0.3,4.),

                       # ETV1 = the Volume that defines that the evaporation is lowered because of not enough water
                       param('ETV1',0.,100.),
                       # fETV0 = factor the ET is multiplied with when water is low
                       param('fETV0',0.,0.25),

                        # Rate of snow melt
                       param('meltrate',0.15,10.),
                       #  Snow_melt_temp = Temperature at which the snow melts (needed because of averaged temp
                       param('snow_melt_temp',-1.0,4.2) ,
    
#                       #Qd_max = maximal flux from lower groundwater to drinking water production
#                       param('Qd_max', 0.,3.),
#                       # tw_thresholt = amount of water that can't be slurped out by the water pumps
#                       param("TW_threshold", 0.,100.),

                       # LAI = leaf area index
                       param('LAI', 1.,12.),
                       # Canopy Closure
                       param("CanopyClosure",0.,0.5),

                       # Ksat = saturated conductivity of the soil 
                       param("Ksat", 0., 1)
                       ]        
        
        # loads the data  
        P,T,Tmin,Tmax,Q = self.loadPETQ()
        self.Q=Q
        # only use one core (quicker for small models)
        cmf.set_parallel_threads(1)
        # Generate a project with on ecell for a lumped model
        self.project = cmf.project()
        p = self.project
        
        # Add cell for soil and so on (x,y,z,area)
        c = p.NewCell(0,0,0,1000)
        
        # Add snow storage
        c.add_storage('Snow','S')
        cmf.Snowfall(c.snow,c)
        
        # Surfacewater is treated as a storage
        c.surfacewater_as_storage()
        
        # Add the soil and groundwater layers to the soil cell
        soil = c.add_layer(2.0)
        gw_upper = c.add_layer(5.0) 
        gw_lower = c.add_layer(20.0)
        
        # Fill storages
        c.layers[0].volume = 15
        c.layers[1].volume = 80
        c.layers[2].volume = 120
        
        # Evapotranspiration
        cmf.HargreaveET(soil,c.transpiration)
        #cmf.PenmanMonteith()
        
        # Add the Fulda River
        self.fulda = p.NewOpenStorage(name="Fulda",x=0,y=0,z=0, area = 3.3*10**6)
        # Giving the Fulda a mean depth
        self.fulda.potential = 1.5   
   
        # add the drinking water outlet
     #   self.trinkwasser = p.NewOutlet('trinkwasser',20,0,0)
   
        # Outlet
        self.outlet = p.NewOutlet('outlet',10,0,0)
        
        # Storage for the interception
        I=c.add_storage('Canopy','C')
        
        # Rain
        self.makestations(P,T,Tmin,Tmax)
        self.project = p
        self.begin = begin
        self.end = end   
        self.with_valid_data = with_valid_data
        self.shift_one_day = shift_one_day
Ejemplo n.º 9
0
    def __init__(self, begin, end):
        """Initializes the model and build the core setup"""
        # tr_soil_GW = Residence time of the water in the soil to the GW
        self.params = [
            spotpy.parameter.List("tr_soil_gw",
                                  [361.95603672540824, 361.95603672540824]),
            spotpy.parameter.List("tr_soil_out",
                                  [86.36633856546166, 86.36633856546166]),
            spotpy.parameter.List("tr_gw_out",
                                  [81.8626412596028, 81.8626412596028]),
            spotpy.parameter.List("V0_soil",
                                  [291.9533350694828, 291.9533350694828]),
            spotpy.parameter.List("beta_soil_gw",
                                  [2.1866023626527475, 2.1866023626527475]),
            spotpy.parameter.List("beta_soil_out", [0.2, 0.2]),
            spotpy.parameter.List("ETV1",
                                  [101.66837396299148, 101.66837396299148]),
            spotpy.parameter.List("fETV0",
                                  [0.4727208059864018, 0.4727208059864018]),
            # spotpy.parameter.List("meltrate",
            #                       [7.609473369272333,
            #                        7.609473369272333]),
            # spotpy.parameter.List("snow_melt_temp",
            #                       [2.887783422377442,
            #                        2.887783422377442]),
            spotpy.parameter.List("LAI", [4.865867934808, 4.865867934808]),
            spotpy.parameter.List("CanopyClosure",
                                  [0.1924997461816065, 0.1924997461816065]),
        ]
        self.begin = begin
        self.end = end

        # load the weather data and discharge data
        prec, temp, temp_min, temp_max, Q, = self.loadPETQ()
        self.Q = Q

        # use only one core (faster when model is small
        cmf.set_parallel_threads(1)

        # Generate a cmf project with one cell for a lumped model
        self.project = cmf.project()
        p = self.project

        # Create a cell in the projectl_evapotranspiration
        c = p.NewCell(0, 0, 0, 1000, True)

        # # Add snow storage
        # c.add_storage("Snow", "S")
        # cmf.Snowfall(c.snow, c)

        # Add the soil and groundwater layers
        soil = c.add_layer(2.0)
        gw_upper = c.add_layer(5.0)

        # Give the storages a initial volume
        soil.volume = 15
        gw_upper.volume = 80

        # Create a storage for Interception
        I = c.add_storage("Canopy", "C")

        # Install a calculation of the evaporation
        cmf.HargreaveET(soil, c.transpiration)

        # Create an outlet
        self.outlet = p.NewOutlet("outlet", 10, 0, 0)

        # Create the meteo stations
        self.make_stations(prec, temp, temp_min, temp_max)

        self.project = p
Ejemplo n.º 10
0
    def __init__(self, begin, end):
        """Initializes the model and build the core setup"""
        # tr_soil_GW = Residence time of the water in the soil to the GW
        self.params = [
            param('tr_soil_gw', 0., 400.),
            # tr_soil_fulda = residence time from soil to river
            param("tr_soil_out", 0., 200.),

            # tr_gw_upper_fulda = residence time from the upper
            # groundwater to the river
            param("tr_gw_out", 0., 650.),

            # V0_soil = field capacity for the soil
            param('V0_soil', 0., 300.),

            # beta_soil_GW = Changes the flux curve of the soil
            # to the groundwater
            param('beta_soil_gw', 0.3, 6.0),

            # beta_soil_out
            param("beta_soil_out", 0.3, 8.0),

            # ETV1 = the Volume that defines that the evaporation
            # is lowered because of not enough water in the soil
            param('ETV1', 0., 300.),
            # fETV0 = factor the ET is multiplied by, when water is
            #  low
            param('fETV0', 0., 0.9),

            # Rate of snow melt
            param('meltrate', 0.01, 15.),
            # Snow_melt_temp = Temperature at which the snow melts
            # (needed because of averaged temp
            param('snow_melt_temp', -3.0, 3.0),

            # LAI = leaf area index
            param('LAI', 1., 12),
            # Canopy Closure
            param("CanopyClosure", 0., 0.9),
        ]
        self.begin = begin
        self.end = end

        # load the weather data and discharge data
        prec, temp, temp_min, temp_max, Q, = self.loadPETQ()
        self.Q = Q

        # use only one core (faster when model is small
        cmf.set_parallel_threads(1)

        # Generate a cmf project with one cell for a lumped model
        self.project = cmf.project()
        p = self.project

        # Create a cell in the projectl_evapotranspiration
        c = p.NewCell(0, 0, 0, 1000)

        # Add snow storage
        c.add_storage("Snow", "S")
        cmf.Snowfall(c.snow, c)

        # Add the soil and groundwater layers
        soil = c.add_layer(2.0)
        gw_upper = c.add_layer(5.0)

        # Give the storages a initial volume
        soil.volume = 15
        gw_upper.volume = 80

        # Create a storage for Interception
        I = c.add_storage("Canopy", "C")

        # Install a calculation of the evaporation
        cmf.HargreaveET(soil, c.transpiration)

        # Create an outlet
        self.outlet = p.NewOutlet("outlet", 10, 0, 0)

        # Create the meteo stations
        self.make_stations(prec, temp, temp_min, temp_max)

        self.project = p
Ejemplo n.º 11
0
 def test_HargreaveET(self):
     m = Model()
     cmf.HargreaveET(m.layer, m.et)
     m(self)