Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
JPSfire
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JuPedSim
JPSfire
Commits
94b5e779
Commit
94b5e779
authored
6 years ago
by
Ben Hein
Browse files
Options
Downloads
Patches
Plain Diff
update readout script for toxicity analysis
parent
9467d19f
Branches
88-ensure-pm-does-not-leak-memory
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
demos/0_demo/JuPedSim/readout_toxicity.py
+47
-69
47 additions, 69 deletions
demos/0_demo/JuPedSim/readout_toxicity.py
with
47 additions
and
69 deletions
demos/0_demo/JuPedSim/readout_toxicity.py
+
47
−
69
View file @
94b5e779
...
@@ -3,80 +3,58 @@ import numpy as np
...
@@ -3,80 +3,58 @@ import numpy as np
import
xml.etree.ElementTree
as
ET
import
xml.etree.ElementTree
as
ET
import
math
import
math
def
label
(
quantity
):
if
quantity
==
'
E
'
:
return
'
Extinction Coefficient (1/m)
'
if
quantity
==
'
FED_In
'
:
return
'
FED Incapacitation
'
#todo:
#"CO2 concentration (ppm)","CO concentration (ppm)",
#"HCN concentration (ppm)", "HCl concentration (ppm)", "FED Heat Dose",
#"FEC Smoke", "FIC Impairment", "FIC Incapacitation"
########## change here ##########
#number of agents
N
=
50
#todo: parse from traj.xml
# possible quantities are: 'E','c_CO2','c_CO','c_HCl','c_HCN','FED_In','FEC_Smoke','FED_Heat','FIC_Im','FED_In'
quantity_select
=
'
E
'
#################################
### traj XML readin
### traj XML readin
tree
=
ET
.
parse
(
'
toxicity_output_jpsfire.xml
'
)
tree
=
ET
.
parse
(
'
toxicity_output_jpsfire.xml
'
)
root
=
tree
.
getroot
()
root
=
tree
.
getroot
()
### empty arrays
t
=
E
=
co2
=
co
=
hcn
=
hcl
=
fed_in
=
fec_smoke
=
fed_heat
=
fic_im
=
fic_in
=
np
.
array
([])
### readout
### readout
data
=
[]
for
frame
in
root
.
iter
(
'
frame
'
):
for
frame
in
root
.
iter
(
'
frame
'
):
frame_id
=
int
(
frame
.
get
(
'
ID
'
))
frame_id
=
int
(
frame
.
get
(
'
ID
'
))
for
agent
in
frame
.
iter
(
'
agent
'
):
for
agent
in
frame
.
iter
(
'
agent
'
):
agent_id
=
int
(
agent
.
get
(
'
ID
'
))
# todo: is it necessary to plot agent specifically
agent_id
=
int
(
agent
.
get
(
'
ID
'
))
t
=
np
.
append
(
t
,
float
(
agent
.
get
(
'
t
'
)))
t
=
float
(
agent
.
get
(
'
t
'
))
E
=
np
.
append
(
E
,
float
(
agent
.
get
(
'
E
'
)))
quantity
=
float
(
agent
.
get
(
'
%s
'
%
quantity_select
))
co2
=
np
.
append
(
co2
,
float
(
agent
.
get
(
'
c_CO2
'
)))
data
+=
[
agent_id
,
t
,
quantity
]
co
=
np
.
append
(
co
,
float
(
agent
.
get
(
'
c_CO
'
)))
data
=
np
.
array
(
data
).
reshape
((
-
1
,
3
))
hcl
=
np
.
append
(
hcl
,
float
(
agent
.
get
(
'
c_HCl
'
)))
hcn
=
np
.
append
(
hcn
,
float
(
agent
.
get
(
'
c_HCN
'
)))
for
i
in
range
(
1
,
N
+
1
):
fed_in
=
np
.
append
(
fed_in
,
float
(
agent
.
get
(
'
FED_In
'
)))
fec_smoke
=
np
.
append
(
fec_smoke
,
float
(
agent
.
get
(
'
FEC_Smoke
'
)))
ids_all
=
data
[:,
0
]
fed_heat
=
np
.
append
(
fed_heat
,
float
(
agent
.
get
(
'
FED_Heat
'
)))
time_all
=
data
[:,
1
]
fic_im
=
np
.
append
(
fic_im
,
float
(
agent
.
get
(
'
FIC_Im
'
)))
quantity_all
=
data
[:,
2
]
fic_in
=
np
.
append
(
fic_in
,
float
(
agent
.
get
(
'
FED_In
'
)))
time_max
=
np
.
max
(
time_all
)
### prepare for plotting
quantity_max
=
np
.
max
(
quantity_all
)
values
=
[
E
,
co2
,
co
,
hcn
,
hcl
,
fed_in
,
fed_heat
,
fec_smoke
,
fic_im
,
fic_in
]
labels
=
[
"
Extinction Coefficient (1/m)
"
,
"
CO2 concentration (ppm)
"
,
"
CO concentration (ppm)
"
,
if
i
==
1
:
"
HCN concentration (ppm)
"
,
"
HCl concentration (ppm)
"
,
"
FED Incapacitation
"
,
"
FED Heat Dose
"
,
plt
.
plot
(
time_all
[
ids_all
==
1
],
quantity_all
[
ids_all
==
1
],
'
b
'
,
lw
=
2
,
label
=
'
agent time series
'
)
"
FEC Smoke
"
,
"
FIC Impairment
"
,
"
FIC Incapacitation
"
]
plt
.
plot
(
time_all
[
ids_all
==
i
],
quantity_all
[
ids_all
==
i
],
'
b
'
,
lw
=
2
,
zorder
=
1
)
units
=
[
"
1/m
"
,
"
ppm
"
,
"
ppm
"
,
"
ppm
"
,
"
ppm
"
,
""
,
""
,
""
,
""
]
#plt.plot([0,time_max], [1, 1], "r--", lw=2.5, label='%s threshold' %quantity_select) #threshold
plt
.
plot
([
0
,
time_max
],
[
quantity_max
,
quantity_max
],
"
k--
"
,
lw
=
2.5
,
label
=
r
'
%s max.
'
%
quantity_select
)
max_values
=
[]
plt
.
xlabel
(
"
time [s]
"
)
plt
.
ylabel
(
"
%s
"
%
label
(
quantity_select
))
for
i
in
values
:
plt
.
xlim
(
50
)
# mean premovement time
max_values
.
append
(
max
(
i
))
plt
.
ticklabel_format
(
style
=
'
sci
'
,
axis
=
'
y
'
,
scilimits
=
(
0
,
0
))
i
[
i
==
0
]
=
float
(
'
nan
'
)
plt
.
ylim
()
plt
.
legend
(
loc
=
0
)
### extinction plot
plt
.
savefig
(
'
toxicity_output_plot_%s.png
'
%
quantity_select
,
dpi
=
400
)
plt
.
show
()
plt
.
plot
(
t
,
E
,
'
bx
'
)
\ No newline at end of file
plt
.
plot
([
0
,
max
(
t
)],
[
max_values
[
0
],
max_values
[
0
]],
'
r-
'
,
label
=
'
max = %.2f %s
'
%
(
max_values
[
0
],
units
[
0
]))
plt
.
xlabel
(
"
Time
"
)
plt
.
ylabel
(
labels
[
0
])
plt
.
ylim
(
0
)
plt
.
legend
()
plt
.
savefig
(
'
toxicity_output_plot_0_extinction.png
'
)
plt
.
close
()
### concentration plot
plt
.
figure
(
figsize
=
(
12
,
9
))
for
i
in
range
(
1
,
5
):
plt
.
subplot
(
2
,
2
,
i
)
plt
.
plot
(
t
,
values
[
i
],
'
bx
'
)
plt
.
plot
([
0
,
max
(
t
)],
[
max_values
[
i
],
max_values
[
i
]],
'
r-
'
,
label
=
'
max = %.2f %s
'
%
(
max_values
[
i
],
units
[
i
]))
plt
.
xlabel
(
"
Time
"
)
plt
.
ylabel
(
labels
[
i
])
plt
.
ylim
(
0
)
plt
.
legend
()
plt
.
savefig
(
'
toxicity_output_plot_1_concentrations.png
'
)
plt
.
close
()
plt
.
figure
(
figsize
=
(
12
,
9
))
values2
=
[
fed_in
,
fec_smoke
,
fed_heat
,
fic_im
,
fic_in
]
for
j
in
range
(
5
,
9
):
plt
.
subplot
(
2
,
2
,
j
-
4
)
plt
.
plot
(
t
,
values
[
j
],
'
bx
'
)
plt
.
plot
([
0
,
max
(
t
)],
[
max_values
[
j
],
max_values
[
j
]],
'
r-
'
,
label
=
'
max = %.3f %s
'
%
(
max_values
[
j
],
units
[
j
]))
plt
.
xlabel
(
"
Time
"
)
plt
.
ylabel
(
labels
[
j
])
plt
.
ylim
(
0
)
plt
.
legend
()
plt
.
savefig
(
'
toxicity_output_plot_2_FED_FEC_FIC.png
'
)
plt
.
close
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment