-
Notifications
You must be signed in to change notification settings - Fork 5
/
FFt_math.py
66 lines (50 loc) · 1.56 KB
/
FFt_math.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 4 09:39:20 2021
@author: bob
"""
from os import devnull, path, makedirs
import numpy as np
read_data=[]
def readCavDat(fileName):
header_Data=[]
with open(fileName) as f:
for lin in range(28):
header_Data.append(f.readline())
read_data = f.readlines()
f.close()
return(read_data, header_Data)
# Number of sample points
def parseCavDat(read_data):
cavDat1 = []
cavDat2 = []
cavDat3 = []
cavDat4 = []
for red in read_data:
cavDat1.append(float(red[0:8]))
if red[10:18] != '':
cavDat2.append(float(red[10:18]))
if red[20:28] != '':
cavDat3.append(float(red[20:28]))
if red[30:38] != '':
cavDat4.append(float(red[30:38]))
#print(cavDat3)
return(cavDat1,cavDat2,cavDat3,cavDat4)
def dummyFileCreator(pathToDatafile):
# print(pathToDatafile)
data, Header = readCavDat("1234_20210617_1227")
brkFile='0/'
indxFilName = pathToDatafile.find(brkFile,0)
NewFileName=pathToDatafile[indxFilName+2:]+"_microphonics.dat"
f = open(pathToDatafile+"/"+NewFileName, "x")
for i in range(len(Header)):
f.write(str(Header[i]))
cavDat1, cavDat2,cavDat3, cavDat4 = parseCavDat(data)
# print(len(cavDat1))
for i in range(len(cavDat1)):
f.write(str(cavDat1[i])+"\n")
f.close()
return
def compatibleMkdirs(filename):
makedirs(path.dirname(filename), exist_ok=True)
return (filename)