##// END OF EJS Templates
Update jroproc_base.py Queue size y jroproc_spectra.py
Alexander Valdez -
r1668:8880a814f9ea
parent child
Show More
@@ -3,7 +3,7 Base clases to create Processing units and operations, the MPDecorator
3 must be used in plotting and writing operations to allow to run as an
3 must be used in plotting and writing operations to allow to run as an
4 external process.
4 external process.
5 '''
5 '''
6
6 # repositorio master
7 import inspect
7 import inspect
8 import zmq
8 import zmq
9 import time
9 import time
@@ -10,7 +10,6 to work with Spectra data type
10
10
11 import time
11 import time
12 import itertools
12 import itertools
13
14 import numpy
13 import numpy
15 # repositorio
14 # repositorio
16 from schainpy.model.proc.jroproc_base import ProcessingUnit, MPDecorator, Operation
15 from schainpy.model.proc.jroproc_base import ProcessingUnit, MPDecorator, Operation
@@ -155,7 +154,6 class SpectraProc(ProcessingUnit):
155
154
156 if self.dataIn.flagDataAsBlock:
155 if self.dataIn.flagDataAsBlock:
157 nVoltProfiles = self.dataIn.data.shape[1]
156 nVoltProfiles = self.dataIn.data.shape[1]
158
159 if nVoltProfiles == nProfiles:
157 if nVoltProfiles == nProfiles:
160 self.buffer = self.dataIn.data.copy()
158 self.buffer = self.dataIn.data.copy()
161 self.profIndex = nVoltProfiles
159 self.profIndex = nVoltProfiles
@@ -171,6 +169,19 class SpectraProc(ProcessingUnit):
171 self.profIndex += nVoltProfiles
169 self.profIndex += nVoltProfiles
172 self.id_min += nVoltProfiles
170 self.id_min += nVoltProfiles
173 self.id_max += nVoltProfiles
171 self.id_max += nVoltProfiles
172 elif nVoltProfiles > nProfiles:
173 self.reader.bypass = True
174 if self.profIndex == 0:
175 self.id_min = 0
176 self.id_max = nProfiles
177
178 self.buffer = self.dataIn.data[:, self.id_min:self.id_max,:]
179 self.profIndex += nProfiles
180 self.id_min += nProfiles
181 self.id_max += nProfiles
182 if self.id_max == nVoltProfiles:
183 self.reader.bypass = False
184
174 else:
185 else:
175 raise ValueError("The type object %s has %d profiles, it should just has %d profiles" % (
186 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))
187 self.dataIn.type, self.dataIn.data.shape[1], nProfiles))
@@ -191,7 +202,8 class SpectraProc(ProcessingUnit):
191 self.__getFft()
202 self.__getFft()
192 self.dataOut.flagNoData = False
203 self.dataOut.flagNoData = False
193 self.firstdatatime = None
204 self.firstdatatime = None
194 self.profIndex = 0
205 if not self.reader.bypass:
206 self.profIndex = 0
195 else:
207 else:
196 raise ValueError("The type of input object '%s' is not valid".format(
208 raise ValueError("The type of input object '%s' is not valid".format(
197 self.dataIn.type))
209 self.dataIn.type))
@@ -215,7 +227,7 class SpectraProc(ProcessingUnit):
215
227
216 return
228 return
217
229
218 def selectFFTs(self, minFFT, maxFFT ):
230 def selectFFTs(self, minFFT, maxFFT):
219 """
231 """
220 Selecciona un bloque de datos en base a un grupo de valores de puntos FFTs segun el rango
232 Selecciona un bloque de datos en base a un grupo de valores de puntos FFTs segun el rango
221 minFFT<= FFT <= maxFFT
233 minFFT<= FFT <= maxFFT
@@ -274,16 +286,13 class SpectraProc(ProcessingUnit):
274 if val >= beacon_dB[0]:
286 if val >= beacon_dB[0]:
275 beacon_heiIndexList.append(avg_dB.tolist().index(val))
287 beacon_heiIndexList.append(avg_dB.tolist().index(val))
276
288
277 #data_spc = data_spc[:,:,beacon_heiIndexList]
278 data_cspc = None
289 data_cspc = None
279 if self.dataOut.data_cspc is not None:
290 if self.dataOut.data_cspc is not None:
280 data_cspc = self.dataOut.data_cspc[:, :, minIndex:maxIndex + 1]
291 data_cspc = self.dataOut.data_cspc[:, :, minIndex:maxIndex + 1]
281 #data_cspc = data_cspc[:,:,beacon_heiIndexList]
282
292
283 data_dc = None
293 data_dc = None
284 if self.dataOut.data_dc is not None:
294 if self.dataOut.data_dc is not None:
285 data_dc = self.dataOut.data_dc[:, minIndex:maxIndex + 1]
295 data_dc = self.dataOut.data_dc[:, minIndex:maxIndex + 1]
286 #data_dc = data_dc[:,beacon_heiIndexList]
287
296
288 self.dataOut.data_spc = data_spc
297 self.dataOut.data_spc = data_spc
289 self.dataOut.data_cspc = data_cspc
298 self.dataOut.data_cspc = data_cspc
@@ -490,20 +499,20 class removeInterference(Operation):
490 for i in range(cspc.shape[0]):
499 for i in range(cspc.shape[0]):
491 LinePower= numpy.sum(realCspc[i], axis=0)
500 LinePower= numpy.sum(realCspc[i], axis=0)
492 Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)]
501 Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)]
493 SelectedHeights = Heights[ numpy.where( LinePower < Threshold ) ]
502 SelectedHeights = Heights[ numpy.where(LinePower < Threshold) ]
494 InterferenceSum = numpy.sum( realCspc[i,:,SelectedHeights], axis=0 )
503 InterferenceSum = numpy.sum(realCspc[i,:,SelectedHeights],axis=0)
495 InterferenceThresholdMin = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)]
504 InterferenceThresholdMin = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)]
496 InterferenceThresholdMax = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.99)]
505 InterferenceThresholdMax = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.99)]
497
506
498
507
499 InterferenceRange = numpy.where( ([InterferenceSum > InterferenceThresholdMin]))# , InterferenceSum < InterferenceThresholdMax]) )
508 InterferenceRange = numpy.where(([InterferenceSum > InterferenceThresholdMin]))# , InterferenceSum < InterferenceThresholdMax]) )
500 #InterferenceRange = numpy.where( ([InterferenceRange < InterferenceThresholdMax]))
509 #InterferenceRange = numpy.where( ([InterferenceRange < InterferenceThresholdMax]))
501 if len(InterferenceRange)<int(cspc.shape[1]*0.3):
510 if len(InterferenceRange)<int(cspc.shape[1]*0.3):
502 cspc[i,InterferenceRange,:] = numpy.NaN
511 cspc[i,InterferenceRange,:] = numpy.NaN
503
512
504 self.dataOut.data_cspc = cspc
513 self.dataOut.data_cspc = cspc
505
514
506 def removeInterference(self, interf = 2, hei_interf = None, nhei_interf = None, offhei_interf = None):
515 def removeInterference(self, interf=2, hei_interf=None, nhei_interf=None, offhei_interf=None):
507
516
508 jspectra = self.dataOut.data_spc
517 jspectra = self.dataOut.data_spc
509 jcspectra = self.dataOut.data_cspc
518 jcspectra = self.dataOut.data_cspc
@@ -686,18 +695,42 class removeInterference(Operation):
686
695
687 return 1
696 return 1
688
697
689 def run(self, dataOut, interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None, mode=1):
698 def run(self, dataOut, interf=2,hei_interf=None, nhei_interf=None, offhei_interf=None, mode=1):
690
699
691 self.dataOut = dataOut
700 self.dataOut = dataOut
692
701
693 if mode == 1:
702 if mode == 1:
694 self.removeInterference(interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None)
703 self.removeInterference(interf=2,hei_interf=None, nhei_interf=None, offhei_interf=None)
695 elif mode == 2:
704 elif mode == 2:
696 self.removeInterference2()
705 self.removeInterference2()
697
706
698 return self.dataOut
707 return self.dataOut
699
708
700
709
710 class deflip(Operation):
711
712 def run(self, dataOut):
713 # arreglo 1: (num_chan, num_profiles, num_heights)
714 self.dataOut = dataOut
715
716 # JULIA-oblicua, indice 2
717 # arreglo 2: (num_profiles, num_heights)
718 jspectra = self.dataOut.data_spc[2]
719 jspectra_tmp=numpy.zeros(jspectra.shape)
720 num_profiles=jspectra.shape[0]
721 freq_dc = int(num_profiles / 2)
722 # Flip con for
723 for j in range(num_profiles):
724 jspectra_tmp[num_profiles-j-1]= jspectra[j]
725 # Intercambio perfil de DC con perfil inmediato anterior
726 jspectra_tmp[freq_dc-1]= jspectra[freq_dc-1]
727 jspectra_tmp[freq_dc]= jspectra[freq_dc]
728 # canal modificado es re-escrito en el arreglo de canales
729 self.dataOut.data_spc[2] = jspectra_tmp
730
731 return self.dataOut
732
733
701 class IncohInt(Operation):
734 class IncohInt(Operation):
702
735
703 __profIndex = 0
736 __profIndex = 0
General Comments 0
You need to be logged in to leave comments. Login now