Exemple #1
0
    def soilStorageVolume(self, state, cellAreaMap):

        if self.numberOfLayers == 2:
            return vos.getMapVolume(state['landSurface']['topWaterLayer'] +
                                    state['landSurface']['storUpp'] +
                                    +state['landSurface']['storLow'] +
                                    state['groundwater']['storGroundwater'],
                                    cellAreaMap)  # unit: m3

        if self.numberOfLayers == 3:
            return vos.getMapVolume(state['landSurface']['topWaterLayer'] +
                                    state['landSurface']['storUpp000005'] +
                                    state['landSurface']['storUpp005030'] +
                                    state['landSurface']['storLow030150'] +
                                    state['groundwater']['storGroundwater'],
                                    cellAreaMap)  # unit: m3
Exemple #2
0
 def totalStorageVolume(self, state, cellAreaMap):
     return self.soilStorageVolume(state, cellAreaMap) + self.groundwaterStorageVolume(state, cellAreaMap) +\
         vos.getMapVolume(
         state['landSurface']['interceptStor'] +
         state['landSurface']['snowFreeWater'] +
         state['landSurface']['snowCoverSWE'],
         cellAreaMap)             # unit: m3
Exemple #3
0
    def getIniStates(self, model):

        if self.numberOfLayers == 2:

            self.iniSoilSto = max(
                1E-20,
                vos.getMapVolume(
                    model.landSurface.topWaterLayer +
                    model.landSurface.storUpp + model.landSurface.storLow +
                    model.groundwater.storGroundwater,
                    model.routing.cellArea))  # unit: m3

        if self.numberOfLayers == 3:

            self.iniSoilSto = max(1E-20,
                                  vos.getMapVolume(
                                      model.landSurface.topWaterLayer +
                                      model.landSurface.storUpp000005 +
                                      model.landSurface.storUpp005030 +
                                      model.landSurface.storLow030150 +
                                      model.groundwater.storGroundwater,
                                      model.routing.cellArea))  # unit: m3

        self.iniGwatSto = max(1E-20,
                              vos.getMapVolume(
                                  model.groundwater.storGroundwater,
                                  model.routing.cellArea))  # unit: m3
        self.iniChanSto = max(
            1E-20, vos.getMapVolume(model.routing.channelStorage, 1))
        # unit: m3
        self.iniTotlSto = max(1E-20, self.iniSoilSto + self.iniChanSto +
                              vos.getMapVolume(
                                  model.landSurface.interceptStor +
                                  model.landSurface.snowFreeWater +
                                  model.landSurface.snowCoverSWE,
                                  model.routing.cellArea))  # unit: m3
Exemple #4
0
    def report(self, storesAtBeginning, storesAtEnd):
        # report the state. which states are written when is based on the configuration

        # set total to 0 on first day of the year
        if self._modelTime.doy == 1 or self._modelTime.isFirstTimestep():

            # set all accumulated variables to zero
            self.precipitationAcc = pcr.ifthen(self.landmask, pcr.scalar(0.0))

            for var in self.landSurface.fluxVars:
                vars(self)[var + 'Acc'] = pcr.ifthen(self.landmask,
                                                     pcr.scalar(0.0))

            self.nonFossilGroundwaterAbsAcc = pcr.ifthen(
                self.landmask, pcr.scalar(0.0))
            self.allocNonFossilGroundwaterAcc = pcr.ifthen(
                self.landmask, pcr.scalar(0.0))
            self.baseflowAcc = pcr.ifthen(self.landmask, pcr.scalar(0.0))

            self.surfaceWaterInfAcc = pcr.ifthen(self.landmask,
                                                 pcr.scalar(0.0))

            self.runoffAcc = pcr.ifthen(self.landmask, pcr.scalar(0.0))
            self.unmetDemandAcc = pcr.ifthen(self.landmask, pcr.scalar(0.0))

            self.waterBalanceAcc = pcr.ifthen(self.landmask, pcr.scalar(0.0))
            self.absWaterBalanceAcc = pcr.ifthen(self.landmask,
                                                 pcr.scalar(0.0))

            # also save the storage at the first day of the year (or the first time step)
            self.storageAtFirstDay = pcr.ifthen(self.landmask,
                                                storesAtBeginning)

        # accumulating until the last day of the year:
        self.precipitationAcc += self.meteo.precipitation
        for var in self.landSurface.fluxVars:
            vars(self)[var + 'Acc'] += vars(self.landSurface)[var]

        self.nonFossilGroundwaterAbsAcc += self.groundwater.nonFossilGroundwaterAbs
        self.allocNonFossilGroundwaterAcc += self.groundwater.allocNonFossilGroundwater
        self.baseflowAcc += self.groundwater.baseflow

        self.surfaceWaterInfAcc += self.groundwater.surfaceWaterInf

        self.runoffAcc += self.routing.runoff
        self.unmetDemandAcc += self.groundwater.unmetDemand

        self.waterBalance = \
            (storesAtBeginning - storesAtEnd +
             self.meteo.precipitation + self.landSurface.irrGrossDemand + self.groundwater.surfaceWaterInf -
             self.landSurface.actualET - self.routing.runoff - self.groundwater.nonFossilGroundwaterAbs)

        self.waterBalanceAcc = self.waterBalanceAcc + self.waterBalance
        self.absWaterBalanceAcc = self.absWaterBalanceAcc + \
            pcr.abs(self.waterBalance)

        if self._modelTime.isLastDayOfYear():
            self.dumpState(self._configuration.endStateDir)

            msg = 'The following waterBalance checks assume fracWat = 0 for all cells (not including surface water bodies).'
            # TODO: Improve these water balance checks.
            logging.getLogger("model").info(msg)

            totalCellArea = vos.getMapTotal(
                pcr.ifthen(self.landmask, self.routing.cellArea))
            msg = 'Total area = %e km2'\
                % (totalCellArea/1e6)
            logging.getLogger("model").info(msg)

            deltaStorageOneYear = vos.getMapVolume(
                pcr.ifthen(self.landmask, storesAtEnd) -
                pcr.ifthen(self.landmask, self.storageAtFirstDay),
                self.routing.cellArea)
            msg = 'Delta total storage days 1 to %i in %i = %e km3 = %e mm'\
                % (int(self._modelTime.doy),
                   int(self._modelTime.year),
                   deltaStorageOneYear/1e9,
                   deltaStorageOneYear*1000/totalCellArea)
            logging.getLogger("model").info(msg)

            # reporting the endStates at the end of the Year:
            variableList = [
                'precipitation', 'nonFossilGroundwaterAbs',
                'allocNonFossilGroundwater', 'baseflow', 'surfaceWaterInf',
                'runoff', 'unmetDemand'
            ]
            variableList += self.landSurface.fluxVars
            variableList += ['waterBalance', 'absWaterBalance']

            for var in variableList:
                volume = vos.getMapVolume(self.__getattribute__(var + 'Acc'),
                                          self.routing.cellArea)
                msg = 'Accumulated %s days 1 to %i in %i = %e km3 = %e mm'\
                    % (var, int(self._modelTime.doy),
                       int(self._modelTime.year), volume/1e9, volume*1000/totalCellArea)
                logging.getLogger("model").info(msg)
Exemple #5
0
 def channelStorageVolume(self, state, cellAreaMap):
     # unit: m3
     return vos.getMapVolume(state['routing']['channelStorage'],
                             cellAreaMap)
Exemple #6
0
 def groundwaterStorageVolume(self, state, cellAreaMap):
     # unit: m3
     return vos.getMapVolume(state['groundwater']['storGroundwater'],
                             cellAreaMap)