Пример #1
0
def drive_zscroll_noTs(ZHIGH, ZLOW, DZ):
    print "Now calling initialize"
    initialize.run()

    for z in np.arange(ZHIGH, ZLOW, DZ):
        print z
        perturb_field.run(z)
    return
Пример #2
0
nzoom = int(sys.argv[3])

x, y, z, r = my.get_xyzr(nstop)
r = r * 2**nzoom

for i in range(nzoom):
    nc = nstart + i * (nstop - nstart) / nzoom
    folder = "output_" + str(nc).zfill(5)
    xc, yc, zc, rc = my.get_xyzr(nc)

    r = r / 2
    xmi = str(xc - r)
    xma = str(xc + r)
    ymi = str(yc - r)
    yma = str(yc + r)
    zmi = str(zc - r / (i + 1))
    zma = str(zc + r / (i + 1))

    bndry = "-xmi " + xmi + " -xma " + xma
    bndry = bndry + " -ymi " + ymi + " -yma " + yma
    bndry = bndry + " -zmi " + zmi + " -zma " + zma

    lma = 9 + i
    stri = str(i)
    cmd1 = "amr2map -typ 1 -lma " + str(
        lma) + " -inp " + folder + " -out mov/gas/gas_zoomstep_" + stri
    cmd1 = cmd1 + ".dat -dir z " + bndry
    cmd2 = "map2img.py -l --colormap=hot mov/gas/gas_zoomstep_" + stri + ".dat "
    cmd2 = cmd2 + "-o mov/gas/gas_zoomstep_" + stri + ".png"
    my.run(cmd1, cmd2, calc, show, run)
Пример #3
0
import initialize
import train_seg

if __name__ == '__main__':
    initialize.run()
    train_seg.run()
Пример #4
0
    def run_atm(self):
        """ Program sequence """
        #====================================================
        # Initialization Process
        #====================================================
        print '==================='
        print ' Initializing ATM'
        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)

        #=========================================
        # Initializing Site Specific Information
        #=========================================
        if self.Simulation_area.lower() == 'barrow':
            run_barrow.initialize_barrow(self)
        elif self.Simulation_area.lower() == 'tanana':
            run_tanana.initialize_tanana(self)
        elif self.Simulation_area.lower() == 'yukon':
            run_yukon.initialize_yukon(self)

        #=======================================
        # READ MET Data, Calculate Degree Days,
        # and Calculate Climatic Data needed
        # for ecotype changes.
        #=======================================
        initialize.Met(self)

        #++++++++++++++++++++++++++++++++++++++++++++++
        #  ========================================
        #    INITIALIZE COHORT PROPERTIES
        #  ========================================
        #++++++++++++++++++++++++++++++++++++++++++++++
        print '======================================'
        print ' Initializing Terrestrial Properties '
        print '======================================'
        if self.Simulation_area.lower() == 'barrow':
            run_barrow.initialize_barrow_cohorts(self)
        elif self.Simulation_area.lower() == 'tanana':
            run_tanana.Terrestrial_Tanana(self)

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

        initialize.run(self)
        if self.Simulation_area.lower() == 'barrow':
            run_barrow.run_barrow(self, time)
        elif self.Simulation_area.lower() == 'tanana':
            run_tanana.run_tanana(self, time)

        print '=================================================='
        print '            Finished the MAIN LOOP '
        print '=================================================='

        # -------------------
        # 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':
            archive.read_archive(self)
            archive.archive(self)
            #----------------------------------------------------------------------------------------------------------
            # 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')
            #----------------------------------------------------------------------------------------------------------
            if self.Simulation_area.lower() == 'barrow':
                os.chdir(self.control['Run_dir'] + self.Input_directory +
                         '/Barrow/')

        print '----------------------------------------'
        print '        Simulation Complete             '
        print '----------------------------------------'
Пример #5
0
#!/usr/bin/python
# shrink_spheres.py
# invoke shrink_sphere.py for all halos on stellar part

import os
import sys
import threading
import initialize as my

d = sys.argv[1]+"/"

os.nice(10)
halo = open(d+"halo","r")
os.system("rm "+d+"halosp")
i = 0
for line in halo:
    i = i + 1
    si = str(i)
    cmd = "shrink_sphere.py "+d+"stars/stars_"+si+".dat >>"+d+"halosp"
    print cmd
    my.run(cmd)
    # this is not done for the stars
    # we want to center only on dm particles
Пример #6
0
import sys
import initialize as my
import mys

brute = True; loop=True;
os.nice(1)

