def initialize(data, grid, grid1): """Initialize random plant type field. Plant types are defined as the following: * GRASS = 0 * SHRUB = 1 * TREE = 2 * BARE = 3 * SHRUBSEEDLING = 4 * TREESEEDLING = 5 """ grid1.at_cell['vegetation__plant_functional_type'] = compose_veg_grid( grid1, percent_bare=data['percent_bare_initial'], percent_grass=data['percent_grass_initial'], percent_shrub=data['percent_shrub_initial'], percent_tree=data['percent_tree_initial']) # Assign plant type for representative ecohydrologic simulations grid.at_cell['vegetation__plant_functional_type'] = np.arange(6) grid1.at_node['topographic__elevation'] = np.full(grid1.number_of_nodes, 1700.) grid.at_node['topographic__elevation'] = np.full(grid.number_of_nodes, 1700.) precip_dry = PrecipitationDistribution( mean_storm_duration=data['mean_storm_dry'], mean_interstorm_duration=data['mean_interstorm_dry'], mean_storm_depth=data['mean_storm_depth_dry']) precip_wet = PrecipitationDistribution( mean_storm_duration=data['mean_storm_wet'], mean_interstorm_duration=data['mean_interstorm_wet'], mean_storm_depth=data['mean_storm_depth_wet']) radiation = Radiation(grid) pet_tree = PotentialEvapotranspiration(grid, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_tree'], delta_d=data['DeltaD']) pet_shrub = PotentialEvapotranspiration(grid, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_shrub'], delta_d=data['DeltaD']) pet_grass = PotentialEvapotranspiration(grid, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_grass'], delta_d=data['DeltaD']) soil_moisture = SoilMoisture(grid, **data) # Soil Moisture object vegetation = Vegetation(grid, **data) # Vegetation object vegca = VegCA(grid1, **data) # Cellular automaton object # Initializing inputs for Soil Moisture object grid.at_cell['vegetation__live_leaf_area_index'] = ( 1.6 * np.ones(grid.number_of_cells)) grid.at_cell['soil_moisture__initial_saturation_fraction'] = ( 0.59 * np.ones(grid.number_of_cells)) return (precip_dry, precip_wet, radiation, pet_tree, pet_shrub, pet_grass, soil_moisture, vegetation, vegca)
def Initialize_(data, grid, grid1): # Plant types are defined as following: # GRASS = 0; SHRUB = 1; TREE = 2; BARE = 3; # SHRUBSEEDLING = 4; TREESEEDLING = 5 # Initialize random plant type field grid1['cell']['vegetation__plant_functional_type'] = compose_veg_grid( grid1, percent_bare=data['percent_bare_initial'], percent_grass=data['percent_grass_initial'], percent_shrub=data['percent_shrub_initial'], percent_tree=data['percent_tree_initial']) # Assign plant type for representative ecohydrologic simulations grid['cell']['vegetation__plant_functional_type'] = np.arange(0, 6) grid1['node']['topographic__elevation'] = (1700. * np.ones(grid1.number_of_nodes)) grid['node']['topographic__elevation'] = (1700. * np.ones(grid.number_of_nodes)) PD_D = PrecipitationDistribution( mean_storm_duration=data['mean_storm_dry'], mean_interstorm_duration=data['mean_interstorm_dry'], mean_storm_depth=data['mean_storm_depth_dry']) PD_W = PrecipitationDistribution( mean_storm_duration=data['mean_storm_wet'], mean_interstorm_duration=data['mean_interstorm_wet'], mean_storm_depth=data['mean_storm_depth_wet']) Rad = Radiation(grid) PET_Tree = PotentialEvapotranspiration(grid, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_tree'], delta_d=data['DeltaD']) PET_Shrub = PotentialEvapotranspiration(grid, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_shrub'], delta_d=data['DeltaD']) PET_Grass = PotentialEvapotranspiration(grid, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_grass'], delta_d=data['DeltaD']) SM = SoilMoisture(grid, **data) # Soil Moisture object VEG = Vegetation(grid, **data) # Vegetation object vegca = VegCA(grid1, **data) # Cellular automaton object # # Initializing inputs for Soil Moisture object grid['cell']['vegetation__live_leaf_area_index'] = ( 1.6 * np.ones(grid.number_of_cells)) grid['cell']['soil_moisture__initial_saturation_fraction'] = ( 0.59 * np.ones(grid.number_of_cells)) # Initializing Soil Moisture return PD_D, PD_W, Rad, PET_Tree, PET_Shrub, PET_Grass, SM, \ VEG, vegca
def initialize_components(data, grid_veg=None, grid=None, pet_method='Cosine'): # Plant types are defined as following: # GRASS = 0; SHRUB = 1; TREE = 2; BARE = 3; # SHRUBSEEDLING = 4; TREESEEDLING = 5 # Initialize random plant type field grid.at_cell['vegetation__plant_functional_type'] = compose_veg_grid( grid, percent_bare=data['percent_bare_initial'], percent_grass=data['percent_grass_initial'], percent_shrub=data['percent_shrub_initial'], percent_tree=data['percent_tree_initial']) # Assign plant type for representative ecohydrologic simulations grid_veg.at_cell['vegetation__plant_functional_type'] = np.arange(0, 6) grid.at_node['topographic__elevation'] = np.full(grid.number_of_nodes, 1700.) grid_veg.at_node['topographic__elevation'] = np.full( grid_veg.number_of_nodes, 1700.) precip_dry = PrecipitationDistribution( mean_storm_duration=data['mean_storm_dry'], mean_interstorm_duration=data['mean_interstorm_dry'], mean_storm_depth=data['mean_storm_depth_dry'], random_seed=None) precip_wet = PrecipitationDistribution( mean_storm_duration=data['mean_storm_wet'], mean_interstorm_duration=data['mean_interstorm_wet'], mean_storm_depth=data['mean_storm_depth_wet'], random_seed=None) radiation = Radiation(grid_veg) if pet_method == 'Cosine': pet_tree = PotentialEvapotranspiration( grid_veg, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_tree'], delta_d=data['DeltaD']) pet_shrub = PotentialEvapotranspiration( grid_veg, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_shrub'], delta_d=data['DeltaD']) pet_grass = PotentialEvapotranspiration( grid_veg, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_grass'], delta_d=data['DeltaD']) elif pet_method == 'PriestleyTaylor': pet_met = PotentialEvapotranspiration(grid_veg, method='PriestleyTaylor') soil_moisture = SoilMoisture(grid_veg, **data) # Soil Moisture object vegetation = Vegetation(grid_veg, **data) # Vegetation object vegca = VegCA(grid, **data) # Cellular automaton object # # Initializing inputs for Soil Moisture object grid_veg.at_cell['vegetation__live_leaf_area_index'] = ( 1.6 * np.ones(grid_veg.number_of_cells)) grid_veg.at_cell['soil_moisture__initial_saturation_fraction'] = ( 0.59 * np.ones(grid_veg.number_of_cells)) # Initializing Soil Moisture if pet_method == 'Cosine': return (precip_dry, precip_wet, radiation, pet_tree, pet_shrub, pet_grass, soil_moisture, vegetation, vegca) elif pet_method == 'PriestleyTaylor': return (precip_dry, precip_wet, radiation, pet_met, soil_moisture, vegetation, vegca)
(watershed, z) = read_esri_ascii('DEM_10m.asc', name='topographic__elevation') imshow_grid(watershed, 'topographic__elevation') plt.show() # Constructions of Landlab Radiation and Potential Evapotranspiration components and codes can be found in the respective links below. # http://landlab.readthedocs.io/en/latest/landlab.components.radiation.html and # http://landlab.readthedocs.io/en/latest/landlab.components.pet.html # The radation components return relative radiation (ratio of radiation of a slopes surface to flat surface), used to scale PET calculated for flat surface by the PET component. # # Let's instantiate the radiation and PET components using only variables relevant to this exercise. rad = Radiation(watershed, method='Grid', latitude=34.) PET = PotentialEvapotranspiration( watershed, method='PriestleyTaylor', albedo=0.2, latitude=34., elevation_of_measurement=2, ) # Set the current_time (0-1) in a year, (calculate as DOY/365). # To see how the magnitude and spatial distribution of radiation and PET changes as a function of DOY we will use two different days, summer and winter solstice. In both cases we will use PET based on the Priestley and Taylor model that requires temperature as input. Temperatures are from cenral NM climatology. In the calculation of PET modeled solar radiation will be used. The Potential Evapotranspiration component of Landlab currently offers several other methods for PET calculation which can be found: http://landlab.readthedocs.io/en/latest/landlab.components.pet.html # # For summer solstice use current_time=0.466 (June 20) and Tmin=14, Tmax=32, Tavg=23 (degree C) # # For summer solstice use current_time=0.997 (December 21) and Tmin=-5, Tmax=11, Tavg=3 (degree C). # As you do this exercise notice when the spatial variability of radiation and PET becomes more pronounced. current_time = 0.466 # 0: beginning of the calender year 0.5: middle of the year rad.update(current_time) PET.update(current_time, Tmin=14, Tmax=32,
ObsT = mat_data['T'] # years for observed biomass ObsBioMlow = mat_data['BioMlow'] # Observed live Biomass low ObsDeadBlow = mat_data['DeadBlow'] # Observed dead Biomass low ObsS = mat_data['ObsS'] BGMBiol = mat_data['BGMBiol'] BGMBiot = mat_data['BGMBiot'] PClim = mat_data['P'] TbClim = mat_data['Tb'] TrClim = mat_data['Tr'] PET_grass = mat_data['Ep'] # Penman Monteith data from file # Create radiation, soil moisture and Vegetation objects Rad = Radiation(grid) PET_Tree = PotentialEvapotranspiration(grid1, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_tree'], DeltaD=data['DeltaD']) PET_Shrub = PotentialEvapotranspiration(grid1, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_shrub'], DeltaD=data['DeltaD']) PET_Grass = PotentialEvapotranspiration(grid1, method = data['PET_method'], MeanTmaxF=data['MeanTmaxF_grass'], DeltaD=data['DeltaD']) SM = SoilMoisture(grid, runon_switch=0, **data) # Soil Moisture object VEG = Vegetation(grid, **data) # Vegetation object vegca = VegCA(grid1, **data) # Cellular automaton object ########## n = 3275 #data['n_short'] # Defining number of storms the model will be run ##########
nfs_mon1_end = np.where(np.array(strm_days) == dt.datetime(2009, 5, 21, 0, 0))[0][0] precip[:nfs_mon1_end] *= data['precip_mult_1'] # introduced 30Mar18 precip[nfs_mon1_end:] *= data['precip_mult_2'] # Input veg composition grid['cell']['vegetation__plant_functional_type'] = compose_veg_grid( grid, percent_bare=data['percent_bare_initial'], percent_grass=data['percent_grass_initial'], percent_shrub=data['percent_shrub_initial'], percent_tree=data['percent_tree_initial']) #grid.at_cell['vegetation__plant_functional_type'][[1748, 1692, 1523]] = 2 # All Trees - 2 means Tree # Create radiation, PET and soil moisture objects ## For modeled Radiation model Rad = Radiation(grid) pet_grass = PotentialEvapotranspiration(grid, method='PenmanMonteith', albedo=data['albedo_grass'], rl=data['rl_grass'], zveg=data['zveg_grass'], LAI=data['LAI_grass'], zm=data['zm_grass'], zh=data['zh_grass']) pet_shrub = PotentialEvapotranspiration(grid, method='PenmanMonteith', albedo=data['albedo_shrub'], rl=data['rl_shrub'], zveg=data['zveg_shrub'], LAI=data['LAI_shrub'], zm=data['zm_shrub'], zh=data['zh_shrub']) pet_tree = PotentialEvapotranspiration(grid, method='PenmanMonteith', albedo=data['albedo_tree'], rl=data['rl_tree'], zveg=data['zveg_tree'], LAI=data['LAI_tree'], zm=data['zm_tree'], zh=data['zh_tree']) if runon_switch: (ordered_cells, grid2) = get_ordered_cells_for_soil_moisture( grid2, outlet_id=1449-(2*58)-2) grid.at_node['flow__receiver_node'] = ( grid2.at_node['flow__receiver_node'])
def initialize(data, grid, grid1, grid2, elevation): """Initialize random plant type field. Plant types are defined as the following: * GRASS = 0 * SHRUB = 1 * TREE = 2 * BARE = 3 * SHRUBSEEDLING = 4 * TREESEEDLING = 5 """ grid['cell']['vegetation__plant_functional_type'] = compose_veg_grid( grid, percent_bare=data['percent_bare_initial'], percent_grass=data['percent_grass_initial'], percent_shrub=data['percent_shrub_initial'], percent_tree=data['percent_tree_initial']) # Assign plant type for representative ecohydrologic simulations grid1.at_cell['vegetation__plant_functional_type'] = np.arange(6) grid1.at_node['topographic__elevation'] = np.full(grid1.number_of_nodes, 1700.) grid.at_node['topographic__elevation'] = elevation grid2.at_node['topographic__elevation'] = elevation if data['runon_switch']: (ordered_cells, grid2) = get_ordered_cells_for_soil_moisture( grid2, outlet_id=4877) # hugo10mws: 1331 # 36704 grid.at_node['flow__receiver_node'] = ( grid2.at_node['flow__receiver_node']) else: ordered_cells = None precip_dry = PrecipitationDistribution( mean_storm_duration=data['mean_storm_dry'], mean_interstorm_duration=data['mean_interstorm_dry'], mean_storm_depth=data['mean_storm_depth_dry'], random_seed=None) precip_wet = PrecipitationDistribution( mean_storm_duration=data['mean_storm_wet'], mean_interstorm_duration=data['mean_interstorm_wet'], mean_storm_depth=data['mean_storm_depth_wet'], random_seed=None) radiation = Radiation(grid) rad_pet = Radiation(grid1) pet_tree = PotentialEvapotranspiration(grid1, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_tree'], delta_d=data['DeltaD']) pet_shrub = PotentialEvapotranspiration(grid1, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_shrub'], delta_d=data['DeltaD']) pet_grass = PotentialEvapotranspiration(grid1, method=data['PET_method'], MeanTmaxF=data['MeanTmaxF_grass'], delta_d=data['DeltaD']) soil_moisture = SoilMoisture(grid, ordered_cells=ordered_cells, **data) # Soil Moisture object vegetation = Vegetation(grid, **data) # Vegetation object vegca = VegCA(grid, **data) # Cellular automaton object # # Initializing inputs for Soil Moisture object grid['cell']['vegetation__live_leaf_area_index'] = ( 1.6 * np.ones(grid.number_of_cells)) grid['cell']['soil_moisture__initial_saturation_fraction'] = ( 0.59 * np.ones(grid.number_of_cells)) # Initializing Soil Moisture return (precip_dry, precip_wet, radiation, rad_pet, pet_tree, pet_shrub, pet_grass, soil_moisture, vegetation, vegca, ordered_cells)