Beispiel #1
0
    def dumpState(self, outputDirectory):
        #write all state to disk to facilitate restarting

        if outputDirectory == None:
            return
        
        state = self.getState()
        
        routingState = state['routing']
        for variable, map in routingState.iteritems():
            vos.writePCRmapToDir(\
             map,\
             str(variable)+"_"+
             str(self._modelTime.fulldate)+".map",\
             outputDirectory)
Beispiel #2
0
    def dumpState(self, outputDirectory, timeStamp="Default"):
        #write all state to disk to facilitate restarting

        state = self.getState()

        groundWaterState = state['groundwater']

        # time stamp used as part of the file name:
        if timeStamp == "Default": timeStamp = str(self._modelTime.fulldate)

        for variable, map in groundWaterState.iteritems():
            vos.writePCRmapToDir(\
             map,\
             str(variable)+"_"+
             timeStamp+".map",\
             outputDirectory)
    def dumpStateDir(self, outputDirectory):
        #write all state to disk to facilitate restarting.

        if outputDirectory == None:
            return

        stateDirectory = outputDirectory

        if not os.path.exists(stateDirectory):
            os.makedirs(stateDirectory)
        
        state = self.getState()
        
        landSurfaceState = state['landSurface']
        
        for coverType, coverTypeState in landSurfaceState.iteritems():
            for variable, map in coverTypeState.iteritems():
                vos.writePCRmapToDir(\
                map,\
                 str(variable)+"_"+coverType+".map",\
                 stateDirectory)
                
        groundWaterState = state['groundwater']
        for variable, map in groundWaterState.iteritems():
            vos.writePCRmapToDir(\
             map,\
             str(variable)+"_"+".map",\
             stateDirectory)

        routingState = state['routing']
        for variable, map in routingState.iteritems():
            vos.writePCRmapToDir(\
             map,\
             str(variable)+"_"+".map",\
             stateDirectory)
    def dumpState(self, outputDirectory):
        #write all state to disk to facilitate restarting

        state = self.getState()
        
        landSurfaceState = state['landSurface']
        
        for coverType, coverTypeState in landSurfaceState.iteritems():
            for variable, map in coverTypeState.iteritems():
                vos.writePCRmapToDir(\
                map,\
                 str(variable)+"_"+coverType+"_"+
                 str(self._modelTime.fulldate)+".map",\
                 outputDirectory)
                
        groundWaterState = state['groundwater']
        for variable, map in groundWaterState.iteritems():
            vos.writePCRmapToDir(\
             map,\
             str(variable)+"_"+
             str(self._modelTime.fulldate)+".map",\
             outputDirectory)

        routingState = state['routing']
        for variable, map in routingState.iteritems():
            vos.writePCRmapToDir(\
             map,\
             str(variable)+"_"+
             str(self._modelTime.fulldate)+".map",\
             outputDirectory)
    def dumpState(self, outputDirectory, specific_date_string = None):
        #write all state to disk to facilitate restarting

        if specific_date_string == None: specific_date_string = str(self._modelTime.fulldate)
        
        state = self.getState()
        
        landSurfaceState = state['landSurface']
        
        for coverType, coverTypeState in list(landSurfaceState.items()):
            for variable, map in list(coverTypeState.items()):
                vos.writePCRmapToDir(\
                map,\
                 str(variable)+"_"+coverType+"_"+
                 specific_date_string+".map",\
                 outputDirectory)
                
        groundWaterState = state['groundwater']
        for variable, map in list(groundWaterState.items()):
            vos.writePCRmapToDir(\
             map,\
             str(variable)+"_"+
             specific_date_string+".map",\
             outputDirectory)

        routingState = state['routing']
        for variable, map in list(routingState.items()):
            vos.writePCRmapToDir(\
             map,\
             str(variable)+"_"+
             specific_date_string+".map",\
             outputDirectory)
