FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CRootBox/python/example3d.py at master · Plant-Root-Soil-Interactions-Modelling/CRootBox · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
Plant-Root-Soil-Interactions-Modelling
/
CRootBox
Public
Notifications
You must be signed in to change notification settings
Fork
12
Star
20
Code
Issues
3
Pull requests
3
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
CRootBox
/
python
/
example3d.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
89 lines (71 loc) · 2.13 KB
Breadcrumbs
CRootBox
/
python
/
example3d.py
Copy path
File metadata and controls
89 lines (71 loc) · 2.13 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
"""sensitivity analysis: insertion anlge on root tip distribution"""
import
py_rootbox
as
rb
import
math
from
multiprocessing
import
Pool
import
numpy
as
np
import
matplotlib
.
pyplot
as
plt
# sets all standard deviation to value*s
def
set_all_sd
(
rs
,
s
):
for
p
in
rs
.
getRootTypeParameter
():
p
.
lbs
=
p
.
lb
*
s
p
.
las
=
p
.
la
*
s
p
.
lns
=
p
.
ln
*
s
p
.
nobs
=
p
.
nob
*
s
p
.
rs
=
p
.
r
*
s
p
.
a_s
=
p
.
a
*
s
# Parameters
name
=
"Triticum_aestivum_a_Bingham_2011"
simtime
=
20
N
=
50
# resolution of paramter
runs
=
10
# iterations
theta0_
=
np
.
linspace
(
0
,
math
.
pi
/
2
,
N
)
# One simulation
def
simulate
(
i
):
rs
=
rb
.
RootSystem
()
rs
.
readParameters
(
"modelparameter/"
+
name
+
".xml"
)
set_all_sd
(
rs
,
0.
)
# set all sd to zero
rs
.
initialize
()
# copy to tap to basal root parameters
# vary parameter
p1
=
rs
.
getRootTypeParameter
(
1
)
# tap root
p4
=
rs
.
getRootTypeParameter
(
4
)
# basal roots
p1
.
theta
=
theta0_
[
i
]
p4
.
theta
=
theta0_
[
i
]
# simulation
rs
.
initialize
()
# build again with theta0
rs
.
simulate
(
simtime
,
True
)
# target
roots
=
rs
.
getPolylines
()
depth
=
0.
rad_dist
=
0.
for
r
in
roots
:
depth
+=
r
[
-
1
].
z
rad_dist
+=
math
.
hypot
(
r
[
-
1
].
x
,
r
[
-
1
].
y
)
depth
/=
len
(
roots
)
rad_dist
/=
len
(
roots
)
return
depth
,
rad_dist
depth_
=
np
.
zeros
(
N
)
rad_dist_
=
np
.
zeros
(
N
)
for
r
in
range
(
0
,
runs
):
# Parallel execution
param
=
[]
# param is a list of tuples
for
i
in
range
(
0
,
N
):
param
.
append
((
i
,))
pool
=
Pool
()
output
=
pool
.
starmap
(
simulate
,
param
)
pool
.
close
()
# Copy results
for
i
,
o
in
enumerate
(
output
):
depth_
[
i
]
+=
(
o
[
0
]
/
runs
)
rad_dist_
[
i
]
+=
(
o
[
1
]
/
runs
)
# Figure
fig
,
axes
=
plt
.
subplots
(
nrows
=
1
,
ncols
=
2
,
figsize
=
(
10
,
8
))
axes
[
0
].
set_xlabel
(
'Insertion angle theta (-)'
)
axes
[
1
].
set_xlabel
(
'Insertion angle theta (-)'
)
axes
[
0
].
set_ylabel
(
'Mean tip depth (cm)'
)
axes
[
1
].
set_ylabel
(
'Mean tip radial distance (cm)'
)
axes
[
0
].
plot
(
theta0_
,
depth_
)
axes
[
1
].
plot
(
theta0_
,
rad_dist_
)
fig
.
subplots_adjust
()
plt
.
savefig
(
"../results/example_3d.png"
)
plt
.
show
()
print
(
"done."
)
Back
|
FazBrowse Home
|
New Git URL