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, wind, sun, \
            rel_hum= 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.PenmanMonteithET(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, wind, sun,
                           rel_hum)
        self.project = p
Esempio n. 2
0
        def create_storages():
            """
            Creates all storages that are present in the genome.

            :return: None
            """
            cell = self.project[0]
            # Make a dictionary to lookup the different storages
            self.storages = {"first": cell.layers[0], "out": self.outlet}

            # Now create all storages which are depended on the genes provided
            if "snow" in self.genes:
                self.snow = cell.add_storage("Snow", "S")
                cmf.Snowfall(cell.snow, cell)
                self.storages["snow"] = self.snow

            if "canopy" in self.genes:
                self.canopy = cell.add_storage("Canopy", "C")
                self.storages["canopy"] = self.canopy

            if "second" in self.genes:
                self.storages["second"] = cell.add_layer(3.0)

            if "third" in self.genes:
                self.storages["third"] = cell.add_layer(5.0)

            # Always create the river, but connect it later with a waterbalance
            # connection to the outlet if it does not exist in the genes. This
            # makes an easier connection with the other
            self.river = cell.add_storage("River", "R")
            self.storages["river"] = self.river
Esempio n. 3
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)
Esempio 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")
Esempio n. 5
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)
    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
Esempio n. 7
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, wind, sun, \
            rel_hum = 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.PenmanMonteithET(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, wind, sun, rel_hum)

        self.project = p