"""analysis of results using signed distance functions""" import py_rootbox as rb import numpy as np import matplotlib.pyplot as plt rs = rb.RootSystem() name = "Brassica_oleracea_Vansteenkiste_2014" rs.readParameters("modelparameter/" + name + ".xml") rs.initialize() rs.simulate(120) # Soil core analysis r, depth, layers = 10, 100., 100 soilcolumn = rb.SDF_PlantContainer(r, r, depth, False) # in the center of the root soilcolumn2 = rb.SDF_RotateTranslate(soilcolumn, 0, 0, rb.Vector3d(10, 0, 0)) # shift 10 cm # pick one geometry for further analysis geom = soilcolumn z_ = np.linspace(0, -1 * depth, layers) fig, axes = plt.subplots(nrows = 1, ncols = 4, figsize = (16, 8)) for a in axes: a.set_xlabel('RLD (cm/cm)') a.set_ylabel('Depth (cm)') # Make a root length distribution ana = rb.SegmentAnalyser(rs) rl_ = ana.distribution("length", 0., depth, layers, True) axes[0].set_title('All roots (120 days)') axes[0].plot(rl_, z_)
"""small example in a container""" import py_rootbox as rb rootsystem = rb.RootSystem() # Open plant and root parameter from a file name = "Anagallis_femina_Leitner_2010" rootsystem.readParameters("modelparameter/" + name + ".xml") # Create and set geometry # 1.creates a cylindrical soil core with top radius 5 cm, bot radius 5 cm, height 50 cm, not square but circular soilcore = rb.SDF_PlantContainer(5, 5, 40, False) # 2. creates a square 27*27 cm containter with height 1.4 cm rhizotron = rb.SDF_PlantBox(1.4, 27, 27) # Pick 1, or 2 rootsystem.setGeometry(soilcore) # soilcore, or rhizotron # Initialize rootsystem.initialize() # Simulate rootsystem.simulate(60) # days # Export final result (as vtp) rootsystem.write("../results/example_1b.vtp") # Export container geometry as Paraview Python script rootsystem.write("../results/example_1b.py")
import py_rootbox as rb import math rs = rb.RootSystem() # Open plant and root parameter from a file name = "Zea_mays_4_Leitner_2014" rs.openFile(name) # 1. Creates a square rhizotron r*r, with height h, rotated around the x-axis r, h, alpha = 20, 4, 45 rhizotron2 = rb.SDF_PlantContainer(r,r,h,True) posA = rb.Vector3d(0,r,-h/2) # origin before rotation A = rb.Matrix3d.rotX(alpha/180.*math.pi) posA = A.times(posA) # origin after rotation rotatedRhizotron = rb.SDF_RotateTranslate(rhizotron2,alpha,0,posA.times(-1)) # 2. A split pot experiment topBox = rb.SDF_PlantBox(22,20,5) sideBox = rb.SDF_PlantBox(10,20,35) left = rb.SDF_RotateTranslate(sideBox, rb.Vector3d(-6,0,-5)) right = rb.SDF_RotateTranslate(sideBox, rb.Vector3d(6,0,-5)) box_ = rb.std_vector_SDF_() box_.append(topBox) box_.append(left) box_.append(right) splitBox = rb.SDF_Union(box_) # 3. Rhizotubes as obstacles box = rb.SDF_PlantBox(96,126,130) # box rhizotube = rb.SDF_PlantContainer(6.4,6.4,96,False) # a single rhizotube
import py_rootbox as rb import math rootsystem = rb.RootSystem() name = "Zea_mays_4_Leitner_2014" # Open plant and root parameter from a file rootsystem.openFile(name) # 1. creates a square rhizotron r*r, with height h, rotated around the x-axis for angle alpha r = 20 h = 4 alpha = 45 rhizotron2 = rb.SDF_PlantContainer(r, r, h, True) posA = rb.Vector3d(0, r, -h / 2) # origin before rotation A = rb.Matrix3d.rotX(alpha / 180. * math.pi) posA = A.times(posA) # origin after rotation rotatedRhizotron = rb.SDF_RotateTranslate(rhizotron2, alpha, 0, posA.times(-1)) # 2. A split pot experiment topBox = rb.SDF_PlantBox(22, 20, 5) sideBox = rb.SDF_PlantBox(10, 20, 35) left = rb.SDF_RotateTranslate(sideBox, rb.Vector3d(-6, 0, -5)) right = rb.SDF_RotateTranslate(sideBox, rb.Vector3d(6, 0, -5)) box_ = rb.std_vector_SDF_() box_.append(topBox) box_.append(left) box_.append(right) splitBox = rb.SDF_Union(box_) # 3. Rhizotubes as obstacles