|
a |
|
b/Sine Generation/data_generation.py |
|
|
1 |
""" |
|
|
2 |
Created on Tue Dec 24 20:25 2019 |
|
|
3 |
@author: anne marie delaney |
|
|
4 |
eoin brophy |
|
|
5 |
|
|
|
6 |
Script to generate a training and test data set of sine waves |
|
|
7 |
""" |
|
|
8 |
|
|
|
9 |
|
|
|
10 |
import pandas as pd |
|
|
11 |
import numpy as np |
|
|
12 |
import random |
|
|
13 |
|
|
|
14 |
"""Create a training set of sine waves with 10000 records""" |
|
|
15 |
a = np.arange(0.1,0.9,0.02) |
|
|
16 |
x = np.arange(0,20,0.5) |
|
|
17 |
r = np.arange(2,6.1,0.1) |
|
|
18 |
count = 0 |
|
|
19 |
fs = len(x) |
|
|
20 |
y = np.zeros((1,len(x))) |
|
|
21 |
|
|
|
22 |
for n in range(10000): |
|
|
23 |
amp = a[random.randint(0,len(a)-1)] |
|
|
24 |
rad = r[random.randint(0,len(r)-1)] |
|
|
25 |
phase = random.uniform(-1,1)*np.pi |
|
|
26 |
y = np.append(y,amp*np.sin(((2*np.pi*rad*x)+phase)/fs).reshape((1,len(x))),axis = 0) |
|
|
27 |
|
|
|
28 |
data = pd.DataFrame(y[1:][:]) |
|
|
29 |
data.to_csv('./sinedata_v2.csv', header = False, index = False) |
|
|
30 |
|
|
|
31 |
"""Creating a test set of sine waves with 3000 records""" |
|
|
32 |
a = np.arange(0.1,0.9,0.02) |
|
|
33 |
x = np.arange(0,20,0.5) |
|
|
34 |
r = np.arange(2,6.1,0.1) |
|
|
35 |
count = 0 |
|
|
36 |
fs = len(x) |
|
|
37 |
y = np.zeros((1,len(x))) |
|
|
38 |
|
|
|
39 |
for n in range(3000): |
|
|
40 |
amp = a[random.randint(0,len(a)-1)] |
|
|
41 |
rad = r[random.randint(0,len(r)-1)] |
|
|
42 |
phase = random.uniform(-1,1)*np.pi |
|
|
43 |
|
|
|
44 |
y = np.append(y,amp*np.sin(((2*np.pi*rad*x)+phase)/fs).reshape((1,len(x))),axis = 0) |
|
|
45 |
|
|
|
46 |
data = pd.DataFrame(y[1:][:]) |
|
|
47 |
data.to_csv('sinedata_test_v2.csv', header = False, index = False) |