コード例 #1
0
ファイル: run_barrow.py プロジェクト: ua-snap/atm
def run_barrow(self, time):
    for time in range(0, self.stop):
        if time == 0:
            cohorts.initial_barrow(self)
        print '    at time step: ', time
        
        # ++++++++++++++++++++++++++++++++++++++
        # Check for significant climatic event
        # ++++++++++++++++++++++++++++++++++++++
        check_climate_event.check_climate_event(self)  

        # ----------------------------------------------------------
        # Looping over elements
        # ----------------------------------------------------------
        for element in range(0, self.ATTM_nrows * self.ATTM_ncols):

            # ----------------------------------------------------
            # Define the total fractional area of cohorts for
            # each element
            # ----------------------------------------------------
            cohort_start = cohort_check.cohort_start(self, element, time)

            # ----------------------------------------------------
            # Expand/Infill lake & ponds by prescribed rates
            # ----------------------------------------------------
            lake_pond_expansion.lake_pond_expansion(self, element)
            lake_pond_expansion.pond_infill(self, element, time)

            # ----------------------------------------------------------
            # Set active layer depth
            # ---------------------------------------------------------
            active_layer_depth.active_layer_depth(self, time, element)

            # ----------------------------------
            # Cycle through terrestrial cohorts
            # ----------------------------------
            check_Wet_NPG.check_Wet_NPG(self, element, time)
            check_Wet_LCP.check_Wet_LCP(self, element, time)
            check_Wet_CLC.check_Wet_CLC(self, element, time)
            check_Wet_FCP.check_Wet_FCP(self, element, time)
            check_Wet_HCP.check_Wet_HCP(self, element, time)

            # ----------------------------------
            # Set pond/lake ice thickness depth
            # ----------------------------------
            ice_thickness.ice_thickness(self, time, element)
            # ------------------------------
            # Cycle through ponds and lakes
            # ------------------------------
            check_Ponds.check_Ponds(self, element, time)
            check_Lakes.check_Lakes(self, element, time)

            # -------------------------------------------------
            # Cohort Fraction Check (mass balance of cohorts)
            # -------------------------------------------------
            cohort_check.cohort_check(self, element, time, cohort_start)

            if time == self.stop -1:
                cohorts.final_barrow(self)

            # ========================================================================
            # END MAIN LOOP 
            # ========================================================================

        # ========================================================================
        # OUTPUT RESULTS (if requested)
        # ========================================================================
        #  - - - - - - - - -
        # Fractional Areas
        #  - - - - - - - - -
        Output_cohorts_by_year.Output_cohorts_by_year(self, time)
        #  - - - - - - - - - - - - -
        # Dominant Fractional Area
        #  - - - - - - - - - - - - - 
        Output_cohorts_by_year.dominant_cohort(self)                 # Terrestrial_Control
        Output_cohorts_by_year.dominant_fractional_plot(self, time)  # Terrestrial_Control

    # =================================
    # OUTPUT ANIMATIONS (if requested)
    # =================================
    # - - - - - - - - - - - - - - -
    # Fractional Area of Cohorts
    # - - - - - - - - - - - - - - - -
    Output_cohorts_by_year.write_Fractions_avi(self)
    Output_cohorts_by_year.write_Dominant_Cohort_avi(self) # Terrestrial_Control
