##// END OF EJS Templates
fix merge conflicts
Juan C. Espinoza -
r1022:0af466e13e36 merge
parent child
Show More
@@ -0,0 +1,113
1 import h5py
2 import numpy
3 import matplotlib.pyplot as plt
4 import glob
5 import os
6
7 #---------------------- Functions ---------------------
8
9 def findFiles(path):
10
11 dirList = []
12 fileList = []
13
14 for thisPath in os.listdir(path):
15 dirList.append(os.path.join(path,thisPath))
16 dirList.sort()
17
18 for thisDirectory in dirList:
19 files = glob.glob1(thisDirectory, "*.hdf5")
20 files.sort()
21 for thisFile in files:
22 fileList.append(os.path.join(thisDirectory,thisFile))
23
24 return fileList
25
26 def readFiles(fileList):
27
28 meteors_array = numpy.zeros((1,4))
29
30 for thisFile in fileList:
31
32 #Leer
33 f1 = h5py.File(thisFile,'r')
34 grp1 = f1['Data']
35 grp2 = grp1['data_output']
36 meteors1 = grp2['table0'][:]
37 meteors_array = numpy.vstack((meteors_array,meteors1))
38 #cerrar
39 f1.close()
40
41 meteors_array = numpy.delete(meteors_array, 0, axis=0)
42 meteors_list = [meteors_array[:,0],meteors_array[:,1],meteors_array[:,2],meteors_array[:,3]]
43 return meteors_list
44
45 def estimateMean(offset_list):
46
47 mean_off = []
48 axisY_off = []
49 axisX_off = []
50
51 for thisOffset in offset_list:
52 mean_aux = numpy.mean(thisOffset, axis = 0)
53 mean_off.append(mean_aux)
54 axisX_off.append(numpy.array([0,numpy.size(thisOffset)]))
55 axisY_off.append(numpy.array([mean_aux,mean_aux]))
56
57 return mean_off, axisY_off, axisX_off
58
59 def plotPhases(offset0, axisY0, axisX0, title):
60 f, axarr = plt.subplots(4, sharey=True)
61 color = ['b','g','r','c']
62 # plt.grid()
63 for i in range(len(offset0)):
64 thisMeteor = offset0[i]
65 thisY = axisY0[i]
66 thisX = axisX0[i]
67 thisColor = color[i]
68
69 opt = thisColor + 'o'
70 axarr[i].plot(thisMeteor,opt)
71 axarr[i].plot(thisX, thisY, thisColor)
72 axarr[i].set_ylabel('Offset ' + str(i))
73
74 plt.ylim((-180,180))
75 axarr[0].set_title(title + ' Offsets')
76 axarr[3].set_xlabel('Number of estimations')
77
78 return
79
80 def filterOffsets(offsets0, stdvLimit):
81 offsets1 = []
82
83 for thisOffset in offsets0:
84 pstd = numpy.std(thisOffset)*stdvLimit
85 pmean = numpy.mean(thisOffset)
86 outlier1 = thisOffset > pmean - pstd
87 outlier2 = thisOffset < pmean + pstd
88 not_outlier = numpy.logical_and(outlier1,outlier2)
89 thisOffset1 = thisOffset[not_outlier]
90 offsets1.append(thisOffset1)
91
92 return offsets1
93
94 #---------------------- Setup ---------------------------
95
96 path = '/home/jespinoza/Pictures/JASMET30/201608/phase'
97 stdvLimit = 0.5
98
99 #---------------------- Script ---------------------------
100
101 fileList = findFiles(path)
102 offsets0 = readFiles(fileList)
103 mean0, axisY0, axisX0 = estimateMean(offsets0)
104 plotPhases(offsets0, axisY0, axisX0, 'Original')
105
106 offsets1 = filterOffsets(offsets0, stdvLimit)
107 mean1, axisY1, axisX1 = estimateMean(offsets1)
108 plotPhases(offsets1, axisY1, axisX1, 'Filtered')
109
110 print "Original Offsets: %.2f, %.2f, %.2f, %.2f" % (mean0[0],mean0[1],mean0[2],mean0[3])
111 print "Filtered Offsets: %.2f, %.2f, %.2f, %.2f" % (mean1[0],mean1[1],mean1[2],mean1[3])
112
113 plt.show()
@@ -105,4 +105,9 ENV/
105
105
106 .vscode
106 .vscode
107
107
108 schainpy/scripts/ No newline at end of file
108 .svn/
109 *.png
110 *.pyc
111 schainpy/scripts
112
113 schaingui/node_modules
1 NO CONTENT: modified file
NO CONTENT: modified file
@@ -710,7 +710,7 class ProcUnitConf():
710 sts = self.procUnitObj.call(opType = opConfObj.type,
710 sts = self.procUnitObj.call(opType = opConfObj.type,
711 opName = opConfObj.name,
711 opName = opConfObj.name,
712 opId = opConfObj.id,
712 opId = opConfObj.id,
713 )
713 **kwargs)
714
714
715 # total_time = time.time() - ini
715 # total_time = time.time() - ini
716 #
716 #
@@ -90,7 +90,7 class ControllerThread(threading.Thread, Project):
90 continue
90 continue
91
91
92 if thisOpObj.name in plotterList:
92 if thisOpObj.name in plotterList:
93 thisOpObj.type = "plotter"
93 thisOpObj.type = "other"
94
94
95 def setPlotterQueue(self, plotter_queue):
95 def setPlotterQueue(self, plotter_queue):
96
96
@@ -638,18 +638,20 class SendToServer(ProcessingUnit):
638 return fullfilenameList
638 return fullfilenameList
639
639
640 def run(self, **kwargs):
640 def run(self, **kwargs):
641
642 if not self.isConfig:
641 if not self.isConfig:
643 self.init = time.time()
642 self.init = time.time()
644 self.setup(**kwargs)
643 self.setup(**kwargs)
645 self.isConfig = True
644 self.isConfig = True
646
645
646 if not self.clientObj.is_alive():
647 print "[Remote Server]: Restarting connection "
648 self.setup(**kwargs)
649
647 if time.time() - self.init >= self.period:
650 if time.time() - self.init >= self.period:
648 fullfilenameList = self.findFiles()
651 fullfilenameList = self.findFiles()
649
652
650 if self.clientObj.updateFileList(fullfilenameList):
653 if self.clientObj.updateFileList(fullfilenameList):
651 print "[Remote Server]: Sending the next files ", str(fullfilenameList)
654 print "[Remote Server]: Sending the next files ", str(fullfilenameList)
652
653 self.init = time.time()
655 self.init = time.time()
654
656
655 def close(self):
657 def close(self):
General Comments 0
You need to be logged in to leave comments. Login now