##// END OF EJS Templates
Add process by profiles when receiving with ZMQ
Juan C. Espinoza -
r1575:934a33e70856
parent child
Show More
@@ -554,6 +554,10 class Project(Process):
554 for key in keys:
554 for key in keys:
555 conf = self.configurations[key]
555 conf = self.configurations[key]
556 conf.createObjects()
556 conf.createObjects()
557 if 'Reader' in str(conf):
558 reader = conf.object
559 else:
560 conf.object.reader = reader
557 if conf.inputId is not None:
561 if conf.inputId is not None:
558 conf.object.setInput(self.configurations[conf.inputId].object)
562 conf.object.setInput(self.configurations[conf.inputId].object)
559
563
@@ -123,6 +123,7 class Beam:
123 class GenericData(object):
123 class GenericData(object):
124
124
125 flagNoData = True
125 flagNoData = True
126 blockReader = False
126
127
127 def copy(self, inputObj=None):
128 def copy(self, inputObj=None):
128
129
@@ -196,7 +197,11 class JROData(GenericData):
196
197
197 def __str__(self):
198 def __str__(self):
198
199
199 return '{} - {}'.format(self.type, self.datatime)
200 try:
201 dt = self.datatime
202 except:
203 dt = 'None'
204 return '{} - {}'.format(self.type, dt)
200
205
201 def getNoise(self):
206 def getNoise(self):
202
207
@@ -22,6 +22,7 class ProcessingUnit(object):
22 '''
22 '''
23
23
24 proc_type = 'processing'
24 proc_type = 'processing'
25 bypass = False
25
26
26 def __init__(self):
27 def __init__(self):
27
28
@@ -60,8 +61,13 class ProcessingUnit(object):
60 try:
61 try:
61 if self.dataIn is not None and self.dataIn.flagNoData and not self.dataIn.error:
62 if self.dataIn is not None and self.dataIn.flagNoData and not self.dataIn.error:
62 return self.dataIn.isReady()
63 return self.dataIn.isReady()
63 elif self.dataIn is None or not self.dataIn.error:
64 elif self.dataIn is None or not self.dataIn.error:
65 if 'Reader' in self.name and self.bypass:
66 print('Skipping...reader')
67 return self.dataOut.isReady()
68
64 self.run(**kwargs)
69 self.run(**kwargs)
70
65 elif self.dataIn.error:
71 elif self.dataIn.error:
66 self.dataOut.error = self.dataIn.error
72 self.dataOut.error = self.dataIn.error
67 self.dataOut.flagNoData = True
73 self.dataOut.flagNoData = True
@@ -81,7 +87,7 class ProcessingUnit(object):
81 self.dataOut = op.run(self.dataOut, **opkwargs)
87 self.dataOut = op.run(self.dataOut, **opkwargs)
82 elif optype == 'external' and not self.dataOut.flagNoData:
88 elif optype == 'external' and not self.dataOut.flagNoData:
83 op.queue.put(aux)
89 op.queue.put(aux)
84 elif optype == 'external' and self.dataOut.error:
90 elif optype == 'external' and self.dataOut.error:
85 op.queue.put(aux)
91 op.queue.put(aux)
86
92
87 return 'Error' if self.dataOut.error else self.dataOut.isReady()
93 return 'Error' if self.dataOut.error else self.dataOut.isReady()
@@ -135,6 +135,7 class SpectraProc(ProcessingUnit):
135 elif self.dataIn.type == "Voltage":
135 elif self.dataIn.type == "Voltage":
136
136
137 self.dataOut.flagNoData = True
137 self.dataOut.flagNoData = True
138 self.reader.bypass = True
138
139
139 if nFFTPoints == None:
140 if nFFTPoints == None:
140 raise ValueError("This SpectraProc.run() need nFFTPoints input variable")
141 raise ValueError("This SpectraProc.run() need nFFTPoints input variable")
@@ -155,7 +156,6 class SpectraProc(ProcessingUnit):
155
156
156 if self.dataIn.flagDataAsBlock:
157 if self.dataIn.flagDataAsBlock:
157 nVoltProfiles = self.dataIn.data.shape[1]
158 nVoltProfiles = self.dataIn.data.shape[1]
158
159 if nVoltProfiles == nProfiles:
159 if nVoltProfiles == nProfiles:
160 self.buffer = self.dataIn.data.copy()
160 self.buffer = self.dataIn.data.copy()
161 self.profIndex = nVoltProfiles
161 self.profIndex = nVoltProfiles
@@ -171,6 +171,19 class SpectraProc(ProcessingUnit):
171 self.profIndex += nVoltProfiles
171 self.profIndex += nVoltProfiles
172 self.id_min += nVoltProfiles
172 self.id_min += nVoltProfiles
173 self.id_max += nVoltProfiles
173 self.id_max += nVoltProfiles
174 elif nVoltProfiles > nProfiles:
175 print('Por perfiles...', self.profIndex)
176 if self.profIndex == 0:
177 self.id_min = 0
178 self.id_max = nProfiles
179
180 self.buffer = self.dataIn.data[:, self.id_min:self.id_max,:]
181 self.profIndex += nProfiles
182 self.id_min += nProfiles
183 self.id_max += nProfiles
184 if self.id_max == nVoltProfiles:
185 self.reader.bypass = False
186
174 else:
187 else:
175 raise ValueError("The type object %s has %d profiles, it should just has %d profiles" % (
188 raise ValueError("The type object %s has %d profiles, it should just has %d profiles" % (
176 self.dataIn.type, self.dataIn.data.shape[1], nProfiles))
189 self.dataIn.type, self.dataIn.data.shape[1], nProfiles))
@@ -182,7 +195,7 class SpectraProc(ProcessingUnit):
182 if self.firstdatatime == None:
195 if self.firstdatatime == None:
183 self.firstdatatime = self.dataIn.utctime
196 self.firstdatatime = self.dataIn.utctime
184
197
185 if self.profIndex == nProfiles:
198 if self.profIndex % nProfiles == 0:
186 self.__updateSpecFromVoltage()
199 self.__updateSpecFromVoltage()
187 if pairsList == None:
200 if pairsList == None:
188 self.dataOut.pairsList = [pair for pair in itertools.combinations(self.dataOut.channelList, 2)]
201 self.dataOut.pairsList = [pair for pair in itertools.combinations(self.dataOut.channelList, 2)]
@@ -191,7 +204,8 class SpectraProc(ProcessingUnit):
191 self.__getFft()
204 self.__getFft()
192 self.dataOut.flagNoData = False
205 self.dataOut.flagNoData = False
193 self.firstdatatime = None
206 self.firstdatatime = None
194 self.profIndex = 0
207 if not self.reader.bypass:
208 self.profIndex = 0
195 else:
209 else:
196 raise ValueError("The type of input object '%s' is not valid".format(
210 raise ValueError("The type of input object '%s' is not valid".format(
197 self.dataIn.type))
211 self.dataIn.type))
General Comments 0
You need to be logged in to leave comments. Login now