コード例 #2
0
def run_barrow(self, time):

    for time in range(0, self.stop):
        if time == 0:
            cohorts.initial_barrow(self)
        print '    at time step: ', time

        # ++++++++++++++++++++++++++++++++++++++
        # Check for significant climatic event
        # ++++++++++++++++++++++++++++++++++++++
        check_climate_event.check_climate_event(self)

        # ----------------------------------------------------------
        # Looping over elements
        # ----------------------------------------------------------
        for element in range(0, self.ATTM_nrows * self.ATTM_ncols):

            # ----------------------------------------------------
            # Define the total fractional area of cohorts for
            # each element
            # ----------------------------------------------------
            cohort_start = cohort_check.cohort_start(self, element, time)
            # ----------------------------------------------------
            # Expand/Infill lake & ponds by prescribed rates
            # ----------------------------------------------------
            lake_pond_expansion.lake_pond_expansion(self, element)
            lake_pond_expansion.pond_infill(self, element, time)

            # ----------------------------------------------------------
            # Set active layer depth
            # ---------------------------------------------------------
            active_layer_depth.active_layer_depth(self, time, element)

            # ----------------------------------
            # Cycle through terrestrial cohorts
            # ----------------------------------
            check_Meadow_WT.check_Meadow_WT_Y(self, element, time)
            check_Meadow_WT.check_Meadow_WT_M(self, element, time)
            check_Meadow_WT.check_Meadow_WT_O(self, element, time)
            check_LCP_WT.check_LCP_WT_Y(self, element, time)
            check_LCP_WT.check_LCP_WT_M(self, element, time)
            check_LCP_WT.check_LCP_WT_O(self, element, time)
            check_CLC_WT.check_CLC_WT_Y(self, element, time)
            check_CLC_WT.check_CLC_WT_M(self, element, time)
            check_CLC_WT.check_CLC_WT_O(self, element, time)
            check_FCP_WT.check_FCP_WT_Y(self, element, time)
            check_FCP_WT.check_FCP_WT_M(self, element, time)
            check_FCP_WT.check_FCP_WT_O(self, element, time)
            check_HCP_WT.check_HCP_WT_Y(self, element, time)
            check_HCP_WT.check_HCP_WT_M(self, element, time)
            check_HCP_WT.check_HCP_WT_O(self, element, time)
            #=====================================================
            # NOTE: 17 Oct 2016. The following are place holders
            # until we figure out if/how these sets of cohorts
            # can transition into other cohorts.
            #-----------------------------------------------------
            #check_CoastalWaters_WT.check_CoastalWaters_WT_O(self, element, time)
            #check_DrainedSlope_WT.check_DrainedSlope_WT_Y(self, element, time)
            #check_DrainedSlope_WT.check_DrainedSlope_WT_M(self, element, time)
            #check_DrainedSlope_WT.check_DrainedSlope_WT_O(self, element, time)
            #check_NoData_WT.check_NoData_WT_O(self, element, time)
            #check_SandDunes_WT.check_SandDunes_WT_Y(self, element, time)
            #check_SandDunes_WT.check_SandDunes_WT_M(self, element, time)
            #check_SandDunes_WT.check_SandDunes_WT_O(self, element, time)
            #check_SaturatedBarrens_WT.check_SaturatedBarrens_WT_Y(self, element, time)
            #check_SaturatedBarrens_WT.check_SaturatedBarrens_WT_M(self, element, time)
            #check_SaturatedBarrens_WT.check_SaturatedBarrens_WT_O(self, element, time)
            #check_Shrubs_WT.check_Shrubs_WT_O(self, element, time)
            #check_Urban_WT.check_Urban_WT(self, element, time)
            #====================================================
            # Note: 17 Oct 2016. The following checks are pretty much obsolete
            # at this point. Will clean up once everything is working well.
            # ----------------------------------------------------
            #            check_Wet_NPG.check_Wet_NPG(self, element, time)
            #            check_Wet_LCP.check_Wet_LCP(self, element, time)
            #            check_Wet_CLC.check_Wet_CLC(self, element, time)
            #            check_Wet_FCP.check_Wet_FCP(self, element, time)
            #            check_Wet_HCP.check_Wet_HCP(self, element, time)
            #=====================================================

            # ----------------------------------
            # Set pond/lake ice thickness depth
            # ----------------------------------
            ice_thickness.ice_thickness(self, time, element)
            # ------------------------------
            # Cycle through ponds and lakes
            # ------------------------------
            check_Ponds_WT.check_Ponds_WT_Y(self, element, time)
            check_Ponds_WT.check_Ponds_WT_M(self, element, time)
            check_Ponds_WT.check_Ponds_WT_O(self, element, time)
            check_Lakes_WT.check_LargeLakes_WT_Y(self, element, time)
            check_Lakes_WT.check_LargeLakes_WT_M(self, element, time)
            check_Lakes_WT.check_LargeLakes_WT_O(self, element, time)
            check_Lakes_WT.check_MediumLakes_WT_Y(self, element, time)
            check_Lakes_WT.check_MediumLakes_WT_M(self, element, time)
            check_Lakes_WT.check_MediumLakes_WT_O(self, element, time)
            check_Lakes_WT.check_SmallLakes_WT_Y(self, element, time)
            check_Lakes_WT.check_SmallLakes_WT_M(self, element, time)
            check_Lakes_WT.check_SmallLakes_WT_O(self, element, time)
            # -------------------------------------------------
            # Cohort Fraction Check (mass balance of cohorts)
            # -------------------------------------------------
            cohort_check.cohort_check(self, element, time, cohort_start)

            if time == self.stop - 1:
                cohorts.final_barrow(self)
            # ========================================================================
            # END MAIN LOOP
            # ========================================================================
        # ========================================================================
        # OUTPUT RESULTS (if requested)
        # ========================================================================
        #  - - - - - - - - -
        # Fractional Areas
        #  - - - - - - - - -
        Output_cohorts_by_year.Output_cohorts_by_year(self, time)
        #  - - - - - - - - - - - - -
        # Dominant Fractional Area
        #  - - - - - - - - - - - - -
        Output_cohorts_by_year.dominant_cohort(self)  # Terrestrial_Control
        Output_cohorts_by_year.dominant_fractional_plot(
            self, time)  # Terrestrial_Control

    # =================================
    # OUTPUT ANIMATIONS (if requested)
    # =================================
    # - - - - - - - - - - - - - - -
    # Fractional Area of Cohorts
    # - - - - - - - - - - - - - - - -
    Output_cohorts_by_year.write_Fractions_avi(self)
    Output_cohorts_by_year.write_Dominant_Cohort_avi(
        self)  # Terrestrial_Control
