##// END OF EJS Templates
Adding the first version of Controller.py and experiment.cfg....
Daniel Valdez -
r104:851c0a59dacb
parent child
Show More
@@ -131,7 +131,8 class ExecUnit:
131 def integrator(*args):
131 def integrator(*args):
132 inputs = args[0]
132 inputs = args[0]
133 N = inputs[0]
133 N = inputs[0]
134 self.execProcObj.integrator(N)
134 timeInterval = inputs[1]
135 self.execProcObj.integrator(N, timeInterval)
135
136
136 pfuncDict = { "setup": setup,
137 pfuncDict = { "setup": setup,
137 "getdata": getData,
138 "getdata": getData,
@@ -10,14 +10,14 type = Voltage
10 input = 0
10 input = 0
11 setup = None,None
11 setup = None,None
12 init = None,None
12 init = None,None
13 integrator = int,10
13 integrator = int,4,None,None
14
14 plotData = float,None,float,None,float,None,float,None,str,iq,str,Test Data Voltage 2,int,1
15
15
16 [Processing1]
16 [Processing1]
17 id = 2
17 id = 2
18 type = Spectra
18 type = Spectra
19 input = 1
19 input = 1
20 setup = int,1024,None,None
20 setup = int,8,None,None
21 init = None,None
21 init = None,None
22 integrator = int,2
22 integrator = int,4,int,3
23 plotData = float,None,float,None,float,None,float,None,str,Test Spectra Data,int,1
23 plotData = float,None,float,None,float,None,float,None,str,Test Spectra Data,int,2
@@ -121,10 +121,7 class Osciloscope:
121
121
122 self.__isPlotIni = True
122 self.__isPlotIni = True
123
123
124 def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, idProfile=None, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False, type='iq', winTitle="Voltage"):
124 def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False, type='iq', winTitle="Voltage"):
125
126 if idProfile != None and idProfile != self.voltageObj.idProfile:
127 return
128
125
129 if not(self.__isPlotConfig):
126 if not(self.__isPlotConfig):
130 self.setup(titleList, xlabelList, ylabelList, XAxisAsTime)
127 self.setup(titleList, xlabelList, ylabelList, XAxisAsTime)
@@ -136,7 +133,7 class Osciloscope:
136
133
137 data = self.voltageObj.data
134 data = self.voltageObj.data
138
135
139 x = self.voltageObj.heights
136 x = self.voltageObj.heightList
140
137
141 if xmin == None: xmin = x[0]
138 if xmin == None: xmin = x[0]
142 if xmax == None: xmax = x[-1]
139 if xmax == None: xmax = x[-1]
@@ -67,6 +67,8 class Spectra(JROData):
67
67
68 self.nFFTPoints = None
68 self.nFFTPoints = None
69
69
70 self.nAvg = None
71
70 self.nPairs = 0
72 self.nPairs = 0
71
73
72 self.pairsList = None
74 self.pairsList = None
@@ -53,7 +53,7 class Voltage(JROData):
53
53
54 self.flagResetProcessing = False
54 self.flagResetProcessing = False
55
55
56
56 self.nAvg = None
57
57
58 self.profileIndex = None
58 self.profileIndex = None
59
59
@@ -140,6 +140,9 class SpectraProcessor:
140 self.dataOutObj.m_ProcessingHeader.spectraComb
140 self.dataOutObj.m_ProcessingHeader.spectraComb
141 self.dataOutObj.m_ProcessingHeader.shif_fft
141 self.dataOutObj.m_ProcessingHeader.shif_fft
142 """
142 """
143 if self.dataInObj.flagNoData:
144 return 0
145
143 blocksize = 0
146 blocksize = 0
144 nFFTPoints = self.nFFTPoints
147 nFFTPoints = self.nFFTPoints
145 nChannels, nheis = self.dataInObj.data.shape
148 nChannels, nheis = self.dataInObj.data.shape
@@ -150,7 +153,7 class SpectraProcessor:
150 self.buffer[:,self.ptsId,:] = self.dataInObj.data
153 self.buffer[:,self.ptsId,:] = self.dataInObj.data
151 self.ptsId += 1
154 self.ptsId += 1
152
155
153 if self.ptsId < self.dataOutObj.nFFTPoints:
156 if self.ptsId < self.nFFTPoints:
154 self.dataOutObj.flagNoData = True
157 self.dataOutObj.flagNoData = True
155 return
158 return
156
159
@@ -241,12 +244,11 class SpectraProcessor:
241 self.plotterObjList.append(plotObj)
244 self.plotterObjList.append(plotObj)
242
245
243
246
244 def addIntegrator(self,N):
247 def addIntegrator(self,N,timeInterval):
245
248
246 objIncohInt = IncoherentIntegration(N)
249 objIncohInt = IncoherentIntegration(N,timeInterval)
247 self.integratorObjList.append(objIncohInt)
250 self.integratorObjList.append(objIncohInt)
248
251
249
250 def writeData(self, wrpath):
252 def writeData(self, wrpath):
251 if self.dataOutObj.flagNoData:
253 if self.dataOutObj.flagNoData:
252 return 0
254 return 0
@@ -269,21 +271,24 class SpectraProcessor:
269
271
270 self.plotterObjIndex += 1
272 self.plotterObjIndex += 1
271
273
272 def integrator(self, N):
274 def integrator(self, N=None, timeInterval=None):
275
273 if self.dataOutObj.flagNoData:
276 if self.dataOutObj.flagNoData:
274 return 0
277 return 0
275
278
276 if len(self.integratorObjList) <= self.integratorObjIndex:
279 if len(self.integratorObjList) <= self.integratorObjIndex:
277 self.addIntegrator(N)
280 self.addIntegrator(N,timeInterval)
278
281
279 myCohIntObj = self.integratorObjList[self.integratorObjIndex]
282 myIncohIntObj = self.integratorObjList[self.integratorObjIndex]
280 myCohIntObj.exe(self.dataOutObj.data_spc)
283 myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc)
281
284
282 if myCohIntObj.flag:
285 if myIncohIntObj.isReady:
283 self.dataOutObj.data_spc = myCohIntObj.data
286 self.dataOutObj.data_spc = myIncohIntObj.data
284 self.dataOutObj.m_ProcessingHeader.incoherentInt *= N
287 self.dataOutObj.nAvg = myIncohIntObj.navg
288 self.dataOutObj.m_ProcessingHeader.incoherentInt *= myIncohIntObj.navg
289 #print "myIncohIntObj.navg: ",myIncohIntObj.navg
285 self.dataOutObj.flagNoData = False
290 self.dataOutObj.flagNoData = False
286
291
287 else:
292 else:
288 self.dataOutObj.flagNoData = True
293 self.dataOutObj.flagNoData = True
289
294
@@ -418,7 +423,6 class SpectraProcessor:
418 self.dataOutObj.nChannels = nChannels
423 self.dataOutObj.nChannels = nChannels
419 self.dataOutObj.m_ProcessingHeader.blockSize = blocksize
424 self.dataOutObj.m_ProcessingHeader.blockSize = blocksize
420
425
421
422 def selectHeightsByValue(self, minHei, maxHei):
426 def selectHeightsByValue(self, minHei, maxHei):
423 """
427 """
424 Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango
428 Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango
@@ -462,8 +466,7 class SpectraProcessor:
462 break
466 break
463
467
464 self.selectHeightsByIndex(minIndex, maxIndex)
468 self.selectHeightsByIndex(minIndex, maxIndex)
465
469
466
467 def selectHeightsByIndex(self, minIndex, maxIndex):
470 def selectHeightsByIndex(self, minIndex, maxIndex):
468 """
471 """
469 Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango
472 Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango
@@ -536,34 +539,82 class SpectraProcessor:
536
539
537 class IncoherentIntegration:
540 class IncoherentIntegration:
538
541
539 profCounter = 1
542 integ_counter = None
540 data = None
543 data = None
544 navg = None
541 buffer = None
545 buffer = None
542 flag = False
543 nIncohInt = None
546 nIncohInt = None
544
547
545 def __init__(self, N):
548 def __init__(self, N = None, timeInterval = None):
549 """
550 N
551 timeInterval - interval time [min], integer value
552 """
546
553
547 self.profCounter = 1
548 self.data = None
554 self.data = None
555 self.navg = None
549 self.buffer = None
556 self.buffer = None
550 self.flag = False
557 self.timeOut = None
558 self.exitCondition = False
559 self.isReady = False
551 self.nIncohInt = N
560 self.nIncohInt = N
561 self.integ_counter = 0
562 if timeInterval!=None:
563 self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line
564
565 if ((timeInterval==None) and (N==None)):
566 print 'N = None ; timeInterval = None'
567 sys.exit(0)
568 elif timeInterval == None:
569 self.timeFlag = False
570 else:
571 self.timeFlag = True
572
552
573
553 def exe(self,data):
574 def exe(self,data,timeOfData):
575 """
576 data
577
578 timeOfData [seconds]
579 """
554
580
555 if self.buffer == None:
581 if self.timeFlag:
556 self.buffer = data
582 if self.timeOut == None:
583 self.timeOut = timeOfData + self.timeIntervalInSeconds
584
585 if timeOfData < self.timeOut:
586 if self.buffer == None:
587 self.buffer = data
588 else:
589 self.buffer = self.buffer + data
590 self.integ_counter += 1
591 else:
592 self.exitCondition = True
593
557 else:
594 else:
558 self.buffer = self.buffer + data
595 if self.integ_counter < self.nIncohInt:
559
596 if self.buffer == None:
560 if self.profCounter == self.nIncohInt:
597 self.buffer = data
598 else:
599 self.buffer = self.buffer + data
600
601 self.integ_counter += 1
602
603 if self.integ_counter == self.nIncohInt:
604 self.exitCondition = True
605
606 if self.exitCondition:
561 self.data = self.buffer
607 self.data = self.buffer
608 self.navg = self.integ_counter
609 self.isReady = True
562 self.buffer = None
610 self.buffer = None
563 self.profCounter = 0
611 self.timeOut = None
564 self.flag = True
612 self.integ_counter = 0
565 else:
613 self.exitCondition = False
566 self.flag = False
567
614
568 self.profCounter += 1
615 if self.timeFlag:
569
616 self.buffer = data
617 self.timeOut = timeOfData + self.timeIntervalInSeconds
618 else:
619 self.isReady = False
620 No newline at end of file
@@ -102,9 +102,9 class VoltageProcessor:
102 plotObj = Osciloscope(self.dataOutObj, index)
102 plotObj = Osciloscope(self.dataOutObj, index)
103 self.plotterObjList.append(plotObj)
103 self.plotterObjList.append(plotObj)
104
104
105 def addIntegrator(self, nCohInt):
105 def addIntegrator(self, N,timeInterval):
106
106
107 objCohInt = CoherentIntegrator(nCohInt)
107 objCohInt = CoherentIntegrator(N,timeInterval)
108 self.integratorObjList.append(objCohInt)
108 self.integratorObjList.append(objCohInt)
109
109
110 def addDecoder(self, code, ncode, nbaud):
110 def addDecoder(self, code, ncode, nbaud):
@@ -143,20 +143,22 class VoltageProcessor:
143
143
144 self.plotterObjIndex += 1
144 self.plotterObjIndex += 1
145
145
146 def integrator(self, N):
146 def integrator(self, N=None, timeInterval=None):
147
147
148 if self.dataOutObj.flagNoData:
148 if self.dataOutObj.flagNoData:
149 return 0
149 return 0
150
150
151 if len(self.integratorObjList) <= self.integratorObjIndex:
151 if len(self.integratorObjList) <= self.integratorObjIndex:
152 self.addIntegrator(N)
152 self.addIntegrator(N,timeInterval)
153
153
154 myCohIntObj = self.integratorObjList[self.integratorObjIndex]
154 myCohIntObj = self.integratorObjList[self.integratorObjIndex]
155 myCohIntObj.exe(self.dataOutObj.data)
155 myCohIntObj.exe(data=self.dataOutObj.data,timeOfData=self.dataOutObj.m_BasicHeader.utc)
156
156
157 if myCohIntObj.flag:
157 if myCohIntObj.isReady:
158 self.dataOutObj.data = myCohIntObj.data
158 self.dataOutObj.data = myCohIntObj.data
159 self.dataOutObj.m_ProcessingHeader.coherentInt *= N
159 self.dataOutObj.nAvg = myCohIntObj.navg
160 self.dataOutObj.m_ProcessingHeader.coherentInt *= myCohIntObj.navg
161 #print "myCohIntObj.navg: ",myCohIntObj.navg
160 self.dataOutObj.flagNoData = False
162 self.dataOutObj.flagNoData = False
161
163
162 else:
164 else:
@@ -480,36 +482,76 class Decoder:
480
482
481 class CoherentIntegrator:
483 class CoherentIntegrator:
482
484
483 profCounter = 1
485 integ_counter = None
484 data = None
486 data = None
487 navg = None
485 buffer = None
488 buffer = None
486 flag = False
487 nCohInt = None
489 nCohInt = None
488
490
489 def __init__(self, N):
491 def __init__(self, N=None,timeInterval=None):
490
492
491 self.profCounter = 1
492 self.data = None
493 self.data = None
494 self.navg = None
493 self.buffer = None
495 self.buffer = None
494 self.flag = False
496 self.timeOut = None
497 self.exitCondition = False
498 self.isReady = False
495 self.nCohInt = N
499 self.nCohInt = N
500 self.integ_counter = 0
501 if timeInterval!=None:
502 self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line
503
504 if ((timeInterval==None) and (N==None)):
505 print 'N = None ; timeInterval = None'
506 sys.exit(0)
507 elif timeInterval == None:
508 self.timeFlag = False
509 else:
510 self.timeFlag = True
496
511
497 def exe(self, data):
512 def exe(self, data, timeOfData):
498
513
499 if self.buffer == None:
514 if self.timeFlag:
500 self.buffer = data
515 if self.timeOut == None:
516 self.timeOut = timeOfData + self.timeIntervalInSeconds
517
518 if timeOfData < self.timeOut:
519 if self.buffer == None:
520 self.buffer = data
521 else:
522 self.buffer = self.buffer + data
523 self.integ_counter += 1
524 else:
525 self.exitCondition = True
526
501 else:
527 else:
502 self.buffer = self.buffer + data
528 if self.integ_counter < self.nCohInt:
503
529 if self.buffer == None:
504 if self.profCounter == self.nCohInt:
530 self.buffer = data
531 else:
532 self.buffer = self.buffer + data
533
534 self.integ_counter += 1
535
536 if self.integ_counter == self.nCohInt:
537 self.exitCondition = True
538
539 if self.exitCondition:
505 self.data = self.buffer
540 self.data = self.buffer
541 self.navg = self.integ_counter
542 self.isReady = True
506 self.buffer = None
543 self.buffer = None
507 self.profCounter = 0
544 self.timeOut = None
508 self.flag = True
545 self.integ_counter = 0
546 self.exitCondition = False
547
548 if self.timeFlag:
549 self.buffer = data
550 self.timeOut = timeOfData + self.timeIntervalInSeconds
509 else:
551 else:
510 self.flag = False
552 self.isReady = False
511
553
512 self.profCounter += 1
554
513
555
514 class ProfileSelector:
556 class ProfileSelector:
515
557
General Comments 0
You need to be logged in to leave comments. Login now