diff --git a/.gitignore b/.gitignore index d63b165..0a065d6 100644 --- a/.gitignore +++ b/.gitignore @@ -105,4 +105,9 @@ ENV/ .vscode -schainpy/scripts/ \ No newline at end of file +.svn/ +*.png +*.pyc +schainpy/scripts + +schaingui/node_modules diff --git a/README.md b/README.md index b8960ef..5704c9f 100644 --- a/README.md +++ b/README.md @@ -129,4 +129,4 @@ op.addParameter(name='wintitle', value='RTI', format='str') controller.start() -``` +``` \ No newline at end of file diff --git a/schainpy/controller.py b/schainpy/controller.py index 3ff6797..795b638 100644 --- a/schainpy/controller.py +++ b/schainpy/controller.py @@ -330,10 +330,10 @@ class OperationConf(): def getParameterValue(self, parameterName): parameterObj = self.getParameterObj(parameterName) - -# if not parameterObj: -# return None - + + # if not parameterObj: + # return None + value = parameterObj.getValue() return value @@ -651,11 +651,11 @@ class ProcUnitConf(): def printattr(self): print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, - self.id, - self.name, - self.datatype, - self.inputId) - + self.id, + self.name, + self.datatype, + self.inputId) + for opConfObj in self.opConfObjList: opConfObj.printattr() @@ -710,13 +710,13 @@ class ProcUnitConf(): sts = self.procUnitObj.call(opType = opConfObj.type, opName = opConfObj.name, opId = opConfObj.id, - ) - -# total_time = time.time() - ini -# -# if total_time > 0.002: -# print "%s::%s took %f seconds" %(self.name, opConfObj.name, total_time) - + **kwargs) + + # total_time = time.time() - ini + # + # if total_time > 0.002: + # print "%s::%s took %f seconds" %(self.name, opConfObj.name, total_time) + is_ok = is_ok or sts return is_ok @@ -862,18 +862,18 @@ class ReadUnitConf(ProcUnitConf): opObj.addParameter(name=key, value=value, format=type(value).__name__) return opObj - -# def makeXml(self, projectElement): -# -# procUnitElement = SubElement(projectElement, self.ELEMENTNAME) -# procUnitElement.set('id', str(self.id)) -# procUnitElement.set('name', self.name) -# procUnitElement.set('datatype', self.datatype) -# procUnitElement.set('inputId', str(self.inputId)) -# -# for opConfObj in self.opConfObjList: -# opConfObj.makeXml(procUnitElement) - + + # def makeXml(self, projectElement): + # + # procUnitElement = SubElement(projectElement, self.ELEMENTNAME) + # procUnitElement.set('id', str(self.id)) + # procUnitElement.set('name', self.name) + # procUnitElement.set('datatype', self.datatype) + # procUnitElement.set('inputId', str(self.inputId)) + # + # for opConfObj in self.opConfObjList: + # opConfObj.makeXml(procUnitElement) + def readXml(self, upElement): self.id = upElement.get('id') @@ -1115,8 +1115,8 @@ class Project(): self.id = self.projectElement.get('id') self.name = self.projectElement.get('name') - self.description = self.projectElement.get('description') - + self.description = self.projectElement.get('description') + readUnitElementList = self.projectElement.iter(ReadUnitConf().getElementName()) for readUnitElement in readUnitElementList: @@ -1146,9 +1146,9 @@ class Project(): def printattr(self): print "Project[%s]: name = %s, description = %s" %(self.id, - self.name, - self.description) - + self.name, + self.description) + for procUnitConfObj in self.procUnitConfObjDict.values(): procUnitConfObj.printattr() @@ -1184,9 +1184,9 @@ class Project(): import socket err = traceback.format_exception(sys.exc_info()[0], - sys.exc_info()[1], - sys.exc_info()[2]) - + sys.exc_info()[1], + sys.exc_info()[2]) + print "***** Error occurred in %s *****" %(procUnitConfObj.name) print "***** %s" %err[-1] @@ -1217,10 +1217,10 @@ class Project(): adminObj = schainpy.admin.SchainNotify() adminObj.sendAlert(message=message, - subject=subject, - subtitle=subtitle, - filename=self.filename) - + subject=subject, + subtitle=subtitle, + filename=self.filename) + def isPaused(self): return 0 diff --git a/schainpy/controller_api.py b/schainpy/controller_api.py index d8d87b9..4e48082 100644 --- a/schainpy/controller_api.py +++ b/schainpy/controller_api.py @@ -90,7 +90,7 @@ class ControllerThread(threading.Thread, Project): continue if thisOpObj.name in plotterList: - thisOpObj.type = "plotter" + thisOpObj.type = "other" def setPlotterQueue(self, plotter_queue): diff --git a/schainpy/model/utils/jroutils_ftp.py b/schainpy/model/utils/jroutils_ftp.py index 0aa361f..87ab15b 100644 --- a/schainpy/model/utils/jroutils_ftp.py +++ b/schainpy/model/utils/jroutils_ftp.py @@ -638,18 +638,20 @@ class SendToServer(ProcessingUnit): return fullfilenameList def run(self, **kwargs): - if not self.isConfig: self.init = time.time() self.setup(**kwargs) self.isConfig = True - + + if not self.clientObj.is_alive(): + print "[Remote Server]: Restarting connection " + self.setup(**kwargs) + if time.time() - self.init >= self.period: fullfilenameList = self.findFiles() if self.clientObj.updateFileList(fullfilenameList): print "[Remote Server]: Sending the next files ", str(fullfilenameList) - self.init = time.time() def close(self): diff --git a/schainpy/scripts/optimun_offset.py b/schainpy/scripts/optimun_offset.py new file mode 100644 index 0000000..8ebcba0 --- /dev/null +++ b/schainpy/scripts/optimun_offset.py @@ -0,0 +1,113 @@ +import h5py +import numpy +import matplotlib.pyplot as plt +import glob +import os + +#---------------------- Functions --------------------- + +def findFiles(path): + + dirList = [] + fileList = [] + + for thisPath in os.listdir(path): + dirList.append(os.path.join(path,thisPath)) + dirList.sort() + + for thisDirectory in dirList: + files = glob.glob1(thisDirectory, "*.hdf5") + files.sort() + for thisFile in files: + fileList.append(os.path.join(thisDirectory,thisFile)) + + return fileList + +def readFiles(fileList): + + meteors_array = numpy.zeros((1,4)) + + for thisFile in fileList: + + #Leer + f1 = h5py.File(thisFile,'r') + grp1 = f1['Data'] + grp2 = grp1['data_output'] + meteors1 = grp2['table0'][:] + meteors_array = numpy.vstack((meteors_array,meteors1)) + #cerrar + f1.close() + + meteors_array = numpy.delete(meteors_array, 0, axis=0) + meteors_list = [meteors_array[:,0],meteors_array[:,1],meteors_array[:,2],meteors_array[:,3]] + return meteors_list + +def estimateMean(offset_list): + + mean_off = [] + axisY_off = [] + axisX_off = [] + + for thisOffset in offset_list: + mean_aux = numpy.mean(thisOffset, axis = 0) + mean_off.append(mean_aux) + axisX_off.append(numpy.array([0,numpy.size(thisOffset)])) + axisY_off.append(numpy.array([mean_aux,mean_aux])) + + return mean_off, axisY_off, axisX_off + +def plotPhases(offset0, axisY0, axisX0, title): + f, axarr = plt.subplots(4, sharey=True) + color = ['b','g','r','c'] +# plt.grid() + for i in range(len(offset0)): + thisMeteor = offset0[i] + thisY = axisY0[i] + thisX = axisX0[i] + thisColor = color[i] + + opt = thisColor + 'o' + axarr[i].plot(thisMeteor,opt) + axarr[i].plot(thisX, thisY, thisColor) + axarr[i].set_ylabel('Offset ' + str(i)) + + plt.ylim((-180,180)) + axarr[0].set_title(title + ' Offsets') + axarr[3].set_xlabel('Number of estimations') + + return + +def filterOffsets(offsets0, stdvLimit): + offsets1 = [] + + for thisOffset in offsets0: + pstd = numpy.std(thisOffset)*stdvLimit + pmean = numpy.mean(thisOffset) + outlier1 = thisOffset > pmean - pstd + outlier2 = thisOffset < pmean + pstd + not_outlier = numpy.logical_and(outlier1,outlier2) + thisOffset1 = thisOffset[not_outlier] + offsets1.append(thisOffset1) + + return offsets1 + +#---------------------- Setup --------------------------- + +path = '/home/jespinoza/Pictures/JASMET30/201608/phase' +stdvLimit = 0.5 + +#---------------------- Script --------------------------- + +fileList = findFiles(path) +offsets0 = readFiles(fileList) +mean0, axisY0, axisX0 = estimateMean(offsets0) +plotPhases(offsets0, axisY0, axisX0, 'Original') + +offsets1 = filterOffsets(offsets0, stdvLimit) +mean1, axisY1, axisX1 = estimateMean(offsets1) +plotPhases(offsets1, axisY1, axisX1, 'Filtered') + +print "Original Offsets: %.2f, %.2f, %.2f, %.2f" % (mean0[0],mean0[1],mean0[2],mean0[3]) +print "Filtered Offsets: %.2f, %.2f, %.2f, %.2f" % (mean1[0],mean1[1],mean1[2],mean1[3]) + +plt.show()