Skip to content
Snippets Groups Projects
Commit 52446e91 authored by milenabaj's avatar milenabaj
Browse files

example script how to load data for car simulation

parent e2c4f56d
Branches
No related tags found
No related merge requests found
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment