-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwavgenerator.py
More file actions
34 lines (25 loc) · 896 Bytes
/
wavgenerator.py
File metadata and controls
34 lines (25 loc) · 896 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
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as pltdates
import datetime as dt
import wave
import sys
from main_functions import readFile, getData, plotGraph
path = "AZ_LV_Battery_V"
currentfile = readFile("csv_files/" + path + ".csv")
clean = currentfile.loc[currentfile['flagID']!="Bad Data"]
#clean.head(10)
#clean.dtypes
clean = clean.drop_duplicates(subset=['dateTimeUTC'], keep='first')
clean = clean[(clean.value < 200) & (clean.value > 0)]
mean = np.mean(clean['value'])
std_dev = np.std(clean['value'])
wavfile = wave.open("wav_files/" + path + ".wav", mode='wb')
nums = (clean['value'] - mean) / std_dev
nums = np.float32(nums)
bytes = nums.tobytes()
wavfile.setparams((1,4, 44100, 0, 'NONE', 'NONE'))
wavfile.writeframes(bytes)
plt.plot(clean['dateTimeUTC'],clean['value'], 'go', label='Eno River Water Temperature')
plt.show