Best Python code snippet using uiautomator
initialize.py
Source:initialize.py  
1import os2import numpy as np3#==================================================================================4def Wet_NPG(self):5    print '..Reading Wetland Tundra Non-Polygonal Ground Parameters'6    self.WetNPG = {}7    with open(self.Wet_NPG_Control, 'r') as f:8        for line in f:9            if line.startswith('#'):10                continue11            else:12                (key, val) = line.split()13                self.WetNPG[(key)] = val14    # Convert strings to floats as necessary15    self.WetNPG['A1_above']    = float(self.WetNPG['A1_above'])16    self.WetNPG['A2_above']    = float(self.WetNPG['A2_above'])17    self.WetNPG['x0_above']    = float(self.WetNPG['x0_above'])18    self.WetNPG['dx_above']    = float(self.WetNPG['dx_above'])19    self.WetNPG['A1_below']    = float(self.WetNPG['A1_below'])20    self.WetNPG['A2_below']    = float(self.WetNPG['A2_below'])21    self.WetNPG['x0_below']    = float(self.WetNPG['x0_below'])22    self.WetNPG['dx_below']    = float(self.WetNPG['dx_below'])23    self.WetNPG['a_above']     = float(self.WetNPG['a_above'])24    self.WetNPG['b_above']     = float(self.WetNPG['b_above'])25    self.WetNPG['a_below']     = float(self.WetNPG['a_below'])26    self.WetNPG['b_below']     = float(self.WetNPG['b_below'])27    self.WetNPG['K_above']     = float(self.WetNPG['K_above'])28    self.WetNPG['C_above']     = float(self.WetNPG['C_above'])29    self.WetNPG['A_above']     = float(self.WetNPG['A_above'])30    self.WetNPG['B_above']     = float(self.WetNPG['B_above'])31    self.WetNPG['K_below']     = float(self.WetNPG['K_below'])32    self.WetNPG['C_below']     = float(self.WetNPG['C_below'])33    self.WetNPG['A_below']     = float(self.WetNPG['A_below'])34    self.WetNPG['B_below']     = float(self.WetNPG['B_below'])35    self.WetNPG['HillB_above'] = float(self.WetNPG['HillB_above'])36    self.WetNPG['HillN_above'] = float(self.WetNPG['HillN_above'])37    self.WetNPG['HillB_below'] = float(self.WetNPG['HillB_below'])38    self.WetNPG['HillN_below'] = float(self.WetNPG['HillN_below'])39    self.WetNPG['max_terrain_transition'] = \40      float(self.WetNPG['max_terrain_transition'])41    self.WetNPG['ice_slope_poor']    = float(self.WetNPG['ice_slope_poor'])42    self.WetNPG['ice_slope_pore']    = float(self.WetNPG['ice_slope_pore'])43    self.WetNPG['ice_slope_wedge']   = float(self.WetNPG['ice_slope_wedge'])44    self.WetNPG['ice_slope_massive'] = float(self.WetNPG['ice_slope_massive'])45    self.WetNPG['porosity'] = float(self.WetNPG['porosity'])46#================================================================================47def Wet_LCP(self):48    print '..Reading Wetland Low Center Polygon Cohort Parameters'49    self.WetLCP = {}50    with open(self.Wet_LCP_Control, 'r') as f:51        for line in f:52            if line.startswith('#'):53                continue54            else:55                (key, val) = line.split()56                self.WetLCP[(key)] = val57    # Convert strings to floats as necessary58    self.WetLCP['A1_above']    = float(self.WetLCP['A1_above'])59    self.WetLCP['A2_above']    = float(self.WetLCP['A2_above'])60    self.WetLCP['x0_above']    = float(self.WetLCP['x0_above'])61    self.WetLCP['dx_above']    = float(self.WetLCP['dx_above'])62    self.WetLCP['A1_below']    = float(self.WetLCP['A1_below'])63    self.WetLCP['A2_below']    = float(self.WetLCP['A2_below'])64    self.WetLCP['x0_below']    = float(self.WetLCP['x0_below'])65    self.WetLCP['dx_below']    = float(self.WetLCP['dx_below'])66    self.WetLCP['a_above']     = float(self.WetLCP['a_above'])67    self.WetLCP['b_above']     = float(self.WetLCP['b_above'])68    self.WetLCP['a_below']     = float(self.WetLCP['a_below'])69    self.WetLCP['b_below']     = float(self.WetLCP['b_below'])70    self.WetLCP['K_above']     = float(self.WetLCP['K_above'])71    self.WetLCP['C_above']     = float(self.WetLCP['C_above'])72    self.WetLCP['A_above']     = float(self.WetLCP['A_above'])73    self.WetLCP['B_above']     = float(self.WetLCP['B_above'])74    self.WetLCP['K_below']     = float(self.WetLCP['K_below'])75    self.WetLCP['C_below']     = float(self.WetLCP['C_below'])76    self.WetLCP['A_below']     = float(self.WetLCP['A_below'])77    self.WetLCP['B_below']     = float(self.WetLCP['B_below'])78    self.WetLCP['HillB_above'] = float(self.WetLCP['HillB_above'])79    self.WetLCP['HillN_above'] = float(self.WetLCP['HillN_above'])80    self.WetLCP['HillB_below'] = float(self.WetLCP['HillB_below'])81    self.WetLCP['HillN_below'] = float(self.WetLCP['HillN_below'])82    self.WetLCP['max_terrain_transition'] = \83      float(self.WetNPG['max_terrain_transition'])84    self.WetLCP['ice_slope_poor']    = float(self.WetLCP['ice_slope_poor'])85    self.WetLCP['ice_slope_pore']    = float(self.WetLCP['ice_slope_pore'])86    self.WetLCP['ice_slope_wedge']   = float(self.WetLCP['ice_slope_wedge'])87    self.WetLCP['ice_slope_massive'] = float(self.WetLCP['ice_slope_massive'])88    self.WetLCP['porosity'] = float(self.WetLCP['porosity'])89#===============================================================================90def Wet_CLC(self):91    print '..Reading Wetland Coalescent Low Center Polygon Cohort Parameters'92    self.WetCLC = {}93    with open(self.Wet_CLC_Control, 'r') as f:94        for line in f:95            if line.startswith('#'):96                continue97            else:98                (key, val) = line.split()99                self.WetCLC[(key)] = val100    # Convert strings to floats as necessary101    self.WetCLC['A1_above']    = float(self.WetCLC['A1_above'])102    self.WetCLC['A2_above']    = float(self.WetCLC['A2_above'])103    self.WetCLC['x0_above']    = float(self.WetCLC['x0_above'])104    self.WetCLC['dx_above']    = float(self.WetCLC['dx_above'])105    self.WetCLC['A1_below']    = float(self.WetCLC['A1_below'])106    self.WetCLC['A2_below']    = float(self.WetCLC['A2_below'])107    self.WetCLC['x0_below']    = float(self.WetCLC['x0_below'])108    self.WetCLC['dx_below']    = float(self.WetCLC['dx_below'])109    self.WetCLC['a_above']     = float(self.WetCLC['a_above'])110    self.WetCLC['b_above']     = float(self.WetCLC['b_above'])111    self.WetCLC['a_below']     = float(self.WetCLC['a_below'])112    self.WetCLC['b_below']     = float(self.WetCLC['b_below'])113    self.WetCLC['K_above']     = float(self.WetCLC['K_above'])114    self.WetCLC['C_above']     = float(self.WetCLC['C_above'])115    self.WetCLC['A_above']     = float(self.WetCLC['A_above'])116    self.WetCLC['B_above']     = float(self.WetCLC['B_above'])117    self.WetCLC['K_below']     = float(self.WetCLC['K_below'])118    self.WetCLC['C_below']     = float(self.WetCLC['C_below'])119    self.WetCLC['A_below']     = float(self.WetCLC['A_below'])120    self.WetCLC['B_below']     = float(self.WetCLC['B_below'])121    self.WetCLC['HillB_above'] = float(self.WetCLC['HillB_above'])122    self.WetCLC['HillN_above'] = float(self.WetCLC['HillN_above'])123    self.WetCLC['HillB_below'] = float(self.WetCLC['HillB_below'])124    self.WetCLC['HillN_below'] = float(self.WetCLC['HillN_below'])125    self.WetCLC['max_terrain_transition'] = \126      float(self.WetCLC['max_terrain_transition'])127    self.WetCLC['ice_slope_poor']    = float(self.WetCLC['ice_slope_poor'])128    self.WetCLC['ice_slope_pore']    = float(self.WetCLC['ice_slope_pore'])129    self.WetCLC['ice_slope_wedge']   = float(self.WetCLC['ice_slope_wedge'])130    self.WetCLC['ice_slope_massive'] = float(self.WetCLC['ice_slope_massive'])131    self.WetCLC['porosity'] = float(self.WetCLC['porosity'])132#=================================================================================133def Wet_FCP(self):134    print '..Reading Wetland Flat Center Polygon Cohort Parameters'135    self.WetFCP = {}136    with open(self.Wet_FCP_Control, 'r') as f:137        for line in f:138            if line.startswith('#'):139                continue140            else:141                (key, val) = line.split()142                self.WetFCP[(key)] = val143    # Convert strings to floats as necessary144    self.WetFCP['A1_above']    = float(self.WetFCP['A1_above'])145    self.WetFCP['A2_above']    = float(self.WetFCP['A2_above'])146    self.WetFCP['x0_above']    = float(self.WetFCP['x0_above'])147    self.WetFCP['dx_above']    = float(self.WetFCP['dx_above'])148    self.WetFCP['A1_below']    = float(self.WetFCP['A1_below'])149    self.WetFCP['A2_below']    = float(self.WetFCP['A2_below'])150    self.WetFCP['x0_below']    = float(self.WetFCP['x0_below'])151    self.WetFCP['dx_below']    = float(self.WetFCP['dx_below'])152    self.WetFCP['a_above']     = float(self.WetFCP['a_above'])153    self.WetFCP['b_above']     = float(self.WetFCP['b_above'])154    self.WetFCP['a_below']     = float(self.WetFCP['a_below'])155    self.WetFCP['b_below']     = float(self.WetFCP['b_below'])156    self.WetFCP['K_above']     = float(self.WetFCP['K_above'])157    self.WetFCP['C_above']     = float(self.WetFCP['C_above'])158    self.WetFCP['A_above']     = float(self.WetFCP['A_above'])159    self.WetFCP['B_above']     = float(self.WetFCP['B_above'])160    self.WetFCP['K_below']     = float(self.WetFCP['K_below'])161    self.WetFCP['C_below']     = float(self.WetFCP['C_below'])162    self.WetFCP['A_below']     = float(self.WetFCP['A_below'])163    self.WetFCP['B_below']     = float(self.WetFCP['B_below'])164    self.WetFCP['HillB_above'] = float(self.WetFCP['HillB_above'])165    self.WetFCP['HillN_above'] = float(self.WetFCP['HillN_above'])166    self.WetFCP['HillB_below'] = float(self.WetFCP['HillB_below'])167    self.WetFCP['HillN_below'] = float(self.WetFCP['HillN_below'])168    self.WetFCP['max_terrain_transition'] = \169      float(self.WetFCP['max_terrain_transition'])170    self.WetFCP['ice_slope_poor']    = float(self.WetFCP['ice_slope_poor'])171    self.WetFCP['ice_slope_pore']    = float(self.WetFCP['ice_slope_pore'])172    self.WetFCP['ice_slope_wedge']   = float(self.WetFCP['ice_slope_wedge'])173    self.WetFCP['ice_slope_massive'] = float(self.WetFCP['ice_slope_massive'])174    self.WetFCP['porosity'] = float(self.WetFCP['porosity'])175#===============================================================================176def Wet_HCP(self):177    print '..Reading Wetland Flat Center Polygon Cohort Parameters'178    self.WetHCP = {}179    with open(self.Wet_HCP_Control, 'r') as f:180        for line in f:181            if line.startswith('#'):182                continue183            else:184                (key, val) = line.split()185                self.WetHCP[(key)] = val186    # Convert strings to floats as necessary187    self.WetHCP['A1_above']    = float(self.WetHCP['A1_above'])188    self.WetHCP['A2_above']    = float(self.WetHCP['A2_above'])189    self.WetHCP['x0_above']    = float(self.WetHCP['x0_above'])190    self.WetHCP['dx_above']    = float(self.WetHCP['dx_above'])191    self.WetHCP['A1_below']    = float(self.WetHCP['A1_below'])192    self.WetHCP['A2_below']    = float(self.WetHCP['A2_below'])193    self.WetHCP['x0_below']    = float(self.WetHCP['x0_below'])194    self.WetHCP['dx_below']    = float(self.WetHCP['dx_below'])195    self.WetHCP['a_above']     = float(self.WetHCP['a_above'])196    self.WetHCP['b_above']     = float(self.WetHCP['b_above'])197    self.WetHCP['a_below']     = float(self.WetHCP['a_below'])198    self.WetHCP['b_below']     = float(self.WetHCP['b_below'])199    self.WetHCP['K_above']     = float(self.WetHCP['K_above'])200    self.WetHCP['C_above']     = float(self.WetHCP['C_above'])201    self.WetHCP['A_above']     = float(self.WetHCP['A_above'])202    self.WetHCP['B_above']     = float(self.WetHCP['B_above'])203    self.WetHCP['K_below']     = float(self.WetHCP['K_below'])204    self.WetHCP['C_below']     = float(self.WetHCP['C_below'])205    self.WetHCP['A_below']     = float(self.WetHCP['A_below'])206    self.WetHCP['B_below']     = float(self.WetHCP['B_below'])207    self.WetHCP['HillB_above'] = float(self.WetHCP['HillB_above'])208    self.WetHCP['HillN_above'] = float(self.WetHCP['HillN_above'])209    self.WetHCP['HillB_below'] = float(self.WetHCP['HillB_below'])210    self.WetHCP['max_terrain_transition'] = \211      float(self.WetHCP['max_terrain_transition'])212    self.WetHCP['ice_slope_poor']    = float(self.WetHCP['ice_slope_poor'])213    self.WetHCP['ice_slope_pore']    = float(self.WetHCP['ice_slope_pore'])214    self.WetHCP['ice_slope_wedge']   = float(self.WetHCP['ice_slope_wedge'])215    self.WetHCP['ice_slope_massive'] = float(self.WetHCP['ice_slope_massive'])216    self.WetHCP['porosity']          = float(self.WetHCP['porosity'])217#===============================================================================218def LakePond(self):219    print '..Reading Land and Pond Cohort Parameters'220    221    """ Read files from the input directory """222    if self.Simulation_area.lower() == 'barrow':223        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\224                     self.Control_directory)225    elif self.Simulation_area.lower() == 'arctic_coast':226        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic'+\227                     self.Control_directory+'/')228    elif self.Simulation_area.lower() == 'tanana':229        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana')230    elif self.Simulation_area.lower() == 'yukon':231        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon')232    elif self.Simulation_area.lower() == 'aiem':233        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM')234    elif self.Simulation_area.lower() == 'ngee':235        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE')236    237    self.LakePond = {}238    with open(self.Lake_Pond_Control, 'r') as f:239        for line in f:240            if line.startswith('#'):241                continue242            else:243                (key, val) = line.split()244                self.LakePond[(key)] = val245    # Convert strings to floats as necessary246    self.LakePond['Uniform_Lake_Depth']          = float(self.LakePond['Uniform_Lake_Depth'])247    248    self.LakePond['Lower_LargeLake_WT_Y_Depth']  = float(self.LakePond['Lower_LargeLake_WT_Y_Depth'])249    self.LakePond['Upper_LargeLake_WT_Y_Depth']  = float(self.LakePond['Upper_LargeLake_WT_Y_Depth'])250    self.LakePond['Lower_MediumLake_WT_Y_Depth'] = float(self.LakePond['Lower_MediumLake_WT_Y_Depth'])251    self.LakePond['Upper_MediumLake_WT_Y_Depth'] = float(self.LakePond['Upper_MediumLake_WT_Y_Depth'])252    self.LakePond['Lower_SmallLake_WT_Y_Depth']  = float(self.LakePond['Lower_SmallLake_WT_Y_Depth'])253    self.LakePond['Upper_SmallLake_WT_Y_Depth']  = float(self.LakePond['Upper_SmallLake_WT_Y_Depth'])254    self.LakePond['Lower_LargeLake_WT_M_Depth']  = float(self.LakePond['Lower_LargeLake_WT_M_Depth'])255    self.LakePond['Upper_LargeLake_WT_M_Depth']  = float(self.LakePond['Upper_LargeLake_WT_M_Depth'])256    self.LakePond['Lower_MediumLake_WT_M_Depth'] = float(self.LakePond['Lower_MediumLake_WT_M_Depth'])257    self.LakePond['Upper_MediumLake_WT_M_Depth'] = float(self.LakePond['Upper_MediumLake_WT_M_Depth'])258    self.LakePond['Lower_SmallLake_WT_M_Depth']  = float(self.LakePond['Lower_SmallLake_WT_M_Depth'])259    self.LakePond['Upper_SmallLake_WT_M_Depth']  = float(self.LakePond['Upper_SmallLake_WT_M_Depth'])    260                                                         261    self.LakePond['Lower_LargeLake_WT_O_Depth']  = float(self.LakePond['Lower_LargeLake_WT_O_Depth'])262    self.LakePond['Upper_LargeLake_WT_O_Depth']  = float(self.LakePond['Upper_LargeLake_WT_O_Depth'])263    self.LakePond['Lower_MediumLake_WT_O_Depth'] = float(self.LakePond['Lower_MediumLake_WT_O_Depth'])264    self.LakePond['Upper_MediumLake_WT_O_Depth'] = float(self.LakePond['Upper_MediumLake_WT_O_Depth'])265    self.LakePond['Lower_SmallLake_WT_O_Depth']  = float(self.LakePond['Lower_SmallLake_WT_O_Depth'])266    self.LakePond['Upper_SmallLake_WT_O_Depth']  = float(self.LakePond['Upper_SmallLake_WT_O_Depth'])  267    self.LakePond['Lower_Lake_Depth']            = float(self.LakePond['Lower_Lake_Depth'])268    self.LakePond['Upper_Lake_Depth']            = float(self.LakePond['Upper_Lake_Depth'])269    self.LakePond['Uniform_Pond_Depth']          = float(self.LakePond['Uniform_Pond_Depth'])270    self.LakePond['Lower_Pond_Depth']            = float(self.LakePond['Lower_Pond_Depth'])271    self.LakePond['Upper_Pond_Depth']            = float(self.LakePond['Upper_Pond_Depth'])272    self.LakePond['Lower_Pond_WT_Y_Depth']       = float(self.LakePond['Lower_Pond_WT_Y_Depth'])273    self.LakePond['Upper_Pond_WT_Y_Depth']       = float(self.LakePond['Upper_Pond_WT_Y_Depth'])274    self.LakePond['Lower_Pond_WT_M_Depth']       = float(self.LakePond['Lower_Pond_WT_M_Depth'])275    self.LakePond['Upper_Pond_WT_M_Depth']       = float(self.LakePond['Upper_Pond_WT_M_Depth'])276    self.LakePond['Lower_Pond_WT_O_Depth']       = float(self.LakePond['Lower_Pond_WT_O_Depth'])277    self.LakePond['Upper_Pond_WT_O_Depth']       = float(self.LakePond['Upper_Pond_WT_O_Depth'])278    279    self.LakePond['Lake_Expansion']              = float(self.LakePond['Lake_Expansion'])280    self.LakePond['Pond_Expansion']              = float(self.LakePond['Pond_Expansion'])281    self.LakePond['LargeLake_WT_Y_Expansion']    = float(self.LakePond['LargeLake_WT_Y_Expansion'])282    self.LakePond['MediumLake_WT_Y_Expansion']   = float(self.LakePond['MediumLake_WT_Y_Expansion'])283    self.LakePond['SmallLake_WT_Y_Expansion']    = float(self.LakePond['SmallLake_WT_Y_Expansion'])284    self.LakePond['LargeLake_WT_M_Expansion']    = float(self.LakePond['LargeLake_WT_M_Expansion'])285    self.LakePond['MediumLake_WT_M_Expansion']   = float(self.LakePond['MediumLake_WT_M_Expansion'])286    self.LakePond['SmallLake_WT_M_Expansion']    = float(self.LakePond['SmallLake_WT_M_Expansion'])287    self.LakePond['LargeLake_WT_O_Expansion']    = float(self.LakePond['LargeLake_WT_O_Expansion'])288    self.LakePond['MediumLake_WT_O_Expansion']   = float(self.LakePond['MediumLake_WT_O_Expansion'])289    self.LakePond['SmallLake_WT_O_Expansion']    = float(self.LakePond['SmallLake_WT_O_Expansion'])290    self.LakePond['Pond_WT_Y_Expansion']         = float(self.LakePond['Pond_WT_Y_Expansion'])291    self.LakePond['Pond_WT_M_Expansion']         = float(self.LakePond['Pond_WT_M_Expansion'])292    self.LakePond['Pond_WT_O_Expansion']         = float(self.LakePond['Pond_WT_O_Expansion'])293    294    self.LakePond['Pond_Infill_Constant']        = float(self.LakePond['Pond_Infill_Constant'])295    self.LakePond['Pond_WT_Y_Infill_Constant']   = float(self.LakePond['Pond_WT_Y_Infill_Constant'])296    self.LakePond['Pond_WT_M_Infill_Constant']   = float(self.LakePond['Pond_WT_M_Infill_Constant'])297    self.LakePond['Pond_WT_O_Infill_Constant']   = float(self.LakePond['Pond_WT_O_Infill_Constant'])298    299    self.LakePond['ice_thickness_uniform_alpha'] = float(self.LakePond['ice_thickness_uniform_alpha'])300    self.LakePond['Lower_ice_thickness_alpha']   = float(self.LakePond['Lower_ice_thickness_alpha'])301    self.LakePond['Upper_ice_thickness_alpha']   = float(self.LakePond['Upper_ice_thickness_alpha'])302    self.LakePond['pond_growth_time_required']   = float(self.LakePond['pond_growth_time_required'])303    self.LakePond['Pond_WT_Y_growth_time_required'] = float(self.LakePond['Pond_WT_Y_growth_time_required'])304    self.LakePond['Pond_WT_M_growth_time_required'] = float(self.LakePond['Pond_WT_M_growth_time_required'])305    self.LakePond['Pond_WT_O_growth_time_required'] = float(self.LakePond['Pond_WT_O_growth_time_required'])306    307    self.LakePond['lake_depth_control']          = float(self.LakePond['lake_depth_control'])308    self.LakePond['LargeLake_WT_Y_depth_control']  = float(self.LakePond['LargeLake_WT_Y_depth_control'])309    self.LakePond['LargeLake_WT_M_depth_control']  = float(self.LakePond['LargeLake_WT_M_depth_control'])310    self.LakePond['LargeLake_WT_O_depth_control']  = float(self.LakePond['LargeLake_WT_O_depth_control'])311    self.LakePond['MediumLake_WT_Y_depth_control'] = float(self.LakePond['MediumLake_WT_Y_depth_control'])312    self.LakePond['MediumLake_WT_M_depth_control'] = float(self.LakePond['MediumLake_WT_M_depth_control'])313    self.LakePond['MediumLake_WT_O_depth_control'] = float(self.LakePond['MediumLake_WT_O_depth_control'])314    self.LakePond['SmallLake_WT_Y_depth_control']  = float(self.LakePond['SmallLake_WT_Y_depth_control'])315    self.LakePond['SmallLake_WT_M_depth_control']  = float(self.LakePond['SmallLake_WT_M_depth_control'])316    self.LakePond['SmallLake_WT_O_depth_control']  = float(self.LakePond['SmallLake_WT_O_depth_control'])317    318    self.LakePond['pond_depth_control']          = float(self.LakePond['pond_depth_control'])319    self.LakePond['Pond_WT_Y_depth_control']     = float(self.LakePond['Pond_WT_Y_depth_control'])320    self.LakePond['Pond_WT_M_depth_control']     = float(self.LakePond['Pond_WT_M_depth_control'])321    self.LakePond['Pond_WT_O_depth_control']     = float(self.LakePond['Pond_WT_O_depth_control'])322#===============================================================================323def Terrestrial_Barrow(self):324    print '..Reading General Terrestrial Parameters'325    """ Move to the control directory """326    self.Terrestrial = {}327    with open(self.Terrestrial_Control, 'r') as f:328        for line in f:329            if line.startswith('#'):330                continue331            else:332                (key, val) = line.split()333                self.Terrestrial[(key)] = val334    # Convert to strings if necessary335    self.Terrestrial['Drainage_Efficiency_Random_Value'] = \336      float(self.Terrestrial['Drainage_Efficiency_Random_Value'])337    self.Terrestrial['ALD_Distribution_Lower_Bound'] = \338      float(self.Terrestrial['ALD_Distribution_Lower_Bound'])339    self.Terrestrial['ALD_Distribution_Upper_Bound'] = \340      float(self.Terrestrial['ALD_Distribution_Upper_Bound'])341    #self.Terrestrial['Wet_NPG_PLF'] = float(self.Terrestrial['Wet_NPG_PLF'])342    #self.Terrestrial['Wet_LCP_PLF'] = float(self.Terrestrial['Wet_LCP_PLF'])343    #self.Terrestrial['Wet_CLC_PLF'] = float(self.Terrestrial['Wet_CLC_PLF'])344    #self.Terrestrial['Wet_FCP_PLF'] = float(self.Terrestrial['Wet_FCP_PLF'])345    #self.Terrestrial['Wet_HCP_PLF'] = float(self.Terrestrial['Wet_HCP_PLF'])346    #self.Terrestrial['Gra_NPG_PLF'] = float(self.Terrestrial['Gra_NPG_PLF'])347    #self.Terrestrial['Gra_LCP_PLF'] = float(self.Terrestrial['Gra_LCP_PLF'])348    #self.Terrestrial['Gra_FCP_PLF'] = float(self.Terrestrial['Gra_FCP_PLF'])349    #self.Terrestrial['Gra_HCP_PLF'] = float(self.Terrestrial['Gra_HCP_PLF'])350    #self.Terrestrial['Shr_NPG_PLF'] = float(self.Terrestrial['Shr_NPG_PLF'])351    #self.Terrestrial['Shr_LCP_PLF'] = float(self.Terrestrial['Shr_LCP_PLF'])352    #self.Terrestrial['Shr_FCP_PLF'] = float(self.Terrestrial['Shr_FCP_PLF'])353    #self.Terrestrial['Shr_HCP_PLF'] = float(self.Terrestrial['Shr_HCP_PLF'])354    #self.Terrestrial['Lakes_PLF']   = float(self.Terrestrial['Lakes_PLF'])355    #self.Terrestrial['Ponds_PLF']   = float(self.Terrestrial['Ponds_PLF'])356    self.Terrestrial['CLC_WT_Y_PLF'] = float(self.Terrestrial['CLC_WT_Y_PLF'])357    self.Terrestrial['CLC_WT_M_PLF'] = float(self.Terrestrial['CLC_WT_M_PLF'])358    self.Terrestrial['CLC_WT_O_PLF'] = float(self.Terrestrial['CLC_WT_O_PLF'])359    self.Terrestrial['CoastalWaters_WT_O_PLF'] = float(self.Terrestrial['CoastalWaters_WT_O_PLF'])    360    self.Terrestrial['DrainedSlope_WT_Y_PLF'] = float(self.Terrestrial['DrainedSlope_WT_Y_PLF'])361    self.Terrestrial['DrainedSlope_WT_M_PLF'] = float(self.Terrestrial['DrainedSlope_WT_M_PLF'])362    self.Terrestrial['DrainedSlope_WT_O_PLF'] = float(self.Terrestrial['DrainedSlope_WT_O_PLF'])    363    self.Terrestrial['FCP_WT_Y_PLF'] = float(self.Terrestrial['FCP_WT_Y_PLF'])364    self.Terrestrial['FCP_WT_M_PLF'] = float(self.Terrestrial['FCP_WT_M_PLF'])365    self.Terrestrial['FCP_WT_O_PLF'] = float(self.Terrestrial['FCP_WT_O_PLF'])    366    self.Terrestrial['HCP_WT_Y_PLF'] = float(self.Terrestrial['HCP_WT_Y_PLF'])367    self.Terrestrial['HCP_WT_M_PLF'] = float(self.Terrestrial['HCP_WT_M_PLF'])368    self.Terrestrial['HCP_WT_O_PLF'] = float(self.Terrestrial['HCP_WT_O_PLF'])    369    self.Terrestrial['LCP_WT_Y_PLF'] = float(self.Terrestrial['LCP_WT_Y_PLF'])370    self.Terrestrial['LCP_WT_M_PLF'] = float(self.Terrestrial['LCP_WT_M_PLF'])371    self.Terrestrial['LCP_WT_O_PLF'] = float(self.Terrestrial['LCP_WT_O_PLF'])    372    self.Terrestrial['Meadow_WT_Y_PLF'] = float(self.Terrestrial['Meadow_WT_Y_PLF'])373    self.Terrestrial['Meadow_WT_M_PLF'] = float(self.Terrestrial['Meadow_WT_M_PLF'])374    self.Terrestrial['Meadow_WT_O_PLF'] = float(self.Terrestrial['Meadow_WT_O_PLF'])    375    self.Terrestrial['NoData_WT_O_PLF'] = float(self.Terrestrial['NoData_WT_O_PLF'])    376    self.Terrestrial['SandDunes_WT_Y_PLF'] = float(self.Terrestrial['SandDunes_WT_Y_PLF'])377    self.Terrestrial['SandDunes_WT_M_PLF'] = float(self.Terrestrial['SandDunes_WT_M_PLF'])378    self.Terrestrial['SandDunes_WT_O_PLF'] = float(self.Terrestrial['SandDunes_WT_O_PLF'])379    self.Terrestrial['SaturatedBarrens_WT_Y_PLF'] = float(self.Terrestrial['SaturatedBarrens_WT_Y_PLF'])380    self.Terrestrial['SaturatedBarrens_WT_M_PLF'] = float(self.Terrestrial['SaturatedBarrens_WT_M_PLF'])381    self.Terrestrial['SaturatedBarrens_WT_O_PLF'] = float(self.Terrestrial['SaturatedBarrens_WT_O_PLF'])382    self.Terrestrial['Shrubs_WT_O_PLF'] = float(self.Terrestrial['Shrubs_WT_O_PLF'])383    self.Terrestrial['Urban_WT_PLF'] = float(self.Terrestrial['Urban_WT_PLF'])384    self.Terrestrial['LargeLakes_WT_Y_PLF'] = float(self.Terrestrial['LargeLakes_WT_Y_PLF'])385    self.Terrestrial['LargeLakes_WT_M_PLF'] = float(self.Terrestrial['LargeLakes_WT_M_PLF'])386    self.Terrestrial['LargeLakes_WT_O_PLF'] = float(self.Terrestrial['LargeLakes_WT_O_PLF'])   387    self.Terrestrial['MediumLakes_WT_Y_PLF'] = float(self.Terrestrial['MediumLakes_WT_Y_PLF'])388    self.Terrestrial['MediumLakes_WT_M_PLF'] = float(self.Terrestrial['MediumLakes_WT_M_PLF'])389    self.Terrestrial['MediumLakes_WT_O_PLF'] = float(self.Terrestrial['MediumLakes_WT_O_PLF'])   390    self.Terrestrial['SmallLakes_WT_Y_PLF'] = float(self.Terrestrial['SmallLakes_WT_Y_PLF'])391    self.Terrestrial['SmallLakes_WT_M_PLF'] = float(self.Terrestrial['SmallLakes_WT_M_PLF'])392    self.Terrestrial['SmallLakes_WT_O_PLF'] = float(self.Terrestrial['SmallLakes_WT_O_PLF'])   393    self.Terrestrial['Ponds_WT_Y_PLF'] = float(self.Terrestrial['Ponds_WT_Y_PLF'])394    self.Terrestrial['Ponds_WT_M_PLF'] = float(self.Terrestrial['Ponds_WT_M_PLF'])395    self.Terrestrial['Ponds_WT_O_PLF'] = float(self.Terrestrial['Ponds_WT_O_PLF'])   396    self.Terrestrial['Rivers_WT_Y_PLF'] = float(self.Terrestrial['Rivers_WT_Y_PLF'])397    self.Terrestrial['Rivers_WT_M_PLF'] = float(self.Terrestrial['Rivers_WT_M_PLF'])398    self.Terrestrial['Rivers_WT_O_PLF'] = float(self.Terrestrial['Rivers_WT_O_PLF'])   399#===============================================================================400def Terrestrial_Tanana(self):401    print '..Reading General Terrestrial Parameters'402    self.Terrestrial = {}403    with open(self.Terrestrial_Control, 'r') as f:404        for line in f:405            if line.startswith('#'):406                continue407            else:408                (key, val) = line.split()409                self.Terrestrial[(key)] = val410    # Convert to strings if necessary411    self.Terrestrial['Drainage_Efficiency_Random_Value'] = \412      float(self.Terrestrial['Drainage_Efficiency_Random_Value'])413    self.Terrestrial['ALD_Distribution_Lower_Bound'] = \414      float(self.Terrestrial['ALD_Distribution_Lower_Bound'])415    self.Terrestrial['ALD_Distribution_Upper_Bound'] = \416      float(self.Terrestrial['ALD_Distribution_Upper_Bound'])417    self.Terrestrial['TF_OB_PLF'] = float(self.Terrestrial['TF_OB_PLF'])418    self.Terrestrial['TF_YB_PLF'] = float(self.Terrestrial['TF_YB_PLF'])419    self.Terrestrial['TF_OF_PLF'] = float(self.Terrestrial['TF_OF_PLF'])420    self.Terrestrial['TF_YF_PLF'] = float(self.Terrestrial['TF_YF_PLF'])421    self.Terrestrial['TF_Dec_PP_PLF'] = float(self.Terrestrial['TF_Dec_PP_PLF'])422    self.Terrestrial['TF_Con_PP_PLF'] = float(self.Terrestrial['TF_Con_PP_PLF'])423    self.Terrestrial['TF_TL_PLF'] = float(self.Terrestrial['TF_TL_PLF'])424#==================================================================================425def Met(self):426    import read_degree_days427    import calc_degree_days428    import read_met_data429    430    print '..Reading General Meteorologic Parameters'431    """ Read files from the input directory """432    if self.Simulation_area.lower() == 'barrow':433        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\434                     self.Control_directory+'/')435    elif self.Simulation_area.lower() == 'arctic_coast':436        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic/'+\437                     self.Control_directory+'/')438    elif self.Simulation_area.lower() == 'tanana':439        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\440                     self.Control_directory+'/')441    elif self.Simulation_area.lower() == 'yukon':442        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\443                     self.Control_directory+'/')444    elif self.Simulation_area.lower() == 'aiem':445        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM/'+\446                     self.Control_directory+'/')447    elif self.Simulation_area.lower() == 'ngee':448        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE/'+\449                     self.Control_directory+'/')450    self.Met = {}451    with open(self.Met_Control, 'r') as f:452        for line in f:453            if line.startswith('#'):454                continue455            else:456                (key, val) = line.split()457                self.Met[(key)] = val458    # Convert string variables if necessary459    self.Met['climate_block_lower_bound'] = int(self.Met['climate_block_lower_bound'])460    self.Met['climate_block_upper_bound'] = int(self.Met['climate_block_upper_bound'])461    self.Met['climate_event_probability'] = float(self.Met['climate_event_probability'])462    self.Met['pond_drain_rate_<0.01']     = float(self.Met['pond_drain_rate_<0.01'])463    self.Met['pond_drain_rate_0.01<0.1']  = float(self.Met['pond_drain_rate_0.01<0.1'])464    self.Met['pond_drain_rate_0.1<0.4']   = float(self.Met['pond_drain_rate_0.1<0.4'])465    self.Met['pond_drain_rate_0.1<1.0']   = float(self.Met['pond_drain_rate_0.4<1.0'])466    self.Met['lake_drain_rate_<0.01']     = float(self.Met['lake_drain_rate_<0.01'])467    self.Met['lake_drain_rate_0.01<0.1']  = float(self.Met['lake_drain_rate_0.01<0.1'])468    self.Met['lake_drain_rate_0.1<0.4']   = float(self.Met['lake_drain_rate_0.1<0.4'])469    self.Met['lake_drain_rate_0.4<1.0']   = float(self.Met['lake_drain_rate_0.4<1.0'])470    #-----------------------------------------------------471    # Read the Met Data472    #-----------------------------------------------------473    if self.Met['met_distribution'].lower() == 'point':474        self.met_file = self.Met['met_file_point']475    elif self.Met['met_distribution'].lower() == 'spatial':476        self.met_file = self.Met['met_file_distributed']477    print '       The meteorologic file to be used is :', self.met_file478    read_met_data.read_met_data(self)479    #_______________________________________480    # READ MET Data & Calculate Degree Days481    #_______________________________________482    if self.Met['degree_day_method'].lower() == 'read':    # 'Read' file or 'Calc' from geotiff input483        read_degree_days.read_degree_days(self)484    else:485        calc_degree_days.calc_degree_days(self)486#====================================================================================487def run(self):488    if self.test_code.lower() == 'yes':489        self.stop = self.test_code_duration490    else:491        self.stop = int(self.ATTM_time_steps)492    493#====================================================================================494def initialize(self):495    print '    Initializing the model'496    497    if self.Simulation_area.lower() == 'barrow':498        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\499                     self.control['Control_dir']+'/')500    elif self.Simulation_area.lower() == 'tanana':501        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\502                     self.control['Control_dir'])503    elif self.Simulation_area.lower() == 'yukon':504        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\505                     self.control['Control_dir'])506    self.initialize = {}507    with open(self.Initialize_Control, 'r') as f:508        for line in f:509            if line.startswith('#'):510                continue511            else:512                (key, val) = line.split()513                self.initialize[(key)] = val514#====================================================================================515def CLC_WT(self):516    517    print '    ..Reading Wetland Tundra Coalescent Low Center Polygon Parameters'518    """ Read files from the input directory """519    if self.Simulation_area.lower() == 'barrow':520        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\521                     self.Control_directory)522    elif self.Simulation_area.lower() == 'arctic_coast':523        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic/'+\524                     self.Control_directory)525    elif self.Simulation_area.lower() == 'tanana':526        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\527                     self.Control_directory)528    elif self.Simulation_area.lower() == 'yukon':529        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\530                     self.Control_directory)531    elif self.Simulation_area.lower() == 'aiem':532        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM/'+\533                     self.Control_directory)534    elif self.Simulation_area.lower() == 'ngee':535        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE/'+\536                     self.Control_directory)537    # - - - - - - - - - - - - - - - - - - - - - - - - -538    # Reading Young Age Parameters from Control file539    # - - - - - - - - - - - - - - - - - - - - - - - - -540    print '      .. Young age parameters'541    self.CLC_WT_Y = {}542    with open(self.CLC_WT_Y_Control, 'r') as f:543        for line in f:544            if line.startswith('#'):545                continue546            else:547                (key, val) = line.split()548                self.CLC_WT_Y[(key)] = val549    # Convert strings to floats as necessary550    self.CLC_WT_Y['A1_above']    = float(self.CLC_WT_Y['A1_above'])551    self.CLC_WT_Y['A2_above']    = float(self.CLC_WT_Y['A2_above'])552    self.CLC_WT_Y['x0_above']    = float(self.CLC_WT_Y['x0_above'])553    self.CLC_WT_Y['dx_above']    = float(self.CLC_WT_Y['dx_above'])554    self.CLC_WT_Y['A1_below']    = float(self.CLC_WT_Y['A1_below'])555    self.CLC_WT_Y['A2_below']    = float(self.CLC_WT_Y['A2_below'])556    self.CLC_WT_Y['x0_below']    = float(self.CLC_WT_Y['x0_below'])557    self.CLC_WT_Y['dx_below']    = float(self.CLC_WT_Y['dx_below'])558    self.CLC_WT_Y['a_above']     = float(self.CLC_WT_Y['a_above'])559    self.CLC_WT_Y['b_above']     = float(self.CLC_WT_Y['b_above'])560    self.CLC_WT_Y['a_below']     = float(self.CLC_WT_Y['a_below'])561    self.CLC_WT_Y['b_below']     = float(self.CLC_WT_Y['b_below'])562    self.CLC_WT_Y['K_above']     = float(self.CLC_WT_Y['K_above'])563    self.CLC_WT_Y['C_above']     = float(self.CLC_WT_Y['C_above'])564    self.CLC_WT_Y['A_above']     = float(self.CLC_WT_Y['A_above'])565    self.CLC_WT_Y['B_above']     = float(self.CLC_WT_Y['B_above'])566    self.CLC_WT_Y['K_below']     = float(self.CLC_WT_Y['K_below'])567    self.CLC_WT_Y['C_below']     = float(self.CLC_WT_Y['C_below'])568    self.CLC_WT_Y['A_below']     = float(self.CLC_WT_Y['A_below'])569    self.CLC_WT_Y['B_below']     = float(self.CLC_WT_Y['B_below'])570    self.CLC_WT_Y['HillB_above'] = float(self.CLC_WT_Y['HillB_above'])571    self.CLC_WT_Y['HillN_above'] = float(self.CLC_WT_Y['HillN_above'])572    self.CLC_WT_Y['HillB_below'] = float(self.CLC_WT_Y['HillB_below'])573    self.CLC_WT_Y['HillN_below'] = float(self.CLC_WT_Y['HillN_below'])574    self.CLC_WT_Y['max_terrain_transition'] = \575      float(self.CLC_WT_Y['max_terrain_transition'])576    self.CLC_WT_Y['ice_slope_poor']    = float(self.CLC_WT_Y['ice_slope_poor'])577    self.CLC_WT_Y['ice_slope_pore']    = float(self.CLC_WT_Y['ice_slope_pore'])578    self.CLC_WT_Y['ice_slope_wedge']   = float(self.CLC_WT_Y['ice_slope_wedge'])579    self.CLC_WT_Y['ice_slope_massive'] = float(self.CLC_WT_Y['ice_slope_massive'])580    self.CLC_WT_Y['porosity'] = float(self.CLC_WT_Y['porosity'])    581    # - - - - - - - - - - - - - - - - - - - - - - - - -582    # Reading Medium Age Parameters from Control file583    # - - - - - - - - - - - - - - - - - - - - - - - - -584    print '      .. Medium age parameters'585    586    self.CLC_WT_M = {}587    with open(self.CLC_WT_M_Control, 'r') as f:588        for line in f:589            if line.startswith('#'):590                continue591            else:592                (key, val) = line.split()593                self.CLC_WT_M[(key)] = val594    # Convert strings to floats as necessary595    self.CLC_WT_M['A1_above']    = float(self.CLC_WT_M['A1_above'])596    self.CLC_WT_M['A2_above']    = float(self.CLC_WT_M['A2_above'])597    self.CLC_WT_M['x0_above']    = float(self.CLC_WT_M['x0_above'])598    self.CLC_WT_M['dx_above']    = float(self.CLC_WT_M['dx_above'])599    self.CLC_WT_M['A1_below']    = float(self.CLC_WT_M['A1_below'])600    self.CLC_WT_M['A2_below']    = float(self.CLC_WT_M['A2_below'])601    self.CLC_WT_M['x0_below']    = float(self.CLC_WT_M['x0_below'])602    self.CLC_WT_M['dx_below']    = float(self.CLC_WT_M['dx_below'])603    self.CLC_WT_M['a_above']     = float(self.CLC_WT_M['a_above'])604    self.CLC_WT_M['b_above']     = float(self.CLC_WT_M['b_above'])605    self.CLC_WT_M['a_below']     = float(self.CLC_WT_M['a_below'])606    self.CLC_WT_M['b_below']     = float(self.CLC_WT_M['b_below'])607    self.CLC_WT_M['K_above']     = float(self.CLC_WT_M['K_above'])608    self.CLC_WT_M['C_above']     = float(self.CLC_WT_M['C_above'])609    self.CLC_WT_M['A_above']     = float(self.CLC_WT_M['A_above'])610    self.CLC_WT_M['B_above']     = float(self.CLC_WT_M['B_above'])611    self.CLC_WT_M['K_below']     = float(self.CLC_WT_M['K_below'])612    self.CLC_WT_M['C_below']     = float(self.CLC_WT_M['C_below'])613    self.CLC_WT_M['A_below']     = float(self.CLC_WT_M['A_below'])614    self.CLC_WT_M['B_below']     = float(self.CLC_WT_M['B_below'])615    self.CLC_WT_M['HillB_above'] = float(self.CLC_WT_M['HillB_above'])616    self.CLC_WT_M['HillN_above'] = float(self.CLC_WT_M['HillN_above'])617    self.CLC_WT_M['HillB_below'] = float(self.CLC_WT_M['HillB_below'])618    self.CLC_WT_M['HillN_below'] = float(self.CLC_WT_M['HillN_below'])619    self.CLC_WT_M['max_terrain_transition'] = \620      float(self.CLC_WT_M['max_terrain_transition'])621    self.CLC_WT_M['ice_slope_poor']    = float(self.CLC_WT_M['ice_slope_poor'])622    self.CLC_WT_M['ice_slope_pore']    = float(self.CLC_WT_M['ice_slope_pore'])623    self.CLC_WT_M['ice_slope_wedge']   = float(self.CLC_WT_M['ice_slope_wedge'])624    self.CLC_WT_M['ice_slope_massive'] = float(self.CLC_WT_M['ice_slope_massive'])625    self.CLC_WT_M['porosity'] = float(self.CLC_WT_M['porosity'])    626    # - - - - - - - - - - - - - - - - - - - - - - - - -627    # Reading Old Age Parameters from Control file628    # - - - - - - - - - - - - - - - - - - - - - - - - -629    print '      .. Old age parameters'630    631    self.CLC_WT_O = {}632    with open(self.CLC_WT_O_Control, 'r') as f:633        for line in f:634            if line.startswith('#'):635                continue636            else:637                (key, val) = line.split()638                self.CLC_WT_O[(key)] = val639    # Convert strings to floats as necessary640    self.CLC_WT_O['A1_above']    = float(self.CLC_WT_O['A1_above'])641    self.CLC_WT_O['A2_above']    = float(self.CLC_WT_O['A2_above'])642    self.CLC_WT_O['x0_above']    = float(self.CLC_WT_O['x0_above'])643    self.CLC_WT_O['dx_above']    = float(self.CLC_WT_O['dx_above'])644    self.CLC_WT_O['A1_below']    = float(self.CLC_WT_O['A1_below'])645    self.CLC_WT_O['A2_below']    = float(self.CLC_WT_O['A2_below'])646    self.CLC_WT_O['x0_below']    = float(self.CLC_WT_O['x0_below'])647    self.CLC_WT_O['dx_below']    = float(self.CLC_WT_O['dx_below'])648    self.CLC_WT_O['a_above']     = float(self.CLC_WT_O['a_above'])649    self.CLC_WT_O['b_above']     = float(self.CLC_WT_O['b_above'])650    self.CLC_WT_O['a_below']     = float(self.CLC_WT_O['a_below'])651    self.CLC_WT_O['b_below']     = float(self.CLC_WT_O['b_below'])652    self.CLC_WT_O['K_above']     = float(self.CLC_WT_O['K_above'])653    self.CLC_WT_O['C_above']     = float(self.CLC_WT_O['C_above'])654    self.CLC_WT_O['A_above']     = float(self.CLC_WT_O['A_above'])655    self.CLC_WT_O['B_above']     = float(self.CLC_WT_O['B_above'])656    self.CLC_WT_O['K_below']     = float(self.CLC_WT_O['K_below'])657    self.CLC_WT_O['C_below']     = float(self.CLC_WT_O['C_below'])658    self.CLC_WT_O['A_below']     = float(self.CLC_WT_O['A_below'])659    self.CLC_WT_O['B_below']     = float(self.CLC_WT_O['B_below'])660    self.CLC_WT_O['HillB_above'] = float(self.CLC_WT_O['HillB_above'])661    self.CLC_WT_O['HillN_above'] = float(self.CLC_WT_O['HillN_above'])662    self.CLC_WT_O['HillB_below'] = float(self.CLC_WT_O['HillB_below'])663    self.CLC_WT_O['HillN_below'] = float(self.CLC_WT_O['HillN_below'])664    self.CLC_WT_O['max_terrain_transition'] = \665      float(self.CLC_WT_O['max_terrain_transition'])666    self.CLC_WT_O['ice_slope_poor']    = float(self.CLC_WT_O['ice_slope_poor'])667    self.CLC_WT_O['ice_slope_pore']    = float(self.CLC_WT_O['ice_slope_pore'])668    self.CLC_WT_O['ice_slope_wedge']   = float(self.CLC_WT_O['ice_slope_wedge'])669    self.CLC_WT_O['ice_slope_massive'] = float(self.CLC_WT_O['ice_slope_massive'])670    self.CLC_WT_O['porosity'] = float(self.CLC_WT_O['porosity'])    671#====================================================================================672def CoastalWaters_WT(self):673    674    print '    ..Reading Wetland Tundra Coastal Waters Parameters'675    """ Read files from the input directory """676    if self.Simulation_area.lower() == 'barrow':677        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\678                 self.Control_directory)679    elif self.Simulation_area.lower() == 'arctic_coast':680        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic/'+\681                 self.Control_directory)682    elif self.Simulation_area.lower() == 'tanana':683        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\684                 self.Control_directory)685    elif self.Simulation_area.lower() == 'yukon':686        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\687                 self.Control_directory)688    elif self.Simulation_area.lower() == 'aiem':689        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM/'+\690                 self.Control_directory)691    elif self.Simulation_area.lower() == 'ngee':692        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE/'+\693                 self.Control_directory)694    # - - - - - - - - - - - - - - - - - - - - - - - - -695    # Reading Old Age Parameters from Control file696    # - - - - - - - - - - - - - - - - - - - - - - - - -697    self.CoastalWaters_WT_O = {}698    with open(self.CoastalWaters_WT_O_Control, 'r') as f:699        for line in f:700            if line.startswith('#'):701                continue702            else:703                (key, val) = line.split()704                self.CoastalWaters_WT_O[(key)] = val705    # Convert strings to floats as necessary706    self.CoastalWaters_WT_O['A1_above']    = float(self.CoastalWaters_WT_O['A1_above'])707    self.CoastalWaters_WT_O['A2_above']    = float(self.CoastalWaters_WT_O['A2_above'])708    self.CoastalWaters_WT_O['x0_above']    = float(self.CoastalWaters_WT_O['x0_above'])709    self.CoastalWaters_WT_O['dx_above']    = float(self.CoastalWaters_WT_O['dx_above'])710    self.CoastalWaters_WT_O['A1_below']    = float(self.CoastalWaters_WT_O['A1_below'])711    self.CoastalWaters_WT_O['A2_below']    = float(self.CoastalWaters_WT_O['A2_below'])712    self.CoastalWaters_WT_O['x0_below']    = float(self.CoastalWaters_WT_O['x0_below'])713    self.CoastalWaters_WT_O['dx_below']    = float(self.CoastalWaters_WT_O['dx_below'])714    self.CoastalWaters_WT_O['a_above']     = float(self.CoastalWaters_WT_O['a_above'])715    self.CoastalWaters_WT_O['b_above']     = float(self.CoastalWaters_WT_O['b_above'])716    self.CoastalWaters_WT_O['a_below']     = float(self.CoastalWaters_WT_O['a_below'])717    self.CoastalWaters_WT_O['b_below']     = float(self.CoastalWaters_WT_O['b_below'])718    self.CoastalWaters_WT_O['K_above']     = float(self.CoastalWaters_WT_O['K_above'])719    self.CoastalWaters_WT_O['C_above']     = float(self.CoastalWaters_WT_O['C_above'])720    self.CoastalWaters_WT_O['A_above']     = float(self.CoastalWaters_WT_O['A_above'])721    self.CoastalWaters_WT_O['B_above']     = float(self.CoastalWaters_WT_O['B_above'])722    self.CoastalWaters_WT_O['K_below']     = float(self.CoastalWaters_WT_O['K_below'])723    self.CoastalWaters_WT_O['C_below']     = float(self.CoastalWaters_WT_O['C_below'])724    self.CoastalWaters_WT_O['A_below']     = float(self.CoastalWaters_WT_O['A_below'])725    self.CoastalWaters_WT_O['B_below']     = float(self.CoastalWaters_WT_O['B_below'])726    self.CoastalWaters_WT_O['HillB_above'] = float(self.CoastalWaters_WT_O['HillB_above'])727    self.CoastalWaters_WT_O['HillN_above'] = float(self.CoastalWaters_WT_O['HillN_above'])728    self.CoastalWaters_WT_O['HillB_below'] = float(self.CoastalWaters_WT_O['HillB_below'])729    self.CoastalWaters_WT_O['HillN_below'] = float(self.CoastalWaters_WT_O['HillN_below'])730    self.CoastalWaters_WT_O['max_terrain_transition'] = \731      float(self.CoastalWaters_WT_O['max_terrain_transition'])732    self.CoastalWaters_WT_O['ice_slope_poor']    = float(self.CoastalWaters_WT_O['ice_slope_poor'])733    self.CoastalWaters_WT_O['ice_slope_pore']    = float(self.CoastalWaters_WT_O['ice_slope_pore'])734    self.CoastalWaters_WT_O['ice_slope_wedge']   = float(self.CoastalWaters_WT_O['ice_slope_wedge'])735    self.CoastalWaters_WT_O['ice_slope_massive'] = float(self.CoastalWaters_WT_O['ice_slope_massive'])736    self.CoastalWaters_WT_O['porosity'] = float(self.CoastalWaters_WT_O['porosity'])    737#====================================================================================738def DrainedSlope_WT(self):739    740    print '    ..Reading Wetland Tundra Drained Slope Parameters'741    """ Read files from the input directory """742    if self.Simulation_area.lower() == 'barrow':743        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\744                 self.Control_directory)745    elif self.Simulation_area.lower() == 'arctic_coast':746        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic/'+\747                 self.Control_directory)748    elif self.Simulation_area.lower() == 'tanana':749        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\750                 self.Control_directory)751    elif self.Simulation_area.lower() == 'yukon':752        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\753                 self.Control_directory)754    elif self.Simulation_area.lower() == 'aiem':755        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM/'+\756                 self.Control_directory)757    elif self.Simulation_area.lower() == 'ngee':758        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE/'+\759                 self.Control_directory)760    # - - - - - - - - - - - - - - - - - - - - - - - - -761    # Reading Young Age Parameters from Control file762    # - - - - - - - - - - - - - - - - - - - - - - - - -763    print '      .. Young age parameters'764    765    self.DrainedSlope_WT_Y = {}766    with open(self.DrainedSlope_WT_Y_Control, 'r') as f:767        for line in f:768            if line.startswith('#'):769                continue770            else:771                (key, val) = line.split()772                self.DrainedSlope_WT_Y[(key)] = val773    # Convert strings to floats as necessary774    self.DrainedSlope_WT_Y['A1_above']    = float(self.DrainedSlope_WT_Y['A1_above'])775    self.DrainedSlope_WT_Y['A2_above']    = float(self.DrainedSlope_WT_Y['A2_above'])776    self.DrainedSlope_WT_Y['x0_above']    = float(self.DrainedSlope_WT_Y['x0_above'])777    self.DrainedSlope_WT_Y['dx_above']    = float(self.DrainedSlope_WT_Y['dx_above'])778    self.DrainedSlope_WT_Y['A1_below']    = float(self.DrainedSlope_WT_Y['A1_below'])779    self.DrainedSlope_WT_Y['A2_below']    = float(self.DrainedSlope_WT_Y['A2_below'])780    self.DrainedSlope_WT_Y['x0_below']    = float(self.DrainedSlope_WT_Y['x0_below'])781    self.DrainedSlope_WT_Y['dx_below']    = float(self.DrainedSlope_WT_Y['dx_below'])782    self.DrainedSlope_WT_Y['a_above']     = float(self.DrainedSlope_WT_Y['a_above'])783    self.DrainedSlope_WT_Y['b_above']     = float(self.DrainedSlope_WT_Y['b_above'])784    self.DrainedSlope_WT_Y['a_below']     = float(self.DrainedSlope_WT_Y['a_below'])785    self.DrainedSlope_WT_Y['b_below']     = float(self.DrainedSlope_WT_Y['b_below'])786    self.DrainedSlope_WT_Y['K_above']     = float(self.DrainedSlope_WT_Y['K_above'])787    self.DrainedSlope_WT_Y['C_above']     = float(self.DrainedSlope_WT_Y['C_above'])788    self.DrainedSlope_WT_Y['A_above']     = float(self.DrainedSlope_WT_Y['A_above'])789    self.DrainedSlope_WT_Y['B_above']     = float(self.DrainedSlope_WT_Y['B_above'])790    self.DrainedSlope_WT_Y['K_below']     = float(self.DrainedSlope_WT_Y['K_below'])791    self.DrainedSlope_WT_Y['C_below']     = float(self.DrainedSlope_WT_Y['C_below'])792    self.DrainedSlope_WT_Y['A_below']     = float(self.DrainedSlope_WT_Y['A_below'])793    self.DrainedSlope_WT_Y['B_below']     = float(self.DrainedSlope_WT_Y['B_below'])794    self.DrainedSlope_WT_Y['HillB_above'] = float(self.DrainedSlope_WT_Y['HillB_above'])795    self.DrainedSlope_WT_Y['HillN_above'] = float(self.DrainedSlope_WT_Y['HillN_above'])796    self.DrainedSlope_WT_Y['HillB_below'] = float(self.DrainedSlope_WT_Y['HillB_below'])797    self.DrainedSlope_WT_Y['HillN_below'] = float(self.DrainedSlope_WT_Y['HillN_below'])798    self.DrainedSlope_WT_Y['max_terrain_transition'] = \799      float(self.DrainedSlope_WT_Y['max_terrain_transition'])800    self.DrainedSlope_WT_Y['ice_slope_poor']    = float(self.DrainedSlope_WT_Y['ice_slope_poor'])801    self.DrainedSlope_WT_Y['ice_slope_pore']    = float(self.DrainedSlope_WT_Y['ice_slope_pore'])802    self.DrainedSlope_WT_Y['ice_slope_wedge']   = float(self.DrainedSlope_WT_Y['ice_slope_wedge'])803    self.DrainedSlope_WT_Y['ice_slope_massive'] = float(self.DrainedSlope_WT_Y['ice_slope_massive'])804    self.DrainedSlope_WT_Y['porosity'] = float(self.DrainedSlope_WT_Y['porosity'])    805    # - - - - - - - - - - - - - - - - - - - - - - - - -806    # Reading Medium Age Parameters from Control file807    # - - - - - - - - - - - - - - - - - - - - - - - - -808    print '      .. Medium age parameters'809    810    self.DrainedSlope_WT_M = {}811    with open(self.DrainedSlope_WT_M_Control, 'r') as f:812        for line in f:813            if line.startswith('#'):814                continue815            else:816                (key, val) = line.split()817                self.DrainedSlope_WT_M[(key)] = val818    # Convert strings to floats as necessary819    self.DrainedSlope_WT_M['A1_above']    = float(self.DrainedSlope_WT_M['A1_above'])820    self.DrainedSlope_WT_M['A2_above']    = float(self.DrainedSlope_WT_M['A2_above'])821    self.DrainedSlope_WT_M['x0_above']    = float(self.DrainedSlope_WT_M['x0_above'])822    self.DrainedSlope_WT_M['dx_above']    = float(self.DrainedSlope_WT_M['dx_above'])823    self.DrainedSlope_WT_M['A1_below']    = float(self.DrainedSlope_WT_M['A1_below'])824    self.DrainedSlope_WT_M['A2_below']    = float(self.DrainedSlope_WT_M['A2_below'])825    self.DrainedSlope_WT_M['x0_below']    = float(self.DrainedSlope_WT_M['x0_below'])826    self.DrainedSlope_WT_M['dx_below']    = float(self.DrainedSlope_WT_M['dx_below'])827    self.DrainedSlope_WT_M['a_above']     = float(self.DrainedSlope_WT_M['a_above'])828    self.DrainedSlope_WT_M['b_above']     = float(self.DrainedSlope_WT_M['b_above'])829    self.DrainedSlope_WT_M['a_below']     = float(self.DrainedSlope_WT_M['a_below'])830    self.DrainedSlope_WT_M['b_below']     = float(self.DrainedSlope_WT_M['b_below'])831    self.DrainedSlope_WT_M['K_above']     = float(self.DrainedSlope_WT_M['K_above'])832    self.DrainedSlope_WT_M['C_above']     = float(self.DrainedSlope_WT_M['C_above'])833    self.DrainedSlope_WT_M['A_above']     = float(self.DrainedSlope_WT_M['A_above'])834    self.DrainedSlope_WT_M['B_above']     = float(self.DrainedSlope_WT_M['B_above'])835    self.DrainedSlope_WT_M['K_below']     = float(self.DrainedSlope_WT_M['K_below'])836    self.DrainedSlope_WT_M['C_below']     = float(self.DrainedSlope_WT_M['C_below'])837    self.DrainedSlope_WT_M['A_below']     = float(self.DrainedSlope_WT_M['A_below'])838    self.DrainedSlope_WT_M['B_below']     = float(self.DrainedSlope_WT_M['B_below'])839    self.DrainedSlope_WT_M['HillB_above'] = float(self.DrainedSlope_WT_M['HillB_above'])840    self.DrainedSlope_WT_M['HillN_above'] = float(self.DrainedSlope_WT_M['HillN_above'])841    self.DrainedSlope_WT_M['HillB_below'] = float(self.DrainedSlope_WT_M['HillB_below'])842    self.DrainedSlope_WT_M['HillN_below'] = float(self.DrainedSlope_WT_M['HillN_below'])843    self.DrainedSlope_WT_M['max_terrain_transition'] = \844      float(self.DrainedSlope_WT_M['max_terrain_transition'])845    self.DrainedSlope_WT_M['ice_slope_poor']    = float(self.DrainedSlope_WT_M['ice_slope_poor'])846    self.DrainedSlope_WT_M['ice_slope_pore']    = float(self.DrainedSlope_WT_M['ice_slope_pore'])847    self.DrainedSlope_WT_M['ice_slope_wedge']   = float(self.DrainedSlope_WT_M['ice_slope_wedge'])848    self.DrainedSlope_WT_M['ice_slope_massive'] = float(self.DrainedSlope_WT_M['ice_slope_massive'])849    self.DrainedSlope_WT_M['porosity'] = float(self.DrainedSlope_WT_M['porosity'])    850    # - - - - - - - - - - - - - - - - - - - - - - - - -851    # Reading Old Age Parameters from Control file852    # - - - - - - - - - - - - - - - - - - - - - - - - -853    print '      .. Old age parameters'854    855    self.DrainedSlope_WT_O = {}856    with open(self.DrainedSlope_WT_O_Control, 'r') as f:857        for line in f:858            if line.startswith('#'):859                continue860            else:861                (key, val) = line.split()862                self.DrainedSlope_WT_O[(key)] = val863    # Convert strings to floats as necessary864    self.DrainedSlope_WT_O['A1_above']    = float(self.DrainedSlope_WT_O['A1_above'])865    self.DrainedSlope_WT_O['A2_above']    = float(self.DrainedSlope_WT_O['A2_above'])866    self.DrainedSlope_WT_O['x0_above']    = float(self.DrainedSlope_WT_O['x0_above'])867    self.DrainedSlope_WT_O['dx_above']    = float(self.DrainedSlope_WT_O['dx_above'])868    self.DrainedSlope_WT_O['A1_below']    = float(self.DrainedSlope_WT_O['A1_below'])869    self.DrainedSlope_WT_O['A2_below']    = float(self.DrainedSlope_WT_O['A2_below'])870    self.DrainedSlope_WT_O['x0_below']    = float(self.DrainedSlope_WT_O['x0_below'])871    self.DrainedSlope_WT_O['dx_below']    = float(self.DrainedSlope_WT_O['dx_below'])872    self.DrainedSlope_WT_O['a_above']     = float(self.DrainedSlope_WT_O['a_above'])873    self.DrainedSlope_WT_O['b_above']     = float(self.DrainedSlope_WT_O['b_above'])874    self.DrainedSlope_WT_O['a_below']     = float(self.DrainedSlope_WT_O['a_below'])875    self.DrainedSlope_WT_O['b_below']     = float(self.DrainedSlope_WT_O['b_below'])876    self.DrainedSlope_WT_O['K_above']     = float(self.DrainedSlope_WT_O['K_above'])877    self.DrainedSlope_WT_O['C_above']     = float(self.DrainedSlope_WT_O['C_above'])878    self.DrainedSlope_WT_O['A_above']     = float(self.DrainedSlope_WT_O['A_above'])879    self.DrainedSlope_WT_O['B_above']     = float(self.DrainedSlope_WT_O['B_above'])880    self.DrainedSlope_WT_O['K_below']     = float(self.DrainedSlope_WT_O['K_below'])881    self.DrainedSlope_WT_O['C_below']     = float(self.DrainedSlope_WT_O['C_below'])882    self.DrainedSlope_WT_O['A_below']     = float(self.DrainedSlope_WT_O['A_below'])883    self.DrainedSlope_WT_O['B_below']     = float(self.DrainedSlope_WT_O['B_below'])884    self.DrainedSlope_WT_O['HillB_above'] = float(self.DrainedSlope_WT_O['HillB_above'])885    self.DrainedSlope_WT_O['HillN_above'] = float(self.DrainedSlope_WT_O['HillN_above'])886    self.DrainedSlope_WT_O['HillB_below'] = float(self.DrainedSlope_WT_O['HillB_below'])887    self.DrainedSlope_WT_O['HillN_below'] = float(self.DrainedSlope_WT_O['HillN_below'])888    self.DrainedSlope_WT_O['max_terrain_transition'] = \889      float(self.DrainedSlope_WT_O['max_terrain_transition'])890    self.DrainedSlope_WT_O['ice_slope_poor']    = float(self.DrainedSlope_WT_O['ice_slope_poor'])891    self.DrainedSlope_WT_O['ice_slope_pore']    = float(self.DrainedSlope_WT_O['ice_slope_pore'])892    self.DrainedSlope_WT_O['ice_slope_wedge']   = float(self.DrainedSlope_WT_O['ice_slope_wedge'])893    self.DrainedSlope_WT_O['ice_slope_massive'] = float(self.DrainedSlope_WT_O['ice_slope_massive'])894    self.DrainedSlope_WT_O['porosity'] = float(self.DrainedSlope_WT_O['porosity'])    895#====================================================================================896def FCP_WT(self):897    898    print '    ..Reading Wetland Tundra Flat Center Polygon Parameters'899    """ Read files from the input directory """900    if self.Simulation_area.lower() == 'barrow':901        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\902                 self.Control_directory)903    elif self.Simulation_area.lower() == 'arctic_coast':904        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic/'+\905                 self.Control_directory)906    elif self.Simulation_area.lower() == 'tanana':907        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\908                 self.Control_directory)909    elif self.Simulation_area.lower() == 'yukon':910        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\911                 self.Control_directory)912    elif self.Simulation_area.lower() == 'aiem':913        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM/'+\914                 self.Control_directory)915    elif self.Simulation_area.lower() == 'ngee':916        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE/'+\917                 self.Control_directory)918    # - - - - - - - - - - - - - - - - - - - - - - - - -919    # Reading Young Age Parameters from Control file920    # - - - - - - - - - - - - - - - - - - - - - - - - -921    print '      .. Young age parameters'922    923    self.FCP_WT_Y = {}924    with open(self.FCP_WT_Y_Control, 'r') as f:925        for line in f:926            if line.startswith('#'):927                continue928            else:929                (key, val) = line.split()930                self.FCP_WT_Y[(key)] = val931    # Convert strings to floats as necessary932    self.FCP_WT_Y['A1_above']    = float(self.FCP_WT_Y['A1_above'])933    self.FCP_WT_Y['A2_above']    = float(self.FCP_WT_Y['A2_above'])934    self.FCP_WT_Y['x0_above']    = float(self.FCP_WT_Y['x0_above'])935    self.FCP_WT_Y['dx_above']    = float(self.FCP_WT_Y['dx_above'])936    self.FCP_WT_Y['A1_below']    = float(self.FCP_WT_Y['A1_below'])937    self.FCP_WT_Y['A2_below']    = float(self.FCP_WT_Y['A2_below'])938    self.FCP_WT_Y['x0_below']    = float(self.FCP_WT_Y['x0_below'])939    self.FCP_WT_Y['dx_below']    = float(self.FCP_WT_Y['dx_below'])940    self.FCP_WT_Y['a_above']     = float(self.FCP_WT_Y['a_above'])941    self.FCP_WT_Y['b_above']     = float(self.FCP_WT_Y['b_above'])942    self.FCP_WT_Y['a_below']     = float(self.FCP_WT_Y['a_below'])943    self.FCP_WT_Y['b_below']     = float(self.FCP_WT_Y['b_below'])944    self.FCP_WT_Y['K_above']     = float(self.FCP_WT_Y['K_above'])945    self.FCP_WT_Y['C_above']     = float(self.FCP_WT_Y['C_above'])946    self.FCP_WT_Y['A_above']     = float(self.FCP_WT_Y['A_above'])947    self.FCP_WT_Y['B_above']     = float(self.FCP_WT_Y['B_above'])948    self.FCP_WT_Y['K_below']     = float(self.FCP_WT_Y['K_below'])949    self.FCP_WT_Y['C_below']     = float(self.FCP_WT_Y['C_below'])950    self.FCP_WT_Y['A_below']     = float(self.FCP_WT_Y['A_below'])951    self.FCP_WT_Y['B_below']     = float(self.FCP_WT_Y['B_below'])952    self.FCP_WT_Y['HillB_above'] = float(self.FCP_WT_Y['HillB_above'])953    self.FCP_WT_Y['HillN_above'] = float(self.FCP_WT_Y['HillN_above'])954    self.FCP_WT_Y['HillB_below'] = float(self.FCP_WT_Y['HillB_below'])955    self.FCP_WT_Y['HillN_below'] = float(self.FCP_WT_Y['HillN_below'])956    self.FCP_WT_Y['max_terrain_transition'] = \957      float(self.FCP_WT_Y['max_terrain_transition'])958    self.FCP_WT_Y['ice_slope_poor']    = float(self.FCP_WT_Y['ice_slope_poor'])959    self.FCP_WT_Y['ice_slope_pore']    = float(self.FCP_WT_Y['ice_slope_pore'])960    self.FCP_WT_Y['ice_slope_wedge']   = float(self.FCP_WT_Y['ice_slope_wedge'])961    self.FCP_WT_Y['ice_slope_massive'] = float(self.FCP_WT_Y['ice_slope_massive'])962    self.FCP_WT_Y['porosity'] = float(self.FCP_WT_Y['porosity'])    963    # - - - - - - - - - - - - - - - - - - - - - - - - -964    # Reading Medium Age Parameters from Control file965    # - - - - - - - - - - - - - - - - - - - - - - - - -966    print '      .. Medium age parameters'967    968    self.FCP_WT_M = {}969    with open(self.FCP_WT_M_Control, 'r') as f:970        for line in f:971            if line.startswith('#'):972                continue973            else:974                (key, val) = line.split()975                self.FCP_WT_M[(key)] = val976    # Convert strings to floats as necessary977    self.FCP_WT_M['A1_above']    = float(self.FCP_WT_M['A1_above'])978    self.FCP_WT_M['A2_above']    = float(self.FCP_WT_M['A2_above'])979    self.FCP_WT_M['x0_above']    = float(self.FCP_WT_M['x0_above'])980    self.FCP_WT_M['dx_above']    = float(self.FCP_WT_M['dx_above'])981    self.FCP_WT_M['A1_below']    = float(self.FCP_WT_M['A1_below'])982    self.FCP_WT_M['A2_below']    = float(self.FCP_WT_M['A2_below'])983    self.FCP_WT_M['x0_below']    = float(self.FCP_WT_M['x0_below'])984    self.FCP_WT_M['dx_below']    = float(self.FCP_WT_M['dx_below'])985    self.FCP_WT_M['a_above']     = float(self.FCP_WT_M['a_above'])986    self.FCP_WT_M['b_above']     = float(self.FCP_WT_M['b_above'])987    self.FCP_WT_M['a_below']     = float(self.FCP_WT_M['a_below'])988    self.FCP_WT_M['b_below']     = float(self.FCP_WT_M['b_below'])989    self.FCP_WT_M['K_above']     = float(self.FCP_WT_M['K_above'])990    self.FCP_WT_M['C_above']     = float(self.FCP_WT_M['C_above'])991    self.FCP_WT_M['A_above']     = float(self.FCP_WT_M['A_above'])992    self.FCP_WT_M['B_above']     = float(self.FCP_WT_M['B_above'])993    self.FCP_WT_M['K_below']     = float(self.FCP_WT_M['K_below'])994    self.FCP_WT_M['C_below']     = float(self.FCP_WT_M['C_below'])995    self.FCP_WT_M['A_below']     = float(self.FCP_WT_M['A_below'])996    self.FCP_WT_M['B_below']     = float(self.FCP_WT_M['B_below'])997    self.FCP_WT_M['HillB_above'] = float(self.FCP_WT_M['HillB_above'])998    self.FCP_WT_M['HillN_above'] = float(self.FCP_WT_M['HillN_above'])999    self.FCP_WT_M['HillB_below'] = float(self.FCP_WT_M['HillB_below'])1000    self.FCP_WT_M['HillN_below'] = float(self.FCP_WT_M['HillN_below'])1001    self.FCP_WT_M['max_terrain_transition'] = \1002      float(self.FCP_WT_M['max_terrain_transition'])1003    self.FCP_WT_M['ice_slope_poor']    = float(self.FCP_WT_M['ice_slope_poor'])1004    self.FCP_WT_M['ice_slope_pore']    = float(self.FCP_WT_M['ice_slope_pore'])1005    self.FCP_WT_M['ice_slope_wedge']   = float(self.FCP_WT_M['ice_slope_wedge'])1006    self.FCP_WT_M['ice_slope_massive'] = float(self.FCP_WT_M['ice_slope_massive'])1007    self.FCP_WT_M['porosity'] = float(self.FCP_WT_M['porosity'])    1008    # - - - - - - - - - - - - - - - - - - - - - - - - -1009    # Reading Old Age Parameters from Control file1010    # - - - - - - - - - - - - - - - - - - - - - - - - -1011    print '      .. Old age parameters'1012    1013    self.FCP_WT_O = {}1014    with open(self.FCP_WT_O_Control, 'r') as f:1015        for line in f:1016            if line.startswith('#'):1017                continue1018            else:1019                (key, val) = line.split()1020                self.FCP_WT_O[(key)] = val1021    # Convert strings to floats as necessary1022    self.FCP_WT_O['A1_above']    = float(self.FCP_WT_O['A1_above'])1023    self.FCP_WT_O['A2_above']    = float(self.FCP_WT_O['A2_above'])1024    self.FCP_WT_O['x0_above']    = float(self.FCP_WT_O['x0_above'])1025    self.FCP_WT_O['dx_above']    = float(self.FCP_WT_O['dx_above'])1026    self.FCP_WT_O['A1_below']    = float(self.FCP_WT_O['A1_below'])1027    self.FCP_WT_O['A2_below']    = float(self.FCP_WT_O['A2_below'])1028    self.FCP_WT_O['x0_below']    = float(self.FCP_WT_O['x0_below'])1029    self.FCP_WT_O['dx_below']    = float(self.FCP_WT_O['dx_below'])1030    self.FCP_WT_O['a_above']     = float(self.FCP_WT_O['a_above'])1031    self.FCP_WT_O['b_above']     = float(self.FCP_WT_O['b_above'])1032    self.FCP_WT_O['a_below']     = float(self.FCP_WT_O['a_below'])1033    self.FCP_WT_O['b_below']     = float(self.FCP_WT_O['b_below'])1034    self.FCP_WT_O['K_above']     = float(self.FCP_WT_O['K_above'])1035    self.FCP_WT_O['C_above']     = float(self.FCP_WT_O['C_above'])1036    self.FCP_WT_O['A_above']     = float(self.FCP_WT_O['A_above'])1037    self.FCP_WT_O['B_above']     = float(self.FCP_WT_O['B_above'])1038    self.FCP_WT_O['K_below']     = float(self.FCP_WT_O['K_below'])1039    self.FCP_WT_O['C_below']     = float(self.FCP_WT_O['C_below'])1040    self.FCP_WT_O['A_below']     = float(self.FCP_WT_O['A_below'])1041    self.FCP_WT_O['B_below']     = float(self.FCP_WT_O['B_below'])1042    self.FCP_WT_O['HillB_above'] = float(self.FCP_WT_O['HillB_above'])1043    self.FCP_WT_O['HillN_above'] = float(self.FCP_WT_O['HillN_above'])1044    self.FCP_WT_O['HillB_below'] = float(self.FCP_WT_O['HillB_below'])1045    self.FCP_WT_O['HillN_below'] = float(self.FCP_WT_O['HillN_below'])1046    self.FCP_WT_O['max_terrain_transition'] = \1047      float(self.FCP_WT_O['max_terrain_transition'])1048    self.FCP_WT_O['ice_slope_poor']    = float(self.FCP_WT_O['ice_slope_poor'])1049    self.FCP_WT_O['ice_slope_pore']    = float(self.FCP_WT_O['ice_slope_pore'])1050    self.FCP_WT_O['ice_slope_wedge']   = float(self.FCP_WT_O['ice_slope_wedge'])1051    self.FCP_WT_O['ice_slope_massive'] = float(self.FCP_WT_O['ice_slope_massive'])1052    self.FCP_WT_O['porosity'] = float(self.FCP_WT_O['porosity'])    1053#====================================================================================1054def HCP_WT(self):1055    1056    print '    ..Reading Wetland Tundra High Center Polygon Parameters'1057    """ Read files from the input directory """1058    if self.Simulation_area.lower() == 'barrow':1059        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\1060                 self.Control_directory)1061    elif self.Simulation_area.lower() == 'arctic_coast':1062        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic/'+\1063                 self.Control_directory)1064    elif self.Simulation_area.lower() == 'tanana':1065        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\1066                 self.Control_directory)1067    elif self.Simulation_area.lower() == 'yukon':1068        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\1069                 self.Control_directory)1070    elif self.Simulation_area.lower() == 'aiem':1071        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM/'+\1072                 self.Control_directory)1073    elif self.Simulation_area.lower() == 'ngee':1074        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE/'+\1075                 self.Control_directory)1076    # - - - - - - - - - - - - - - - - - - - - - - - - -1077    # Reading Young Age Parameters from Control file1078    # - - - - - - - - - - - - - - - - - - - - - - - - -1079    print '      .. Young age parameters'1080    1081    self.HCP_WT_Y = {}1082    with open(self.HCP_WT_Y_Control, 'r') as f:1083        for line in f:1084            if line.startswith('#'):1085                continue1086            else:1087                (key, val) = line.split()1088                self.HCP_WT_Y[(key)] = val1089    # Convert strings to floats as necessary1090    self.HCP_WT_Y['A1_above']    = float(self.HCP_WT_Y['A1_above'])1091    self.HCP_WT_Y['A2_above']    = float(self.HCP_WT_Y['A2_above'])1092    self.HCP_WT_Y['x0_above']    = float(self.HCP_WT_Y['x0_above'])1093    self.HCP_WT_Y['dx_above']    = float(self.HCP_WT_Y['dx_above'])1094    self.HCP_WT_Y['A1_below']    = float(self.HCP_WT_Y['A1_below'])1095    self.HCP_WT_Y['A2_below']    = float(self.HCP_WT_Y['A2_below'])1096    self.HCP_WT_Y['x0_below']    = float(self.HCP_WT_Y['x0_below'])1097    self.HCP_WT_Y['dx_below']    = float(self.HCP_WT_Y['dx_below'])1098    self.HCP_WT_Y['a_above']     = float(self.HCP_WT_Y['a_above'])1099    self.HCP_WT_Y['b_above']     = float(self.HCP_WT_Y['b_above'])1100    self.HCP_WT_Y['a_below']     = float(self.HCP_WT_Y['a_below'])1101    self.HCP_WT_Y['b_below']     = float(self.HCP_WT_Y['b_below'])1102    self.HCP_WT_Y['K_above']     = float(self.HCP_WT_Y['K_above'])1103    self.HCP_WT_Y['C_above']     = float(self.HCP_WT_Y['C_above'])1104    self.HCP_WT_Y['A_above']     = float(self.HCP_WT_Y['A_above'])1105    self.HCP_WT_Y['B_above']     = float(self.HCP_WT_Y['B_above'])1106    self.HCP_WT_Y['K_below']     = float(self.HCP_WT_Y['K_below'])1107    self.HCP_WT_Y['C_below']     = float(self.HCP_WT_Y['C_below'])1108    self.HCP_WT_Y['A_below']     = float(self.HCP_WT_Y['A_below'])1109    self.HCP_WT_Y['B_below']     = float(self.HCP_WT_Y['B_below'])1110    self.HCP_WT_Y['HillB_above'] = float(self.HCP_WT_Y['HillB_above'])1111    self.HCP_WT_Y['HillN_above'] = float(self.HCP_WT_Y['HillN_above'])1112    self.HCP_WT_Y['HillB_below'] = float(self.HCP_WT_Y['HillB_below'])1113    self.HCP_WT_Y['HillN_below'] = float(self.HCP_WT_Y['HillN_below'])1114    self.HCP_WT_Y['max_terrain_transition'] = \1115      float(self.HCP_WT_Y['max_terrain_transition'])1116    self.HCP_WT_Y['ice_slope_poor']    = float(self.HCP_WT_Y['ice_slope_poor'])1117    self.HCP_WT_Y['ice_slope_pore']    = float(self.HCP_WT_Y['ice_slope_pore'])1118    self.HCP_WT_Y['ice_slope_wedge']   = float(self.HCP_WT_Y['ice_slope_wedge'])1119    self.HCP_WT_Y['ice_slope_massive'] = float(self.HCP_WT_Y['ice_slope_massive'])1120    self.HCP_WT_Y['porosity'] = float(self.HCP_WT_Y['porosity'])    1121    # - - - - - - - - - - - - - - - - - - - - - - - - -1122    # Reading Medium Age Parameters from Control file1123    # - - - - - - - - - - - - - - - - - - - - - - - - -1124    print '      .. Medium age parameters'1125    1126    self.HCP_WT_M = {}1127    with open(self.HCP_WT_M_Control, 'r') as f:1128        for line in f:1129            if line.startswith('#'):1130                continue1131            else:1132                (key, val) = line.split()1133                self.HCP_WT_M[(key)] = val1134    # Convert strings to floats as necessary1135    self.HCP_WT_M['A1_above']    = float(self.HCP_WT_M['A1_above'])1136    self.HCP_WT_M['A2_above']    = float(self.HCP_WT_M['A2_above'])1137    self.HCP_WT_M['x0_above']    = float(self.HCP_WT_M['x0_above'])1138    self.HCP_WT_M['dx_above']    = float(self.HCP_WT_M['dx_above'])1139    self.HCP_WT_M['A1_below']    = float(self.HCP_WT_M['A1_below'])1140    self.HCP_WT_M['A2_below']    = float(self.HCP_WT_M['A2_below'])1141    self.HCP_WT_M['x0_below']    = float(self.HCP_WT_M['x0_below'])1142    self.HCP_WT_M['dx_below']    = float(self.HCP_WT_M['dx_below'])1143    self.HCP_WT_M['a_above']     = float(self.HCP_WT_M['a_above'])1144    self.HCP_WT_M['b_above']     = float(self.HCP_WT_M['b_above'])1145    self.HCP_WT_M['a_below']     = float(self.HCP_WT_M['a_below'])1146    self.HCP_WT_M['b_below']     = float(self.HCP_WT_M['b_below'])1147    self.HCP_WT_M['K_above']     = float(self.HCP_WT_M['K_above'])1148    self.HCP_WT_M['C_above']     = float(self.HCP_WT_M['C_above'])1149    self.HCP_WT_M['A_above']     = float(self.HCP_WT_M['A_above'])1150    self.HCP_WT_M['B_above']     = float(self.HCP_WT_M['B_above'])1151    self.HCP_WT_M['K_below']     = float(self.HCP_WT_M['K_below'])1152    self.HCP_WT_M['C_below']     = float(self.HCP_WT_M['C_below'])1153    self.HCP_WT_M['A_below']     = float(self.HCP_WT_M['A_below'])1154    self.HCP_WT_M['B_below']     = float(self.HCP_WT_M['B_below'])1155    self.HCP_WT_M['HillB_above'] = float(self.HCP_WT_M['HillB_above'])1156    self.HCP_WT_M['HillN_above'] = float(self.HCP_WT_M['HillN_above'])1157    self.HCP_WT_M['HillB_below'] = float(self.HCP_WT_M['HillB_below'])1158    self.HCP_WT_M['HillN_below'] = float(self.HCP_WT_M['HillN_below'])1159    self.HCP_WT_M['max_terrain_transition'] = \1160      float(self.HCP_WT_M['max_terrain_transition'])1161    self.HCP_WT_M['ice_slope_poor']    = float(self.HCP_WT_M['ice_slope_poor'])1162    self.HCP_WT_M['ice_slope_pore']    = float(self.HCP_WT_M['ice_slope_pore'])1163    self.HCP_WT_M['ice_slope_wedge']   = float(self.HCP_WT_M['ice_slope_wedge'])1164    self.HCP_WT_M['ice_slope_massive'] = float(self.HCP_WT_M['ice_slope_massive'])1165    self.HCP_WT_M['porosity'] = float(self.HCP_WT_M['porosity'])    1166    # - - - - - - - - - - - - - - - - - - - - - - - - -1167    # Reading Old Age Parameters from Control file1168    # - - - - - - - - - - - - - - - - - - - - - - - - -1169    print '      .. Old age parameters'1170    1171    self.HCP_WT_O = {}1172    with open(self.HCP_WT_O_Control, 'r') as f:1173        for line in f:1174            if line.startswith('#'):1175                continue1176            else:1177                (key, val) = line.split()1178                self.HCP_WT_O[(key)] = val1179    # Convert strings to floats as necessary1180    self.HCP_WT_O['A1_above']    = float(self.HCP_WT_O['A1_above'])1181    self.HCP_WT_O['A2_above']    = float(self.HCP_WT_O['A2_above'])1182    self.HCP_WT_O['x0_above']    = float(self.HCP_WT_O['x0_above'])1183    self.HCP_WT_O['dx_above']    = float(self.HCP_WT_O['dx_above'])1184    self.HCP_WT_O['A1_below']    = float(self.HCP_WT_O['A1_below'])1185    self.HCP_WT_O['A2_below']    = float(self.HCP_WT_O['A2_below'])1186    self.HCP_WT_O['x0_below']    = float(self.HCP_WT_O['x0_below'])1187    self.HCP_WT_O['dx_below']    = float(self.HCP_WT_O['dx_below'])1188    self.HCP_WT_O['a_above']     = float(self.HCP_WT_O['a_above'])1189    self.HCP_WT_O['b_above']     = float(self.HCP_WT_O['b_above'])1190    self.HCP_WT_O['a_below']     = float(self.HCP_WT_O['a_below'])1191    self.HCP_WT_O['b_below']     = float(self.HCP_WT_O['b_below'])1192    self.HCP_WT_O['K_above']     = float(self.HCP_WT_O['K_above'])1193    self.HCP_WT_O['C_above']     = float(self.HCP_WT_O['C_above'])1194    self.HCP_WT_O['A_above']     = float(self.HCP_WT_O['A_above'])1195    self.HCP_WT_O['B_above']     = float(self.HCP_WT_O['B_above'])1196    self.HCP_WT_O['K_below']     = float(self.HCP_WT_O['K_below'])1197    self.HCP_WT_O['C_below']     = float(self.HCP_WT_O['C_below'])1198    self.HCP_WT_O['A_below']     = float(self.HCP_WT_O['A_below'])1199    self.HCP_WT_O['B_below']     = float(self.HCP_WT_O['B_below'])1200    self.HCP_WT_O['HillB_above'] = float(self.HCP_WT_O['HillB_above'])1201    self.HCP_WT_O['HillN_above'] = float(self.HCP_WT_O['HillN_above'])1202    self.HCP_WT_O['HillB_below'] = float(self.HCP_WT_O['HillB_below'])1203    self.HCP_WT_O['HillN_below'] = float(self.HCP_WT_O['HillN_below'])1204    self.HCP_WT_O['max_terrain_transition'] = \1205      float(self.HCP_WT_O['max_terrain_transition'])1206    self.HCP_WT_O['ice_slope_poor']    = float(self.HCP_WT_O['ice_slope_poor'])1207    self.HCP_WT_O['ice_slope_pore']    = float(self.HCP_WT_O['ice_slope_pore'])1208    self.HCP_WT_O['ice_slope_wedge']   = float(self.HCP_WT_O['ice_slope_wedge'])1209    self.HCP_WT_O['ice_slope_massive'] = float(self.HCP_WT_O['ice_slope_massive'])1210    self.HCP_WT_O['porosity'] = float(self.HCP_WT_O['porosity'])    1211#====================================================================================1212def LCP_WT(self):1213    1214    print '    ..Reading Wetland Tundra Low Center Polygon Parameters'1215    """ Read files from the input directory """1216    if self.Simulation_area.lower() == 'barrow':1217        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\1218                 self.Control_directory)1219    elif self.Simulation_area.lower() == 'arctic_coast':1220        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic/'+\1221                 self.Control_directory)1222    elif self.Simulation_area.lower() == 'tanana':1223        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\1224                 self.Control_directory)1225    elif self.Simulation_area.lower() == 'yukon':1226        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\1227                 self.Control_directory)1228    elif self.Simulation_area.lower() == 'aiem':1229        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM/'+\1230                 self.Control_directory)1231    elif self.Simulation_area.lower() == 'ngee':1232        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE/'+\1233                 self.Control_directory)1234    # - - - - - - - - - - - - - - - - - - - - - - - - -1235    # Reading Young Age Parameters from Control file1236    # - - - - - - - - - - - - - - - - - - - - - - - - -1237    print '      .. Young age parameters'1238    1239    self.LCP_WT_Y = {}1240    with open(self.LCP_WT_Y_Control, 'r') as f:1241        for line in f:1242            if line.startswith('#'):1243                continue1244            else:1245                (key, val) = line.split()1246                self.LCP_WT_Y[(key)] = val1247    # Convert strings to floats as necessary1248    self.LCP_WT_Y['A1_above']    = float(self.LCP_WT_Y['A1_above'])1249    self.LCP_WT_Y['A2_above']    = float(self.LCP_WT_Y['A2_above'])1250    self.LCP_WT_Y['x0_above']    = float(self.LCP_WT_Y['x0_above'])1251    self.LCP_WT_Y['dx_above']    = float(self.LCP_WT_Y['dx_above'])1252    self.LCP_WT_Y['A1_below']    = float(self.LCP_WT_Y['A1_below'])1253    self.LCP_WT_Y['A2_below']    = float(self.LCP_WT_Y['A2_below'])1254    self.LCP_WT_Y['x0_below']    = float(self.LCP_WT_Y['x0_below'])1255    self.LCP_WT_Y['dx_below']    = float(self.LCP_WT_Y['dx_below'])1256    self.LCP_WT_Y['a_above']     = float(self.LCP_WT_Y['a_above'])1257    self.LCP_WT_Y['b_above']     = float(self.LCP_WT_Y['b_above'])1258    self.LCP_WT_Y['a_below']     = float(self.LCP_WT_Y['a_below'])1259    self.LCP_WT_Y['b_below']     = float(self.LCP_WT_Y['b_below'])1260    self.LCP_WT_Y['K_above']     = float(self.LCP_WT_Y['K_above'])1261    self.LCP_WT_Y['C_above']     = float(self.LCP_WT_Y['C_above'])1262    self.LCP_WT_Y['A_above']     = float(self.LCP_WT_Y['A_above'])1263    self.LCP_WT_Y['B_above']     = float(self.LCP_WT_Y['B_above'])1264    self.LCP_WT_Y['K_below']     = float(self.LCP_WT_Y['K_below'])1265    self.LCP_WT_Y['C_below']     = float(self.LCP_WT_Y['C_below'])1266    self.LCP_WT_Y['A_below']     = float(self.LCP_WT_Y['A_below'])1267    self.LCP_WT_Y['B_below']     = float(self.LCP_WT_Y['B_below'])1268    self.LCP_WT_Y['HillB_above'] = float(self.LCP_WT_Y['HillB_above'])1269    self.LCP_WT_Y['HillN_above'] = float(self.LCP_WT_Y['HillN_above'])1270    self.LCP_WT_Y['HillB_below'] = float(self.LCP_WT_Y['HillB_below'])1271    self.LCP_WT_Y['HillN_below'] = float(self.LCP_WT_Y['HillN_below'])1272    self.LCP_WT_Y['max_terrain_transition'] = \1273      float(self.LCP_WT_Y['max_terrain_transition'])1274    self.LCP_WT_Y['ice_slope_poor']    = float(self.LCP_WT_Y['ice_slope_poor'])1275    self.LCP_WT_Y['ice_slope_pore']    = float(self.LCP_WT_Y['ice_slope_pore'])1276    self.LCP_WT_Y['ice_slope_wedge']   = float(self.LCP_WT_Y['ice_slope_wedge'])1277    self.LCP_WT_Y['ice_slope_massive'] = float(self.LCP_WT_Y['ice_slope_massive'])1278    self.LCP_WT_Y['porosity'] = float(self.LCP_WT_Y['porosity'])    1279    # - - - - - - - - - - - - - - - - - - - - - - - - -1280    # Reading Medium Age Parameters from Control file1281    # - - - - - - - - - - - - - - - - - - - - - - - - -1282    print '      .. Medium age parameters'1283    1284    self.LCP_WT_M = {}1285    with open(self.LCP_WT_M_Control, 'r') as f:1286        for line in f:1287            if line.startswith('#'):1288                continue1289            else:1290                (key, val) = line.split()1291                self.LCP_WT_M[(key)] = val1292    # Convert strings to floats as necessary1293    self.LCP_WT_M['A1_above']    = float(self.LCP_WT_M['A1_above'])1294    self.LCP_WT_M['A2_above']    = float(self.LCP_WT_M['A2_above'])1295    self.LCP_WT_M['x0_above']    = float(self.LCP_WT_M['x0_above'])1296    self.LCP_WT_M['dx_above']    = float(self.LCP_WT_M['dx_above'])1297    self.LCP_WT_M['A1_below']    = float(self.LCP_WT_M['A1_below'])1298    self.LCP_WT_M['A2_below']    = float(self.LCP_WT_M['A2_below'])1299    self.LCP_WT_M['x0_below']    = float(self.LCP_WT_M['x0_below'])1300    self.LCP_WT_M['dx_below']    = float(self.LCP_WT_M['dx_below'])1301    self.LCP_WT_M['a_above']     = float(self.LCP_WT_M['a_above'])1302    self.LCP_WT_M['b_above']     = float(self.LCP_WT_M['b_above'])1303    self.LCP_WT_M['a_below']     = float(self.LCP_WT_M['a_below'])1304    self.LCP_WT_M['b_below']     = float(self.LCP_WT_M['b_below'])1305    self.LCP_WT_M['K_above']     = float(self.LCP_WT_M['K_above'])1306    self.LCP_WT_M['C_above']     = float(self.LCP_WT_M['C_above'])1307    self.LCP_WT_M['A_above']     = float(self.LCP_WT_M['A_above'])1308    self.LCP_WT_M['B_above']     = float(self.LCP_WT_M['B_above'])1309    self.LCP_WT_M['K_below']     = float(self.LCP_WT_M['K_below'])1310    self.LCP_WT_M['C_below']     = float(self.LCP_WT_M['C_below'])1311    self.LCP_WT_M['A_below']     = float(self.LCP_WT_M['A_below'])1312    self.LCP_WT_M['B_below']     = float(self.LCP_WT_M['B_below'])1313    self.LCP_WT_M['HillB_above'] = float(self.LCP_WT_M['HillB_above'])1314    self.LCP_WT_M['HillN_above'] = float(self.LCP_WT_M['HillN_above'])1315    self.LCP_WT_M['HillB_below'] = float(self.LCP_WT_M['HillB_below'])1316    self.LCP_WT_M['HillN_below'] = float(self.LCP_WT_M['HillN_below'])1317    self.LCP_WT_M['max_terrain_transition'] = \1318      float(self.LCP_WT_M['max_terrain_transition'])1319    self.LCP_WT_M['ice_slope_poor']    = float(self.LCP_WT_M['ice_slope_poor'])1320    self.LCP_WT_M['ice_slope_pore']    = float(self.LCP_WT_M['ice_slope_pore'])1321    self.LCP_WT_M['ice_slope_wedge']   = float(self.LCP_WT_M['ice_slope_wedge'])1322    self.LCP_WT_M['ice_slope_massive'] = float(self.LCP_WT_M['ice_slope_massive'])1323    self.LCP_WT_M['porosity'] = float(self.LCP_WT_M['porosity'])    1324    # - - - - - - - - - - - - - - - - - - - - - - - - -1325    # Reading Old Age Parameters from Control file1326    # - - - - - - - - - - - - - - - - - - - - - - - - -1327    print '      .. Old age parameters'1328    1329    self.LCP_WT_O = {}1330    with open(self.LCP_WT_O_Control, 'r') as f:1331        for line in f:1332            if line.startswith('#'):1333                continue1334            else:1335                (key, val) = line.split()1336                self.LCP_WT_O[(key)] = val1337    # Convert strings to floats as necessary1338    self.LCP_WT_O['A1_above']    = float(self.LCP_WT_O['A1_above'])1339    self.LCP_WT_O['A2_above']    = float(self.LCP_WT_O['A2_above'])1340    self.LCP_WT_O['x0_above']    = float(self.LCP_WT_O['x0_above'])1341    self.LCP_WT_O['dx_above']    = float(self.LCP_WT_O['dx_above'])1342    self.LCP_WT_O['A1_below']    = float(self.LCP_WT_O['A1_below'])1343    self.LCP_WT_O['A2_below']    = float(self.LCP_WT_O['A2_below'])1344    self.LCP_WT_O['x0_below']    = float(self.LCP_WT_O['x0_below'])1345    self.LCP_WT_O['dx_below']    = float(self.LCP_WT_O['dx_below'])1346    self.LCP_WT_O['a_above']     = float(self.LCP_WT_O['a_above'])1347    self.LCP_WT_O['b_above']     = float(self.LCP_WT_O['b_above'])1348    self.LCP_WT_O['a_below']     = float(self.LCP_WT_O['a_below'])1349    self.LCP_WT_O['b_below']     = float(self.LCP_WT_O['b_below'])1350    self.LCP_WT_O['K_above']     = float(self.LCP_WT_O['K_above'])1351    self.LCP_WT_O['C_above']     = float(self.LCP_WT_O['C_above'])1352    self.LCP_WT_O['A_above']     = float(self.LCP_WT_O['A_above'])1353    self.LCP_WT_O['B_above']     = float(self.LCP_WT_O['B_above'])1354    self.LCP_WT_O['K_below']     = float(self.LCP_WT_O['K_below'])1355    self.LCP_WT_O['C_below']     = float(self.LCP_WT_O['C_below'])1356    self.LCP_WT_O['A_below']     = float(self.LCP_WT_O['A_below'])1357    self.LCP_WT_O['B_below']     = float(self.LCP_WT_O['B_below'])1358    self.LCP_WT_O['HillB_above'] = float(self.LCP_WT_O['HillB_above'])1359    self.LCP_WT_O['HillN_above'] = float(self.LCP_WT_O['HillN_above'])1360    self.LCP_WT_O['HillB_below'] = float(self.LCP_WT_O['HillB_below'])1361    self.LCP_WT_O['HillN_below'] = float(self.LCP_WT_O['HillN_below'])1362    self.LCP_WT_O['max_terrain_transition'] = \1363      float(self.LCP_WT_O['max_terrain_transition'])1364    self.LCP_WT_O['ice_slope_poor']    = float(self.LCP_WT_O['ice_slope_poor'])1365    self.LCP_WT_O['ice_slope_pore']    = float(self.LCP_WT_O['ice_slope_pore'])1366    self.LCP_WT_O['ice_slope_wedge']   = float(self.LCP_WT_O['ice_slope_wedge'])1367    self.LCP_WT_O['ice_slope_massive'] = float(self.LCP_WT_O['ice_slope_massive'])1368    self.LCP_WT_O['porosity'] = float(self.LCP_WT_O['porosity'])    1369#====================================================================================1370def Meadow_WT(self):1371    1372    print '    ..Reading Wetland Tundra Meadow Parameters'1373    """ Read files from the input directory """1374    if self.Simulation_area.lower() == 'barrow':1375        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\1376                 self.Control_directory)1377    elif self.Simulation_area.lower() == 'arctic_coast':1378        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic/'+\1379                 self.Control_directory)1380    elif self.Simulation_area.lower() == 'tanana':1381        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\1382                 self.Control_directory)1383    elif self.Simulation_area.lower() == 'yukon':1384        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\1385                 self.Control_directory)1386    elif self.Simulation_area.lower() == 'aiem':1387        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM/'+\1388                 self.Control_directory)1389    elif self.Simulation_area.lower() == 'ngee':1390        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE/'+\1391                 self.Control_directory)1392    # - - - - - - - - - - - - - - - - - - - - - - - - -1393    # Reading Young Age Parameters from Control file1394    # - - - - - - - - - - - - - - - - - - - - - - - - -1395    print '      .. Young age parameters'1396    1397    self.Meadow_WT_Y = {}1398    with open(self.Meadow_WT_Y_Control, 'r') as f:1399        for line in f:1400            if line.startswith('#'):1401                continue1402            else:1403                (key, val) = line.split()1404                self.Meadow_WT_Y[(key)] = val1405    # Convert strings to floats as necessary1406    self.Meadow_WT_Y['A1_above']    = float(self.Meadow_WT_Y['A1_above'])1407    self.Meadow_WT_Y['A2_above']    = float(self.Meadow_WT_Y['A2_above'])1408    self.Meadow_WT_Y['x0_above']    = float(self.Meadow_WT_Y['x0_above'])1409    self.Meadow_WT_Y['dx_above']    = float(self.Meadow_WT_Y['dx_above'])1410    self.Meadow_WT_Y['A1_below']    = float(self.Meadow_WT_Y['A1_below'])1411    self.Meadow_WT_Y['A2_below']    = float(self.Meadow_WT_Y['A2_below'])1412    self.Meadow_WT_Y['x0_below']    = float(self.Meadow_WT_Y['x0_below'])1413    self.Meadow_WT_Y['dx_below']    = float(self.Meadow_WT_Y['dx_below'])1414    self.Meadow_WT_Y['a_above']     = float(self.Meadow_WT_Y['a_above'])1415    self.Meadow_WT_Y['b_above']     = float(self.Meadow_WT_Y['b_above'])1416    self.Meadow_WT_Y['a_below']     = float(self.Meadow_WT_Y['a_below'])1417    self.Meadow_WT_Y['b_below']     = float(self.Meadow_WT_Y['b_below'])1418    self.Meadow_WT_Y['K_above']     = float(self.Meadow_WT_Y['K_above'])1419    self.Meadow_WT_Y['C_above']     = float(self.Meadow_WT_Y['C_above'])1420    self.Meadow_WT_Y['A_above']     = float(self.Meadow_WT_Y['A_above'])1421    self.Meadow_WT_Y['B_above']     = float(self.Meadow_WT_Y['B_above'])1422    self.Meadow_WT_Y['K_below']     = float(self.Meadow_WT_Y['K_below'])1423    self.Meadow_WT_Y['C_below']     = float(self.Meadow_WT_Y['C_below'])1424    self.Meadow_WT_Y['A_below']     = float(self.Meadow_WT_Y['A_below'])1425    self.Meadow_WT_Y['B_below']     = float(self.Meadow_WT_Y['B_below'])1426    self.Meadow_WT_Y['HillB_above'] = float(self.Meadow_WT_Y['HillB_above'])1427    self.Meadow_WT_Y['HillN_above'] = float(self.Meadow_WT_Y['HillN_above'])1428    self.Meadow_WT_Y['HillB_below'] = float(self.Meadow_WT_Y['HillB_below'])1429    self.Meadow_WT_Y['HillN_below'] = float(self.Meadow_WT_Y['HillN_below'])1430    self.Meadow_WT_Y['max_terrain_transition'] = \1431      float(self.Meadow_WT_Y['max_terrain_transition'])1432    self.Meadow_WT_Y['ice_slope_poor']    = float(self.Meadow_WT_Y['ice_slope_poor'])1433    self.Meadow_WT_Y['ice_slope_pore']    = float(self.Meadow_WT_Y['ice_slope_pore'])1434    self.Meadow_WT_Y['ice_slope_wedge']   = float(self.Meadow_WT_Y['ice_slope_wedge'])1435    self.Meadow_WT_Y['ice_slope_massive'] = float(self.Meadow_WT_Y['ice_slope_massive'])1436    self.Meadow_WT_Y['porosity'] = float(self.Meadow_WT_Y['porosity'])    1437    # - - - - - - - - - - - - - - - - - - - - - - - - -1438    # Reading Medium Age Parameters from Control file1439    # - - - - - - - - - - - - - - - - - - - - - - - - -1440    print '      .. Medium age parameters'1441    1442    self.Meadow_WT_M = {}1443    with open(self.Meadow_WT_M_Control, 'r') as f:1444        for line in f:1445            if line.startswith('#'):1446                continue1447            else:1448                (key, val) = line.split()1449                self.Meadow_WT_M[(key)] = val1450    # Convert strings to floats as necessary1451    self.Meadow_WT_M['A1_above']    = float(self.Meadow_WT_M['A1_above'])1452    self.Meadow_WT_M['A2_above']    = float(self.Meadow_WT_M['A2_above'])1453    self.Meadow_WT_M['x0_above']    = float(self.Meadow_WT_M['x0_above'])1454    self.Meadow_WT_M['dx_above']    = float(self.Meadow_WT_M['dx_above'])1455    self.Meadow_WT_M['A1_below']    = float(self.Meadow_WT_M['A1_below'])1456    self.Meadow_WT_M['A2_below']    = float(self.Meadow_WT_M['A2_below'])1457    self.Meadow_WT_M['x0_below']    = float(self.Meadow_WT_M['x0_below'])1458    self.Meadow_WT_M['dx_below']    = float(self.Meadow_WT_M['dx_below'])1459    self.Meadow_WT_M['a_above']     = float(self.Meadow_WT_M['a_above'])1460    self.Meadow_WT_M['b_above']     = float(self.Meadow_WT_M['b_above'])1461    self.Meadow_WT_M['a_below']     = float(self.Meadow_WT_M['a_below'])1462    self.Meadow_WT_M['b_below']     = float(self.Meadow_WT_M['b_below'])1463    self.Meadow_WT_M['K_above']     = float(self.Meadow_WT_M['K_above'])1464    self.Meadow_WT_M['C_above']     = float(self.Meadow_WT_M['C_above'])1465    self.Meadow_WT_M['A_above']     = float(self.Meadow_WT_M['A_above'])1466    self.Meadow_WT_M['B_above']     = float(self.Meadow_WT_M['B_above'])1467    self.Meadow_WT_M['K_below']     = float(self.Meadow_WT_M['K_below'])1468    self.Meadow_WT_M['C_below']     = float(self.Meadow_WT_M['C_below'])1469    self.Meadow_WT_M['A_below']     = float(self.Meadow_WT_M['A_below'])1470    self.Meadow_WT_M['B_below']     = float(self.Meadow_WT_M['B_below'])1471    self.Meadow_WT_M['HillB_above'] = float(self.Meadow_WT_M['HillB_above'])1472    self.Meadow_WT_M['HillN_above'] = float(self.Meadow_WT_M['HillN_above'])1473    self.Meadow_WT_M['HillB_below'] = float(self.Meadow_WT_M['HillB_below'])1474    self.Meadow_WT_M['HillN_below'] = float(self.Meadow_WT_M['HillN_below'])1475    self.Meadow_WT_M['max_terrain_transition'] = \1476      float(self.Meadow_WT_M['max_terrain_transition'])1477    self.Meadow_WT_M['ice_slope_poor']    = float(self.Meadow_WT_M['ice_slope_poor'])1478    self.Meadow_WT_M['ice_slope_pore']    = float(self.Meadow_WT_M['ice_slope_pore'])1479    self.Meadow_WT_M['ice_slope_wedge']   = float(self.Meadow_WT_M['ice_slope_wedge'])1480    self.Meadow_WT_M['ice_slope_massive'] = float(self.Meadow_WT_M['ice_slope_massive'])1481    self.Meadow_WT_M['porosity'] = float(self.Meadow_WT_M['porosity'])    1482    # - - - - - - - - - - - - - - - - - - - - - - - - -1483    # Reading Old Age Parameters from Control file1484    # - - - - - - - - - - - - - - - - - - - - - - - - -1485    print '      .. Old age parameters'1486    1487    self.Meadow_WT_O = {}1488    with open(self.Meadow_WT_O_Control, 'r') as f:1489        for line in f:1490            if line.startswith('#'):1491                continue1492            else:1493                (key, val) = line.split()1494                self.Meadow_WT_O[(key)] = val1495    # Convert strings to floats as necessary1496    self.Meadow_WT_O['A1_above']    = float(self.Meadow_WT_O['A1_above'])1497    self.Meadow_WT_O['A2_above']    = float(self.Meadow_WT_O['A2_above'])1498    self.Meadow_WT_O['x0_above']    = float(self.Meadow_WT_O['x0_above'])1499    self.Meadow_WT_O['dx_above']    = float(self.Meadow_WT_O['dx_above'])1500    self.Meadow_WT_O['A1_below']    = float(self.Meadow_WT_O['A1_below'])1501    self.Meadow_WT_O['A2_below']    = float(self.Meadow_WT_O['A2_below'])1502    self.Meadow_WT_O['x0_below']    = float(self.Meadow_WT_O['x0_below'])1503    self.Meadow_WT_O['dx_below']    = float(self.Meadow_WT_O['dx_below'])1504    self.Meadow_WT_O['a_above']     = float(self.Meadow_WT_O['a_above'])1505    self.Meadow_WT_O['b_above']     = float(self.Meadow_WT_O['b_above'])1506    self.Meadow_WT_O['a_below']     = float(self.Meadow_WT_O['a_below'])1507    self.Meadow_WT_O['b_below']     = float(self.Meadow_WT_O['b_below'])1508    self.Meadow_WT_O['K_above']     = float(self.Meadow_WT_O['K_above'])1509    self.Meadow_WT_O['C_above']     = float(self.Meadow_WT_O['C_above'])1510    self.Meadow_WT_O['A_above']     = float(self.Meadow_WT_O['A_above'])1511    self.Meadow_WT_O['B_above']     = float(self.Meadow_WT_O['B_above'])1512    self.Meadow_WT_O['K_below']     = float(self.Meadow_WT_O['K_below'])1513    self.Meadow_WT_O['C_below']     = float(self.Meadow_WT_O['C_below'])1514    self.Meadow_WT_O['A_below']     = float(self.Meadow_WT_O['A_below'])1515    self.Meadow_WT_O['B_below']     = float(self.Meadow_WT_O['B_below'])1516    self.Meadow_WT_O['HillB_above'] = float(self.Meadow_WT_O['HillB_above'])1517    self.Meadow_WT_O['HillN_above'] = float(self.Meadow_WT_O['HillN_above'])1518    self.Meadow_WT_O['HillB_below'] = float(self.Meadow_WT_O['HillB_below'])1519    self.Meadow_WT_O['HillN_below'] = float(self.Meadow_WT_O['HillN_below'])1520    self.Meadow_WT_O['max_terrain_transition'] = \1521      float(self.Meadow_WT_O['max_terrain_transition'])1522    self.Meadow_WT_O['ice_slope_poor']    = float(self.Meadow_WT_O['ice_slope_poor'])1523    self.Meadow_WT_O['ice_slope_pore']    = float(self.Meadow_WT_O['ice_slope_pore'])1524    self.Meadow_WT_O['ice_slope_wedge']   = float(self.Meadow_WT_O['ice_slope_wedge'])1525    self.Meadow_WT_O['ice_slope_massive'] = float(self.Meadow_WT_O['ice_slope_massive'])1526    self.Meadow_WT_O['porosity'] = float(self.Meadow_WT_O['porosity'])    1527#====================================================================================1528def NoData_WT(self):1529    1530    print '    ..Reading Wetland Tundra No Data Parameters'1531    """ Read files from the input directory """1532    if self.Simulation_area.lower() == 'barrow':1533        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\1534                 self.Control_directory)1535    elif self.Simulation_area.lower() == 'arctic_coast':1536        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic/'+\1537                 self.Control_directory)1538    elif self.Simulation_area.lower() == 'tanana':1539        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\1540                 self.Control_directory)1541    elif self.Simulation_area.lower() == 'yukon':1542        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\1543                 self.Control_directory)1544    elif self.Simulation_area.lower() == 'aiem':1545        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM/'+\1546                 self.Control_directory)1547    elif self.Simulation_area.lower() == 'ngee':1548        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE/'+\1549                 self.Control_directory)1550    # - - - - - - - - - - - - - - - - - - - - - - - - -1551    # Reading Old Age Parameters from Control file1552    # - - - - - - - - - - - - - - - - - - - - - - - - -1553    self.NoData_WT_O = {}1554    with open(self.NoData_WT_O_Control, 'r') as f:1555        for line in f:1556            if line.startswith('#'):1557                continue1558            else:1559                (key, val) = line.split()1560                self.NoData_WT_O[(key)] = val1561    # Convert strings to floats as necessary1562    self.NoData_WT_O['A1_above']    = float(self.NoData_WT_O['A1_above'])1563    self.NoData_WT_O['A2_above']    = float(self.NoData_WT_O['A2_above'])1564    self.NoData_WT_O['x0_above']    = float(self.NoData_WT_O['x0_above'])1565    self.NoData_WT_O['dx_above']    = float(self.NoData_WT_O['dx_above'])1566    self.NoData_WT_O['A1_below']    = float(self.NoData_WT_O['A1_below'])1567    self.NoData_WT_O['A2_below']    = float(self.NoData_WT_O['A2_below'])1568    self.NoData_WT_O['x0_below']    = float(self.NoData_WT_O['x0_below'])1569    self.NoData_WT_O['dx_below']    = float(self.NoData_WT_O['dx_below'])1570    self.NoData_WT_O['a_above']     = float(self.NoData_WT_O['a_above'])1571    self.NoData_WT_O['b_above']     = float(self.NoData_WT_O['b_above'])1572    self.NoData_WT_O['a_below']     = float(self.NoData_WT_O['a_below'])1573    self.NoData_WT_O['b_below']     = float(self.NoData_WT_O['b_below'])1574    self.NoData_WT_O['K_above']     = float(self.NoData_WT_O['K_above'])1575    self.NoData_WT_O['C_above']     = float(self.NoData_WT_O['C_above'])1576    self.NoData_WT_O['A_above']     = float(self.NoData_WT_O['A_above'])1577    self.NoData_WT_O['B_above']     = float(self.NoData_WT_O['B_above'])1578    self.NoData_WT_O['K_below']     = float(self.NoData_WT_O['K_below'])1579    self.NoData_WT_O['C_below']     = float(self.NoData_WT_O['C_below'])1580    self.NoData_WT_O['A_below']     = float(self.NoData_WT_O['A_below'])1581    self.NoData_WT_O['B_below']     = float(self.NoData_WT_O['B_below'])1582    self.NoData_WT_O['HillB_above'] = float(self.NoData_WT_O['HillB_above'])1583    self.NoData_WT_O['HillN_above'] = float(self.NoData_WT_O['HillN_above'])1584    self.NoData_WT_O['HillB_below'] = float(self.NoData_WT_O['HillB_below'])1585    self.NoData_WT_O['HillN_below'] = float(self.NoData_WT_O['HillN_below'])1586    self.NoData_WT_O['max_terrain_transition'] = \1587      float(self.NoData_WT_O['max_terrain_transition'])1588    self.NoData_WT_O['ice_slope_poor']    = float(self.NoData_WT_O['ice_slope_poor'])1589    self.NoData_WT_O['ice_slope_pore']    = float(self.NoData_WT_O['ice_slope_pore'])1590    self.NoData_WT_O['ice_slope_wedge']   = float(self.NoData_WT_O['ice_slope_wedge'])1591    self.NoData_WT_O['ice_slope_massive'] = float(self.NoData_WT_O['ice_slope_massive'])1592    self.NoData_WT_O['porosity'] = float(self.NoData_WT_O['porosity'])1593#====================================================================================1594def SandDunes_WT(self):1595    1596    print '    ..Reading Wetland Tundra Sand Dune Parameters'1597    """ Read files from the input directory """1598    if self.Simulation_area.lower() == 'barrow':1599        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\1600                 self.Control_directory)1601    elif self.Simulation_area.lower() == 'arctic_coast':1602        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic/'+\1603                 self.Control_directory)1604    elif self.Simulation_area.lower() == 'tanana':1605        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\1606                 self.Control_directory)1607    elif self.Simulation_area.lower() == 'yukon':1608        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\1609                 self.Control_directory)1610    elif self.Simulation_area.lower() == 'aiem':1611        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM/'+\1612                 self.Control_directory)1613    elif self.Simulation_area.lower() == 'ngee':1614        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE/'+\1615                 self.Control_directory)1616    # - - - - - - - - - - - - - - - - - - - - - - - - -1617    # Reading Young Age Parameters from Control file1618    # - - - - - - - - - - - - - - - - - - - - - - - - -1619    print '      .. Young age parameters'1620    1621    self.SandDunes_WT_Y = {}1622    with open(self.SandDunes_WT_Y_Control, 'r') as f:1623        for line in f:1624            if line.startswith('#'):1625                continue1626            else:1627                (key, val) = line.split()1628                self.SandDunes_WT_Y[(key)] = val1629    # Convert strings to floats as necessary1630    self.SandDunes_WT_Y['A1_above']    = float(self.SandDunes_WT_Y['A1_above'])1631    self.SandDunes_WT_Y['A2_above']    = float(self.SandDunes_WT_Y['A2_above'])1632    self.SandDunes_WT_Y['x0_above']    = float(self.SandDunes_WT_Y['x0_above'])1633    self.SandDunes_WT_Y['dx_above']    = float(self.SandDunes_WT_Y['dx_above'])1634    self.SandDunes_WT_Y['A1_below']    = float(self.SandDunes_WT_Y['A1_below'])1635    self.SandDunes_WT_Y['A2_below']    = float(self.SandDunes_WT_Y['A2_below'])1636    self.SandDunes_WT_Y['x0_below']    = float(self.SandDunes_WT_Y['x0_below'])1637    self.SandDunes_WT_Y['dx_below']    = float(self.SandDunes_WT_Y['dx_below'])1638    self.SandDunes_WT_Y['a_above']     = float(self.SandDunes_WT_Y['a_above'])1639    self.SandDunes_WT_Y['b_above']     = float(self.SandDunes_WT_Y['b_above'])1640    self.SandDunes_WT_Y['a_below']     = float(self.SandDunes_WT_Y['a_below'])1641    self.SandDunes_WT_Y['b_below']     = float(self.SandDunes_WT_Y['b_below'])1642    self.SandDunes_WT_Y['K_above']     = float(self.SandDunes_WT_Y['K_above'])1643    self.SandDunes_WT_Y['C_above']     = float(self.SandDunes_WT_Y['C_above'])1644    self.SandDunes_WT_Y['A_above']     = float(self.SandDunes_WT_Y['A_above'])1645    self.SandDunes_WT_Y['B_above']     = float(self.SandDunes_WT_Y['B_above'])1646    self.SandDunes_WT_Y['K_below']     = float(self.SandDunes_WT_Y['K_below'])1647    self.SandDunes_WT_Y['C_below']     = float(self.SandDunes_WT_Y['C_below'])1648    self.SandDunes_WT_Y['A_below']     = float(self.SandDunes_WT_Y['A_below'])1649    self.SandDunes_WT_Y['B_below']     = float(self.SandDunes_WT_Y['B_below'])1650    self.SandDunes_WT_Y['HillB_above'] = float(self.SandDunes_WT_Y['HillB_above'])1651    self.SandDunes_WT_Y['HillN_above'] = float(self.SandDunes_WT_Y['HillN_above'])1652    self.SandDunes_WT_Y['HillB_below'] = float(self.SandDunes_WT_Y['HillB_below'])1653    self.SandDunes_WT_Y['HillN_below'] = float(self.SandDunes_WT_Y['HillN_below'])1654    self.SandDunes_WT_Y['max_terrain_transition'] = \1655      float(self.SandDunes_WT_Y['max_terrain_transition'])1656    self.SandDunes_WT_Y['ice_slope_poor']    = float(self.SandDunes_WT_Y['ice_slope_poor'])1657    self.SandDunes_WT_Y['ice_slope_pore']    = float(self.SandDunes_WT_Y['ice_slope_pore'])1658    self.SandDunes_WT_Y['ice_slope_wedge']   = float(self.SandDunes_WT_Y['ice_slope_wedge'])1659    self.SandDunes_WT_Y['ice_slope_massive'] = float(self.SandDunes_WT_Y['ice_slope_massive'])1660    self.SandDunes_WT_Y['porosity'] = float(self.SandDunes_WT_Y['porosity'])    1661    # - - - - - - - - - - - - - - - - - - - - - - - - -1662    # Reading Medium Age Parameters from Control file1663    # - - - - - - - - - - - - - - - - - - - - - - - - -1664    print '      .. Medium age parameters'1665    1666    self.SandDunes_WT_M = {}1667    with open(self.SandDunes_WT_M_Control, 'r') as f:1668        for line in f:1669            if line.startswith('#'):1670                continue1671            else:1672                (key, val) = line.split()1673                self.SandDunes_WT_M[(key)] = val1674    # Convert strings to floats as necessary1675    self.SandDunes_WT_M['A1_above']    = float(self.SandDunes_WT_M['A1_above'])1676    self.SandDunes_WT_M['A2_above']    = float(self.SandDunes_WT_M['A2_above'])1677    self.SandDunes_WT_M['x0_above']    = float(self.SandDunes_WT_M['x0_above'])1678    self.SandDunes_WT_M['dx_above']    = float(self.SandDunes_WT_M['dx_above'])1679    self.SandDunes_WT_M['A1_below']    = float(self.SandDunes_WT_M['A1_below'])1680    self.SandDunes_WT_M['A2_below']    = float(self.SandDunes_WT_M['A2_below'])1681    self.SandDunes_WT_M['x0_below']    = float(self.SandDunes_WT_M['x0_below'])1682    self.SandDunes_WT_M['dx_below']    = float(self.SandDunes_WT_M['dx_below'])1683    self.SandDunes_WT_M['a_above']     = float(self.SandDunes_WT_M['a_above'])1684    self.SandDunes_WT_M['b_above']     = float(self.SandDunes_WT_M['b_above'])1685    self.SandDunes_WT_M['a_below']     = float(self.SandDunes_WT_M['a_below'])1686    self.SandDunes_WT_M['b_below']     = float(self.SandDunes_WT_M['b_below'])1687    self.SandDunes_WT_M['K_above']     = float(self.SandDunes_WT_M['K_above'])1688    self.SandDunes_WT_M['C_above']     = float(self.SandDunes_WT_M['C_above'])1689    self.SandDunes_WT_M['A_above']     = float(self.SandDunes_WT_M['A_above'])1690    self.SandDunes_WT_M['B_above']     = float(self.SandDunes_WT_M['B_above'])1691    self.SandDunes_WT_M['K_below']     = float(self.SandDunes_WT_M['K_below'])1692    self.SandDunes_WT_M['C_below']     = float(self.SandDunes_WT_M['C_below'])1693    self.SandDunes_WT_M['A_below']     = float(self.SandDunes_WT_M['A_below'])1694    self.SandDunes_WT_M['B_below']     = float(self.SandDunes_WT_M['B_below'])1695    self.SandDunes_WT_M['HillB_above'] = float(self.SandDunes_WT_M['HillB_above'])1696    self.SandDunes_WT_M['HillN_above'] = float(self.SandDunes_WT_M['HillN_above'])1697    self.SandDunes_WT_M['HillB_below'] = float(self.SandDunes_WT_M['HillB_below'])1698    self.SandDunes_WT_M['HillN_below'] = float(self.SandDunes_WT_M['HillN_below'])1699    self.SandDunes_WT_M['max_terrain_transition'] = \1700      float(self.SandDunes_WT_M['max_terrain_transition'])1701    self.SandDunes_WT_M['ice_slope_poor']    = float(self.SandDunes_WT_M['ice_slope_poor'])1702    self.SandDunes_WT_M['ice_slope_pore']    = float(self.SandDunes_WT_M['ice_slope_pore'])1703    self.SandDunes_WT_M['ice_slope_wedge']   = float(self.SandDunes_WT_M['ice_slope_wedge'])1704    self.SandDunes_WT_M['ice_slope_massive'] = float(self.SandDunes_WT_M['ice_slope_massive'])1705    self.SandDunes_WT_M['porosity'] = float(self.SandDunes_WT_M['porosity'])    1706    # - - - - - - - - - - - - - - - - - - - - - - - - -1707    # Reading Old Age Parameters from Control file1708    # - - - - - - - - - - - - - - - - - - - - - - - - -1709    print '      .. Old age parameters'1710    1711    self.SandDunes_WT_O = {}1712    with open(self.SandDunes_WT_O_Control, 'r') as f:1713        for line in f:1714            if line.startswith('#'):1715                continue1716            else:1717                (key, val) = line.split()1718                self.SandDunes_WT_O[(key)] = val1719    # Convert strings to floats as necessary1720    self.SandDunes_WT_O['A1_above']    = float(self.SandDunes_WT_O['A1_above'])1721    self.SandDunes_WT_O['A2_above']    = float(self.SandDunes_WT_O['A2_above'])1722    self.SandDunes_WT_O['x0_above']    = float(self.SandDunes_WT_O['x0_above'])1723    self.SandDunes_WT_O['dx_above']    = float(self.SandDunes_WT_O['dx_above'])1724    self.SandDunes_WT_O['A1_below']    = float(self.SandDunes_WT_O['A1_below'])1725    self.SandDunes_WT_O['A2_below']    = float(self.SandDunes_WT_O['A2_below'])1726    self.SandDunes_WT_O['x0_below']    = float(self.SandDunes_WT_O['x0_below'])1727    self.SandDunes_WT_O['dx_below']    = float(self.SandDunes_WT_O['dx_below'])1728    self.SandDunes_WT_O['a_above']     = float(self.SandDunes_WT_O['a_above'])1729    self.SandDunes_WT_O['b_above']     = float(self.SandDunes_WT_O['b_above'])1730    self.SandDunes_WT_O['a_below']     = float(self.SandDunes_WT_O['a_below'])1731    self.SandDunes_WT_O['b_below']     = float(self.SandDunes_WT_O['b_below'])1732    self.SandDunes_WT_O['K_above']     = float(self.SandDunes_WT_O['K_above'])1733    self.SandDunes_WT_O['C_above']     = float(self.SandDunes_WT_O['C_above'])1734    self.SandDunes_WT_O['A_above']     = float(self.SandDunes_WT_O['A_above'])1735    self.SandDunes_WT_O['B_above']     = float(self.SandDunes_WT_O['B_above'])1736    self.SandDunes_WT_O['K_below']     = float(self.SandDunes_WT_O['K_below'])1737    self.SandDunes_WT_O['C_below']     = float(self.SandDunes_WT_O['C_below'])1738    self.SandDunes_WT_O['A_below']     = float(self.SandDunes_WT_O['A_below'])1739    self.SandDunes_WT_O['B_below']     = float(self.SandDunes_WT_O['B_below'])1740    self.SandDunes_WT_O['HillB_above'] = float(self.SandDunes_WT_O['HillB_above'])1741    self.SandDunes_WT_O['HillN_above'] = float(self.SandDunes_WT_O['HillN_above'])1742    self.SandDunes_WT_O['HillB_below'] = float(self.SandDunes_WT_O['HillB_below'])1743    self.SandDunes_WT_O['HillN_below'] = float(self.SandDunes_WT_O['HillN_below'])1744    self.SandDunes_WT_O['max_terrain_transition'] = \1745      float(self.SandDunes_WT_O['max_terrain_transition'])1746    self.SandDunes_WT_O['ice_slope_poor']    = float(self.SandDunes_WT_O['ice_slope_poor'])1747    self.SandDunes_WT_O['ice_slope_pore']    = float(self.SandDunes_WT_O['ice_slope_pore'])1748    self.SandDunes_WT_O['ice_slope_wedge']   = float(self.SandDunes_WT_O['ice_slope_wedge'])1749    self.SandDunes_WT_O['ice_slope_massive'] = float(self.SandDunes_WT_O['ice_slope_massive'])1750    self.SandDunes_WT_O['porosity'] = float(self.SandDunes_WT_O['porosity'])    1751    1752#====================================================================================1753def SaturatedBarrens_WT(self):1754    1755    print '    ..Reading Wetland Tundra Saturated Barren Parameters'1756    """ Read files from the input directory """1757    if self.Simulation_area.lower() == 'barrow':1758        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\1759                 self.Control_directory)1760    elif self.Simulation_area.lower() == 'arctic_coast':1761        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic/'+\1762                 self.Control_directory)1763    elif self.Simulation_area.lower() == 'tanana':1764        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\1765                 self.Control_directory)1766    elif self.Simulation_area.lower() == 'yukon':1767        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\1768                 self.Control_directory)1769    elif self.Simulation_area.lower() == 'aiem':1770        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM/'+\1771                 self.Control_directory)1772    elif self.Simulation_area.lower() == 'ngee':1773        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE/'+\1774                 self.Control_directory)1775    # - - - - - - - - - - - - - - - - - - - - - - - - -1776    # Reading Young Age Parameters from Control file1777    # - - - - - - - - - - - - - - - - - - - - - - - - -1778    print '      .. Young age parameters'1779    1780    self.SaturatedBarrens_WT_Y = {}1781    with open(self.SaturatedBarrens_WT_Y_Control, 'r') as f:1782        for line in f:1783            if line.startswith('#'):1784                continue1785            else:1786                (key, val) = line.split()1787                self.SaturatedBarrens_WT_Y[(key)] = val1788    # Convert strings to floats as necessary1789    self.SaturatedBarrens_WT_Y['A1_above']    = float(self.SaturatedBarrens_WT_Y['A1_above'])1790    self.SaturatedBarrens_WT_Y['A2_above']    = float(self.SaturatedBarrens_WT_Y['A2_above'])1791    self.SaturatedBarrens_WT_Y['x0_above']    = float(self.SaturatedBarrens_WT_Y['x0_above'])1792    self.SaturatedBarrens_WT_Y['dx_above']    = float(self.SaturatedBarrens_WT_Y['dx_above'])1793    self.SaturatedBarrens_WT_Y['A1_below']    = float(self.SaturatedBarrens_WT_Y['A1_below'])1794    self.SaturatedBarrens_WT_Y['A2_below']    = float(self.SaturatedBarrens_WT_Y['A2_below'])1795    self.SaturatedBarrens_WT_Y['x0_below']    = float(self.SaturatedBarrens_WT_Y['x0_below'])1796    self.SaturatedBarrens_WT_Y['dx_below']    = float(self.SaturatedBarrens_WT_Y['dx_below'])1797    self.SaturatedBarrens_WT_Y['a_above']     = float(self.SaturatedBarrens_WT_Y['a_above'])1798    self.SaturatedBarrens_WT_Y['b_above']     = float(self.SaturatedBarrens_WT_Y['b_above'])1799    self.SaturatedBarrens_WT_Y['a_below']     = float(self.SaturatedBarrens_WT_Y['a_below'])1800    self.SaturatedBarrens_WT_Y['b_below']     = float(self.SaturatedBarrens_WT_Y['b_below'])1801    self.SaturatedBarrens_WT_Y['K_above']     = float(self.SaturatedBarrens_WT_Y['K_above'])1802    self.SaturatedBarrens_WT_Y['C_above']     = float(self.SaturatedBarrens_WT_Y['C_above'])1803    self.SaturatedBarrens_WT_Y['A_above']     = float(self.SaturatedBarrens_WT_Y['A_above'])1804    self.SaturatedBarrens_WT_Y['B_above']     = float(self.SaturatedBarrens_WT_Y['B_above'])1805    self.SaturatedBarrens_WT_Y['K_below']     = float(self.SaturatedBarrens_WT_Y['K_below'])1806    self.SaturatedBarrens_WT_Y['C_below']     = float(self.SaturatedBarrens_WT_Y['C_below'])1807    self.SaturatedBarrens_WT_Y['A_below']     = float(self.SaturatedBarrens_WT_Y['A_below'])1808    self.SaturatedBarrens_WT_Y['B_below']     = float(self.SaturatedBarrens_WT_Y['B_below'])1809    self.SaturatedBarrens_WT_Y['HillB_above'] = float(self.SaturatedBarrens_WT_Y['HillB_above'])1810    self.SaturatedBarrens_WT_Y['HillN_above'] = float(self.SaturatedBarrens_WT_Y['HillN_above'])1811    self.SaturatedBarrens_WT_Y['HillB_below'] = float(self.SaturatedBarrens_WT_Y['HillB_below'])1812    self.SaturatedBarrens_WT_Y['HillN_below'] = float(self.SaturatedBarrens_WT_Y['HillN_below'])1813    self.SaturatedBarrens_WT_Y['max_terrain_transition'] = \1814      float(self.SaturatedBarrens_WT_Y['max_terrain_transition'])1815    self.SaturatedBarrens_WT_Y['ice_slope_poor']    = float(self.SaturatedBarrens_WT_Y['ice_slope_poor'])1816    self.SaturatedBarrens_WT_Y['ice_slope_pore']    = float(self.SaturatedBarrens_WT_Y['ice_slope_pore'])1817    self.SaturatedBarrens_WT_Y['ice_slope_wedge']   = float(self.SaturatedBarrens_WT_Y['ice_slope_wedge'])1818    self.SaturatedBarrens_WT_Y['ice_slope_massive'] = float(self.SaturatedBarrens_WT_Y['ice_slope_massive'])1819    self.SaturatedBarrens_WT_Y['porosity'] = float(self.SaturatedBarrens_WT_Y['porosity'])    1820    # - - - - - - - - - - - - - - - - - - - - - - - - -1821    # Reading Medium Age Parameters from Control file1822    # - - - - - - - - - - - - - - - - - - - - - - - - -1823    print '      .. Medium age parameters'1824    1825    self.SaturatedBarrens_WT_M = {}1826    with open(self.SaturatedBarrens_WT_M_Control, 'r') as f:1827        for line in f:1828            if line.startswith('#'):1829                continue1830            else:1831                (key, val) = line.split()1832                self.SaturatedBarrens_WT_M[(key)] = val1833    # Convert strings to floats as necessary1834    self.SaturatedBarrens_WT_M['A1_above']    = float(self.SaturatedBarrens_WT_M['A1_above'])1835    self.SaturatedBarrens_WT_M['A2_above']    = float(self.SaturatedBarrens_WT_M['A2_above'])1836    self.SaturatedBarrens_WT_M['x0_above']    = float(self.SaturatedBarrens_WT_M['x0_above'])1837    self.SaturatedBarrens_WT_M['dx_above']    = float(self.SaturatedBarrens_WT_M['dx_above'])1838    self.SaturatedBarrens_WT_M['A1_below']    = float(self.SaturatedBarrens_WT_M['A1_below'])1839    self.SaturatedBarrens_WT_M['A2_below']    = float(self.SaturatedBarrens_WT_M['A2_below'])1840    self.SaturatedBarrens_WT_M['x0_below']    = float(self.SaturatedBarrens_WT_M['x0_below'])1841    self.SaturatedBarrens_WT_M['dx_below']    = float(self.SaturatedBarrens_WT_M['dx_below'])1842    self.SaturatedBarrens_WT_M['a_above']     = float(self.SaturatedBarrens_WT_M['a_above'])1843    self.SaturatedBarrens_WT_M['b_above']     = float(self.SaturatedBarrens_WT_M['b_above'])1844    self.SaturatedBarrens_WT_M['a_below']     = float(self.SaturatedBarrens_WT_M['a_below'])1845    self.SaturatedBarrens_WT_M['b_below']     = float(self.SaturatedBarrens_WT_M['b_below'])1846    self.SaturatedBarrens_WT_M['K_above']     = float(self.SaturatedBarrens_WT_M['K_above'])1847    self.SaturatedBarrens_WT_M['C_above']     = float(self.SaturatedBarrens_WT_M['C_above'])1848    self.SaturatedBarrens_WT_M['A_above']     = float(self.SaturatedBarrens_WT_M['A_above'])1849    self.SaturatedBarrens_WT_M['B_above']     = float(self.SaturatedBarrens_WT_M['B_above'])1850    self.SaturatedBarrens_WT_M['K_below']     = float(self.SaturatedBarrens_WT_M['K_below'])1851    self.SaturatedBarrens_WT_M['C_below']     = float(self.SaturatedBarrens_WT_M['C_below'])1852    self.SaturatedBarrens_WT_M['A_below']     = float(self.SaturatedBarrens_WT_M['A_below'])1853    self.SaturatedBarrens_WT_M['B_below']     = float(self.SaturatedBarrens_WT_M['B_below'])1854    self.SaturatedBarrens_WT_M['HillB_above'] = float(self.SaturatedBarrens_WT_M['HillB_above'])1855    self.SaturatedBarrens_WT_M['HillN_above'] = float(self.SaturatedBarrens_WT_M['HillN_above'])1856    self.SaturatedBarrens_WT_M['HillB_below'] = float(self.SaturatedBarrens_WT_M['HillB_below'])1857    self.SaturatedBarrens_WT_M['HillN_below'] = float(self.SaturatedBarrens_WT_M['HillN_below'])1858    self.SaturatedBarrens_WT_M['max_terrain_transition'] = \1859      float(self.SaturatedBarrens_WT_M['max_terrain_transition'])1860    self.SaturatedBarrens_WT_M['ice_slope_poor']    = float(self.SaturatedBarrens_WT_M['ice_slope_poor'])1861    self.SaturatedBarrens_WT_M['ice_slope_pore']    = float(self.SaturatedBarrens_WT_M['ice_slope_pore'])1862    self.SaturatedBarrens_WT_M['ice_slope_wedge']   = float(self.SaturatedBarrens_WT_M['ice_slope_wedge'])1863    self.SaturatedBarrens_WT_M['ice_slope_massive'] = float(self.SaturatedBarrens_WT_M['ice_slope_massive'])1864    self.SaturatedBarrens_WT_M['porosity'] = float(self.SaturatedBarrens_WT_M['porosity'])    1865    # - - - - - - - - - - - - - - - - - - - - - - - - -1866    # Reading Old Age Parameters from Control file1867    # - - - - - - - - - - - - - - - - - - - - - - - - -1868    print '      .. Old age parameters'1869    1870    self.SaturatedBarrens_WT_O = {}1871    with open(self.SaturatedBarrens_WT_O_Control, 'r') as f:1872        for line in f:1873            if line.startswith('#'):1874                continue1875            else:1876                (key, val) = line.split()1877                self.SaturatedBarrens_WT_O[(key)] = val1878    # Convert strings to floats as necessary1879    self.SaturatedBarrens_WT_O['A1_above']    = float(self.SaturatedBarrens_WT_O['A1_above'])1880    self.SaturatedBarrens_WT_O['A2_above']    = float(self.SaturatedBarrens_WT_O['A2_above'])1881    self.SaturatedBarrens_WT_O['x0_above']    = float(self.SaturatedBarrens_WT_O['x0_above'])1882    self.SaturatedBarrens_WT_O['dx_above']    = float(self.SaturatedBarrens_WT_O['dx_above'])1883    self.SaturatedBarrens_WT_O['A1_below']    = float(self.SaturatedBarrens_WT_O['A1_below'])1884    self.SaturatedBarrens_WT_O['A2_below']    = float(self.SaturatedBarrens_WT_O['A2_below'])1885    self.SaturatedBarrens_WT_O['x0_below']    = float(self.SaturatedBarrens_WT_O['x0_below'])1886    self.SaturatedBarrens_WT_O['dx_below']    = float(self.SaturatedBarrens_WT_O['dx_below'])1887    self.SaturatedBarrens_WT_O['a_above']     = float(self.SaturatedBarrens_WT_O['a_above'])1888    self.SaturatedBarrens_WT_O['b_above']     = float(self.SaturatedBarrens_WT_O['b_above'])1889    self.SaturatedBarrens_WT_O['a_below']     = float(self.SaturatedBarrens_WT_O['a_below'])1890    self.SaturatedBarrens_WT_O['b_below']     = float(self.SaturatedBarrens_WT_O['b_below'])1891    self.SaturatedBarrens_WT_O['K_above']     = float(self.SaturatedBarrens_WT_O['K_above'])1892    self.SaturatedBarrens_WT_O['C_above']     = float(self.SaturatedBarrens_WT_O['C_above'])1893    self.SaturatedBarrens_WT_O['A_above']     = float(self.SaturatedBarrens_WT_O['A_above'])1894    self.SaturatedBarrens_WT_O['B_above']     = float(self.SaturatedBarrens_WT_O['B_above'])1895    self.SaturatedBarrens_WT_O['K_below']     = float(self.SaturatedBarrens_WT_O['K_below'])1896    self.SaturatedBarrens_WT_O['C_below']     = float(self.SaturatedBarrens_WT_O['C_below'])1897    self.SaturatedBarrens_WT_O['A_below']     = float(self.SaturatedBarrens_WT_O['A_below'])1898    self.SaturatedBarrens_WT_O['B_below']     = float(self.SaturatedBarrens_WT_O['B_below'])1899    self.SaturatedBarrens_WT_O['HillB_above'] = float(self.SaturatedBarrens_WT_O['HillB_above'])1900    self.SaturatedBarrens_WT_O['HillN_above'] = float(self.SaturatedBarrens_WT_O['HillN_above'])1901    self.SaturatedBarrens_WT_O['HillB_below'] = float(self.SaturatedBarrens_WT_O['HillB_below'])1902    self.SaturatedBarrens_WT_O['HillN_below'] = float(self.SaturatedBarrens_WT_O['HillN_below'])1903    self.SaturatedBarrens_WT_O['max_terrain_transition'] = \1904      float(self.SaturatedBarrens_WT_O['max_terrain_transition'])1905    self.SaturatedBarrens_WT_O['ice_slope_poor']    = float(self.SaturatedBarrens_WT_O['ice_slope_poor'])1906    self.SaturatedBarrens_WT_O['ice_slope_pore']    = float(self.SaturatedBarrens_WT_O['ice_slope_pore'])1907    self.SaturatedBarrens_WT_O['ice_slope_wedge']   = float(self.SaturatedBarrens_WT_O['ice_slope_wedge'])1908    self.SaturatedBarrens_WT_O['ice_slope_massive'] = float(self.SaturatedBarrens_WT_O['ice_slope_massive'])1909    self.SaturatedBarrens_WT_O['porosity'] = float(self.SaturatedBarrens_WT_O['porosity'])    1910    1911#====================================================================================1912def Shrubs_WT(self):1913    1914    print '    ..Reading Wetland Tundra Shrub Parameters'1915    """ Read files from the input directory """1916    if self.Simulation_area.lower() == 'barrow':1917        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+1918                 self.Control_directory)1919    elif self.Simulation_area.lower() == 'arctic_coast':1920        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic/'+\1921                 self.Control_directory)1922    elif self.Simulation_area.lower() == 'tanana':1923        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\1924                 self.Control_directory)1925    elif self.Simulation_area.lower() == 'yukon':1926        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\1927                 self.Control_directory)1928    elif self.Simulation_area.lower() == 'aiem':1929        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM/'+\1930                 self.Control_directory)1931    elif self.Simulation_area.lower() == 'ngee':1932        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE/'+\1933                 self.Control_directory)1934    # - - - - - - - - - - - - - - - - - - - - - - - - -1935    # Reading Old Age Parameters from Control file1936    # - - - - - - - - - - - - - - - - - - - - - - - - -1937    self.Shrubs_WT_O = {}1938    with open(self.Shrubs_WT_O_Control, 'r') as f:1939        for line in f:1940            if line.startswith('#'):1941                continue1942            else:1943                (key, val) = line.split()1944                self.Shrubs_WT_O[(key)] = val1945    # Convert strings to floats as necessary1946    self.Shrubs_WT_O['A1_above']    = float(self.Shrubs_WT_O['A1_above'])1947    self.Shrubs_WT_O['A2_above']    = float(self.Shrubs_WT_O['A2_above'])1948    self.Shrubs_WT_O['x0_above']    = float(self.Shrubs_WT_O['x0_above'])1949    self.Shrubs_WT_O['dx_above']    = float(self.Shrubs_WT_O['dx_above'])1950    self.Shrubs_WT_O['A1_below']    = float(self.Shrubs_WT_O['A1_below'])1951    self.Shrubs_WT_O['A2_below']    = float(self.Shrubs_WT_O['A2_below'])1952    self.Shrubs_WT_O['x0_below']    = float(self.Shrubs_WT_O['x0_below'])1953    self.Shrubs_WT_O['dx_below']    = float(self.Shrubs_WT_O['dx_below'])1954    self.Shrubs_WT_O['a_above']     = float(self.Shrubs_WT_O['a_above'])1955    self.Shrubs_WT_O['b_above']     = float(self.Shrubs_WT_O['b_above'])1956    self.Shrubs_WT_O['a_below']     = float(self.Shrubs_WT_O['a_below'])1957    self.Shrubs_WT_O['b_below']     = float(self.Shrubs_WT_O['b_below'])1958    self.Shrubs_WT_O['K_above']     = float(self.Shrubs_WT_O['K_above'])1959    self.Shrubs_WT_O['C_above']     = float(self.Shrubs_WT_O['C_above'])1960    self.Shrubs_WT_O['A_above']     = float(self.Shrubs_WT_O['A_above'])1961    self.Shrubs_WT_O['B_above']     = float(self.Shrubs_WT_O['B_above'])1962    self.Shrubs_WT_O['K_below']     = float(self.Shrubs_WT_O['K_below'])1963    self.Shrubs_WT_O['C_below']     = float(self.Shrubs_WT_O['C_below'])1964    self.Shrubs_WT_O['A_below']     = float(self.Shrubs_WT_O['A_below'])1965    self.Shrubs_WT_O['B_below']     = float(self.Shrubs_WT_O['B_below'])1966    self.Shrubs_WT_O['HillB_above'] = float(self.Shrubs_WT_O['HillB_above'])1967    self.Shrubs_WT_O['HillN_above'] = float(self.Shrubs_WT_O['HillN_above'])1968    self.Shrubs_WT_O['HillB_below'] = float(self.Shrubs_WT_O['HillB_below'])1969    self.Shrubs_WT_O['HillN_below'] = float(self.Shrubs_WT_O['HillN_below'])1970    self.Shrubs_WT_O['max_terrain_transition'] = \1971      float(self.Shrubs_WT_O['max_terrain_transition'])1972    self.Shrubs_WT_O['ice_slope_poor']    = float(self.Shrubs_WT_O['ice_slope_poor'])1973    self.Shrubs_WT_O['ice_slope_pore']    = float(self.Shrubs_WT_O['ice_slope_pore'])1974    self.Shrubs_WT_O['ice_slope_wedge']   = float(self.Shrubs_WT_O['ice_slope_wedge'])1975    self.Shrubs_WT_O['ice_slope_massive'] = float(self.Shrubs_WT_O['ice_slope_massive'])1976    self.Shrubs_WT_O['porosity'] = float(self.Shrubs_WT_O['porosity'])1977#====================================================================================1978def Urban_WT(self):1979    1980    print '    ..Reading Wetland Tundra Urban Parameters'1981    """ Read files from the input directory """1982    if self.Simulation_area.lower() == 'barrow':1983        os.chdir(self.control['Run_dir']+self.Input_directory+'/Barrow/'+\1984                 self.Control_directory)1985    elif self.Simulation_area.lower() == 'arctic_coast':1986        os.chdir(self.control['Run_dir']+self.Input_directory+'/Arctic/'+\1987                 self.Control_directory)1988    elif self.Simulation_area.lower() == 'tanana':1989        os.chdir(self.control['Run_dir']+self.Input_directory+'/Tanana/'+\1990                 self.Control_directory)1991    elif self.Simulation_area.lower() == 'yukon':1992        os.chdir(self.control['Run_dir']+self.Input_directory+'/Yukon/'+\1993                 self.Control_directory)1994    elif self.Simulation_area.lower() == 'aiem':1995        os.chdir(self.control['Run_dir']+self.Input_directory+'/AIEM/'+\1996                 self.Control_directory)1997    elif self.Simulation_area.lower() == 'ngee':1998        os.chdir(self.control['Run_dir']+self.Input_directory+'/NGEE/'+\1999                 self.Control_directory)2000    # - - - - - - - - - - - - - - - - - - - - - - - - -2001    # Reading Old Age Parameters from Control file2002    # - - - - - - - - - - - - - - - - - - - - - - - - -2003    self.Urban_WT = {}2004    with open(self.Urban_WT_Control, 'r') as f:2005        for line in f:2006            if line.startswith('#'):2007                continue2008            else:2009                (key, val) = line.split()2010                self.Urban_WT[(key)] = val2011    # Convert strings to floats as necessary2012    self.Urban_WT['A1_above']    = float(self.Urban_WT['A1_above'])2013    self.Urban_WT['A2_above']    = float(self.Urban_WT['A2_above'])2014    self.Urban_WT['x0_above']    = float(self.Urban_WT['x0_above'])2015    self.Urban_WT['dx_above']    = float(self.Urban_WT['dx_above'])2016    self.Urban_WT['A1_below']    = float(self.Urban_WT['A1_below'])2017    self.Urban_WT['A2_below']    = float(self.Urban_WT['A2_below'])2018    self.Urban_WT['x0_below']    = float(self.Urban_WT['x0_below'])2019    self.Urban_WT['dx_below']    = float(self.Urban_WT['dx_below'])2020    self.Urban_WT['a_above']     = float(self.Urban_WT['a_above'])2021    self.Urban_WT['b_above']     = float(self.Urban_WT['b_above'])2022    self.Urban_WT['a_below']     = float(self.Urban_WT['a_below'])2023    self.Urban_WT['b_below']     = float(self.Urban_WT['b_below'])2024    self.Urban_WT['K_above']     = float(self.Urban_WT['K_above'])2025    self.Urban_WT['C_above']     = float(self.Urban_WT['C_above'])2026    self.Urban_WT['A_above']     = float(self.Urban_WT['A_above'])2027    self.Urban_WT['B_above']     = float(self.Urban_WT['B_above'])2028    self.Urban_WT['K_below']     = float(self.Urban_WT['K_below'])2029    self.Urban_WT['C_below']     = float(self.Urban_WT['C_below'])2030    self.Urban_WT['A_below']     = float(self.Urban_WT['A_below'])2031    self.Urban_WT['B_below']     = float(self.Urban_WT['B_below'])2032    self.Urban_WT['HillB_above'] = float(self.Urban_WT['HillB_above'])2033    self.Urban_WT['HillN_above'] = float(self.Urban_WT['HillN_above'])2034    self.Urban_WT['HillB_below'] = float(self.Urban_WT['HillB_below'])2035    self.Urban_WT['HillN_below'] = float(self.Urban_WT['HillN_below'])2036    self.Urban_WT['max_terrain_transition'] = \2037      float(self.Urban_WT['max_terrain_transition'])2038    self.Urban_WT['ice_slope_poor']    = float(self.Urban_WT['ice_slope_poor'])2039    self.Urban_WT['ice_slope_pore']    = float(self.Urban_WT['ice_slope_pore'])2040    self.Urban_WT['ice_slope_wedge']   = float(self.Urban_WT['ice_slope_wedge'])2041    self.Urban_WT['ice_slope_massive'] = float(self.Urban_WT['ice_slope_massive'])...__init__.py
Source:__init__.py  
1# -*- coding: utf-8 -*-2# -----------------------------------------------------------------------------3# (C) British Crown copyright. The Met Office.4# All rights reserved.5#6# Redistribution and use in source and binary forms, with or without7# modification, are permitted provided that the following conditions are met:8#9# * Redistributions of source code must retain the above copyright notice, this10#   list of conditions and the following disclaimer.11#12# * Redistributions in binary form must reproduce the above copyright notice,13#   this list of conditions and the following disclaimer in the documentation14#   and/or other materials provided with the distribution.15#16# * Neither the name of the copyright holder nor the names of its17#   contributors may be used to endorse or promote products derived from18#   this software without specific prior written permission.19#20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"21# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE24# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR25# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF26# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS27# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN28# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)29# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE30# POSSIBILITY OF SUCH DAMAGE.31"""Utilities for Unit tests for Weather Symbols"""32import datetime33from typing import Any, Dict34import numpy as np35from improver.synthetic_data.set_up_test_cubes import set_up_variable_cube36from improver.wxcode.utilities import weather_code_attributes37def set_up_wxcube(38    data=np.ones((16, 16), dtype=np.int8),39    time=datetime.datetime(2018, 9, 12, 5, 43),40    time_bounds=None,41    frt=datetime.datetime(2018, 9, 12, 3),42    lat_lon=False,43):44    """45    Set up a wxcube for a particular time and location, which can cover46    the terminator and test the "update_daynight" functionality47    Args:48        data (numpy array):49            The weather codes with which to populate the array.50        time (datetime.datetime):51            Validity time for cube.52        time_bounds ([datetime.datetime, datetime.datetime]):53            Validity time bounds.54        frt (datetime.datetime):55            Forecast reference time for cube.56        lat_lon (bool):57            If True, returns a cube on a lat-lon grid.58            If False, returns equal area.59    Returns:60        iris.cube.Cube:61            cube of weather codes set to 162            data shape (time_points, 16, 16)63    """64    kwargs = {65        "name": "weather_code",66        "units": 1,67        "time": time,68        "time_bounds": time_bounds,69        "frt": frt,70        "attributes": weather_code_attributes(),71        "spatial_grid": "equalarea",72        "domain_corner": (0, -30000),73    }74    if lat_lon:75        kwargs.update(76            {"spatial_grid": "latlon", "domain_corner": (49, -8), "grid_spacing": 1}77        )78    cube = set_up_variable_cube(data, **kwargs)79    return cube80def wxcode_decision_tree(accumulation: bool = False) -> Dict[str, Dict[str, Any]]:81    """82    Define an example decision tree to test the weather symbols code.83    Args:84        accumulation:85            A boolean that if true means the "heavy_precipitation" node86            should be modified to use a precipitation accumulation rather than87            a rate.88    Returns:89        A dictionary containing the queries that comprise the decision90        tree.91    """92    queries = {93        "lightning": {94            "if_true": "lightning_shower",95            "if_false": "hail",96            "if_diagnostic_missing": "if_false",97            "probability_thresholds": [0.3],98            "threshold_condition": ">=",99            "condition_combination": "",100            "diagnostic_fields": [101                "probability_of_number_of_lightning_flashes_per_unit_area_in_vicinity_above_threshold"  # noqa: E501102            ],103            "diagnostic_thresholds": [[0.0, "m-2"]],104            "diagnostic_conditions": ["above"],105        },106        "lightning_shower": {107            "if_true": 29,108            "if_false": 30,109            "probability_thresholds": [0.5],110            "threshold_condition": ">=",111            "condition_combination": "",112            "diagnostic_fields": ["probability_of_shower_condition_above_threshold"],113            "diagnostic_thresholds": [[1.0, 1]],114            "diagnostic_conditions": ["above"],115        },116        "hail": {117            "if_true": "hail_precip",118            "if_false": "heavy_precipitation",119            "if_diagnostic_missing": "if_false",120            "probability_thresholds": [0.5],121            "threshold_condition": ">=",122            "condition_combination": "",123            "diagnostic_fields": [124                "probability_of_lwe_graupel_and_hail_fall_rate_in_vicinity_above_threshold"125            ],126            "diagnostic_thresholds": [[0.0, "mm hr-1"]],127            "diagnostic_conditions": ["above"],128        },129        "hail_precip": {130            "if_true": "hail_shower",131            "if_false": "heavy_precipitation",132            "if_diagnostic_missing": "if_false",133            "probability_thresholds": [0.5],134            "threshold_condition": ">=",135            "condition_combination": "",136            "diagnostic_fields": [137                "probability_of_lwe_precipitation_rate_max_above_threshold"138            ],139            "diagnostic_thresholds": [[1.0, "mm hr-1"]],140            "diagnostic_conditions": ["above"],141        },142        "hail_shower": {143            "if_true": 20,144            "if_false": 21,145            "probability_thresholds": [0.5],146            "threshold_condition": ">=",147            "condition_combination": "",148            "diagnostic_fields": ["probability_of_shower_condition_above_threshold"],149            "diagnostic_thresholds": [[1.0, 1]],150            "diagnostic_conditions": ["above"],151        },152        "heavy_precipitation": {153            "if_true": "heavy_precipitation_cloud",154            "if_false": "precipitation_in_vicinity",155            "if_diagnostic_missing": "if_false",156            "probability_thresholds": [0.5],157            "threshold_condition": ">=",158            "condition_combination": "",159            "diagnostic_fields": [160                "probability_of_lwe_precipitation_rate_above_threshold"161            ],162            "diagnostic_thresholds": [[1.0, "mm hr-1"]],163            "diagnostic_conditions": ["above"],164        },165        "heavy_precipitation_cloud": {166            "if_true": "heavy_snow_shower",167            "if_false": "heavy_snow_continuous",168            "if_diagnostic_missing": "if_true",169            "probability_thresholds": [0.5],170            "threshold_condition": ">=",171            "condition_combination": "",172            "diagnostic_fields": ["probability_of_shower_condition_above_threshold"],173            "diagnostic_thresholds": [[1.0, 1]],174            "diagnostic_conditions": ["above"],175        },176        "heavy_snow_shower": {177            "if_true": 26,178            "if_false": "heavy_rain_or_sleet_shower",179            "probability_thresholds": [0.0],180            "threshold_condition": "<",181            "condition_combination": "",182            "diagnostic_fields": [183                [184                    "probability_of_lwe_sleetfall_rate_above_threshold",185                    "+",186                    "probability_of_rainfall_rate_above_threshold",187                    "-",188                    "probability_of_lwe_snowfall_rate_above_threshold",189                ]190            ],191            "diagnostic_thresholds": [192                [[1.0, "mm hr-1"], [1.0, "mm hr-1"], [1.0, "mm hr-1"]]193            ],194            "diagnostic_conditions": [["above", "above", "above"]],195        },196        "heavy_rain_or_sleet_shower": {197            "if_true": 14,198            "if_false": 17,199            "probability_thresholds": [0.0],200            "threshold_condition": "<",201            "condition_combination": "",202            "diagnostic_fields": [203                [204                    "probability_of_lwe_sleetfall_rate_above_threshold",205                    "+",206                    "probability_of_lwe_snowfall_rate_above_threshold",207                    "-",208                    "probability_of_rainfall_rate_above_threshold",209                ]210            ],211            "diagnostic_thresholds": [212                [[1.0, "mm hr-1"], [1.0, "mm hr-1"], [1.0, "mm hr-1"]]213            ],214            "diagnostic_conditions": [["above", "above", "above"]],215        },216        "heavy_snow_continuous": {217            "if_true": 27,218            "if_false": "heavy_rain_or_sleet_continuous",219            "probability_thresholds": [0.0],220            "threshold_condition": "<",221            "condition_combination": "",222            "diagnostic_fields": [223                [224                    "probability_of_lwe_sleetfall_rate_above_threshold",225                    "+",226                    "probability_of_rainfall_rate_above_threshold",227                    "-",228                    "probability_of_lwe_snowfall_rate_above_threshold",229                ]230            ],231            "diagnostic_thresholds": [232                [[1.0, "mm hr-1"], [1.0, "mm hr-1"], [1.0, "mm hr-1"]]233            ],234            "diagnostic_conditions": [["above", "above", "above"]],235        },236        "heavy_rain_or_sleet_continuous": {237            "if_true": 15,238            "if_false": 18,239            "probability_thresholds": [0.0],240            "threshold_condition": "<",241            "condition_combination": "",242            "diagnostic_fields": [243                [244                    "probability_of_lwe_sleetfall_rate_above_threshold",245                    "+",246                    "probability_of_lwe_snowfall_rate_above_threshold",247                    "-",248                    "probability_of_rainfall_rate_above_threshold",249                ]250            ],251            "diagnostic_thresholds": [252                [[1.0, "mm hr-1"], [1.0, "mm hr-1"], [1.0, "mm hr-1"]]253            ],254            "diagnostic_conditions": [["above", "above", "above"]],255        },256        "precipitation_in_vicinity": {257            "if_true": "snow_in_vicinity",258            "if_false": "drizzle_mist",259            "probability_thresholds": [0.5],260            "threshold_condition": ">=",261            "condition_combination": "",262            "diagnostic_fields": [263                "probability_of_lwe_precipitation_rate_in_vicinity_above_threshold"264            ],265            "diagnostic_thresholds": [[0.1, "mm hr-1"]],266            "diagnostic_conditions": ["above"],267        },268        "snow_in_vicinity": {269            "if_true": "snow_in_vicinity_cloud",270            "if_false": "rain_or_sleet_in_vicinity",271            "probability_thresholds": [0.0],272            "threshold_condition": "<",273            "condition_combination": "",274            "diagnostic_fields": [275                [276                    "probability_of_lwe_sleetfall_rate_above_threshold",277                    "+",278                    "probability_of_rainfall_rate_above_threshold",279                    "-",280                    "probability_of_lwe_snowfall_rate_above_threshold",281                ]282            ],283            "diagnostic_thresholds": [284                [[0.03, "mm hr-1"], [0.03, "mm hr-1"], [0.03, "mm hr-1"]]285            ],286            "diagnostic_conditions": [["above", "above", "above"]],287        },288        "snow_in_vicinity_cloud": {289            "if_true": "heavy_snow_shower_in_vicinity",290            "if_false": "heavy_snow_continuous_in_vicinity",291            "probability_thresholds": [0.5],292            "threshold_condition": ">=",293            "condition_combination": "",294            "diagnostic_fields": ["probability_of_shower_condition_above_threshold"],295            "diagnostic_thresholds": [[1.0, 1]],296            "diagnostic_conditions": ["above"],297        },298        "heavy_snow_shower_in_vicinity": {299            "if_true": 26,300            "if_false": 23,301            "probability_thresholds": [0.5],302            "threshold_condition": ">=",303            "condition_combination": "",304            "diagnostic_fields": [305                "probability_of_lwe_precipitation_rate_in_vicinity_above_threshold"306            ],307            "diagnostic_thresholds": [[1.0, "mm hr-1"]],308            "diagnostic_conditions": ["above"],309        },310        "heavy_snow_continuous_in_vicinity": {311            "if_true": 27,312            "if_false": 24,313            "probability_thresholds": [0.5],314            "threshold_condition": ">=",315            "condition_combination": "",316            "diagnostic_fields": [317                "probability_of_lwe_precipitation_rate_in_vicinity_above_threshold"318            ],319            "diagnostic_thresholds": [[1.0, "mm hr-1"]],320            "diagnostic_conditions": ["above"],321        },322        "rain_or_sleet_in_vicinity": {323            "if_true": "rain_in_vicinity_cloud",324            "if_false": "sleet_in_vicinity_cloud",325            "probability_thresholds": [0.0],326            "threshold_condition": "<",327            "condition_combination": "",328            "diagnostic_fields": [329                [330                    "probability_of_lwe_sleetfall_rate_above_threshold",331                    "+",332                    "probability_of_lwe_snowfall_rate_above_threshold",333                    "-",334                    "probability_of_rainfall_rate_above_threshold",335                ]336            ],337            "diagnostic_thresholds": [338                [[0.03, "mm hr-1"], [0.03, "mm hr-1"], [0.03, "mm hr-1"]]339            ],340            "diagnostic_conditions": [["above", "above", "above"]],341        },342        "rain_in_vicinity_cloud": {343            "if_true": "heavy_rain_shower_in_vicinity",344            "if_false": "heavy_rain_continuous_in_vicinity",345            "probability_thresholds": [0.5],346            "threshold_condition": ">=",347            "condition_combination": "",348            "diagnostic_fields": ["probability_of_shower_condition_above_threshold"],349            "diagnostic_thresholds": [[1.0, 1]],350            "diagnostic_conditions": ["above"],351        },352        "heavy_rain_shower_in_vicinity": {353            "if_true": 14,354            "if_false": 10,355            "probability_thresholds": [0.5],356            "threshold_condition": ">=",357            "condition_combination": "",358            "diagnostic_fields": [359                "probability_of_lwe_precipitation_rate_in_vicinity_above_threshold"360            ],361            "diagnostic_thresholds": [[1.0, "mm hr-1"]],362            "diagnostic_conditions": ["above"],363        },364        "heavy_rain_continuous_in_vicinity": {365            "if_true": 15,366            "if_false": 12,367            "probability_thresholds": [0.5],368            "threshold_condition": ">=",369            "condition_combination": "",370            "diagnostic_fields": [371                "probability_of_lwe_precipitation_rate_in_vicinity_above_threshold"372            ],373            "diagnostic_thresholds": [[1.0, "mm hr-1"]],374            "diagnostic_conditions": ["above"],375        },376        "sleet_in_vicinity_cloud": {377            "if_true": 17,378            "if_false": 18,379            "probability_thresholds": [0.5],380            "threshold_condition": ">=",381            "condition_combination": "",382            "diagnostic_fields": ["probability_of_shower_condition_above_threshold"],383            "diagnostic_thresholds": [[1.0, 1]],384            "diagnostic_conditions": ["above"],385        },386        "drizzle_mist": {387            "if_true": "drizzle_is_rain",388            "if_false": "drizzle_cloud",389            "probability_thresholds": [0.5, 0.5],390            "threshold_condition": ">=",391            "condition_combination": "AND",392            "diagnostic_fields": [393                "probability_of_lwe_precipitation_rate_above_threshold",394                "probability_of_visibility_in_air_below_threshold",395            ],396            "diagnostic_thresholds": [[0.03, "mm hr-1"], [5000.0, "m"]],397            "diagnostic_conditions": ["above", "below"],398        },399        "drizzle_cloud": {400            "if_true": "drizzle_is_rain",401            "if_false": "mist_conditions",402            "probability_thresholds": [0.5, 0.5],403            "threshold_condition": ">=",404            "condition_combination": "AND",405            "diagnostic_fields": [406                "probability_of_lwe_precipitation_rate_above_threshold",407                "probability_of_low_type_cloud_area_fraction_above_threshold",408            ],409            "diagnostic_thresholds": [[0.03, "mm hr-1"], [0.85, 1]],410            "diagnostic_conditions": ["above", "above"],411        },412        "drizzle_is_rain": {413            "if_true": 11,414            "if_false": "mist_conditions",415            "probability_thresholds": [0.0],416            "threshold_condition": "<",417            "condition_combination": "",418            "diagnostic_fields": [419                [420                    "probability_of_lwe_sleetfall_rate_above_threshold",421                    "+",422                    "probability_of_lwe_snowfall_rate_above_threshold",423                    "-",424                    "probability_of_rainfall_rate_above_threshold",425                ]426            ],427            "diagnostic_thresholds": [428                [[0.03, "mm hr-1"], [0.03, "mm hr-1"], [0.03, "mm hr-1"]]429            ],430            "diagnostic_conditions": [["above", "above", "above"]],431        },432        "mist_conditions": {433            "if_true": "fog_conditions",434            "if_false": "no_precipitation_cloud",435            "probability_thresholds": [0.5],436            "threshold_condition": ">=",437            "condition_combination": "",438            "diagnostic_fields": ["probability_of_visibility_in_air_below_threshold"],439            "diagnostic_thresholds": [[5000.0, "m"]],440            "diagnostic_conditions": ["below"],441        },442        "fog_conditions": {443            "if_true": 6,444            "if_false": 5,445            "probability_thresholds": [0.5],446            "threshold_condition": ">=",447            "condition_combination": "",448            "diagnostic_fields": ["probability_of_visibility_in_air_below_threshold"],449            "diagnostic_thresholds": [[1000.0, "m"]],450            "diagnostic_conditions": ["below"],451        },452        "no_precipitation_cloud": {453            "if_true": "overcast_cloud",454            "if_false": "partly_cloudy",455            "probability_thresholds": [0.5],456            "threshold_condition": ">=",457            "condition_combination": "",458            "diagnostic_fields": [459                "probability_of_low_and_medium_type_cloud_area_fraction_above_threshold"460            ],461            "diagnostic_thresholds": [[0.8125, 1]],462            "diagnostic_conditions": ["above"],463        },464        "overcast_cloud": {465            "if_true": 8,466            "if_false": 7,467            "probability_thresholds": [0.5],468            "threshold_condition": ">=",469            "condition_combination": "",470            "diagnostic_fields": [471                "probability_of_low_type_cloud_area_fraction_above_threshold"472            ],473            "diagnostic_thresholds": [[0.85, 1]],474            "diagnostic_conditions": ["above"],475        },476        "partly_cloudy": {477            "if_true": 3,478            "if_false": 1,479            "probability_thresholds": [0.5],480            "threshold_condition": ">=",481            "condition_combination": "",482            "diagnostic_fields": [483                "probability_of_low_and_medium_type_cloud_area_fraction_above_threshold"484            ],485            "diagnostic_thresholds": [[0.1875, 1]],486            "diagnostic_conditions": ["above"],487        },488    }489    if accumulation:490        queries["heavy_precipitation"] = {491            "if_true": "heavy_precipitation_cloud",492            "if_false": "precipitation_in_vicinity",493            "probability_thresholds": [0.5],494            "threshold_condition": ">=",495            "condition_combination": "",496            "diagnostic_fields": [497                "probability_of_lwe_thickness_of_precipitation_amount_above_threshold"498            ],499            "diagnostic_thresholds": [[1.0, "mm", 3600]],500            "diagnostic_conditions": ["above"],501        }...cif_unicode.py
Source:cif_unicode.py  
1'''2Conversion of text from a Crystallographic Information File (CIF) format to3unicode. CIF text is neither unicode nor bibtex/latex code.4Rules for character formatting in CIF files are specified at:5https://www.iucr.org/resources/cif/spec/version1.1/semantics6'''7import re8import html9subs_dict = {10    '\r': '',            # Windows line ending11    '\t': ' ',           # tabs12    r'\a': u'\u03b1',    # alpha13    r'\b': u'\u03b2',    # beta14    r'\g': u'\u03b3',    # gamma15    r'\d': u'\u03b4',    # delta16    r'\e': u'\u03b5',    # epsilon17    r'\z': u'\u03b6',    # zeta18    r'\h': u'\u03b7',    # eta19    r'\q': u'\u03b8',    # theta20    r'\i': u'\u03b9',    # iota21    r'\k': u'\u03ba',    # kappa22    r'\l': u'\u03bb',    # lambda23    r'\m': u'\u03bc',    # mu24    r'\n': u'\u03bd',    # nu25    r'\x': u'\u03be',    # xi26    r'\o': u'\u03bf',    # omicron27    r'\p': u'\u03c0',    # pi28    r'\r': u'\u03c1',    # rho29    r'\s': u'\u03c3',    # sigma30    r'\t': u'\u03c4',    # tau31    r'\u': u'\u03c5',    # upsilon32    r'\f': u'\u03c6',    # phi33    r'\c': u'\u03c7',    # chi34    r'\y': u'\u03c8',    # psi35    r'\w': u'\u03c9',    # omega36    r'\A': u'\u0391',    # Alpha37    r'\B': u'\u0392',    # Beta38    r'\G': u'\u0393',    # Gamma39    r'\D': u'\u0394',    # Delta40    r'\E': u'\u0395',    # Epsilon41    r'\Z': u'\u0396',    # Zeta42    r'\H': u'\u0397',    # Eta43    r'\Q': u'\u0398',    # Theta44    r'\I': u'\u0399',    # Ioto45    r'\K': u'\u039a',    # Kappa46    r'\L': u'\u039b',    # Lambda47    r'\M': u'\u039c',    # Mu48    r'\N': u'\u039d',    # Nu49    r'\X': u'\u039e',    # Xi50    r'\O': u'\u039f',    # Omicron51    r'\P': u'\u03a0',    # Pi52    r'\R': u'\u03a1',    # Rho53    r'\S': u'\u03a3',    # Sigma54    r'\T': u'\u03a4',    # Tau55    r'\U': u'\u03a5',    # Upsilon56    r'\F': u'\u03a6',    # Phi57    r'\C': u'\u03a7',    # Chi58    r'\Y': u'\u03a8',    # Psi59    r'\W': u'\u03a9',    # Omega60    r'\%a': u'\u00e5',   # a-ring61    r'\/o': u'\u00f8',   # o-slash62    r'\?i': u'\u0131',   # dotless i63    r'\/l': u'\u0142',   # Polish l64    r'\&s': u'\u00df',   # German eszett65    r'\/d': u'\u0111',   # barred d66    r'\%A': u'\u00c5',   # A-ring67    r'\/O': u'\u00d8',   # O-slash68    r'\?I': 'I',         # dotless I69    r'\/L': u'\u0141',   # Polish L70    r'\&S': u'\u1e9e',   # German Eszett71    r'\/D': u'\u0110',   # barred D72    r'\%': u'\u00b0',           # degree73    r'--': u'\u2013',           # dash74    r'---': u'\u2014',          # single bond75    r'\\db': u'\u003d',         # double bond76    r'\\tb': u'\u2261',         # triple bond77    r'\\ddb': u'\u2248',        # delocalized double bond78    r'\\sim': '~',79    r'\\simeq': u'\u2243',80    r'\\infty': u'\u221e',      # infinity81    r'\\times': u'\u00d7',82    r'+-': u'\u00b1',           # plusminus83    r'-+': u'\u2213',           # minusplus84    r'\\square': u'\u25a0',85    r'\\neq': u'\u2660',86    r'\\rangle': u'\u3009',87    r'\\langle': u'\u3008',88    r'\\rightarrow': u'\u2192',89    r'\\leftarrow': u'\u2190',90    r"\'A": u'\u00c1',  # A acute91    r"\'E": u'\u00c9',  # E acute92    r"\'I": u'\u00cd',  # I acute93    r"\'O": u'\u00d3',  # O acute94    r"\'U": u'\u00da',  # U acute95    r"\'Y": u'\u00dd',  # Y acute96    r"\'a": u'\u00e1',  # a acute97    r"\'e": u'\u00e9',  # e acute98    r"\'i": u'\u00ed',  # i acute99    r"\'o": u'\u00f3',  # o acute100    r"\'u": u'\u00fa',  # u acute101    r"\'y": u'\u00fd',  # y acute102    r"\'C": u'\u0106',  # C acute103    r"\'c": u'\u0107',  # c acute104    r"\'L": u'\u0139',  # L acute105    r"\'l": u'\u013a',  # l acute106    r"\'N": u'\u0143',  # N acute107    r"\'n": u'\u0144',  # n acute108    r"\'R": u'\u0154',  # R acute109    r"\'r": u'\u0155',  # r acute110    r"\'S": u'\u015a',  # S acute111    r"\'s": u'\u015b',  # s acute112    r"\'Z": u'\u0179',  # Z acute113    r"\'z": u'\u017a',  # z acute114    r"\'G": u'\u01f4',  # G acute115    r"\'g": u'\u01f5',  # g acute116    r"\'K": u'\u1e30',  # K acute117    r"\'k": u'\u1e31',  # k acute118    r"\'M": u'\u1e3e',  # M acute119    r"\'m": u'\u1e3f',  # m acute120    r"\'P": u'\u1e54',  # P acute121    r"\'p": u'\u1e55',  # p acute122    r"\'W": u'\u1e82',  # W acute123    r"\'w": u'\u1e83',  # w acute124    r'\;A': u'\u0104',  # A ogonek125    r'\;a': u'\u0105',  # a ogonek126    r'\;E': u'\u0118',  # E ogonek127    r'\;e': u'\u0119',  # e ogonek128    r'\;I': u'\u012e',  # I ogonek129    r'\;i': u'\u012f',  # i ogonek130    r'\;U': u'\u0172',  # U ogonek131    r'\;u': u'\u0173',  # u ogonek132    r'\;O': u'\u01ea',  # O ogonek133    r'\;o': u'\u01eb',  # o ogonek134    r'\.C': u'\u010a',  # C dot above135    r'\.c': u'\u010b',  # c dot above136    r'\.E': u'\u0116',  # E dot above137    r'\.e': u'\u0117',  # e dot above138    r'\.G': u'\u0120',  # G dot above139    r'\.g': u'\u0121',  # g dot above140    r'\.I': u'\u0130',  # I dot above141    r'\.Z': u'\u017b',  # Z dot above142    r'\.z': u'\u017c',  # z dot above143    r'\.A': u'\u0226',  # A dot above144    r'\.a': u'\u0227',  # a dot above145    r'\.O': u'\u022e',  # O dot above146    r'\.o': u'\u022f',  # o dot above147    r'\.B': u'\u1e02',  # B dot above148    r'\.b': u'\u1e03',  # b dot above149    r'\.D': u'\u1e0a',  # D dot above150    r'\.d': u'\u1e0b',  # d dot above151    r'\.F': u'\u1e1e',  # F dot above152    r'\.f': u'\u1e1f',  # f dot above153    r'\.H': u'\u1e22',  # H dot above154    r'\.h': u'\u1e23',  # h dot above155    r'\.M': u'\u1e40',  # M dot above156    r'\.m': u'\u1e41',  # m dot above157    r'\.N': u'\u1e44',  # N dot above158    r'\.n': u'\u1e45',  # n dot above159    r'\.P': u'\u1e56',  # P dot above160    r'\.p': u'\u1e57',  # p dot above161    r'\.R': u'\u1e58',  # R dot above162    r'\.r': u'\u1e59',  # r dot above163    r'\.S': u'\u1e60',  # S dot above164    r'\.s': u'\u1e61',  # s dot above165    r'\.T': u'\u1e6a',  # T dot above166    r'\.t': u'\u1e6b',  # t dot above167    r'\.W': u'\u1e86',  # W dot above168    r'\.w': u'\u1e87',  # w dot above169    r'\.X': u'\u1e8a',  # X dot above170    r'\.x': u'\u1e8b',  # x dot above171    r'\.Y': u'\u1e8e',  # Y dot above172    r'\.y': u'\u1e8f',  # y dot above173    r'\(A': u'\u0102',  # A breve174    r'\(a': u'\u0103',  # a breve175    r'\(E': u'\u0114',  # E breve176    r'\(e': u'\u0115',  # e breve177    r'\(G': u'\u011e',  # G breve178    r'\(g': u'\u011f',  # g breve179    r'\(I': u'\u012c',  # I breve180    r'\(i': u'\u012d',  # i breve181    r'\(O': u'\u014e',  # O breve182    r'\(o': u'\u014f',  # o breve183    r'\(U': u'\u016c',  # U breve184    r'\(u': u'\u016d',  # u breve185    r'\=A': u'\u0100',  # A macron186    r'\=a': u'\u0101',  # a macron187    r'\=E': u'\u0112',  # E macron188    r'\=e': u'\u0113',  # e macron189    r'\=I': u'\u012a',  # I macron190    r'\=i': u'\u012b',  # i macron191    r'\=O': u'\u014c',  # O macron192    r'\=o': u'\u014d',  # o macron193    r'\=U': u'\u016a',  # U macron194    r'\=u': u'\u016b',  # u macron195    r'\=Y': u'\u0232',  # Y macron196    r'\=y': u'\u0233',  # y macron197    r'\=G': u'\u1e20',  # G macron198    r'\=g': u'\u1e21',  # g macron199    r'\^A': u'\u00c2',  # A circumflex200    r'\^E': u'\u00ca',  # E circumflex201    r'\^I': u'\u00ce',  # I circumflex202    r'\^O': u'\u00d4',  # O circumflex203    r'\^U': u'\u00db',  # U circumflex204    r'\^a': u'\u00e2',  # a circumflex205    r'\^e': u'\u00ea',  # e circumflex206    r'\^i': u'\u00ee',  # i circumflex207    r'\^o': u'\u00f4',  # o circumflex208    r'\^u': u'\u00fb',  # u circumflex209    r'\^C': u'\u0108',  # C circumflex210    r'\^c': u'\u0109',  # c circumflex211    r'\^G': u'\u011c',  # G circumflex212    r'\^g': u'\u011d',  # g circumflex213    r'\^H': u'\u0124',  # H circumflex214    r'\^h': u'\u0125',  # h circumflex215    r'\^J': u'\u0134',  # J circumflex216    r'\^j': u'\u0135',  # j circumflex217    r'\^S': u'\u015c',  # S circumflex218    r'\^s': u'\u015d',  # s circumflex219    r'\^W': u'\u0174',  # W circumflex220    r'\^w': u'\u0175',  # w circumflex221    r'\^Y': u'\u0176',  # Y circumflex222    r'\^y': u'\u0177',  # y circumflex223    r'\^Z': u'\u1e90',  # Z circumflex224    r'\^z': u'\u1e91',  # z circumflex225    r'\"A': u'\u00c4',  # A diaeresis226    r'\"E': u'\u00cb',  # E diaeresis227    r'\"I': u'\u00cf',  # I diaeresis228    r'\"O': u'\u00d6',  # O diaeresis229    r'\"U': u'\u00dc',  # U diaeresis230    r'\"a': u'\u00e4',  # a diaeresis231    r'\"e': u'\u00eb',  # e diaeresis232    r'\"i': u'\u00ef',  # i diaeresis233    r'\"o': u'\u00f6',  # o diaeresis234    r'\"u': u'\u00fc',  # u diaeresis235    r'\"y': u'\u00ff',  # y diaeresis236    r'\"Y': u'\u0178',  # Y diaeresis237    r'\"H': u'\u1e26',  # H diaeresis238    r'\"h': u'\u1e27',  # h diaeresis239    r'\"W': u'\u1e84',  # W diaeresis240    r'\"w': u'\u1e85',  # w diaeresis241    r'\"X': u'\u1e8c',  # X diaeresis242    r'\"x': u'\u1e8d',  # x diaeresis243    r'\"t': u'\u1e97',  # t diaeresis244    r'\~A': u'\u00c3',  # A tilde245    r'\~N': u'\u00d1',  # N tilde246    r'\~O': u'\u00d5',  # O tilde247    r'\~a': u'\u00e3',  # a tilde248    r'\~n': u'\u00f1',  # n tilde249    r'\~o': u'\u00f5',  # o tilde250    r'\~I': u'\u0128',  # I tilde251    r'\~i': u'\u0129',  # i tilde252    r'\~U': u'\u0168',  # U tilde253    r'\~u': u'\u0169',  # u tilde254    r'\~V': u'\u1e7c',  # V tilde255    r'\~v': u'\u1e7d',  # v tilde256    r'\~E': u'\u1ebc',  # E tilde257    r'\~e': u'\u1ebd',  # e tilde258    r'\~Y': u'\u1ef8',  # Y tilde259    r'\~y': u'\u1ef9',  # y tilde260    r'\<C': u'\u010c',  # C caron261    r'\<c': u'\u010d',  # c caron262    r'\<D': u'\u010e',  # D caron263    r'\<d': u'\u010f',  # d caron264    r'\<E': u'\u011a',  # E caron265    r'\<e': u'\u011b',  # e caron266    r'\<L': u'\u013d',  # L caron267    r'\<l': u'\u013e',  # l caron268    r'\<N': u'\u0147',  # N caron269    r'\<n': u'\u0148',  # n caron270    r'\<R': u'\u0158',  # R caron271    r'\<r': u'\u0159',  # r caron272    r'\<S': u'\u0160',  # S caron273    r'\<s': u'\u0161',  # s caron274    r'\<T': u'\u0164',  # T caron275    r'\<t': u'\u0165',  # t caron276    r'\<Z': u'\u017d',  # Z caron277    r'\<z': u'\u017e',  # z caron278    r'\<A': u'\u01cd',  # A caron279    r'\<a': u'\u01ce',  # a caron280    r'\<I': u'\u01cf',  # I caron281    r'\<i': u'\u01d0',  # i caron282    r'\<O': u'\u01d1',  # O caron283    r'\<o': u'\u01d2',  # o caron284    r'\<U': u'\u01d3',  # U caron285    r'\<u': u'\u01d4',  # u caron286    r'\<G': u'\u01e6',  # G caron287    r'\<g': u'\u01e7',  # g caron288    r'\<K': u'\u01e8',  # K caron289    r'\<k': u'\u01e9',  # k caron290    r'\<j': u'\u01f0',  # j caron291    r'\<H': u'\u021e',  # H caron292    r'\<h': u'\u021f',  # h caron293    r'\>O': u'\u0150',  # O double acute294    r'\>o': u'\u0151',  # o double acute295    r'\>U': u'\u0170',  # U double acute296    r'\>u': u'\u0171',  # u double acute297    r'\,C': u'\u00c7',  # C cedilla298    r'\,c': u'\u00e7',  # c cedilla299    r'\,G': u'\u0122',  # G cedilla300    r'\,g': u'\u0123',  # g cedilla301    r'\,K': u'\u0136',  # K cedilla302    r'\,k': u'\u0137',  # k cedilla303    r'\,L': u'\u013b',  # L cedilla304    r'\,l': u'\u013c',  # l cedilla305    r'\,N': u'\u0145',  # N cedilla306    r'\,n': u'\u0146',  # n cedilla307    r'\,R': u'\u0156',  # R cedilla308    r'\,r': u'\u0157',  # r cedilla309    r'\,S': u'\u015e',  # S cedilla310    r'\,s': u'\u015f',  # s cedilla311    r'\,T': u'\u0162',  # T cedilla312    r'\,t': u'\u0163',  # t cedilla313    r'\,E': u'\u0228',  # E cedilla314    r'\,e': u'\u0229',  # e cedilla315    r'\,D': u'\u1e10',  # D cedilla316    r'\,d': u'\u1e11',  # d cedilla317    r'\,H': u'\u1e28',  # H cedilla318    r'\,h': u'\u1e29',  # h cedilla319    r'\`A': u'\u00c0',  # A grave320    r'\`E': u'\u00c8',  # E grave321    r'\`I': u'\u00cc',  # I grave322    r'\`O': u'\u00d2',  # O grave323    r'\`U': u'\u00d9',  # U grave324    r'\`a': u'\u00e0',  # a grave325    r'\`e': u'\u00e8',  # e grave326    r'\`i': u'\u00ec',  # i grave327    r'\`o': u'\u00f2',  # o grave328    r'\`u': u'\u00f9',  # u grave329    r'\`N': u'\u01f8',  # N grave330    r'\`n': u'\u01f9',  # n grave331    r'\`W': u'\u1e80',  # W grave332    r'\`w': u'\u1e81',  # w grave333    r'\`Y': u'\u1ef2',  # Y grave334    r'\`y': u'\u1ef3',  # y grave335}336superscript_dict = {337    '0': u'\u2070',  # superscript 0338    '1': u'\u00b9',  # superscript 1339    '2': u'\u00b2',  # superscript 2340    '3': u'\u00b3',  # superscript 3341    '4': u'\u2074',  # superscript 4342    '5': u'\u2075',  # superscript 5343    '6': u'\u2076',  # superscript 6344    '7': u'\u2077',  # superscript 7345    '8': u'\u2078',  # superscript 8346    '9': u'\u2079',  # superscript 9347}348subscript_dict = {349    '0': u'\u2080',  # subscript 0350    '1': u'\u2081',  # subscript 1351    '2': u'\u2082',  # subscript 2352    '3': u'\u2083',  # subscript 3353    '4': u'\u2084',  # subscript 4354    '5': u'\u2085',  # subscript 5355    '6': u'\u2086',  # subscript 6356    '7': u'\u2087',  # subscript 7357    '8': u'\u2088',  # subscript 8358    '9': u'\u2089',  # subscript 9359}360def replace_subscript(s: str, subscript=True) -> str:361    target = '~'362    rdict = subscript_dict363    if not subscript:364        target = '^'365        rdict = superscript_dict366    replaced = []367    inside = False368    for char in s:369        if char == target:370            inside = not inside371        elif not inside:372            replaced += [char]373        # note: do not use char.isdigit - this also matches (sub/super)scripts374        elif char in rdict:375            replaced += [rdict[char]]376        else:377            replaced += [char]378    return ''.join(replaced)379def multiple_replace(text: str, adict) -> str:380    rx = re.compile('|'.join(map(re.escape, adict)))381    def one_xlat(match):382        return adict[match.group(0)]383    return rx.sub(one_xlat, text)384def format_unicode(s: str) -> str:385    """Converts a string in CIF text-format to unicode.  Any HTML tags386    contained in the string are removed.  HTML numeric character references387    are unescaped (i.e. converted to unicode).388    Parameters:389    s: string390        The CIF text string to convert391    Returns:392    u: string393        A unicode formatted string.394    """395    s = html.unescape(s)396    s = multiple_replace(s, subs_dict)397    tagclean = re.compile('<.*?>')398    return re.sub(tagclean, '', s)399def handle_subscripts(s: str) -> str:400    s = replace_subscript(s, subscript=True)401    s = replace_subscript(s, subscript=False)...pokemon.py
Source:pokemon.py  
1import csv2from collections import Counter3def pokemon():4    filename = 'pokemonTrain.csv'5    reader = csv.DictReader(open(filename))6    out = open("pokemon1.txt", "w")7    numFire = numAbove = float(0)8    for index, row in enumerate(reader):9        # print(row)10        if row['type'] == 'fire':11            numFire += 112            if float(row['level']) >= 40:13                numAbove += 114    percent = round(100 * numAbove / numFire)15    out.write(f'Percentage of fire type Pokemons at or above level 40 = {percent}')16    weaknesses = {}17    sum_hp_above = sum_hp_below = sum_atk_above = sum_atk_below = sum_def_above = sum_def_below = 018    num_hp_above = num_hp_below = num_atk_above = num_atk_below = num_def_above = num_def_below = 019    reader = csv.DictReader(open(filename))20    for index, row in enumerate(reader):21        pokeType = row['type']22        weakness = row['weakness']23        if float(row['level']) > 40:24            if row['hp'] != 'NaN':25                sum_hp_above += float(row['hp'])26                num_hp_above += 127            if row['atk'] != 'NaN':28                sum_atk_above += float(row['atk'])29                num_atk_above += 130            if row['def'] != 'NaN':31                sum_def_above += float(row['def'])32                num_def_above += 133        elif float(row['level']) <= 40:34            if row['hp'] != 'NaN':35                sum_hp_below += float(row['hp'])36                num_hp_below += 137            if row['atk'] != 'NaN':38                sum_atk_below += float(row['atk'])39                num_atk_below += 140            if row['def'] != 'NaN':41                sum_def_below += float(row['def'])42                num_def_below += 143        if pokeType == 'NaN' or weakness == 'NaN':44            continue45        if weakness not in weaknesses:46            weaknesses[weakness] = Counter()47        weaknesses[weakness][pokeType] += 148    avg_hp_above, avg_atk_above, avg_def_above, avg_hp_below, avg_atk_below, avg_def_below = round(49        sum_hp_above / num_hp_above, 1), round(sum_atk_above / num_atk_above, 1), round(sum_def_above / num_def_above,50                                                                                        1), round(51        sum_hp_below / num_hp_below, 1), round(sum_atk_below / num_atk_below, 1), round(sum_def_below / num_def_below,52                                                                                        1)53    out = {}54    for key in weaknesses.keys():55        out[key] = sorted(weaknesses[key].most_common(), key=lambda x: (-x[1], x[0]))[0][0]56    with open('pokemonResult.csv', 'w', newline='') as csvfile:57        reader = csv.DictReader(open(filename))58        writer = csv.DictWriter(csvfile, fieldnames=reader.fieldnames, delimiter=',')59        writer.writeheader()60        for row in reader:61            if row['type'] == 'NaN':62                row['type'] = out[row['weakness']]63            if float(row['level']) > 40:64                if row['hp'] == 'NaN':65                    row['hp'] = avg_hp_above66                if row['atk'] == 'NaN':67                    row['atk'] = avg_atk_above68                if row['def'] == 'NaN':69                    row['def'] = avg_def_above70            elif float(row['level']) <= 40:71                if row['hp'] == 'NaN':72                    row['hp'] = avg_hp_below73                if row['atk'] == 'NaN':74                    row['atk'] = avg_atk_below75                if row['def'] == 'NaN':76                    row['def'] = avg_def_below77            writer.writerow(row)78    with open('pokemonResult.csv') as newcsv:79        reader = csv.DictReader(newcsv)80        personalities = {}81        sum_stage_3 = num_stage_3 = 082        for row in reader:83            if float(row['stage']) == 3:84                sum_stage_3 += float(row['hp'])85                num_stage_3 += 186            pokeType = row['type']87            personality = row['personality']88            if pokeType not in personalities:89                personalities[pokeType] = [personality]90            else:91                if personality not in personalities[pokeType]:92                    personalities[pokeType].append(personality)93            personalities[pokeType].sort()94        sorted_personalities = sorted(personalities.items())95        out = open('pokemon4.txt', 'w')96        out.write('Pokemon type to personality mapping:\n')97        for item in sorted_personalities:98            out.write(f'\n\t{item[0]}: ')99            first = True100            for p in item[1]:101                if first:102                    out.write(f'{p}')103                    first = False104                else:105                    out.write(f', {p}')106        out = open('pokemon5.txt', 'w')107        out.write(f'Average hit point for Pokemons of stage 3.0 = {round(sum_stage_3 / num_stage_3)}')108def main():109    pokemon()110if __name__ == '__main__':...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