コード例 #3
0
    def run_attm(self):
        
        """ Program sequence """
        #====================================================
        # Initialization Process
        #====================================================
        print '==================='
        print ' Initializing ATTM'
        print '==================='
        read_control.read_control(self)
        initialize.initialize(self)
        read_layers.read_layers(self)
        model_domain.model_domain(self)
        create_attm_cohort_arrays.create_attm_cohort_arrays(self)
        if self.Simulation_area.lower() == 'barrow':
            initial_cohort_population.barrow_initial_cohort_population(self)
            initial_cohort_check.barrow_initial_cohort_check(self)
            cohort_present.barrow_cohort_present(self)
        elif self.Simulation_area.lower() == 'tanana':
            initial_cohort_population.tanana_initial_cohort_population(self)
            initial_cohort_check.tanana_initial_cohort_check(self)
            cohort_present.tanana_cohort_present(self)

         
        #=======================================
        # READ MET Data & Calculate Degree Days
        #=======================================
        initialize.Met(self)


        #++++++++++++++++++++++++++++++++++++++++++++++
        #  ========================================
        #    INITIALIZE BARROW COHORT PROPERTIES
        #  ========================================
        #++++++++++++++++++++++++++++++++++++++++++++++
        if self.Simulation_area.lower() == 'barrow':
            print '=================================== '
            print ' Initializing Lake & Pond Properties'
            print '===================================='
            initialize.LakePond(self)
            set_lake_pond_depth.set_lake_pond_depth(self)
            set_lake_ice_depth_constant.set_lake_ice_depth_constant(self)
            set_ice_thickness_array.set_ice_thickness_array(self)
            climate_expansion_arrays.set_climate_expansion_arrays(self)
            set_pond_growth_array.set_pond_growth_array(self)

            print '====================================='
            print ' Initializing Terrestrial Properties'
            print '====================================='
            initialize.Terrestrial_Barrow(self)
            read_ice_content.read_ice_content(self)
            read_drainage_efficiency.read_drainage_efficiency(self)
            read_initial_ALD.read_initial_ALD(self)
            set_ALD_constant.set_ALD_constant(self)
            set_ALD_array.set_ALD_array(self)
            set_protective_layer.set_protective_layer(self)
            set_initial_cumulative_probability.set_initial_cumulative_probability(self)
            # Initializing Terrestrial Cohort Properties 
            initialize.Wet_NPG(self)
            initialize.Wet_LCP(self)
            initialize.Wet_CLC(self)
            initialize.Wet_FCP(self)
            initialize.Wet_HCP(self)
            # Other needed information [in the future]
            initial_cohort_age.initial_cohort_age(self)

        elif self.Simulation_area.lower() == 'tanana':
            print '======================================'
            print ' Initializing Terrestrial Properties '
            print '======================================'
            initialize.Terrestrial_Tanana(self)


        print '=================================================='
        print '            Starting the MAIN LOOP '
        print '=================================================='

        initialize.run(self)
        for time in range(0, self.stop):
            if time == 0:
                if self.Simulation_area.lower() == 'barrow':
                    cohorts.initial_barrow(self)
                elif self.Simulation_area.lower() == 'tanana':
                    cohorts.initial_tanana(self)
            print '    at time step: ', time
            
            # ++++++++++++++++++++++++++++++++++++++
            # Check for significant climatic event
            # ++++++++++++++++++++++++++++++++++++++
            check_climate_event.check_climate_event(self)            
           
            # ----------------------------------------------------------
            # Looping over elements
            # ----------------------------------------------------------
            for element in range(0, self.ATTM_nrows * self.ATTM_ncols):
                
                # ----------------------------------------------------
                # Define the total fractional area of cohorts for
                # each element
                # ----------------------------------------------------
                cohort_start = cohort_check.cohort_start(self, element, time)
                
                # ----------------------------------------------------
                # Expand/Infill lake & ponds by prescribed rates
                # ----------------------------------------------------
                lake_pond_expansion.lake_pond_expansion(self, element)
                lake_pond_expansion.pond_infill(self, element, time)
                
                # ----------------------------------------------------------
                # Set active layer depth
                # ---------------------------------------------------------
                active_layer_depth.active_layer_depth(self, time, element)
                
                # ----------------------------------
                # Cycle through terrestrial cohorts
                # ----------------------------------
                check_Wet_NPG.check_Wet_NPG(self, element, time)
                check_Wet_LCP.check_Wet_LCP(self, element, time)
                check_Wet_CLC.check_Wet_CLC(self, element, time)
                check_Wet_FCP.check_Wet_FCP(self, element, time)
                check_Wet_HCP.check_Wet_HCP(self, element, time)

                # ----------------------------------
                # Set pond/lake ice thickness depth
                # ----------------------------------
                ice_thickness.ice_thickness(self, time, element)
                # ------------------------------
                # Cycle through ponds and lakes
                # ------------------------------
                check_Ponds.check_Ponds(self, element, time)
                check_Lakes.check_Lakes(self, element, time)
                 
                # -------------------------------------------------
                # Cohort Fraction Check (mass balance of cohorts)
                # -------------------------------------------------
                cohort_check.cohort_check(self, element, time, cohort_start)

                if time == self.stop-1:
                    if self.Simulation_area.lower() == 'barrow':
                        cohorts.final_barrow(self)
                    elif self.Simulation_area.lower() == 'tanana':
                        cohorts.final_tanana(self)
                    
            # ========================================================================
            # END MAIN LOOP 
            # ========================================================================
            
            # ========================================================================
            # OUTPUT RESULTS (if requested)
            # ========================================================================
            #  - - - - - - - - -
            # Fractional Areas
            #  - - - - - - - - -
            Output_cohorts_by_year.Output_cohorts_by_year(self, time)
            #  - - - - - - - - - - - - -
            # Dominant Fractional Area
            #  - - - - - - - - - - - - - 
            Output_cohorts_by_year.dominant_cohort(self)                 # Terrestrial_Control
            Output_cohorts_by_year.dominant_fractional_plot(self, time)  # Terrestrial_Control

        # =================================
        # OUTPUT ANIMATIONS (if requested)
        # =================================
        # - - - - - - - - - - - - - - -
        # Fractional Area of Cohorts
        # - - - - - - - - - - - - - - - -
        Output_cohorts_by_year.write_Fractions_avi(self)
        Output_cohorts_by_year.write_Dominant_Cohort_avi(self) # Terrestrial_Control

        # -------------------
        # Simulation End Time
        # -------------------
        clock.finish(self)
        
        #===========================
        # Output Simulation Results
        #===========================
        if self.results_onscreen.lower() == 'yes':
            results.on_screen(self)
        if self.archive_simulation.lower() == 'yes':
            results.on_file(self)

        
        # ================
        # Archive Results
        # ================
        if self.archive_simulation.lower() == 'yes':
        #----------------------------------------------------------------------------------------------------------
        # Create the tarfile
        #----------------------------------------------------------------------------------------------------------
            self.archive_file =tarfile.open(self.control['Run_dir']+self.Output_directory+str('/Archive/')+ \
                                            self.archive_time+str('_')+self.simulation_name+".tar.gz", mode='w:gz')
        #----------------------------------------------------------------------------------------------------------
            archive.read_archive(self)
            archive.archive(self)
            
        print '----------------------------------------'
        print '        Simulation Complete             '
        print '----------------------------------------'        
