4.backup
This commit is contained in:
parent
a4700cfb05
commit
8b97b8f304
24
jar_functions.py
Normal file
24
jar_functions.py
Normal 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
|
@ -2,35 +2,31 @@ import matplotlib.pyplot as plt
|
|||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import IPython
|
import IPython
|
||||||
|
import numpy as np
|
||||||
from IPython import embed
|
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.plot(t, f)
|
||||||
|
|
||||||
|
plt.xlabel('time [s]')
|
||||||
|
plt.ylabel('frequency [Hz]')
|
||||||
|
plt.xlim([-10,200])
|
||||||
|
plt.title('second try because first try was sold out')
|
||||||
plt.show()
|
plt.show()
|
Loading…
Reference in New Issue
Block a user