PET_ = np.zeros([365,grid.number_of_cells]) Rad_Factor = np.empty([365,grid.number_of_cells]) EP30 = np.empty([365, grid.number_of_cells]) # 30 day average PET to determine season PET_threshold = 0 # Initializing PET_threshold to ETThresholddown ## Initializing inputs for Soil Moisture object grid['cell']['LiveLeafAreaIndex'] = 1.6 * np.ones( grid.number_of_cells ) SM._SO = 0.59 * np.ones(grid.number_of_cells) # Initializing Soil Moisture Tg = 365 # Growing season in days ## Calculate current time in years such that Julian time can be calculated current_time = 0 # Start from first day of June for i in range(0,365): Rad.update( float(i)/365.25) PET_Tree.update( float(i)/365.25 ) PET_Shrub.update( float(i)/365.25 ) PET_Grass.update( float(i)/365.25 ) PET_[i] = [PET_Grass._PET_value, PET_Shrub._PET_value, PET_Tree._PET_value, 0., PET_Shrub._PET_value, PET_Tree._PET_value] Rad_Factor[i] = grid['cell']['RadiationFactor'] if i < 30: if i == 0: EP30[0] = PET_[0] else: EP30[i] = np.mean(PET_[:i],axis = 0) else: EP30[i] = np.mean(PET_[i-30:i], axis = 0)
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. """ rad.update(current_time) """ Create a figure window available from pyplot library. This allows separating figures while plotting multiple figures. """ plt.figure(0) """ Plot the cellular field 'TotalShortWaveRadiation' that is available on the grid. imshow_grid is a Landlab plotting tool that reads the input of grid, the variable name that needs to be plotted, and type of field (whether it is 'cell' or 'node', etc... It also reads optional inputs (keywords), grid_units (units of grid X and Y axes , e.g. 'm'). For more options, please refer documentation for landlab.plot.imshow. """ imshow_grid(grid, 'TotalShortWaveRadiation',
PET_ = np.zeros([365, grid.number_of_cells]) Rad_Factor = np.empty([365, grid.number_of_cells]) EP30 = np.empty([365, grid.number_of_cells ]) # 30 day average PET to determine season PET_threshold = 0 # Initializing PET_threshold to ETThresholddown ## Initializing inputs for Soil Moisture object grid['cell']['LiveLeafAreaIndex'] = 1.6 * np.ones(grid.number_of_cells) SM._SO = 0.59 * np.ones(grid.number_of_cells) # Initializing Soil Moisture #TG = np.array([104, 365, 365, 365, 365, 365])#365 # Growing season in days ## Calculate current time in years such that Julian time can be calculated current_time = 0 # Start from first day of June for i in range(0, 365): Rad.update(float(i) / 365.25) PET_Tree.update(float(i) / 365.25) PET_Shrub.update(float(i) / 365.25) PET_Grass.update(float(i) / 365.25) PET_[i] = [ PET_Grass._PET_value, PET_Shrub._PET_value, PET_Tree._PET_value, 0., PET_Shrub._PET_value, PET_Tree._PET_value ] Rad_Factor[i] = grid['cell']['RadiationFactor'] if i < 30: if i == 0: EP30[0] = PET_[0] else: EP30[i] = np.mean(PET_[:i], axis=0) else: EP30[i] = np.mean(PET_[i - 30:i], axis=0)
# 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()