grid['cell']['VegetationType'] = np.arange(0,6) ## Create input dictionary from text file InputFile = 'Inputs_Vegetation_CA.txt' data = txt_data_dict( InputFile ) # Create dictionary that holds the inputs # Create rainfall, radiation, potential evapotranspiration, # soil moisture and Vegetation objects # Assign parameters to the components PD_D = PrecipitationDistribution(mean_storm = data['mean_storm_dry'], \ mean_interstorm = data['mean_interstorm_dry'], mean_storm_depth = data['mean_storm_depth_dry']) PD_W = PrecipitationDistribution(mean_storm = data['mean_storm_wet'], \ mean_interstorm = data['mean_interstorm_wet'], mean_storm_depth = data['mean_storm_depth_wet']) 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, data ) # Soil Moisture object VEG = Vegetation( grid, data ) # Vegetation object vegca = VegCA( grid1, data ) # Cellular automaton object ##########
grid1.number_of_cells) # Age of the plants is randomnly generated by the constructor of vegca # component. Seedlings of shrubs and trees are determined by their age # within the constructor as well. Hence the random vegetation type # field is called for types GRASS, SHRUB, TREE and BARE only. -SN 10Mar15 grid['cell']['VegetationType'] = np.arange(0, 6) # Create radiation, soil moisture and Vegetation objects PD_D = PrecipitationDistribution(mean_storm = data['mean_storm_dry'], \ mean_interstorm = data['mean_interstorm_dry'], mean_storm_depth = data['mean_storm_depth_dry']) PD_W = PrecipitationDistribution(mean_storm = data['mean_storm_wet'], \ mean_interstorm = data['mean_interstorm_wet'], mean_storm_depth = data['mean_storm_depth_wet']) 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, data) # Soil Moisture object VEG = Vegetation(grid, data) # Vegetation object vegca = VegCA(grid1, data) # Cellular automaton object ##########
# Sai Nudurupati and Erkan Istanbulluoglu- 16May2014 : # Example to use potential_evapotranspiration_field.py #import landlab from landlab import RasterModelGrid from landlab.components.radiation import Radiation from landlab.components.pet import PotentialEvapotranspiration import numpy as np import matplotlib.pyplot as plt from landlab.plot.imshow import imshow_grid grid = RasterModelGrid( 100, 100, 20. ) elevation = np.random.rand(grid.number_of_nodes) * 1000 grid.add_zeros('node','Elevation',units = 'm') grid['node']['Elevation'] = elevation rad = Radiation( grid ) PET = PotentialEvapotranspiration( grid ) current_time = 0.56 rad.update( current_time ) PET.update( ConstantPotentialEvapotranspiration = 10.0 ) plt.figure(0) imshow_grid(grid,'RadiationFactor', values_at = 'cell', grid_units = ('m','m')) plt.figure(1) imshow_grid(grid,'PotentialEvapotranspiration', values_at = 'cell', grid_units = ('m','m')) plt.savefig('PET_test') plt.show()
""" Creat a nodal field called 'Elevation' on the grid with units in metres and populate it with zeros. """ grid.add_zeros('node', 'Elevation', units='m') """ This 'Elevation' field stored on the grid can be accessed as following: """ grid['node']['Elevation'] = elevation """ Instantiate an object for 'Radiation' Class. This instantiation associates the object 'rad' with the capabilities of the class 'Radiation'. This initiation requires an input of a grid. Creation of the object automatically associates this grid to the object 'rad'. """ rad = Radiation(grid) """ Set random time for our example. Time is in years. """ current_time = 0.56 """ 'Radiation' class has an update function (like CSDMS BMI component). This function takes current_time as an input argument and calculates Total Short Wave Radiation incident on each cell at noon of the julian day represented by current_time input. It also calculates the Radiation Factor which represents the ratio of total short wave radiation incident on a grid cell and flat surface. Hence Radiation Factor will be 1.0 if the grid cell has a slope of 0.0 . Therefore, two cellular fields are created on the grid (which means that the two arrays of length equivalent to number of cells that the grid has are created and stored in conjunction with the grid. Whenever this grid is transferred, these two cellular fields go with them.
# component. Seedlings of shrubs and trees are determined by their age # within the constructor as well. Hence the random vegetation type # field is called for types GRASS, SHRUB, TREE and BARE only. -SN 10Mar15 # Dummy grid for PET grid1 = rmg(5, 4, 5) grid1['node']['Elevation'] = 1700. * np.ones(grid1.number_of_nodes) grid1['cell']['VegetationType'] = np.arange(0, 6) # Create radiation, soil moisture and Vegetation objects PD_D = PrecipitationDistribution(mean_storm = data['mean_storm_dry'], \ mean_interstorm = data['mean_interstorm_dry'], mean_storm_depth = data['mean_storm_depth_dry']) PD_W = PrecipitationDistribution(mean_storm = data['mean_storm_wet'], \ mean_interstorm = data['mean_interstorm_wet'], mean_storm_depth = data['mean_storm_depth_wet']) Rad = Radiation(grid) Rad_PET = Radiation(grid1) 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, data) # Soil Moisture object VEG = Vegetation(grid, data) # Vegetation object vegca = VegCA(grid, data) # Cellular automaton object ##########