Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
shared
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
02460F20-Advanced Machine Learning - TSAD project
shared
Commits
52446e91
Commit
52446e91
authored
Mar 16, 2020
by
milenabaj
Browse files
Options
Downloads
Patches
Plain Diff
example script how to load data for car simulation
parent
e2c4f56d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
load_data.py
+37
-0
37 additions, 0 deletions
load_data.py
with
37 additions
and
0 deletions
load_data.py
0 → 100644
+
37
−
0
View file @
52446e91
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Example script how to load simulated data.
"""
import
glob
from
scipy.io
import
loadmat
# Load files for given cases only
input_dir
=
'
data/Lira/Synt_data_20052019/
'
min_index
=
7000
max_index
=
18000
file_pattern
=
'
{0}*.mat
'
.
format
(
input_dir
)
# Load data from mat files into python dictionary
data
=
{}
for
filename
in
glob
.
glob
(
file_pattern
):
print
(
'
Loading file: {0}
'
.
format
(
filename
))
defect_type
=
filename
.
split
(
'
_
'
)[
-
2
]
# Get variables
f
=
loadmat
(
filename
)
acc
=
f
[
'
acceleration
'
][
min_index
:
max_index
,:].
reshape
(
1
,
-
1
)
time
=
f
[
'
time
'
][
min_index
:
max_index
,:].
reshape
(
1
,
-
1
)
label
=
f
[
'
type
'
][
min_index
:
max_index
,:].
reshape
(
1
,
-
1
)
severity
=
f
[
'
severity
'
][
min_index
:
max_index
,:].
reshape
(
1
,
-
1
)
# Update dictionary with the data from this file
data
[
filename
]
=
{
'
time
'
:
time
,
'
acc
'
:
acc
,
'
true_labels
'
:
label
,
'
severity
'
:
severity
,
'
defect
'
:
defect_type
}
'''
# Example how to get variables for 1 file:
t = data[
'
data/Lira/Synt_data_20052019/qcar_accelerations_pothole_case8.mat
'
][
'
time
'
]
acc = data[
'
data/Lira/Synt_data_20052019/qcar_accelerations_pothole_case8.mat
'
][
'
acc
'
]
'''
\ 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