This commit is contained in:
xaver 2020-06-24 17:18:33 +02:00
parent a4700cfb05
commit 8b97b8f304
2 changed files with 40 additions and 20 deletions

24
jar_functions.py Normal file
View File

@ -0,0 +1,24 @@
import os
def parse_dataset(dataset_name):
assert(os.path.exists(dataset_name))
f = open(dataset_name, 'r')
lines = f.readlines()
f.close()
time = []
frequency = []
amplitude = []
for i in range(len(lines)):
l = lines[i].strip()
if len(l) > 0 and l[0] is not '#':
temp = list(map(float, l.split()))
time.append(temp[0])
frequency.append(temp[1])
amplitude.append(temp[2])
return time, frequency, amplitude

View File

@ -2,35 +2,31 @@ import matplotlib.pyplot as plt
import os
import glob
import IPython
import numpy as np
from IPython import embed
from jar_functions import parse_dataset
dataset = os.path.join('D:\\', 'jar_project', 'JAR', '2020-06-22-ac', 'beats-eod.dat')
t, f, a = parse_dataset(dataset)
avg_frequency = np.mean(f)
print(avg_frequency)
def parse_dataset(dataset_name):
assert(os.path.exists(dataset_name))
f = open(dataset_name, 'r')
lines = f.readlines()
f.close()
time = []
frequency = []
amplitude = []
for i in range(len(lines)):
print(lines[i])
l = lines[i].strip()
if len(l) > 0 and l[0] is not '#':
temp = list(map(float, l.split()))
time.append(temp[0])
frequency.append(temp[1])
amplitude.append(temp[2])
return time, frequency, amplitude
dataset = os.path.join('D:\\', 'jar_project', 'JAR', '2020-06-22-ac', 'beats-eod.dat')
t, f, a = parse_dataset(dataset)
plt.plot(t, f)
plt.show()
plt.xlabel('time [s]')
plt.ylabel('frequency [Hz]')
plt.xlim([-10,200])
plt.title('second try because first try was sold out')
plt.show()