コード例 #4
0
def check_water_climate(self, check_climate, i):
    """
    The purpose of this module is to determine whether or not
    a water body (lake or pond) exists in an element during
    a major climatic event.

    If a water exists in the element, the elements will undergo
    expansion and drainage.  Expansion will continue at the
    assigned rate (set by lake-pond expansion rate - currently
    this is 0.005 (15 Oct).

    Drainage will occur at different rates depending upon the
    fractional area of the water bodies.  Loosely based upon
    Ben Jones et al paper.

    If Lakes + Ponds is between 0.001 to .01, 25.5% area will be
    drained and 8.5% will be partially drained.

    If Lakes + Ponds is between 0.01 and 0.1, 17.1% area will be
    completely drained and 5.7% will be partially drained.

    If Lakes + Ponds is between 0.1 and 0.4, 60% of area will be
    completely drained and 20% will be partialy drained.

    If Lakes + Ponds is between 0.1 and less than 1.0, 100%.

    If Lakes + Ponds = 1.0, no drainage or expansion will occur.

    Partial drainage will occur in the element at a randomly
    defined rate between 0 and the drain rate assigned.
    """

    # ---------------------------------------------
    # Check element for water and expand and drain
    # ---------------------------------------------
    if self.ATTM_Ponds[i] + self.ATTM_Lakes[i] > 0.0:
        # ------------------------
        # Set the Drainage Rates
        # ------------------------
        if self.ATTM_Ponds[i] + self.ATTM_Lakes[i] <= 0.01:
            drain_rate = 0.085
            partial_rate = random.uniform(0, drain_rate)
        if self.ATTM_Ponds[i] + self.ATTM_Lakes[i] > 0.01 and \
           self.ATTM_Ponds[i] + self.ATTM_Lakes[i] <= 0.1 :
            drain_rate = 0.057
            partial_rate = random.uniform(0, drain_rate)
        if self.ATTM_Ponds[i] + self.ATTM_Lakes[i] > 0.1 and \
           self.ATTM_Ponds[i] + self.ATTM_Lakes[i] <= 0.4 :
            drain_rate = 0.2
            partial_rate = random.uniform(0, drain_rate)
        if self.ATTM_Ponds[i] + self.ATTM_Lakes[i] > 0.4 and \
           self.ATTM_Ponds[i] + self.ATTM_Lakes[i] < 1.0 :
            drain_rate = 0.2
            partial_rate = random.uniform(0, drain_rate)
        if self.ATTM_Ponds[i] + self.ATTM_Lakes[i] == 1.0:
            drain_rate = 0.0
            partial_rate = 0.0

        # Expansion of lakes and ponds by expansion rate
        lake_pond_expansion.lake_pond_expansion(self, i)

        # Complete Drainage of Pond/Lake & Increase Meadows at prescribed rate
        if self.ATTM_Ponds[i] > 0.0 and self.ATTM_Ponds[i] < 1.0:
            self.ATTM_Ponds[
                i] = self.ATTM_Ponds[i] - self.ATTM_Ponds[i] * drain_rate
            self.ATTM_Wet_NPG[
                i] = self.ATTM_Wet_NPG[i] + self.ATTM_Ponds[i] * drain_rate
        if self.ATTM_Lakes[i] > 0.0 and self.ATTM_Lakes[i] < 1.0:
            self.ATTM_Lakes[
                i] = self.ATTM_Lakes[i] - self.ATTM_Lakes[i] * drain_rate
            self.ATTM_Wet_NPG[
                i] = self.ATTM_Wet_NPG[i] + self.ATTM_Lakes[i] * drain_rate

        # Complete Partial Drainage of Pond/Lake & Increase Meadows at prescribed rate
        if self.ATTM_Ponds[i] > 0.0 and self.ATTM_Ponds[i] < 1.0:
            self.ATTM_Ponds[
                i] = self.ATTM_Ponds[i] - self.ATTM_Ponds[i] * partial_rate
            self.ATTM_Wet_NPG[
                i] = self.ATTM_Wet_NPG[i] + self.ATTM_Ponds[i] * partial_rate
        if self.ATTM_Lakes[i] > 0.0 and self.ATTM_Lakes[i] < 1.0:
            self.ATTM_Lakes[
                i] = self.ATTM_Lakes[i] - self.ATTM_Lakes[i] * partial_rate
            self.ATTM_Wet_NPG[
                i] = self.ATTM_Wet_NPG[i] + self.ATTM_Lakes[i] * partial_rate