-
Notifications
You must be signed in to change notification settings - Fork 1
/
getFunctions.py
78 lines (56 loc) · 1.99 KB
/
getFunctions.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
67
68
69
70
71
72
73
74
75
76
77
__author__ = 'Anochjhn Iruthayam'
import os
###########################USED BY GUI#############
def getFileList(path, extension):
sampleList = []
for file in os.listdir(path):
if file.endswith(extension):
sampleList.append(file)
return sampleList
def getFileListDepthScan(path, extension):
sampleList = []
for root, dirs, files in os.walk(path):
if len(files) > 0:
for file in files:
if file.endswith(extension):
currentPath = root +"/" + file
sampleList.append(currentPath)
return sampleList
###################################3
def toTime(timePixel):
imageLength = 5000.0
return (1000.0/imageLength)*timePixel
def tokFreq(freqPixel):
imageWidth = 1025.0
return (250.0/imageWidth)*(imageWidth-freqPixel)
def getAllEvents(rootpath):
import EventExtraction
SearchPath = rootpath + "/Spectrogram/"
SavePath = rootpath + "/SpectrogramMarked/"
sampleList = getFileList(SearchPath,".png")
for eventFile in sampleList:
print "Analyzing " + os.path.splitext((eventFile))[0]
#topX to endX is the time range, while topX and bottomY is the frequency range
EventExtraction.findEvent(SearchPath, eventFile, SavePath)
print "Event extraction done!"
def get_all_bat_event(rootpath):
path = rootpath + "SpectrogramMarked/"
listdirectoryTEMP = os.listdir(path)
#eventlist = getFileList(path, ".png")
listdirectory = []
list_event = []
list_event_dir = []
temppath = ""
for dir in listdirectoryTEMP:
if not ".png" in dir:
if not "~" in dir:
listdirectory.append(dir)
#print dir
for dir in listdirectory:
eventlist = getFileList(path+dir, ".png")
for current_event in eventlist:
list_event.append(current_event)
list_event_dir.append(dir)
#print list_event
#print list_event_dir
return list_event, list_event_dir