-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_data.py
More file actions
49 lines (34 loc) · 1013 Bytes
/
process_data.py
File metadata and controls
49 lines (34 loc) · 1013 Bytes
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
import numpy as np
from scipy.io import loadmat
from typing import Union
import os
DATA_DIR = 'data'
def get_states_and_values() -> Union[np.ndarray, np.ndarray]:
"""Load states and values from Haimin's data file
returns:
states: states of CBF
values: values of CBF
"""
X = load_data('X')
y = load_data('y')
states = X[:, :6]
values = y[:, 0]
test_sizes(states, values)
return states, values
def load_data(name: str) -> np.ndarray:
"""Load data from MATLAB file and store as np array
params:
* name: .mat filename of MATLAB array
returns:
* numpy array of datapoints
"""
data = loadmat(os.path.join(DATA_DIR, name))
return np.array(data[name])
def test_sizes(arr1: np.ndarray, arr2: np.ndarray):
"""Assert that there are the same number of elements in two arrays
params:
* arr1, arr2
"""
assert(arr1.shape[0] == arr2.shape[0])
if __name__ == '__main__':
get_states_and_values()