my.print_usage()

# get parameters
# no parameter: run all
# one param:    run specified
i = len(sys.argv)
if(i==1):
    for k in range(18):
        my.run("master.py "+str(k))
    sys.exit(0)
    
action = int(sys.argv[1])

if(action==-1):
    mys.clear()

if(action==0):
    print "prepare output folder structure, MySQL structure"
#    mys.setup()
#    mys.fill_sim(simdir,num,nstart,nstop)
    for ncounter in range(nstop-nstart+1):
        d=mys.d(nstart+ncounter)
#        d=simdir+"/output_"+str(ncounter+nstart).zfill(5)+"/";
        my.mkdir(d+'amr')
Пример #7
0
Файл: ATM.py Проект: ua-snap/atm
    def run_atm(self):
        
        """ Program sequence """
        #====================================================
        # Initialization Process
        #====================================================
        print '==================='
        print ' Initializing ATM'
        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)


        #=========================================
        # Initializing Site Specific Information
        #=========================================
        if self.Simulation_area.lower() == 'barrow':
            run_barrow.initialize_barrow(self)
        elif self.Simulation_area.lower() == 'tanana':
            run_tanana.initialize_tanana(self)
         
        #=======================================
        # READ MET Data, Calculate Degree Days,
        # and Calculate Climatic Data needed
        # for ecotype changes.
        #=======================================
        initialize.Met(self)

        #++++++++++++++++++++++++++++++++++++++++++++++
        #  ========================================
        #    INITIALIZE COHORT PROPERTIES
        #  ========================================
        #++++++++++++++++++++++++++++++++++++++++++++++
    	print '======================================'
        print ' Initializing Terrestrial Properties '
        print '======================================'
        if self.Simulation_area.lower() == 'barrow':
            run_barrow.initialize_barrow_cohorts(self)
        elif self.Simulation_area.lower() == 'tanana':
            run_tanana.Terrestrial_Tanana(self)

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

        initialize.run(self)
        if self.Simulation_area.lower() == 'barrow':
            run_barrow.run_barrow(self, time)
	elif self.Simulation_area.lower() == 'tanana':
	    run_tanana.run_tanana(self, time)

        print '=================================================='
        print '            Finished the MAIN LOOP '
        print '=================================================='


        # -------------------
        # 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 '----------------------------------------'        
Пример #8
0
import initialize as my
import mys

brute = True
loop = True
os.nice(1)

my.print_usage()

# get parameters
# no parameter: run all
# one param:    run specified
i = len(sys.argv)
if (i == 1):
    for k in range(18):
        my.run("master.py " + str(k))
    sys.exit(0)

action = int(sys.argv[1])

if (action == -1):
    mys.clear()

if (action == 0):
    print "prepare output folder structure, MySQL structure"
    #    mys.setup()
    #    mys.fill_sim(simdir,num,nstart,nstop)
    for ncounter in range(nstop - nstart + 1):
        d = mys.d(nstart + ncounter)
        #        d=simdir+"/output_"+str(ncounter+nstart).zfill(5)+"/";
        my.mkdir(d + 'amr')
Пример #9
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 '----------------------------------------'        
Пример #10
0
nstart = int(sys.argv[1])
nstop  = int(sys.argv[2])
nzoom  = int(sys.argv[3])

x,y,z,r= my.get_xyzr(nstop)
r = r*2**nzoom

for i in range(nzoom):
    nc = nstart+i*(nstop-nstart)/nzoom
    folder = "output_"+str(nc).zfill(5)
    xc,yc,zc,rc=my.get_xyzr(nc)

    r = r/2
    xmi= str(xc-r); xma = str(xc+r)
    ymi= str(yc-r); yma = str(yc+r)
    zmi= str(zc-r/(i+1)); zma = str(zc+r/(i+1))

    bndry="-xmi "+xmi+" -xma "+xma
    bndry=bndry+" -ymi "+ymi+" -yma "+yma
    bndry=bndry+" -zmi "+zmi+" -zma "+zma
    
    lma = 9+i
    stri = str(i)
    cmd1 = "amr2map -typ 1 -lma "+str(lma)+" -inp "+folder+" -out mov/gas/gas_zoomstep_"+stri
    cmd1 = cmd1 +".dat -dir z "+bndry
    cmd2 = "map2img.py -l --colormap=hot mov/gas/gas_zoomstep_"+stri+".dat "
    cmd2 = cmd2+"-o mov/gas/gas_zoomstep_"+stri+".png"
    my.run(cmd1,cmd2,calc,show,run)