forked from Plant-Root-Soil-Interactions-Modelling/CRootBox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_tips.py
100 lines (81 loc) · 2.34 KB
/
example_tips.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import py_rootbox as rb
import numpy as np
import matplotlib.pyplot as plt
from math import sqrt
rootsystem = rb.RootSystem()
name = "zeamays_test" # anagallis2010, zeamays_test, ZeaMays_Leitner et al.(2010)
#
# Open plant and root parameter from a file
#
rootsystem.openFile(name,"modelparameter/")
# rootsystem.writeParameters() # not exposed to python yet
#
# Initialize
#
rootsystem.initialize(4,5) # TODO expose default values
#
# Simulate
#
simtime = 60;
rootsystem.simulate(simtime);
#
# Analyse root system
#
tips = rootsystem.getRootTips()
notips = len(tips)
ana = rb.AnalysisSDF(rootsystem)
totalLength = ana.getSummed(rb.ScalarType.length)
l = ana.getScalar(rb.ScalarType.length)
nos = len(l)
print('\nNumber of root tips is '+str(notips))
print('Number of nodes is ' + str(rootsystem.getNumberOfNodes()))
print('Number of segmentes is '+str(nos))
print('Length of root system is '+ str(totalLength)+ " cm")
rp1 = rootsystem.getRootTypeParameter(1)
rp2 = rootsystem.getRootTypeParameter(2)
rp3 = rootsystem.getRootTypeParameter(3)
rp4 = rootsystem.getRootTypeParameter(4)
print('\nTropisms')
print('#1 Type '+str(rp1.tropismT)+', N '+str(rp1.tropismN)+', sigma '+str(rp1.tropismS)+', dx '+str(rp1.dx))
print('#2 Type '+str(rp2.tropismT)+', N '+str(rp2.tropismN)+', sigma '+str(rp2.tropismS)+', dx '+str(rp2.dx))
print('#3 Type '+str(rp3.tropismT)+', N '+str(rp3.tropismN)+', sigma '+str(rp3.tropismS)+', dx '+str(rp3.dx))
print('#4 Type '+str(rp4.tropismT)+', N '+str(rp4.tropismN)+', sigma '+str(rp4.tropismS)+', dx '+str(rp4.dx))
#
# Analyse tip distribution
#
tipcoords = np.zeros((notips,3))
z_ = np.zeros(notips)
l_ = np.zeros(notips)
#
# Copy everything we need
#
c=0;
for t in tips:
tipcoords[c,0] = t.x
tipcoords[c,1] = t.y
tipcoords[c,2] = t.z
z_[c] = t.z
l_[c] = sqrt(t.x*t.x + t.y*t.y)
c+=1
#
# Figure params
#
lbins = 10
lrange = (0,10)
zbins = 120
zrange = (-120,0)
#
# Plot histograms
#
plt.figure(1)
plt.hist(l_, bins=lbins, range=lrange)
plt.title("Root tip radial distance")
plt.show(False)
hl, bins = np.histogram(l_, bins=lbins, range=lrange)
np.savetxt('radialdistribution.txt',hl); # save results
plt.figure(2)
plt.hist(z_, bins=zbins, range=zrange)
plt.title("Root tip depth")
plt.show()
hz, bins = np.histogram(z_, bins=zbins, range=zrange)
np.savetxt('depthdistribution.txt',hz); # save results