import numpy as np from landlab import RasterModelGrid # Create a 10x10 grid grid = RasterModelGrid((10,10), 1.0) # Add a new field of zeros to store tree density data grid.add_zeros('tree_density', at='node') # Set some random values for tree density (0 to 100 trees per hectare) tree_density = np.random.randint(0, 101, size=grid.number_of_nodes) # Assign the tree density values to the grid grid.at_node['tree_density'] = tree_density
import numpy as np from landlab import RasterModelGrid # Create a 20x20 grid grid = RasterModelGrid((20,20), 0.5) # Add a new field of zeros to store soil temperature data grid.add_zeros('soil_temperature', at='node') # Set some initial soil temperature values (10 to 30 degrees Celsius) soil_temp = np.random.uniform(10.0, 30.0, size=grid.number_of_nodes) # Assign the soil temperature values to the grid grid.at_node['soil_temperature'] = soil_tempIn this example, a new field called 'soil_temperature' is added to the grid using the add_zeros method. Initial soil temperature values are randomly generated and assigned to each grid node using the at_node property. Package library: Landlab