Beispiel #6
0
    def dumpState(self, outputDirectory, timeStamp="Default"):

        state = self.getState()

        groundWaterState = state['groundwater']

        # time stamp used as part of the file name:
        if timeStamp == "Default": timeStamp = str(self._modelTime.fulldate)

        for variable, map in groundWaterState.iteritems():
            vos.writePCRmapToDir(\
             map,\
             str(variable)+"_"+
             timeStamp+".map",\
             outputDirectory)

        for variable, map in groundWaterState.iteritems():
            vos.writePCRmapToDir(\
             pcr.ifthen(self.landmask, map),\
             str(variable)+"_"+
             timeStamp+".masked.map",\
             outputDirectory)
Beispiel #7
0
    def calculateAndDumpMonthlyValuesForMODFLOW(self, outputDirectory, timeStamp = "Default"):

        logger.debug('Calculating (accumulating and averaging) and dumping some monthly variables for the MODFLOW input.')
        
        if self._modelTime.day == 1 or self._modelTime.timeStepPCR == 1:
            
            self.variables = {}
            
            self.variables['monthly_discharge_cubic_meter_per_second'] = pcr.ifthen(self.routing.landmask, pcr.max(0.0, self.routing.disChanWaterBody))
            self.variables['groundwater_recharge_meter_per_day'] = pcr.ifthen(self.routing.landmask, self.landSurface.gwRecharge)
            self.variables['groundwater_abstraction_meter_per_day'] = pcr.ifthen(self.routing.landmask, self.landSurface.totalGroundwaterAbstraction)
        
        self.variables['monthly_discharge_cubic_meter_per_second'] += pcr.ifthen(self.routing.landmask, pcr.max(0.0, self.routing.disChanWaterBody))
        self.variables['groundwater_recharge_meter_per_day'] += pcr.ifthen(self.routing.landmask, self.landSurface.gwRecharge)
        self.variables['groundwater_abstraction_meter_per_day'] += pcr.ifthen(self.routing.landmask, self.landSurface.totalGroundwaterAbstraction)
        
        if self._modelTime.isLastDayOfMonth():

            # averaging monthly discharge, groundwater recharge and groundwater abstraction
            number_of_days = min(self._modelTime.day, self._modelTime.timeStepPCR)
            self.variables['monthly_discharge_cubic_meter_per_second'] = self.variables['monthly_discharge_cubic_meter_per_second'] / number_of_days # unit: m3/s
            self.variables['groundwater_recharge_meter_per_day'] = self.variables['groundwater_recharge_meter_per_day'] / number_of_days             # unit: m/day
            self.variables['groundwater_abstraction_meter_per_day'] = self.variables['groundwater_abstraction_meter_per_day'] / number_of_days       # unit: m/day
        
            # channel storage at the last day of the month
            self.variables['channel_storage_cubic_meter'] = pcr.ifthen(self.routing.landmask, self.routing.channelStorage)                           # unit: m/day

            # time stamp used as part of the file name:
            if timeStamp == "Default": timeStamp = str(self._modelTime.fulldate) 
            
            logger.info('Dumping some monthly variables for the MODFLOW input.')

            for variable, map in self.variables.iteritems():
                vos.writePCRmapToDir(\
                 map,\
                 str(variable)+"_"+
                 timeStamp+".map",\
                 outputDirectory)
Beispiel #8
0
    def dumpVariableValuesForPCRGLOBWB(self,
                                       outputDirectory,
                                       timeStamp="Default"):

        variables = self.modflow.getVariableValuesForPCRGLOBWB()

        # time stamp used as part of the file name:
        if timeStamp == "Default": timeStamp = str(self._modelTime.fulldate)

        for variable, map in variables.iteritems():
            vos.writePCRmapToDir(\
             map,\
             str(variable)+"_"+
             timeStamp+".map",\
             outputDirectory)

        # for a transient run with the coupled PCR-GLOBWB-MODFLOW, make an empty file to indicate that modflow files are ready
        if self._configuration.online_coupling_between_pcrglobwb_and_modflow and \
           self._configuration.steady_state_only == False:
            filename = outputDirectory + "/modflow_files_for_" + str(
                self._modelTime.fulldate) + "_are_ready.txt"
            if os.path.exists(filename): os.remove(filename)
            open(filename, "w").close()