FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CRootBox/python/example3a.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
/
example3a.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
76 lines (65 loc) · 2.03 KB
Breadcrumbs
CRootBox
/
python
/
example3a.py
Copy path
File metadata and controls
76 lines (65 loc) · 2.03 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
"""root system length over time, root tip distriubtion"""
import
py_rootbox
as
rb
from
rb_tools
import
*
import
numpy
as
np
import
matplotlib
.
pyplot
as
plt
rs
=
rb
.
RootSystem
()
name
=
"Brassica_oleracea_Vansteenkiste_2014"
rs
.
readParameters
(
"modelparameter/"
+
name
+
".xml"
)
rs
.
initialize
()
simtime
=
60.
# days
dt
=
1.
N
=
round
(
simtime
/
dt
)
# steps
# Plot some scalar value over time
stype
=
"length"
stype_str
=
"length (cm)"
v_
=
np
.
zeros
(
N
)
v1_
=
np
.
zeros
(
N
)
v2_
=
np
.
zeros
(
N
)
v3_
=
np
.
zeros
(
N
)
for
i
in
range
(
0
,
N
):
rs
.
simulate
(
dt
)
t
=
v2a
(
rs
.
getParameter
(
"type"
))
v
=
v2a
(
rs
.
getParameter
(
stype
))
v_
[
i
]
=
np
.
sum
(
v
)
v1_
[
i
]
=
np
.
sum
(
v
[
t
==
1
])
v2_
[
i
]
=
np
.
sum
(
v
[
t
==
2
])
v3_
[
i
]
=
np
.
sum
(
v
[
t
==
3
])
t_
=
np
.
linspace
(
dt
,
N
*
dt
,
N
)
plt
.
plot
(
t_
,
v_
)
plt
.
plot
(
t_
,
v1_
)
plt
.
plot
(
t_
,
v2_
)
plt
.
plot
(
t_
,
v3_
)
plt
.
xlabel
(
"time (days)"
)
plt
.
ylabel
(
stype_str
)
plt
.
legend
([
"total"
,
"tap root"
,
"lateral"
,
"2. order lateral"
])
plt
.
savefig
(
"../results/example_3a.png"
)
plt
.
show
()
# Find root tips and bases (two approaches)
rs
.
initialize
()
# <------------
rs
.
simulate
(
7
)
# 7 days young....
print
(
rs
.
getNumberOfNodes
(),
"nodes"
)
print
(
rs
.
getNumberOfSegments
(),
"segments"
)
# Use polyline representation of the roots
polylines
=
rs
.
getPolylines
()
bases
=
np
.
zeros
((
len
(
polylines
),
3
))
tips
=
np
.
zeros
((
len
(
polylines
),
3
))
for
i
,
r
in
enumerate
(
polylines
):
bases
[
i
, :]
=
[
r
[
0
].
x
,
r
[
0
].
y
,
r
[
0
].
z
]
tips
[
i
, :]
=
[
r
[
-
1
].
x
,
r
[
-
1
].
y
,
r
[
-
1
].
z
]
# Or, use node indices to find tip or base nodes
nodes
=
vv2a
(
rs
.
getNodes
())
tipI
=
rs
.
getRootTips
()
baseI
=
rs
.
getRootBases
()
# Plot results (1st approach)
plt
.
title
(
"Top view"
)
plt
.
xlabel
(
"cm"
)
plt
.
ylabel
(
"cm"
)
plt
.
scatter
(
nodes
[
baseI
,
0
],
nodes
[
baseI
,
1
],
c
=
"g"
,
label
=
"root bases"
)
plt
.
scatter
(
nodes
[
tipI
,
0
],
nodes
[
tipI
,
1
],
c
=
"r"
,
label
=
"root tips"
)
plt
.
savefig
(
"../results/example_3a2.png"
)
plt
.
show
()
# check if the two approaches yield the same result
uneq
=
np
.
sum
(
nodes
[
baseI
, :]
!=
bases
)
+
np
.
sum
(
nodes
[
tipI
, :]
!=
tips
)
print
(
"Unequal tips and basals:"
,
uneq
)
print
(
"done."
)
Back
|
FazBrowse Home
|
New Git URL