@@ -3,7 +3,7 Base clases to create Processing units and operations, the MPDecorator | |||
|
3 | 3 | must be used in plotting and writing operations to allow to run as an |
|
4 | 4 | external process. |
|
5 | 5 | ''' |
|
6 | ||
|
6 | # repositorio master | |
|
7 | 7 | import inspect |
|
8 | 8 | import zmq |
|
9 | 9 | import time |
@@ -10,7 +10,6 to work with Spectra data type | |||
|
10 | 10 | |
|
11 | 11 | import time |
|
12 | 12 | import itertools |
|
13 | ||
|
14 | 13 | import numpy |
|
15 | 14 | # repositorio |
|
16 | 15 | from schainpy.model.proc.jroproc_base import ProcessingUnit, MPDecorator, Operation |
@@ -155,7 +154,6 class SpectraProc(ProcessingUnit): | |||
|
155 | 154 | |
|
156 | 155 | if self.dataIn.flagDataAsBlock: |
|
157 | 156 | nVoltProfiles = self.dataIn.data.shape[1] |
|
158 | ||
|
159 | 157 | if nVoltProfiles == nProfiles: |
|
160 | 158 | self.buffer = self.dataIn.data.copy() |
|
161 | 159 | self.profIndex = nVoltProfiles |
@@ -171,6 +169,19 class SpectraProc(ProcessingUnit): | |||
|
171 | 169 | self.profIndex += nVoltProfiles |
|
172 | 170 | self.id_min += nVoltProfiles |
|
173 | 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 | 185 | else: |
|
175 | 186 | raise ValueError("The type object %s has %d profiles, it should just has %d profiles" % ( |
|
176 | 187 | self.dataIn.type, self.dataIn.data.shape[1], nProfiles)) |
@@ -191,7 +202,8 class SpectraProc(ProcessingUnit): | |||
|
191 | 202 | self.__getFft() |
|
192 | 203 | self.dataOut.flagNoData = False |
|
193 | 204 | self.firstdatatime = None |
|
194 |
self. |
|
|
205 | if not self.reader.bypass: | |
|
206 | self.profIndex = 0 | |
|
195 | 207 | else: |
|
196 | 208 | raise ValueError("The type of input object '%s' is not valid".format( |
|
197 | 209 | self.dataIn.type)) |
@@ -215,7 +227,7 class SpectraProc(ProcessingUnit): | |||
|
215 | 227 | |
|
216 | 228 | return |
|
217 | 229 | |
|
218 |
def selectFFTs(self, minFFT, maxFFT |
|
|
230 | def selectFFTs(self, minFFT, maxFFT): | |
|
219 | 231 | """ |
|
220 | 232 | Selecciona un bloque de datos en base a un grupo de valores de puntos FFTs segun el rango |
|
221 | 233 | minFFT<= FFT <= maxFFT |
@@ -274,16 +286,13 class SpectraProc(ProcessingUnit): | |||
|
274 | 286 | if val >= beacon_dB[0]: |
|
275 | 287 | beacon_heiIndexList.append(avg_dB.tolist().index(val)) |
|
276 | 288 | |
|
277 | #data_spc = data_spc[:,:,beacon_heiIndexList] | |
|
278 | 289 | data_cspc = None |
|
279 | 290 | if self.dataOut.data_cspc is not None: |
|
280 | 291 | data_cspc = self.dataOut.data_cspc[:, :, minIndex:maxIndex + 1] |
|
281 | #data_cspc = data_cspc[:,:,beacon_heiIndexList] | |
|
282 | 292 | |
|
283 | 293 | data_dc = None |
|
284 | 294 | if self.dataOut.data_dc is not None: |
|
285 | 295 | data_dc = self.dataOut.data_dc[:, minIndex:maxIndex + 1] |
|
286 | #data_dc = data_dc[:,beacon_heiIndexList] | |
|
287 | 296 | |
|
288 | 297 | self.dataOut.data_spc = data_spc |
|
289 | 298 | self.dataOut.data_cspc = data_cspc |
@@ -490,20 +499,20 class removeInterference(Operation): | |||
|
490 | 499 | for i in range(cspc.shape[0]): |
|
491 | 500 | LinePower= numpy.sum(realCspc[i], axis=0) |
|
492 | 501 | Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)] |
|
493 |
SelectedHeights = Heights[ numpy.where( |
|
|
494 |
InterferenceSum = numpy.sum( |
|
|
502 | SelectedHeights = Heights[ numpy.where(LinePower < Threshold) ] | |
|
503 | InterferenceSum = numpy.sum(realCspc[i,:,SelectedHeights],axis=0) | |
|
495 | 504 | InterferenceThresholdMin = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)] |
|
496 | 505 | InterferenceThresholdMax = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.99)] |
|
497 | 506 | |
|
498 | 507 | |
|
499 |
InterferenceRange = numpy.where( |
|
|
508 | InterferenceRange = numpy.where(([InterferenceSum > InterferenceThresholdMin]))# , InterferenceSum < InterferenceThresholdMax]) ) | |
|
500 | 509 | #InterferenceRange = numpy.where( ([InterferenceRange < InterferenceThresholdMax])) |
|
501 | 510 | if len(InterferenceRange)<int(cspc.shape[1]*0.3): |
|
502 | 511 | cspc[i,InterferenceRange,:] = numpy.NaN |
|
503 | 512 | |
|
504 | 513 | self.dataOut.data_cspc = cspc |
|
505 | 514 | |
|
506 |
def removeInterference(self, interf |
|
|
515 | def removeInterference(self, interf=2, hei_interf=None, nhei_interf=None, offhei_interf=None): | |
|
507 | 516 | |
|
508 | 517 | jspectra = self.dataOut.data_spc |
|
509 | 518 | jcspectra = self.dataOut.data_cspc |
@@ -686,18 +695,42 class removeInterference(Operation): | |||
|
686 | 695 | |
|
687 | 696 | return 1 |
|
688 | 697 | |
|
689 |
def run(self, dataOut, interf |
|
|
698 | def run(self, dataOut, interf=2,hei_interf=None, nhei_interf=None, offhei_interf=None, mode=1): | |
|
690 | 699 | |
|
691 | 700 | self.dataOut = dataOut |
|
692 | 701 | |
|
693 | 702 | if mode == 1: |
|
694 |
self.removeInterference(interf |
|
|
703 | self.removeInterference(interf=2,hei_interf=None, nhei_interf=None, offhei_interf=None) | |
|
695 | 704 | elif mode == 2: |
|
696 | 705 | self.removeInterference2() |
|
697 | 706 | |
|
698 | 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 | 734 | class IncohInt(Operation): |
|
702 | 735 | |
|
703 | 736 | __profIndex = 0 |
General Comments 0
You need to be logged in to leave comments.
Login now