Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matthias Mayr
AS1 Activity Recognition
Commits
8ccbc33c
Commit
8ccbc33c
authored
Mar 25, 2020
by
pandersson
Browse files
Adds script for data visualization
parent
8809e4e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/data_visualization.py
0 → 100644
View file @
8ccbc33c
# Activity Recognition
import
matplotlib.pyplot
as
plt
import
statistics
import
glob
import
sys
import
numpy
as
np
def
main
():
person
=
sys
.
argv
[
1
]
# Frida or Momina
visualization
=
sys
.
argv
[
2
]
# ACC or GYR
verbose
=
True
if
len
(
sys
.
argv
)
>
3
else
False
data_path
=
'../Data_'
+
person
+
'/'
data_paths
=
(
glob
.
glob
(
data_path
+
'/*.txt'
))
data_x
=
[]
data_y
=
[]
data_z
=
[]
all_nbr_measurements
=
[]
for
path
in
data_paths
:
nbr_measurements
=
0
with
open
(
path
,
'r'
)
as
f
:
for
l
in
f
:
l
=
l
.
split
(
'
\t
'
)
if
visualization
==
l
[
1
]:
data_x
.
append
(
float
(
l
[
2
]))
data_y
.
append
(
float
(
l
[
3
]))
data_z
.
append
(
float
(
l
[
4
][:
-
1
]))
# don't include newline
nbr_measurements
+=
1
if
verbose
:
print
(
"Mean value x: {:0.3f}"
.
format
(
statistics
.
mean
(
data_x
)))
print
(
"Mean value y: {:0.3f}"
.
format
(
statistics
.
mean
(
data_y
)))
print
(
"Mean value z: {:0.3f}"
.
format
(
statistics
.
mean
(
data_z
)))
all_nbr_measurements
.
append
(
nbr_measurements
)
print
(
"Mean of means for file {:s}: {:0.3f}"
.
format
(
path
,
(
statistics
.
mean
(
data_x
)
+
statistics
.
mean
(
data_y
)
+
statistics
.
mean
(
data_z
))
/
3
))
cumulative_all_nbr_measurements
=
np
.
cumsum
(
all_nbr_measurements
)
plt
.
figure
(
figsize
=
(
24
,
9
))
plt
.
suptitle
(
visualization
+
' data visualization'
)
plt
.
subplot
(
311
)
plt
.
plot
(
data_x
)
for
nbr
in
cumulative_all_nbr_measurements
:
plt
.
axvline
(
nbr
,
color
=
'r'
)
plt
.
subplot
(
312
)
plt
.
plot
(
data_y
)
for
nbr
in
cumulative_all_nbr_measurements
:
plt
.
axvline
(
nbr
,
color
=
'r'
)
plt
.
subplot
(
313
)
plt
.
plot
(
data_z
)
for
nbr
in
cumulative_all_nbr_measurements
:
plt
.
axvline
(
nbr
,
color
=
'r'
)
plt
.
show
()
if
__name__
==
"__main__"
:
main
()
script_frida.py
→
src/
script_frida.py
View file @
8ccbc33c
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment