@@ -1,8 +1,8 | |||||
1 | """Signal chain python package""" |
|
1 | """Signal chain python package""" | |
2 |
|
2 | |||
3 | try: |
|
3 | try: | |
4 | from schainpy.controller import Project |
|
4 | from schainpy.controller import Project | |
5 | except: |
|
5 | except: | |
6 | pass |
|
6 | pass | |
7 |
|
7 | |||
8 |
__version__ = '3.0.0b |
|
8 | __version__ = '3.0.0b6' |
@@ -1,876 +1,898 | |||||
1 | # Copyright (c) 2012-2020 Jicamarca Radio Observatory |
|
1 | # Copyright (c) 2012-2020 Jicamarca Radio Observatory | |
2 | # All rights reserved. |
|
2 | # All rights reserved. | |
3 | # |
|
3 | # | |
4 | # Distributed under the terms of the BSD 3-clause license. |
|
4 | # Distributed under the terms of the BSD 3-clause license. | |
5 | """Spectra processing Unit and operations |
|
5 | """Spectra processing Unit and operations | |
6 |
|
6 | |||
7 | Here you will find the processing unit `SpectraProc` and several operations |
|
7 | Here you will find the processing unit `SpectraProc` and several operations | |
8 | to work with Spectra data type |
|
8 | to work with Spectra data type | |
9 | """ |
|
9 | """ | |
10 |
|
10 | |||
11 | import time |
|
11 | import time | |
12 | import itertools |
|
12 | import itertools | |
13 |
|
13 | |||
14 | import numpy |
|
14 | import numpy | |
15 |
|
15 | |||
16 | from schainpy.model.proc.jroproc_base import ProcessingUnit, MPDecorator, Operation |
|
16 | from schainpy.model.proc.jroproc_base import ProcessingUnit, MPDecorator, Operation | |
17 | from schainpy.model.data.jrodata import Spectra |
|
17 | from schainpy.model.data.jrodata import Spectra | |
18 | from schainpy.model.data.jrodata import hildebrand_sekhon |
|
18 | from schainpy.model.data.jrodata import hildebrand_sekhon | |
19 | from schainpy.utils import log |
|
19 | from schainpy.utils import log | |
20 |
|
20 | |||
21 |
|
21 | |||
22 | class SpectraProc(ProcessingUnit): |
|
22 | class SpectraProc(ProcessingUnit): | |
23 |
|
23 | |||
24 | def __init__(self): |
|
24 | def __init__(self): | |
25 |
|
25 | |||
26 | ProcessingUnit.__init__(self) |
|
26 | ProcessingUnit.__init__(self) | |
27 |
|
27 | |||
28 | self.buffer = None |
|
28 | self.buffer = None | |
29 | self.firstdatatime = None |
|
29 | self.firstdatatime = None | |
30 | self.profIndex = 0 |
|
30 | self.profIndex = 0 | |
31 | self.dataOut = Spectra() |
|
31 | self.dataOut = Spectra() | |
32 | self.id_min = None |
|
32 | self.id_min = None | |
33 | self.id_max = None |
|
33 | self.id_max = None | |
34 | self.setupReq = False #Agregar a todas las unidades de proc |
|
34 | self.setupReq = False #Agregar a todas las unidades de proc | |
35 |
|
35 | |||
36 | def __updateSpecFromVoltage(self): |
|
36 | def __updateSpecFromVoltage(self): | |
37 |
|
37 | |||
38 | self.dataOut.timeZone = self.dataIn.timeZone |
|
38 | self.dataOut.timeZone = self.dataIn.timeZone | |
39 | self.dataOut.dstFlag = self.dataIn.dstFlag |
|
39 | self.dataOut.dstFlag = self.dataIn.dstFlag | |
40 | self.dataOut.errorCount = self.dataIn.errorCount |
|
40 | self.dataOut.errorCount = self.dataIn.errorCount | |
41 | self.dataOut.useLocalTime = self.dataIn.useLocalTime |
|
41 | self.dataOut.useLocalTime = self.dataIn.useLocalTime | |
42 | try: |
|
42 | try: | |
43 | self.dataOut.processingHeaderObj = self.dataIn.processingHeaderObj.copy() |
|
43 | self.dataOut.processingHeaderObj = self.dataIn.processingHeaderObj.copy() | |
44 | except: |
|
44 | except: | |
45 | pass |
|
45 | pass | |
46 | self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy() |
|
46 | self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy() | |
47 | self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy() |
|
47 | self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy() | |
48 | self.dataOut.channelList = self.dataIn.channelList |
|
48 | self.dataOut.channelList = self.dataIn.channelList | |
49 | self.dataOut.heightList = self.dataIn.heightList |
|
49 | self.dataOut.heightList = self.dataIn.heightList | |
50 | self.dataOut.dtype = numpy.dtype([('real', '<f4'), ('imag', '<f4')]) |
|
50 | self.dataOut.dtype = numpy.dtype([('real', '<f4'), ('imag', '<f4')]) | |
51 | self.dataOut.nProfiles = self.dataOut.nFFTPoints |
|
51 | self.dataOut.nProfiles = self.dataOut.nFFTPoints | |
52 | self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock |
|
52 | self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock | |
53 | self.dataOut.utctime = self.firstdatatime |
|
53 | self.dataOut.utctime = self.firstdatatime | |
54 | self.dataOut.flagDecodeData = self.dataIn.flagDecodeData |
|
54 | self.dataOut.flagDecodeData = self.dataIn.flagDecodeData | |
55 | self.dataOut.flagDeflipData = self.dataIn.flagDeflipData |
|
55 | self.dataOut.flagDeflipData = self.dataIn.flagDeflipData | |
56 | self.dataOut.flagShiftFFT = False |
|
56 | self.dataOut.flagShiftFFT = False | |
57 | self.dataOut.nCohInt = self.dataIn.nCohInt |
|
57 | self.dataOut.nCohInt = self.dataIn.nCohInt | |
58 | self.dataOut.nIncohInt = 1 |
|
58 | self.dataOut.nIncohInt = 1 | |
59 | self.dataOut.windowOfFilter = self.dataIn.windowOfFilter |
|
59 | self.dataOut.windowOfFilter = self.dataIn.windowOfFilter | |
60 | self.dataOut.frequency = self.dataIn.frequency |
|
60 | self.dataOut.frequency = self.dataIn.frequency | |
61 | self.dataOut.realtime = self.dataIn.realtime |
|
61 | self.dataOut.realtime = self.dataIn.realtime | |
62 | self.dataOut.azimuth = self.dataIn.azimuth |
|
62 | self.dataOut.azimuth = self.dataIn.azimuth | |
63 | self.dataOut.zenith = self.dataIn.zenith |
|
63 | self.dataOut.zenith = self.dataIn.zenith | |
64 | self.dataOut.beam.codeList = self.dataIn.beam.codeList |
|
64 | self.dataOut.beam.codeList = self.dataIn.beam.codeList | |
65 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList |
|
65 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList | |
66 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList |
|
66 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList | |
67 |
|
67 | |||
68 | def __getFft(self): |
|
68 | def __getFft(self): | |
69 | """ |
|
69 | """ | |
70 | Convierte valores de Voltaje a Spectra |
|
70 | Convierte valores de Voltaje a Spectra | |
71 |
|
71 | |||
72 | Affected: |
|
72 | Affected: | |
73 | self.dataOut.data_spc |
|
73 | self.dataOut.data_spc | |
74 | self.dataOut.data_cspc |
|
74 | self.dataOut.data_cspc | |
75 | self.dataOut.data_dc |
|
75 | self.dataOut.data_dc | |
76 | self.dataOut.heightList |
|
76 | self.dataOut.heightList | |
77 | self.profIndex |
|
77 | self.profIndex | |
78 | self.buffer |
|
78 | self.buffer | |
79 | self.dataOut.flagNoData |
|
79 | self.dataOut.flagNoData | |
80 | """ |
|
80 | """ | |
81 | fft_volt = numpy.fft.fft( |
|
81 | fft_volt = numpy.fft.fft( | |
82 | self.buffer, n=self.dataOut.nFFTPoints, axis=1) |
|
82 | self.buffer, n=self.dataOut.nFFTPoints, axis=1) | |
83 | fft_volt = fft_volt.astype(numpy.dtype('complex')) |
|
83 | fft_volt = fft_volt.astype(numpy.dtype('complex')) | |
84 | dc = fft_volt[:, 0, :] |
|
84 | dc = fft_volt[:, 0, :] | |
85 |
|
85 | |||
86 | # calculo de self-spectra |
|
86 | # calculo de self-spectra | |
87 | fft_volt = numpy.fft.fftshift(fft_volt, axes=(1,)) |
|
87 | fft_volt = numpy.fft.fftshift(fft_volt, axes=(1,)) | |
88 | spc = fft_volt * numpy.conjugate(fft_volt) |
|
88 | spc = fft_volt * numpy.conjugate(fft_volt) | |
89 | spc = spc.real |
|
89 | spc = spc.real | |
90 |
|
90 | |||
91 | blocksize = 0 |
|
91 | blocksize = 0 | |
92 | blocksize += dc.size |
|
92 | blocksize += dc.size | |
93 | blocksize += spc.size |
|
93 | blocksize += spc.size | |
94 |
|
94 | |||
95 | cspc = None |
|
95 | cspc = None | |
96 | pairIndex = 0 |
|
96 | pairIndex = 0 | |
97 | if self.dataOut.pairsList != None: |
|
97 | if self.dataOut.pairsList != None: | |
98 | # calculo de cross-spectra |
|
98 | # calculo de cross-spectra | |
99 | cspc = numpy.zeros( |
|
99 | cspc = numpy.zeros( | |
100 | (self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex') |
|
100 | (self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex') | |
101 | for pair in self.dataOut.pairsList: |
|
101 | for pair in self.dataOut.pairsList: | |
102 | if pair[0] not in self.dataOut.channelList: |
|
102 | if pair[0] not in self.dataOut.channelList: | |
103 | raise ValueError("Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" % ( |
|
103 | raise ValueError("Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" % ( | |
104 | str(pair), str(self.dataOut.channelList))) |
|
104 | str(pair), str(self.dataOut.channelList))) | |
105 | if pair[1] not in self.dataOut.channelList: |
|
105 | if pair[1] not in self.dataOut.channelList: | |
106 | raise ValueError("Error getting CrossSpectra: pair 1 of %s is not in channelList = %s" % ( |
|
106 | raise ValueError("Error getting CrossSpectra: pair 1 of %s is not in channelList = %s" % ( | |
107 | str(pair), str(self.dataOut.channelList))) |
|
107 | str(pair), str(self.dataOut.channelList))) | |
108 |
|
108 | |||
109 | cspc[pairIndex, :, :] = fft_volt[pair[0], :, :] * \ |
|
109 | cspc[pairIndex, :, :] = fft_volt[pair[0], :, :] * \ | |
110 | numpy.conjugate(fft_volt[pair[1], :, :]) |
|
110 | numpy.conjugate(fft_volt[pair[1], :, :]) | |
111 | pairIndex += 1 |
|
111 | pairIndex += 1 | |
112 | blocksize += cspc.size |
|
112 | blocksize += cspc.size | |
113 |
|
113 | |||
114 | self.dataOut.data_spc = spc |
|
114 | self.dataOut.data_spc = spc | |
115 | self.dataOut.data_cspc = cspc |
|
115 | self.dataOut.data_cspc = cspc | |
116 | self.dataOut.data_dc = dc |
|
116 | self.dataOut.data_dc = dc | |
117 | self.dataOut.blockSize = blocksize |
|
117 | self.dataOut.blockSize = blocksize | |
118 | self.dataOut.flagShiftFFT = False |
|
118 | self.dataOut.flagShiftFFT = False | |
119 |
|
119 | |||
120 | def run(self, nProfiles=None, nFFTPoints=None, pairsList=None, ippFactor=None, shift_fft=False): |
|
120 | def run(self, nProfiles=None, nFFTPoints=None, pairsList=None, ippFactor=None, shift_fft=False): | |
121 |
|
121 | |||
122 | if self.dataIn.type == "Spectra": |
|
122 | if self.dataIn.type == "Spectra": | |
123 | self.dataOut.copy(self.dataIn) |
|
123 | self.dataOut.copy(self.dataIn) | |
124 | if shift_fft: |
|
124 | if shift_fft: | |
125 | #desplaza a la derecha en el eje 2 determinadas posiciones |
|
125 | #desplaza a la derecha en el eje 2 determinadas posiciones | |
126 | shift = int(self.dataOut.nFFTPoints/2) |
|
126 | shift = int(self.dataOut.nFFTPoints/2) | |
127 | self.dataOut.data_spc = numpy.roll(self.dataOut.data_spc, shift , axis=1) |
|
127 | self.dataOut.data_spc = numpy.roll(self.dataOut.data_spc, shift , axis=1) | |
128 |
|
128 | |||
129 | if self.dataOut.data_cspc is not None: |
|
129 | if self.dataOut.data_cspc is not None: | |
130 | #desplaza a la derecha en el eje 2 determinadas posiciones |
|
130 | #desplaza a la derecha en el eje 2 determinadas posiciones | |
131 | self.dataOut.data_cspc = numpy.roll(self.dataOut.data_cspc, shift, axis=1) |
|
131 | self.dataOut.data_cspc = numpy.roll(self.dataOut.data_cspc, shift, axis=1) | |
132 | if pairsList: |
|
132 | if pairsList: | |
133 | self.__selectPairs(pairsList) |
|
133 | self.__selectPairs(pairsList) | |
134 |
|
134 | |||
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 |
|
138 | |||
139 | if nFFTPoints == None: |
|
139 | if nFFTPoints == None: | |
140 | raise ValueError("This SpectraProc.run() need nFFTPoints input variable") |
|
140 | raise ValueError("This SpectraProc.run() need nFFTPoints input variable") | |
141 |
|
141 | |||
142 | if nProfiles == None: |
|
142 | if nProfiles == None: | |
143 | nProfiles = nFFTPoints |
|
143 | nProfiles = nFFTPoints | |
144 |
|
144 | |||
145 | if ippFactor == None: |
|
145 | if ippFactor == None: | |
146 | self.dataOut.ippFactor = 1 |
|
146 | self.dataOut.ippFactor = 1 | |
147 |
|
147 | |||
148 | self.dataOut.nFFTPoints = nFFTPoints |
|
148 | self.dataOut.nFFTPoints = nFFTPoints | |
149 |
|
149 | |||
150 | if self.buffer is None: |
|
150 | if self.buffer is None: | |
151 | self.buffer = numpy.zeros((self.dataIn.nChannels, |
|
151 | self.buffer = numpy.zeros((self.dataIn.nChannels, | |
152 | nProfiles, |
|
152 | nProfiles, | |
153 | self.dataIn.nHeights), |
|
153 | self.dataIn.nHeights), | |
154 | dtype='complex') |
|
154 | dtype='complex') | |
155 |
|
155 | |||
156 | if self.dataIn.flagDataAsBlock: |
|
156 | if self.dataIn.flagDataAsBlock: | |
157 | nVoltProfiles = self.dataIn.data.shape[1] |
|
157 | nVoltProfiles = self.dataIn.data.shape[1] | |
158 |
|
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 | |
162 |
|
162 | |||
163 | elif nVoltProfiles < nProfiles: |
|
163 | elif nVoltProfiles < nProfiles: | |
164 |
|
164 | |||
165 | if self.profIndex == 0: |
|
165 | if self.profIndex == 0: | |
166 | self.id_min = 0 |
|
166 | self.id_min = 0 | |
167 | self.id_max = nVoltProfiles |
|
167 | self.id_max = nVoltProfiles | |
168 |
|
168 | |||
169 | self.buffer[:, self.id_min:self.id_max, |
|
169 | self.buffer[:, self.id_min:self.id_max, | |
170 | :] = self.dataIn.data |
|
170 | :] = self.dataIn.data | |
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 | else: |
|
174 | else: | |
175 | raise ValueError("The type object %s has %d profiles, it should just has %d profiles" % ( |
|
175 | 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)) |
|
176 | self.dataIn.type, self.dataIn.data.shape[1], nProfiles)) | |
177 | self.dataOut.flagNoData = True |
|
177 | self.dataOut.flagNoData = True | |
178 | else: |
|
178 | else: | |
179 | self.buffer[:, self.profIndex, :] = self.dataIn.data.copy() |
|
179 | self.buffer[:, self.profIndex, :] = self.dataIn.data.copy() | |
180 | self.profIndex += 1 |
|
180 | self.profIndex += 1 | |
181 |
|
181 | |||
182 | if self.firstdatatime == None: |
|
182 | if self.firstdatatime == None: | |
183 | self.firstdatatime = self.dataIn.utctime |
|
183 | self.firstdatatime = self.dataIn.utctime | |
184 |
|
184 | |||
185 | if self.profIndex == nProfiles: |
|
185 | if self.profIndex == nProfiles: | |
186 | self.__updateSpecFromVoltage() |
|
186 | self.__updateSpecFromVoltage() | |
187 | if pairsList == None: |
|
187 | if pairsList == None: | |
188 | self.dataOut.pairsList = [pair for pair in itertools.combinations(self.dataOut.channelList, 2)] |
|
188 | self.dataOut.pairsList = [pair for pair in itertools.combinations(self.dataOut.channelList, 2)] | |
189 | else: |
|
189 | else: | |
190 | self.dataOut.pairsList = pairsList |
|
190 | self.dataOut.pairsList = pairsList | |
191 | self.__getFft() |
|
191 | self.__getFft() | |
192 | self.dataOut.flagNoData = False |
|
192 | self.dataOut.flagNoData = False | |
193 | self.firstdatatime = None |
|
193 | self.firstdatatime = None | |
194 | self.profIndex = 0 |
|
194 | self.profIndex = 0 | |
195 | else: |
|
195 | else: | |
196 | raise ValueError("The type of input object '%s' is not valid".format( |
|
196 | raise ValueError("The type of input object '%s' is not valid".format( | |
197 | self.dataIn.type)) |
|
197 | self.dataIn.type)) | |
198 |
|
198 | |||
199 | def __selectPairs(self, pairsList): |
|
199 | def __selectPairs(self, pairsList): | |
200 |
|
200 | |||
201 | if not pairsList: |
|
201 | if not pairsList: | |
202 | return |
|
202 | return | |
203 |
|
203 | |||
204 | pairs = [] |
|
204 | pairs = [] | |
205 | pairsIndex = [] |
|
205 | pairsIndex = [] | |
206 |
|
206 | |||
207 | for pair in pairsList: |
|
207 | for pair in pairsList: | |
208 | if pair[0] not in self.dataOut.channelList or pair[1] not in self.dataOut.channelList: |
|
208 | if pair[0] not in self.dataOut.channelList or pair[1] not in self.dataOut.channelList: | |
209 | continue |
|
209 | continue | |
210 | pairs.append(pair) |
|
210 | pairs.append(pair) | |
211 | pairsIndex.append(pairs.index(pair)) |
|
211 | pairsIndex.append(pairs.index(pair)) | |
212 |
|
212 | |||
213 | self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndex] |
|
213 | self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndex] | |
214 | self.dataOut.pairsList = pairs |
|
214 | self.dataOut.pairsList = pairs | |
215 |
|
215 | |||
216 | return |
|
216 | return | |
217 |
|
217 | |||
218 | def selectFFTs(self, minFFT, maxFFT ): |
|
218 | def selectFFTs(self, minFFT, maxFFT ): | |
219 | """ |
|
219 | """ | |
220 | Selecciona un bloque de datos en base a un grupo de valores de puntos FFTs segun el rango |
|
220 | Selecciona un bloque de datos en base a un grupo de valores de puntos FFTs segun el rango | |
221 | minFFT<= FFT <= maxFFT |
|
221 | minFFT<= FFT <= maxFFT | |
222 | """ |
|
222 | """ | |
223 |
|
223 | |||
224 | if (minFFT > maxFFT): |
|
224 | if (minFFT > maxFFT): | |
225 | raise ValueError("Error selecting heights: Height range (%d,%d) is not valid" % (minFFT, maxFFT)) |
|
225 | raise ValueError("Error selecting heights: Height range (%d,%d) is not valid" % (minFFT, maxFFT)) | |
226 |
|
226 | |||
227 | if (minFFT < self.dataOut.getFreqRange()[0]): |
|
227 | if (minFFT < self.dataOut.getFreqRange()[0]): | |
228 | minFFT = self.dataOut.getFreqRange()[0] |
|
228 | minFFT = self.dataOut.getFreqRange()[0] | |
229 |
|
229 | |||
230 | if (maxFFT > self.dataOut.getFreqRange()[-1]): |
|
230 | if (maxFFT > self.dataOut.getFreqRange()[-1]): | |
231 | maxFFT = self.dataOut.getFreqRange()[-1] |
|
231 | maxFFT = self.dataOut.getFreqRange()[-1] | |
232 |
|
232 | |||
233 | minIndex = 0 |
|
233 | minIndex = 0 | |
234 | maxIndex = 0 |
|
234 | maxIndex = 0 | |
235 | FFTs = self.dataOut.getFreqRange() |
|
235 | FFTs = self.dataOut.getFreqRange() | |
236 |
|
236 | |||
237 | inda = numpy.where(FFTs >= minFFT) |
|
237 | inda = numpy.where(FFTs >= minFFT) | |
238 | indb = numpy.where(FFTs <= maxFFT) |
|
238 | indb = numpy.where(FFTs <= maxFFT) | |
239 |
|
239 | |||
240 | try: |
|
240 | try: | |
241 | minIndex = inda[0][0] |
|
241 | minIndex = inda[0][0] | |
242 | except: |
|
242 | except: | |
243 | minIndex = 0 |
|
243 | minIndex = 0 | |
244 |
|
244 | |||
245 | try: |
|
245 | try: | |
246 | maxIndex = indb[0][-1] |
|
246 | maxIndex = indb[0][-1] | |
247 | except: |
|
247 | except: | |
248 | maxIndex = len(FFTs) |
|
248 | maxIndex = len(FFTs) | |
249 |
|
249 | |||
250 | self.selectFFTsByIndex(minIndex, maxIndex) |
|
250 | self.selectFFTsByIndex(minIndex, maxIndex) | |
251 |
|
251 | |||
252 | return 1 |
|
252 | return 1 | |
253 |
|
253 | |||
254 | def getBeaconSignal(self, tauindex=0, channelindex=0, hei_ref=None): |
|
254 | def getBeaconSignal(self, tauindex=0, channelindex=0, hei_ref=None): | |
255 | newheis = numpy.where( |
|
255 | newheis = numpy.where( | |
256 | self.dataOut.heightList > self.dataOut.radarControllerHeaderObj.Taus[tauindex]) |
|
256 | self.dataOut.heightList > self.dataOut.radarControllerHeaderObj.Taus[tauindex]) | |
257 |
|
257 | |||
258 | if hei_ref != None: |
|
258 | if hei_ref != None: | |
259 | newheis = numpy.where(self.dataOut.heightList > hei_ref) |
|
259 | newheis = numpy.where(self.dataOut.heightList > hei_ref) | |
260 |
|
260 | |||
261 | minIndex = min(newheis[0]) |
|
261 | minIndex = min(newheis[0]) | |
262 | maxIndex = max(newheis[0]) |
|
262 | maxIndex = max(newheis[0]) | |
263 | data_spc = self.dataOut.data_spc[:, :, minIndex:maxIndex + 1] |
|
263 | data_spc = self.dataOut.data_spc[:, :, minIndex:maxIndex + 1] | |
264 | heightList = self.dataOut.heightList[minIndex:maxIndex + 1] |
|
264 | heightList = self.dataOut.heightList[minIndex:maxIndex + 1] | |
265 |
|
265 | |||
266 | # determina indices |
|
266 | # determina indices | |
267 | nheis = int(self.dataOut.radarControllerHeaderObj.txB / |
|
267 | nheis = int(self.dataOut.radarControllerHeaderObj.txB / | |
268 | (self.dataOut.heightList[1] - self.dataOut.heightList[0])) |
|
268 | (self.dataOut.heightList[1] - self.dataOut.heightList[0])) | |
269 | avg_dB = 10 * \ |
|
269 | avg_dB = 10 * \ | |
270 | numpy.log10(numpy.sum(data_spc[channelindex, :, :], axis=0)) |
|
270 | numpy.log10(numpy.sum(data_spc[channelindex, :, :], axis=0)) | |
271 | beacon_dB = numpy.sort(avg_dB)[-nheis:] |
|
271 | beacon_dB = numpy.sort(avg_dB)[-nheis:] | |
272 | beacon_heiIndexList = [] |
|
272 | beacon_heiIndexList = [] | |
273 | for val in avg_dB.tolist(): |
|
273 | for val in avg_dB.tolist(): | |
274 | if val >= beacon_dB[0]: |
|
274 | if val >= beacon_dB[0]: | |
275 | beacon_heiIndexList.append(avg_dB.tolist().index(val)) |
|
275 | beacon_heiIndexList.append(avg_dB.tolist().index(val)) | |
276 |
|
276 | |||
277 | #data_spc = data_spc[:,:,beacon_heiIndexList] |
|
277 | #data_spc = data_spc[:,:,beacon_heiIndexList] | |
278 | data_cspc = None |
|
278 | data_cspc = None | |
279 | if self.dataOut.data_cspc is not None: |
|
279 | if self.dataOut.data_cspc is not None: | |
280 | data_cspc = self.dataOut.data_cspc[:, :, minIndex:maxIndex + 1] |
|
280 | data_cspc = self.dataOut.data_cspc[:, :, minIndex:maxIndex + 1] | |
281 | #data_cspc = data_cspc[:,:,beacon_heiIndexList] |
|
281 | #data_cspc = data_cspc[:,:,beacon_heiIndexList] | |
282 |
|
282 | |||
283 | data_dc = None |
|
283 | data_dc = None | |
284 | if self.dataOut.data_dc is not None: |
|
284 | if self.dataOut.data_dc is not None: | |
285 | data_dc = self.dataOut.data_dc[:, minIndex:maxIndex + 1] |
|
285 | data_dc = self.dataOut.data_dc[:, minIndex:maxIndex + 1] | |
286 | #data_dc = data_dc[:,beacon_heiIndexList] |
|
286 | #data_dc = data_dc[:,beacon_heiIndexList] | |
287 |
|
287 | |||
288 | self.dataOut.data_spc = data_spc |
|
288 | self.dataOut.data_spc = data_spc | |
289 | self.dataOut.data_cspc = data_cspc |
|
289 | self.dataOut.data_cspc = data_cspc | |
290 | self.dataOut.data_dc = data_dc |
|
290 | self.dataOut.data_dc = data_dc | |
291 | self.dataOut.heightList = heightList |
|
291 | self.dataOut.heightList = heightList | |
292 | self.dataOut.beacon_heiIndexList = beacon_heiIndexList |
|
292 | self.dataOut.beacon_heiIndexList = beacon_heiIndexList | |
293 |
|
293 | |||
294 | return 1 |
|
294 | return 1 | |
295 |
|
295 | |||
296 | def selectFFTsByIndex(self, minIndex, maxIndex): |
|
296 | def selectFFTsByIndex(self, minIndex, maxIndex): | |
297 | """ |
|
297 | """ | |
298 |
|
298 | |||
299 | """ |
|
299 | """ | |
300 |
|
300 | |||
301 | if (minIndex < 0) or (minIndex > maxIndex): |
|
301 | if (minIndex < 0) or (minIndex > maxIndex): | |
302 | raise ValueError("Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex)) |
|
302 | raise ValueError("Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex)) | |
303 |
|
303 | |||
304 | if (maxIndex >= self.dataOut.nProfiles): |
|
304 | if (maxIndex >= self.dataOut.nProfiles): | |
305 | maxIndex = self.dataOut.nProfiles-1 |
|
305 | maxIndex = self.dataOut.nProfiles-1 | |
306 |
|
306 | |||
307 | #Spectra |
|
307 | #Spectra | |
308 | data_spc = self.dataOut.data_spc[:,minIndex:maxIndex+1,:] |
|
308 | data_spc = self.dataOut.data_spc[:,minIndex:maxIndex+1,:] | |
309 |
|
309 | |||
310 | data_cspc = None |
|
310 | data_cspc = None | |
311 | if self.dataOut.data_cspc is not None: |
|
311 | if self.dataOut.data_cspc is not None: | |
312 | data_cspc = self.dataOut.data_cspc[:,minIndex:maxIndex+1,:] |
|
312 | data_cspc = self.dataOut.data_cspc[:,minIndex:maxIndex+1,:] | |
313 |
|
313 | |||
314 | data_dc = None |
|
314 | data_dc = None | |
315 | if self.dataOut.data_dc is not None: |
|
315 | if self.dataOut.data_dc is not None: | |
316 | data_dc = self.dataOut.data_dc[minIndex:maxIndex+1,:] |
|
316 | data_dc = self.dataOut.data_dc[minIndex:maxIndex+1,:] | |
317 |
|
317 | |||
318 | self.dataOut.data_spc = data_spc |
|
318 | self.dataOut.data_spc = data_spc | |
319 | self.dataOut.data_cspc = data_cspc |
|
319 | self.dataOut.data_cspc = data_cspc | |
320 | self.dataOut.data_dc = data_dc |
|
320 | self.dataOut.data_dc = data_dc | |
321 |
|
321 | |||
322 | self.dataOut.ippSeconds = self.dataOut.ippSeconds*(self.dataOut.nFFTPoints / numpy.shape(data_cspc)[1]) |
|
322 | self.dataOut.ippSeconds = self.dataOut.ippSeconds*(self.dataOut.nFFTPoints / numpy.shape(data_cspc)[1]) | |
323 | self.dataOut.nFFTPoints = numpy.shape(data_cspc)[1] |
|
323 | self.dataOut.nFFTPoints = numpy.shape(data_cspc)[1] | |
324 | self.dataOut.profilesPerBlock = numpy.shape(data_cspc)[1] |
|
324 | self.dataOut.profilesPerBlock = numpy.shape(data_cspc)[1] | |
325 |
|
325 | |||
326 | return 1 |
|
326 | return 1 | |
327 |
|
327 | |||
328 | def getNoise(self, minHei=None, maxHei=None, minVel=None, maxVel=None): |
|
328 | def getNoise(self, minHei=None, maxHei=None, minVel=None, maxVel=None): | |
329 | # validacion de rango |
|
329 | # validacion de rango | |
330 | if minHei == None: |
|
330 | if minHei == None: | |
331 | minHei = self.dataOut.heightList[0] |
|
331 | minHei = self.dataOut.heightList[0] | |
332 |
|
332 | |||
333 | if maxHei == None: |
|
333 | if maxHei == None: | |
334 | maxHei = self.dataOut.heightList[-1] |
|
334 | maxHei = self.dataOut.heightList[-1] | |
335 |
|
335 | |||
336 | if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): |
|
336 | if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): | |
337 | print('minHei: %.2f is out of the heights range' % (minHei)) |
|
337 | print('minHei: %.2f is out of the heights range' % (minHei)) | |
338 | print('minHei is setting to %.2f' % (self.dataOut.heightList[0])) |
|
338 | print('minHei is setting to %.2f' % (self.dataOut.heightList[0])) | |
339 | minHei = self.dataOut.heightList[0] |
|
339 | minHei = self.dataOut.heightList[0] | |
340 |
|
340 | |||
341 | if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei): |
|
341 | if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei): | |
342 | print('maxHei: %.2f is out of the heights range' % (maxHei)) |
|
342 | print('maxHei: %.2f is out of the heights range' % (maxHei)) | |
343 | print('maxHei is setting to %.2f' % (self.dataOut.heightList[-1])) |
|
343 | print('maxHei is setting to %.2f' % (self.dataOut.heightList[-1])) | |
344 | maxHei = self.dataOut.heightList[-1] |
|
344 | maxHei = self.dataOut.heightList[-1] | |
345 |
|
345 | |||
346 | # validacion de velocidades |
|
346 | # validacion de velocidades | |
347 | velrange = self.dataOut.getVelRange(1) |
|
347 | velrange = self.dataOut.getVelRange(1) | |
348 |
|
348 | |||
349 | if minVel == None: |
|
349 | if minVel == None: | |
350 | minVel = velrange[0] |
|
350 | minVel = velrange[0] | |
351 |
|
351 | |||
352 | if maxVel == None: |
|
352 | if maxVel == None: | |
353 | maxVel = velrange[-1] |
|
353 | maxVel = velrange[-1] | |
354 |
|
354 | |||
355 | if (minVel < velrange[0]) or (minVel > maxVel): |
|
355 | if (minVel < velrange[0]) or (minVel > maxVel): | |
356 | print('minVel: %.2f is out of the velocity range' % (minVel)) |
|
356 | print('minVel: %.2f is out of the velocity range' % (minVel)) | |
357 | print('minVel is setting to %.2f' % (velrange[0])) |
|
357 | print('minVel is setting to %.2f' % (velrange[0])) | |
358 | minVel = velrange[0] |
|
358 | minVel = velrange[0] | |
359 |
|
359 | |||
360 | if (maxVel > velrange[-1]) or (maxVel < minVel): |
|
360 | if (maxVel > velrange[-1]) or (maxVel < minVel): | |
361 | print('maxVel: %.2f is out of the velocity range' % (maxVel)) |
|
361 | print('maxVel: %.2f is out of the velocity range' % (maxVel)) | |
362 | print('maxVel is setting to %.2f' % (velrange[-1])) |
|
362 | print('maxVel is setting to %.2f' % (velrange[-1])) | |
363 | maxVel = velrange[-1] |
|
363 | maxVel = velrange[-1] | |
364 |
|
364 | |||
365 | # seleccion de indices para rango |
|
365 | # seleccion de indices para rango | |
366 | minIndex = 0 |
|
366 | minIndex = 0 | |
367 | maxIndex = 0 |
|
367 | maxIndex = 0 | |
368 | heights = self.dataOut.heightList |
|
368 | heights = self.dataOut.heightList | |
369 |
|
369 | |||
370 | inda = numpy.where(heights >= minHei) |
|
370 | inda = numpy.where(heights >= minHei) | |
371 | indb = numpy.where(heights <= maxHei) |
|
371 | indb = numpy.where(heights <= maxHei) | |
372 |
|
372 | |||
373 | try: |
|
373 | try: | |
374 | minIndex = inda[0][0] |
|
374 | minIndex = inda[0][0] | |
375 | except: |
|
375 | except: | |
376 | minIndex = 0 |
|
376 | minIndex = 0 | |
377 |
|
377 | |||
378 | try: |
|
378 | try: | |
379 | maxIndex = indb[0][-1] |
|
379 | maxIndex = indb[0][-1] | |
380 | except: |
|
380 | except: | |
381 | maxIndex = len(heights) |
|
381 | maxIndex = len(heights) | |
382 |
|
382 | |||
383 | if (minIndex < 0) or (minIndex > maxIndex): |
|
383 | if (minIndex < 0) or (minIndex > maxIndex): | |
384 | raise ValueError("some value in (%d,%d) is not valid" % ( |
|
384 | raise ValueError("some value in (%d,%d) is not valid" % ( | |
385 | minIndex, maxIndex)) |
|
385 | minIndex, maxIndex)) | |
386 |
|
386 | |||
387 | if (maxIndex >= self.dataOut.nHeights): |
|
387 | if (maxIndex >= self.dataOut.nHeights): | |
388 | maxIndex = self.dataOut.nHeights - 1 |
|
388 | maxIndex = self.dataOut.nHeights - 1 | |
389 |
|
389 | |||
390 | # seleccion de indices para velocidades |
|
390 | # seleccion de indices para velocidades | |
391 | indminvel = numpy.where(velrange >= minVel) |
|
391 | indminvel = numpy.where(velrange >= minVel) | |
392 | indmaxvel = numpy.where(velrange <= maxVel) |
|
392 | indmaxvel = numpy.where(velrange <= maxVel) | |
393 | try: |
|
393 | try: | |
394 | minIndexVel = indminvel[0][0] |
|
394 | minIndexVel = indminvel[0][0] | |
395 | except: |
|
395 | except: | |
396 | minIndexVel = 0 |
|
396 | minIndexVel = 0 | |
397 |
|
397 | |||
398 | try: |
|
398 | try: | |
399 | maxIndexVel = indmaxvel[0][-1] |
|
399 | maxIndexVel = indmaxvel[0][-1] | |
400 | except: |
|
400 | except: | |
401 | maxIndexVel = len(velrange) |
|
401 | maxIndexVel = len(velrange) | |
402 |
|
402 | |||
403 | # seleccion del espectro |
|
403 | # seleccion del espectro | |
404 | data_spc = self.dataOut.data_spc[:, |
|
404 | data_spc = self.dataOut.data_spc[:, | |
405 | minIndexVel:maxIndexVel + 1, minIndex:maxIndex + 1] |
|
405 | minIndexVel:maxIndexVel + 1, minIndex:maxIndex + 1] | |
406 | # estimacion de ruido |
|
406 | # estimacion de ruido | |
407 | noise = numpy.zeros(self.dataOut.nChannels) |
|
407 | noise = numpy.zeros(self.dataOut.nChannels) | |
408 |
|
408 | |||
409 | for channel in range(self.dataOut.nChannels): |
|
409 | for channel in range(self.dataOut.nChannels): | |
410 | daux = data_spc[channel, :, :] |
|
410 | daux = data_spc[channel, :, :] | |
411 | sortdata = numpy.sort(daux, axis=None) |
|
411 | sortdata = numpy.sort(daux, axis=None) | |
412 | noise[channel] = hildebrand_sekhon(sortdata, self.dataOut.nIncohInt) |
|
412 | noise[channel] = hildebrand_sekhon(sortdata, self.dataOut.nIncohInt) | |
413 |
|
413 | |||
414 | self.dataOut.noise_estimation = noise.copy() |
|
414 | self.dataOut.noise_estimation = noise.copy() | |
415 |
|
415 | |||
416 | return 1 |
|
416 | return 1 | |
417 |
|
417 | |||
418 | class removeDC(Operation): |
|
418 | class removeDC(Operation): | |
419 |
|
419 | |||
420 | def run(self, dataOut, mode=2): |
|
420 | def run(self, dataOut, mode=2): | |
421 | self.dataOut = dataOut |
|
421 | self.dataOut = dataOut | |
422 | jspectra = self.dataOut.data_spc |
|
422 | jspectra = self.dataOut.data_spc | |
423 | jcspectra = self.dataOut.data_cspc |
|
423 | jcspectra = self.dataOut.data_cspc | |
424 |
|
424 | |||
425 | num_chan = jspectra.shape[0] |
|
425 | num_chan = jspectra.shape[0] | |
426 | num_hei = jspectra.shape[2] |
|
426 | num_hei = jspectra.shape[2] | |
427 |
|
427 | |||
428 | if jcspectra is not None: |
|
428 | if jcspectra is not None: | |
429 | jcspectraExist = True |
|
429 | jcspectraExist = True | |
430 | num_pairs = jcspectra.shape[0] |
|
430 | num_pairs = jcspectra.shape[0] | |
431 | else: |
|
431 | else: | |
432 | jcspectraExist = False |
|
432 | jcspectraExist = False | |
433 |
|
433 | |||
434 | freq_dc = int(jspectra.shape[1] / 2) |
|
434 | freq_dc = int(jspectra.shape[1] / 2) | |
435 | ind_vel = numpy.array([-2, -1, 1, 2]) + freq_dc |
|
435 | ind_vel = numpy.array([-2, -1, 1, 2]) + freq_dc | |
436 | ind_vel = ind_vel.astype(int) |
|
436 | ind_vel = ind_vel.astype(int) | |
437 |
|
437 | |||
438 | if ind_vel[0] < 0: |
|
438 | if ind_vel[0] < 0: | |
439 | ind_vel[list(range(0, 1))] = ind_vel[list(range(0, 1))] + self.num_prof |
|
439 | ind_vel[list(range(0, 1))] = ind_vel[list(range(0, 1))] + self.num_prof | |
440 |
|
440 | |||
441 | if mode == 1: |
|
441 | if mode == 1: | |
442 | jspectra[:, freq_dc, :] = ( |
|
442 | jspectra[:, freq_dc, :] = ( | |
443 | jspectra[:, ind_vel[1], :] + jspectra[:, ind_vel[2], :]) / 2 # CORRECCION |
|
443 | jspectra[:, ind_vel[1], :] + jspectra[:, ind_vel[2], :]) / 2 # CORRECCION | |
444 |
|
444 | |||
445 | if jcspectraExist: |
|
445 | if jcspectraExist: | |
446 | jcspectra[:, freq_dc, :] = ( |
|
446 | jcspectra[:, freq_dc, :] = ( | |
447 | jcspectra[:, ind_vel[1], :] + jcspectra[:, ind_vel[2], :]) / 2 |
|
447 | jcspectra[:, ind_vel[1], :] + jcspectra[:, ind_vel[2], :]) / 2 | |
448 |
|
448 | |||
449 | if mode == 2: |
|
449 | if mode == 2: | |
450 |
|
450 | |||
451 | vel = numpy.array([-2, -1, 1, 2]) |
|
451 | vel = numpy.array([-2, -1, 1, 2]) | |
452 | xx = numpy.zeros([4, 4]) |
|
452 | xx = numpy.zeros([4, 4]) | |
453 |
|
453 | |||
454 | for fil in range(4): |
|
454 | for fil in range(4): | |
455 | xx[fil, :] = vel[fil]**numpy.asarray(list(range(4))) |
|
455 | xx[fil, :] = vel[fil]**numpy.asarray(list(range(4))) | |
456 |
|
456 | |||
457 | xx_inv = numpy.linalg.inv(xx) |
|
457 | xx_inv = numpy.linalg.inv(xx) | |
458 | xx_aux = xx_inv[0, :] |
|
458 | xx_aux = xx_inv[0, :] | |
459 |
|
459 | |||
460 | for ich in range(num_chan): |
|
460 | for ich in range(num_chan): | |
461 | yy = jspectra[ich, ind_vel, :] |
|
461 | yy = jspectra[ich, ind_vel, :] | |
462 | jspectra[ich, freq_dc, :] = numpy.dot(xx_aux, yy) |
|
462 | jspectra[ich, freq_dc, :] = numpy.dot(xx_aux, yy) | |
463 |
|
463 | |||
464 | junkid = jspectra[ich, freq_dc, :] <= 0 |
|
464 | junkid = jspectra[ich, freq_dc, :] <= 0 | |
465 | cjunkid = sum(junkid) |
|
465 | cjunkid = sum(junkid) | |
466 |
|
466 | |||
467 | if cjunkid.any(): |
|
467 | if cjunkid.any(): | |
468 | jspectra[ich, freq_dc, junkid.nonzero()] = ( |
|
468 | jspectra[ich, freq_dc, junkid.nonzero()] = ( | |
469 | jspectra[ich, ind_vel[1], junkid] + jspectra[ich, ind_vel[2], junkid]) / 2 |
|
469 | jspectra[ich, ind_vel[1], junkid] + jspectra[ich, ind_vel[2], junkid]) / 2 | |
470 |
|
470 | |||
471 | if jcspectraExist: |
|
471 | if jcspectraExist: | |
472 | for ip in range(num_pairs): |
|
472 | for ip in range(num_pairs): | |
473 | yy = jcspectra[ip, ind_vel, :] |
|
473 | yy = jcspectra[ip, ind_vel, :] | |
474 | jcspectra[ip, freq_dc, :] = numpy.dot(xx_aux, yy) |
|
474 | jcspectra[ip, freq_dc, :] = numpy.dot(xx_aux, yy) | |
475 |
|
475 | |||
476 | self.dataOut.data_spc = jspectra |
|
476 | self.dataOut.data_spc = jspectra | |
477 | self.dataOut.data_cspc = jcspectra |
|
477 | self.dataOut.data_cspc = jcspectra | |
478 |
|
478 | |||
479 | return self.dataOut |
|
479 | return self.dataOut | |
480 |
|
480 | |||
481 | class removeInterference(Operation): |
|
481 | class removeInterference(Operation): | |
482 |
|
482 | |||
483 | def removeInterference2(self): |
|
483 | def removeInterference2(self): | |
484 |
|
484 | |||
485 | cspc = self.dataOut.data_cspc |
|
485 | cspc = self.dataOut.data_cspc | |
486 | spc = self.dataOut.data_spc |
|
486 | spc = self.dataOut.data_spc | |
487 | Heights = numpy.arange(cspc.shape[2]) |
|
487 | Heights = numpy.arange(cspc.shape[2]) | |
488 | realCspc = numpy.abs(cspc) |
|
488 | realCspc = numpy.abs(cspc) | |
489 |
|
489 | |||
490 | for i in range(cspc.shape[0]): |
|
490 | for i in range(cspc.shape[0]): | |
491 | LinePower= numpy.sum(realCspc[i], axis=0) |
|
491 | LinePower= numpy.sum(realCspc[i], axis=0) | |
492 | Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)] |
|
492 | Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)] | |
493 | SelectedHeights = Heights[ numpy.where( LinePower < Threshold ) ] |
|
493 | SelectedHeights = Heights[ numpy.where( LinePower < Threshold ) ] | |
494 | InterferenceSum = numpy.sum( realCspc[i,:,SelectedHeights], axis=0 ) |
|
494 | InterferenceSum = numpy.sum( realCspc[i,:,SelectedHeights], axis=0 ) | |
495 | InterferenceThresholdMin = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)] |
|
495 | InterferenceThresholdMin = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)] | |
496 | InterferenceThresholdMax = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.99)] |
|
496 | InterferenceThresholdMax = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.99)] | |
497 |
|
497 | |||
498 |
|
498 | |||
499 | InterferenceRange = numpy.where( ([InterferenceSum > InterferenceThresholdMin]))# , InterferenceSum < InterferenceThresholdMax]) ) |
|
499 | InterferenceRange = numpy.where( ([InterferenceSum > InterferenceThresholdMin]))# , InterferenceSum < InterferenceThresholdMax]) ) | |
500 | #InterferenceRange = numpy.where( ([InterferenceRange < InterferenceThresholdMax])) |
|
500 | #InterferenceRange = numpy.where( ([InterferenceRange < InterferenceThresholdMax])) | |
501 | if len(InterferenceRange)<int(cspc.shape[1]*0.3): |
|
501 | if len(InterferenceRange)<int(cspc.shape[1]*0.3): | |
502 | cspc[i,InterferenceRange,:] = numpy.NaN |
|
502 | cspc[i,InterferenceRange,:] = numpy.NaN | |
503 |
|
503 | |||
504 | self.dataOut.data_cspc = cspc |
|
504 | self.dataOut.data_cspc = cspc | |
505 |
|
505 | |||
506 | def removeInterference(self, interf = 2, hei_interf = None, nhei_interf = None, offhei_interf = None): |
|
506 | def removeInterference(self, interf = 2, hei_interf = None, nhei_interf = None, offhei_interf = None): | |
507 |
|
507 | |||
508 | jspectra = self.dataOut.data_spc |
|
508 | jspectra = self.dataOut.data_spc | |
509 | jcspectra = self.dataOut.data_cspc |
|
509 | jcspectra = self.dataOut.data_cspc | |
510 | jnoise = self.dataOut.getNoise() |
|
510 | jnoise = self.dataOut.getNoise() | |
511 | num_incoh = self.dataOut.nIncohInt |
|
511 | num_incoh = self.dataOut.nIncohInt | |
512 |
|
512 | |||
513 | num_channel = jspectra.shape[0] |
|
513 | num_channel = jspectra.shape[0] | |
514 | num_prof = jspectra.shape[1] |
|
514 | num_prof = jspectra.shape[1] | |
515 | num_hei = jspectra.shape[2] |
|
515 | num_hei = jspectra.shape[2] | |
516 |
|
516 | |||
517 | # hei_interf |
|
517 | # hei_interf | |
518 | if hei_interf is None: |
|
518 | if hei_interf is None: | |
519 | count_hei = int(num_hei / 2) |
|
519 | count_hei = int(num_hei / 2) | |
520 | hei_interf = numpy.asmatrix(list(range(count_hei))) + num_hei - count_hei |
|
520 | hei_interf = numpy.asmatrix(list(range(count_hei))) + num_hei - count_hei | |
521 | hei_interf = numpy.asarray(hei_interf)[0] |
|
521 | hei_interf = numpy.asarray(hei_interf)[0] | |
522 | # nhei_interf |
|
522 | # nhei_interf | |
523 | if (nhei_interf == None): |
|
523 | if (nhei_interf == None): | |
524 | nhei_interf = 5 |
|
524 | nhei_interf = 5 | |
525 | if (nhei_interf < 1): |
|
525 | if (nhei_interf < 1): | |
526 | nhei_interf = 1 |
|
526 | nhei_interf = 1 | |
527 | if (nhei_interf > count_hei): |
|
527 | if (nhei_interf > count_hei): | |
528 | nhei_interf = count_hei |
|
528 | nhei_interf = count_hei | |
529 | if (offhei_interf == None): |
|
529 | if (offhei_interf == None): | |
530 | offhei_interf = 0 |
|
530 | offhei_interf = 0 | |
531 |
|
531 | |||
532 | ind_hei = list(range(num_hei)) |
|
532 | ind_hei = list(range(num_hei)) | |
533 | # mask_prof = numpy.asarray(range(num_prof - 2)) + 1 |
|
533 | # mask_prof = numpy.asarray(range(num_prof - 2)) + 1 | |
534 | # mask_prof[range(num_prof/2 - 1,len(mask_prof))] += 1 |
|
534 | # mask_prof[range(num_prof/2 - 1,len(mask_prof))] += 1 | |
535 | mask_prof = numpy.asarray(list(range(num_prof))) |
|
535 | mask_prof = numpy.asarray(list(range(num_prof))) | |
536 | num_mask_prof = mask_prof.size |
|
536 | num_mask_prof = mask_prof.size | |
537 | comp_mask_prof = [0, num_prof / 2] |
|
537 | comp_mask_prof = [0, num_prof / 2] | |
538 |
|
538 | |||
539 | # noise_exist: Determina si la variable jnoise ha sido definida y contiene la informacion del ruido de cada canal |
|
539 | # noise_exist: Determina si la variable jnoise ha sido definida y contiene la informacion del ruido de cada canal | |
540 | if (jnoise.size < num_channel or numpy.isnan(jnoise).any()): |
|
540 | if (jnoise.size < num_channel or numpy.isnan(jnoise).any()): | |
541 | jnoise = numpy.nan |
|
541 | jnoise = numpy.nan | |
542 | noise_exist = jnoise[0] < numpy.Inf |
|
542 | noise_exist = jnoise[0] < numpy.Inf | |
543 |
|
543 | |||
544 | # Subrutina de Remocion de la Interferencia |
|
544 | # Subrutina de Remocion de la Interferencia | |
545 | for ich in range(num_channel): |
|
545 | for ich in range(num_channel): | |
546 | # Se ordena los espectros segun su potencia (menor a mayor) |
|
546 | # Se ordena los espectros segun su potencia (menor a mayor) | |
547 | power = jspectra[ich, mask_prof, :] |
|
547 | power = jspectra[ich, mask_prof, :] | |
548 | power = power[:, hei_interf] |
|
548 | power = power[:, hei_interf] | |
549 | power = power.sum(axis=0) |
|
549 | power = power.sum(axis=0) | |
550 | psort = power.ravel().argsort() |
|
550 | psort = power.ravel().argsort() | |
551 |
|
551 | |||
552 | # Se estima la interferencia promedio en los Espectros de Potencia empleando |
|
552 | # Se estima la interferencia promedio en los Espectros de Potencia empleando | |
553 | junkspc_interf = jspectra[ich, :, hei_interf[psort[list(range( |
|
553 | junkspc_interf = jspectra[ich, :, hei_interf[psort[list(range( | |
554 | offhei_interf, nhei_interf + offhei_interf))]]] |
|
554 | offhei_interf, nhei_interf + offhei_interf))]]] | |
555 |
|
555 | |||
556 | if noise_exist: |
|
556 | if noise_exist: | |
557 | # tmp_noise = jnoise[ich] / num_prof |
|
557 | # tmp_noise = jnoise[ich] / num_prof | |
558 | tmp_noise = jnoise[ich] |
|
558 | tmp_noise = jnoise[ich] | |
559 | junkspc_interf = junkspc_interf - tmp_noise |
|
559 | junkspc_interf = junkspc_interf - tmp_noise | |
560 | #junkspc_interf[:,comp_mask_prof] = 0 |
|
560 | #junkspc_interf[:,comp_mask_prof] = 0 | |
561 |
|
561 | |||
562 | jspc_interf = junkspc_interf.sum(axis=0) / nhei_interf |
|
562 | jspc_interf = junkspc_interf.sum(axis=0) / nhei_interf | |
563 | jspc_interf = jspc_interf.transpose() |
|
563 | jspc_interf = jspc_interf.transpose() | |
564 | # Calculando el espectro de interferencia promedio |
|
564 | # Calculando el espectro de interferencia promedio | |
565 | noiseid = numpy.where( |
|
565 | noiseid = numpy.where( | |
566 | jspc_interf <= tmp_noise / numpy.sqrt(num_incoh)) |
|
566 | jspc_interf <= tmp_noise / numpy.sqrt(num_incoh)) | |
567 | noiseid = noiseid[0] |
|
567 | noiseid = noiseid[0] | |
568 | cnoiseid = noiseid.size |
|
568 | cnoiseid = noiseid.size | |
569 | interfid = numpy.where( |
|
569 | interfid = numpy.where( | |
570 | jspc_interf > tmp_noise / numpy.sqrt(num_incoh)) |
|
570 | jspc_interf > tmp_noise / numpy.sqrt(num_incoh)) | |
571 | interfid = interfid[0] |
|
571 | interfid = interfid[0] | |
572 | cinterfid = interfid.size |
|
572 | cinterfid = interfid.size | |
573 |
|
573 | |||
574 | if (cnoiseid > 0): |
|
574 | if (cnoiseid > 0): | |
575 | jspc_interf[noiseid] = 0 |
|
575 | jspc_interf[noiseid] = 0 | |
576 |
|
576 | |||
577 | # Expandiendo los perfiles a limpiar |
|
577 | # Expandiendo los perfiles a limpiar | |
578 | if (cinterfid > 0): |
|
578 | if (cinterfid > 0): | |
579 | new_interfid = ( |
|
579 | new_interfid = ( | |
580 | numpy.r_[interfid - 1, interfid, interfid + 1] + num_prof) % num_prof |
|
580 | numpy.r_[interfid - 1, interfid, interfid + 1] + num_prof) % num_prof | |
581 | new_interfid = numpy.asarray(new_interfid) |
|
581 | new_interfid = numpy.asarray(new_interfid) | |
582 | new_interfid = {x for x in new_interfid} |
|
582 | new_interfid = {x for x in new_interfid} | |
583 | new_interfid = numpy.array(list(new_interfid)) |
|
583 | new_interfid = numpy.array(list(new_interfid)) | |
584 | new_cinterfid = new_interfid.size |
|
584 | new_cinterfid = new_interfid.size | |
585 | else: |
|
585 | else: | |
586 | new_cinterfid = 0 |
|
586 | new_cinterfid = 0 | |
587 |
|
587 | |||
588 | for ip in range(new_cinterfid): |
|
588 | for ip in range(new_cinterfid): | |
589 | ind = junkspc_interf[:, new_interfid[ip]].ravel().argsort() |
|
589 | ind = junkspc_interf[:, new_interfid[ip]].ravel().argsort() | |
590 | jspc_interf[new_interfid[ip] |
|
590 | jspc_interf[new_interfid[ip] | |
591 | ] = junkspc_interf[ind[nhei_interf // 2], new_interfid[ip]] |
|
591 | ] = junkspc_interf[ind[nhei_interf // 2], new_interfid[ip]] | |
592 |
|
592 | |||
593 | jspectra[ich, :, ind_hei] = jspectra[ich, :, |
|
593 | jspectra[ich, :, ind_hei] = jspectra[ich, :, | |
594 | ind_hei] - jspc_interf # Corregir indices |
|
594 | ind_hei] - jspc_interf # Corregir indices | |
595 |
|
595 | |||
596 | # Removiendo la interferencia del punto de mayor interferencia |
|
596 | # Removiendo la interferencia del punto de mayor interferencia | |
597 | ListAux = jspc_interf[mask_prof].tolist() |
|
597 | ListAux = jspc_interf[mask_prof].tolist() | |
598 | maxid = ListAux.index(max(ListAux)) |
|
598 | maxid = ListAux.index(max(ListAux)) | |
599 |
|
599 | |||
600 | if cinterfid > 0: |
|
600 | if cinterfid > 0: | |
601 | for ip in range(cinterfid * (interf == 2) - 1): |
|
601 | for ip in range(cinterfid * (interf == 2) - 1): | |
602 | ind = (jspectra[ich, interfid[ip], :] < tmp_noise * |
|
602 | ind = (jspectra[ich, interfid[ip], :] < tmp_noise * | |
603 | (1 + 1 / numpy.sqrt(num_incoh))).nonzero() |
|
603 | (1 + 1 / numpy.sqrt(num_incoh))).nonzero() | |
604 | cind = len(ind) |
|
604 | cind = len(ind) | |
605 |
|
605 | |||
606 | if (cind > 0): |
|
606 | if (cind > 0): | |
607 | jspectra[ich, interfid[ip], ind] = tmp_noise * \ |
|
607 | jspectra[ich, interfid[ip], ind] = tmp_noise * \ | |
608 | (1 + (numpy.random.uniform(cind) - 0.5) / |
|
608 | (1 + (numpy.random.uniform(cind) - 0.5) / | |
609 | numpy.sqrt(num_incoh)) |
|
609 | numpy.sqrt(num_incoh)) | |
610 |
|
610 | |||
611 | ind = numpy.array([-2, -1, 1, 2]) |
|
611 | ind = numpy.array([-2, -1, 1, 2]) | |
612 | xx = numpy.zeros([4, 4]) |
|
612 | xx = numpy.zeros([4, 4]) | |
613 |
|
613 | |||
614 | for id1 in range(4): |
|
614 | for id1 in range(4): | |
615 | xx[:, id1] = ind[id1]**numpy.asarray(list(range(4))) |
|
615 | xx[:, id1] = ind[id1]**numpy.asarray(list(range(4))) | |
616 |
|
616 | |||
617 | xx_inv = numpy.linalg.inv(xx) |
|
617 | xx_inv = numpy.linalg.inv(xx) | |
618 | xx = xx_inv[:, 0] |
|
618 | xx = xx_inv[:, 0] | |
619 | ind = (ind + maxid + num_mask_prof) % num_mask_prof |
|
619 | ind = (ind + maxid + num_mask_prof) % num_mask_prof | |
620 | yy = jspectra[ich, mask_prof[ind], :] |
|
620 | yy = jspectra[ich, mask_prof[ind], :] | |
621 | jspectra[ich, mask_prof[maxid], :] = numpy.dot( |
|
621 | jspectra[ich, mask_prof[maxid], :] = numpy.dot( | |
622 | yy.transpose(), xx) |
|
622 | yy.transpose(), xx) | |
623 |
|
623 | |||
624 | indAux = (jspectra[ich, :, :] < tmp_noise * |
|
624 | indAux = (jspectra[ich, :, :] < tmp_noise * | |
625 | (1 - 1 / numpy.sqrt(num_incoh))).nonzero() |
|
625 | (1 - 1 / numpy.sqrt(num_incoh))).nonzero() | |
626 | jspectra[ich, indAux[0], indAux[1]] = tmp_noise * \ |
|
626 | jspectra[ich, indAux[0], indAux[1]] = tmp_noise * \ | |
627 | (1 - 1 / numpy.sqrt(num_incoh)) |
|
627 | (1 - 1 / numpy.sqrt(num_incoh)) | |
628 |
|
628 | |||
629 | # Remocion de Interferencia en el Cross Spectra |
|
629 | # Remocion de Interferencia en el Cross Spectra | |
630 | if jcspectra is None: |
|
630 | if jcspectra is None: | |
631 | return jspectra, jcspectra |
|
631 | return jspectra, jcspectra | |
632 | num_pairs = int(jcspectra.size / (num_prof * num_hei)) |
|
632 | num_pairs = int(jcspectra.size / (num_prof * num_hei)) | |
633 | jcspectra = jcspectra.reshape(num_pairs, num_prof, num_hei) |
|
633 | jcspectra = jcspectra.reshape(num_pairs, num_prof, num_hei) | |
634 |
|
634 | |||
635 | for ip in range(num_pairs): |
|
635 | for ip in range(num_pairs): | |
636 |
|
636 | |||
637 | #------------------------------------------- |
|
637 | #------------------------------------------- | |
638 |
|
638 | |||
639 | cspower = numpy.abs(jcspectra[ip, mask_prof, :]) |
|
639 | cspower = numpy.abs(jcspectra[ip, mask_prof, :]) | |
640 | cspower = cspower[:, hei_interf] |
|
640 | cspower = cspower[:, hei_interf] | |
641 | cspower = cspower.sum(axis=0) |
|
641 | cspower = cspower.sum(axis=0) | |
642 |
|
642 | |||
643 | cspsort = cspower.ravel().argsort() |
|
643 | cspsort = cspower.ravel().argsort() | |
644 | junkcspc_interf = jcspectra[ip, :, hei_interf[cspsort[list(range( |
|
644 | junkcspc_interf = jcspectra[ip, :, hei_interf[cspsort[list(range( | |
645 | offhei_interf, nhei_interf + offhei_interf))]]] |
|
645 | offhei_interf, nhei_interf + offhei_interf))]]] | |
646 | junkcspc_interf = junkcspc_interf.transpose() |
|
646 | junkcspc_interf = junkcspc_interf.transpose() | |
647 | jcspc_interf = junkcspc_interf.sum(axis=1) / nhei_interf |
|
647 | jcspc_interf = junkcspc_interf.sum(axis=1) / nhei_interf | |
648 |
|
648 | |||
649 | ind = numpy.abs(jcspc_interf[mask_prof]).ravel().argsort() |
|
649 | ind = numpy.abs(jcspc_interf[mask_prof]).ravel().argsort() | |
650 |
|
650 | |||
651 | median_real = int(numpy.median(numpy.real( |
|
651 | median_real = int(numpy.median(numpy.real( | |
652 | junkcspc_interf[mask_prof[ind[list(range(3 * num_prof // 4))]], :]))) |
|
652 | junkcspc_interf[mask_prof[ind[list(range(3 * num_prof // 4))]], :]))) | |
653 | median_imag = int(numpy.median(numpy.imag( |
|
653 | median_imag = int(numpy.median(numpy.imag( | |
654 | junkcspc_interf[mask_prof[ind[list(range(3 * num_prof // 4))]], :]))) |
|
654 | junkcspc_interf[mask_prof[ind[list(range(3 * num_prof // 4))]], :]))) | |
655 | comp_mask_prof = [int(e) for e in comp_mask_prof] |
|
655 | comp_mask_prof = [int(e) for e in comp_mask_prof] | |
656 | junkcspc_interf[comp_mask_prof, :] = numpy.complex( |
|
656 | junkcspc_interf[comp_mask_prof, :] = numpy.complex( | |
657 | median_real, median_imag) |
|
657 | median_real, median_imag) | |
658 |
|
658 | |||
659 | for iprof in range(num_prof): |
|
659 | for iprof in range(num_prof): | |
660 | ind = numpy.abs(junkcspc_interf[iprof, :]).ravel().argsort() |
|
660 | ind = numpy.abs(junkcspc_interf[iprof, :]).ravel().argsort() | |
661 | jcspc_interf[iprof] = junkcspc_interf[iprof, ind[nhei_interf // 2]] |
|
661 | jcspc_interf[iprof] = junkcspc_interf[iprof, ind[nhei_interf // 2]] | |
662 |
|
662 | |||
663 | # Removiendo la Interferencia |
|
663 | # Removiendo la Interferencia | |
664 | jcspectra[ip, :, ind_hei] = jcspectra[ip, |
|
664 | jcspectra[ip, :, ind_hei] = jcspectra[ip, | |
665 | :, ind_hei] - jcspc_interf |
|
665 | :, ind_hei] - jcspc_interf | |
666 |
|
666 | |||
667 | ListAux = numpy.abs(jcspc_interf[mask_prof]).tolist() |
|
667 | ListAux = numpy.abs(jcspc_interf[mask_prof]).tolist() | |
668 | maxid = ListAux.index(max(ListAux)) |
|
668 | maxid = ListAux.index(max(ListAux)) | |
669 |
|
669 | |||
670 | ind = numpy.array([-2, -1, 1, 2]) |
|
670 | ind = numpy.array([-2, -1, 1, 2]) | |
671 | xx = numpy.zeros([4, 4]) |
|
671 | xx = numpy.zeros([4, 4]) | |
672 |
|
672 | |||
673 | for id1 in range(4): |
|
673 | for id1 in range(4): | |
674 | xx[:, id1] = ind[id1]**numpy.asarray(list(range(4))) |
|
674 | xx[:, id1] = ind[id1]**numpy.asarray(list(range(4))) | |
675 |
|
675 | |||
676 | xx_inv = numpy.linalg.inv(xx) |
|
676 | xx_inv = numpy.linalg.inv(xx) | |
677 | xx = xx_inv[:, 0] |
|
677 | xx = xx_inv[:, 0] | |
678 |
|
678 | |||
679 | ind = (ind + maxid + num_mask_prof) % num_mask_prof |
|
679 | ind = (ind + maxid + num_mask_prof) % num_mask_prof | |
680 | yy = jcspectra[ip, mask_prof[ind], :] |
|
680 | yy = jcspectra[ip, mask_prof[ind], :] | |
681 | jcspectra[ip, mask_prof[maxid], :] = numpy.dot(yy.transpose(), xx) |
|
681 | jcspectra[ip, mask_prof[maxid], :] = numpy.dot(yy.transpose(), xx) | |
682 |
|
682 | |||
683 | # Guardar Resultados |
|
683 | # Guardar Resultados | |
684 | self.dataOut.data_spc = jspectra |
|
684 | self.dataOut.data_spc = jspectra | |
685 | self.dataOut.data_cspc = jcspectra |
|
685 | self.dataOut.data_cspc = jcspectra | |
686 |
|
686 | |||
687 | return 1 |
|
687 | return 1 | |
688 |
|
688 | |||
689 | def run(self, dataOut, interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None, mode=1): |
|
689 | def run(self, dataOut, interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None, mode=1): | |
690 |
|
690 | |||
691 | self.dataOut = dataOut |
|
691 | self.dataOut = dataOut | |
692 |
|
692 | |||
693 | if mode == 1: |
|
693 | if mode == 1: | |
694 | self.removeInterference(interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None) |
|
694 | self.removeInterference(interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None) | |
695 | elif mode == 2: |
|
695 | elif mode == 2: | |
696 | self.removeInterference2() |
|
696 | self.removeInterference2() | |
697 |
|
697 | |||
698 | return self.dataOut |
|
698 | return self.dataOut | |
699 |
|
699 | |||
700 |
|
700 | |||
701 | class IncohInt(Operation): |
|
701 | class IncohInt(Operation): | |
702 |
|
702 | |||
703 | __profIndex = 0 |
|
703 | __profIndex = 0 | |
704 | __withOverapping = False |
|
704 | __withOverapping = False | |
705 |
|
705 | |||
706 | __byTime = False |
|
706 | __byTime = False | |
707 | __initime = None |
|
707 | __initime = None | |
708 | __lastdatatime = None |
|
708 | __lastdatatime = None | |
709 | __integrationtime = None |
|
709 | __integrationtime = None | |
710 |
|
710 | |||
711 | __buffer_spc = None |
|
711 | __buffer_spc = None | |
712 | __buffer_cspc = None |
|
712 | __buffer_cspc = None | |
713 | __buffer_dc = None |
|
713 | __buffer_dc = None | |
714 |
|
714 | |||
715 | __dataReady = False |
|
715 | __dataReady = False | |
716 |
|
716 | |||
717 | __timeInterval = None |
|
717 | __timeInterval = None | |
718 |
|
718 | |||
719 | n = None |
|
719 | n = None | |
720 |
|
720 | |||
721 | def __init__(self): |
|
721 | def __init__(self): | |
722 |
|
722 | |||
723 | Operation.__init__(self) |
|
723 | Operation.__init__(self) | |
724 |
|
724 | |||
725 | def setup(self, n=None, timeInterval=None, overlapping=False): |
|
725 | def setup(self, n=None, timeInterval=None, overlapping=False): | |
726 | """ |
|
726 | """ | |
727 | Set the parameters of the integration class. |
|
727 | Set the parameters of the integration class. | |
728 |
|
728 | |||
729 | Inputs: |
|
729 | Inputs: | |
730 |
|
730 | |||
731 | n : Number of coherent integrations |
|
731 | n : Number of coherent integrations | |
732 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work |
|
732 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work | |
733 | overlapping : |
|
733 | overlapping : | |
734 |
|
734 | |||
735 | """ |
|
735 | """ | |
736 |
|
736 | |||
737 | self.__initime = None |
|
737 | self.__initime = None | |
738 | self.__lastdatatime = 0 |
|
738 | self.__lastdatatime = 0 | |
739 |
|
739 | |||
740 | self.__buffer_spc = 0 |
|
740 | self.__buffer_spc = 0 | |
741 | self.__buffer_cspc = 0 |
|
741 | self.__buffer_cspc = 0 | |
742 | self.__buffer_dc = 0 |
|
742 | self.__buffer_dc = 0 | |
743 |
|
743 | |||
744 | self.__profIndex = 0 |
|
744 | self.__profIndex = 0 | |
745 | self.__dataReady = False |
|
745 | self.__dataReady = False | |
746 | self.__byTime = False |
|
746 | self.__byTime = False | |
747 |
|
747 | |||
748 | if n is None and timeInterval is None: |
|
748 | if n is None and timeInterval is None: | |
749 | raise ValueError("n or timeInterval should be specified ...") |
|
749 | raise ValueError("n or timeInterval should be specified ...") | |
750 |
|
750 | |||
751 | if n is not None: |
|
751 | if n is not None: | |
752 | self.n = int(n) |
|
752 | self.n = int(n) | |
753 | else: |
|
753 | else: | |
754 |
|
754 | |||
755 | self.__integrationtime = int(timeInterval) |
|
755 | self.__integrationtime = int(timeInterval) | |
756 | self.n = None |
|
756 | self.n = None | |
757 | self.__byTime = True |
|
757 | self.__byTime = True | |
758 |
|
758 | |||
759 | def putData(self, data_spc, data_cspc, data_dc): |
|
759 | def putData(self, data_spc, data_cspc, data_dc): | |
760 | """ |
|
760 | """ | |
761 | Add a profile to the __buffer_spc and increase in one the __profileIndex |
|
761 | Add a profile to the __buffer_spc and increase in one the __profileIndex | |
762 |
|
762 | |||
763 | """ |
|
763 | """ | |
764 |
|
764 | |||
765 | self.__buffer_spc += data_spc |
|
765 | self.__buffer_spc += data_spc | |
766 |
|
766 | |||
767 | if data_cspc is None: |
|
767 | if data_cspc is None: | |
768 | self.__buffer_cspc = None |
|
768 | self.__buffer_cspc = None | |
769 | else: |
|
769 | else: | |
770 | self.__buffer_cspc += data_cspc |
|
770 | self.__buffer_cspc += data_cspc | |
771 |
|
771 | |||
772 | if data_dc is None: |
|
772 | if data_dc is None: | |
773 | self.__buffer_dc = None |
|
773 | self.__buffer_dc = None | |
774 | else: |
|
774 | else: | |
775 | self.__buffer_dc += data_dc |
|
775 | self.__buffer_dc += data_dc | |
776 |
|
776 | |||
777 | self.__profIndex += 1 |
|
777 | self.__profIndex += 1 | |
778 |
|
778 | |||
779 | return |
|
779 | return | |
780 |
|
780 | |||
781 | def pushData(self): |
|
781 | def pushData(self): | |
782 | """ |
|
782 | """ | |
783 | Return the sum of the last profiles and the profiles used in the sum. |
|
783 | Return the sum of the last profiles and the profiles used in the sum. | |
784 |
|
784 | |||
785 | Affected: |
|
785 | Affected: | |
786 |
|
786 | |||
787 | self.__profileIndex |
|
787 | self.__profileIndex | |
788 |
|
788 | |||
789 | """ |
|
789 | """ | |
790 |
|
790 | |||
791 | data_spc = self.__buffer_spc |
|
791 | data_spc = self.__buffer_spc | |
792 | data_cspc = self.__buffer_cspc |
|
792 | data_cspc = self.__buffer_cspc | |
793 | data_dc = self.__buffer_dc |
|
793 | data_dc = self.__buffer_dc | |
794 | n = self.__profIndex |
|
794 | n = self.__profIndex | |
795 |
|
795 | |||
796 | self.__buffer_spc = 0 |
|
796 | self.__buffer_spc = 0 | |
797 | self.__buffer_cspc = 0 |
|
797 | self.__buffer_cspc = 0 | |
798 | self.__buffer_dc = 0 |
|
798 | self.__buffer_dc = 0 | |
799 | self.__profIndex = 0 |
|
799 | self.__profIndex = 0 | |
800 |
|
800 | |||
801 | return data_spc, data_cspc, data_dc, n |
|
801 | return data_spc, data_cspc, data_dc, n | |
802 |
|
802 | |||
803 | def byProfiles(self, *args): |
|
803 | def byProfiles(self, *args): | |
804 |
|
804 | |||
805 | self.__dataReady = False |
|
805 | self.__dataReady = False | |
806 | avgdata_spc = None |
|
806 | avgdata_spc = None | |
807 | avgdata_cspc = None |
|
807 | avgdata_cspc = None | |
808 | avgdata_dc = None |
|
808 | avgdata_dc = None | |
809 |
|
809 | |||
810 | self.putData(*args) |
|
810 | self.putData(*args) | |
811 |
|
811 | |||
812 | if self.__profIndex == self.n: |
|
812 | if self.__profIndex == self.n: | |
813 |
|
813 | |||
814 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() |
|
814 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() | |
815 | self.n = n |
|
815 | self.n = n | |
816 | self.__dataReady = True |
|
816 | self.__dataReady = True | |
817 |
|
817 | |||
818 | return avgdata_spc, avgdata_cspc, avgdata_dc |
|
818 | return avgdata_spc, avgdata_cspc, avgdata_dc | |
819 |
|
819 | |||
820 | def byTime(self, datatime, *args): |
|
820 | def byTime(self, datatime, *args): | |
821 |
|
821 | |||
822 | self.__dataReady = False |
|
822 | self.__dataReady = False | |
823 | avgdata_spc = None |
|
823 | avgdata_spc = None | |
824 | avgdata_cspc = None |
|
824 | avgdata_cspc = None | |
825 | avgdata_dc = None |
|
825 | avgdata_dc = None | |
826 |
|
826 | |||
827 | self.putData(*args) |
|
827 | self.putData(*args) | |
828 |
|
828 | |||
829 | if (datatime - self.__initime) >= self.__integrationtime: |
|
829 | if (datatime - self.__initime) >= self.__integrationtime: | |
830 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() |
|
830 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() | |
831 | self.n = n |
|
831 | self.n = n | |
832 | self.__dataReady = True |
|
832 | self.__dataReady = True | |
833 |
|
833 | |||
834 | return avgdata_spc, avgdata_cspc, avgdata_dc |
|
834 | return avgdata_spc, avgdata_cspc, avgdata_dc | |
835 |
|
835 | |||
836 | def integrate(self, datatime, *args): |
|
836 | def integrate(self, datatime, *args): | |
837 |
|
837 | |||
838 | if self.__profIndex == 0: |
|
838 | if self.__profIndex == 0: | |
839 | self.__initime = datatime |
|
839 | self.__initime = datatime | |
840 |
|
840 | |||
841 | if self.__byTime: |
|
841 | if self.__byTime: | |
842 | avgdata_spc, avgdata_cspc, avgdata_dc = self.byTime( |
|
842 | avgdata_spc, avgdata_cspc, avgdata_dc = self.byTime( | |
843 | datatime, *args) |
|
843 | datatime, *args) | |
844 | else: |
|
844 | else: | |
845 | avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles(*args) |
|
845 | avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles(*args) | |
846 |
|
846 | |||
847 | if not self.__dataReady: |
|
847 | if not self.__dataReady: | |
848 | return None, None, None, None |
|
848 | return None, None, None, None | |
849 |
|
849 | |||
850 | return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc |
|
850 | return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc | |
851 |
|
851 | |||
852 | def run(self, dataOut, n=None, timeInterval=None, overlapping=False): |
|
852 | def run(self, dataOut, n=None, timeInterval=None, overlapping=False): | |
853 | if n == 1: |
|
853 | if n == 1: | |
854 | return dataOut |
|
854 | return dataOut | |
855 |
|
855 | |||
856 | dataOut.flagNoData = True |
|
856 | dataOut.flagNoData = True | |
857 |
|
857 | |||
858 | if not self.isConfig: |
|
858 | if not self.isConfig: | |
859 | self.setup(n, timeInterval, overlapping) |
|
859 | self.setup(n, timeInterval, overlapping) | |
860 | self.isConfig = True |
|
860 | self.isConfig = True | |
861 |
|
861 | |||
862 | avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime, |
|
862 | avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime, | |
863 | dataOut.data_spc, |
|
863 | dataOut.data_spc, | |
864 | dataOut.data_cspc, |
|
864 | dataOut.data_cspc, | |
865 | dataOut.data_dc) |
|
865 | dataOut.data_dc) | |
866 |
|
866 | |||
867 | if self.__dataReady: |
|
867 | if self.__dataReady: | |
868 |
|
868 | |||
869 | dataOut.data_spc = avgdata_spc |
|
869 | dataOut.data_spc = avgdata_spc | |
870 | dataOut.data_cspc = avgdata_cspc |
|
870 | dataOut.data_cspc = avgdata_cspc | |
871 | dataOut.data_dc = avgdata_dc |
|
871 | dataOut.data_dc = avgdata_dc | |
872 | dataOut.nIncohInt *= self.n |
|
872 | dataOut.nIncohInt *= self.n | |
873 | dataOut.utctime = avgdatatime |
|
873 | dataOut.utctime = avgdatatime | |
874 | dataOut.flagNoData = False |
|
874 | dataOut.flagNoData = False | |
875 |
|
875 | |||
876 | return dataOut No newline at end of file |
|
876 | return dataOut | |
|
877 | ||||
|
878 | class dopplerFlip(Operation): | |||
|
879 | ||||
|
880 | def run(self, dataOut): | |||
|
881 | # arreglo 1: (num_chan, num_profiles, num_heights) | |||
|
882 | self.dataOut = dataOut | |||
|
883 | # JULIA-oblicua, indice 2 | |||
|
884 | # arreglo 2: (num_profiles, num_heights) | |||
|
885 | jspectra = self.dataOut.data_spc[2] | |||
|
886 | jspectra_tmp = numpy.zeros(jspectra.shape) | |||
|
887 | num_profiles = jspectra.shape[0] | |||
|
888 | freq_dc = int(num_profiles / 2) | |||
|
889 | # Flip con for | |||
|
890 | for j in range(num_profiles): | |||
|
891 | jspectra_tmp[num_profiles-j-1]= jspectra[j] | |||
|
892 | # Intercambio perfil de DC con perfil inmediato anterior | |||
|
893 | jspectra_tmp[freq_dc-1]= jspectra[freq_dc-1] | |||
|
894 | jspectra_tmp[freq_dc]= jspectra[freq_dc] | |||
|
895 | # canal modificado es re-escrito en el arreglo de canales | |||
|
896 | self.dataOut.data_spc[2] = jspectra_tmp | |||
|
897 | ||||
|
898 | return self.dataOut No newline at end of file |
@@ -1,1629 +1,1625 | |||||
1 | import sys |
|
1 | import sys | |
2 | import numpy,math |
|
2 | import numpy,math | |
3 | from scipy import interpolate |
|
3 | from scipy import interpolate | |
4 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator |
|
4 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator | |
5 | from schainpy.model.data.jrodata import Voltage,hildebrand_sekhon |
|
5 | from schainpy.model.data.jrodata import Voltage,hildebrand_sekhon | |
6 | from schainpy.utils import log |
|
6 | from schainpy.utils import log | |
7 | from time import time |
|
7 | from time import time | |
8 |
|
8 | |||
9 |
|
9 | |||
10 |
|
10 | |||
11 | class VoltageProc(ProcessingUnit): |
|
11 | class VoltageProc(ProcessingUnit): | |
12 |
|
12 | |||
13 | def __init__(self): |
|
13 | def __init__(self): | |
14 |
|
14 | |||
15 | ProcessingUnit.__init__(self) |
|
15 | ProcessingUnit.__init__(self) | |
16 |
|
16 | |||
17 | self.dataOut = Voltage() |
|
17 | self.dataOut = Voltage() | |
18 | self.flip = 1 |
|
18 | self.flip = 1 | |
19 | self.setupReq = False |
|
19 | self.setupReq = False | |
20 |
|
20 | |||
21 | def run(self): |
|
21 | def run(self): | |
22 |
|
22 | |||
23 | if self.dataIn.type == 'AMISR': |
|
23 | if self.dataIn.type == 'AMISR': | |
24 | self.__updateObjFromAmisrInput() |
|
24 | self.__updateObjFromAmisrInput() | |
25 |
|
25 | |||
26 | if self.dataIn.type == 'Voltage': |
|
26 | if self.dataIn.type == 'Voltage': | |
27 | self.dataOut.copy(self.dataIn) |
|
27 | self.dataOut.copy(self.dataIn) | |
28 |
|
28 | |||
29 | def __updateObjFromAmisrInput(self): |
|
29 | def __updateObjFromAmisrInput(self): | |
30 |
|
30 | |||
31 | self.dataOut.timeZone = self.dataIn.timeZone |
|
31 | self.dataOut.timeZone = self.dataIn.timeZone | |
32 | self.dataOut.dstFlag = self.dataIn.dstFlag |
|
32 | self.dataOut.dstFlag = self.dataIn.dstFlag | |
33 | self.dataOut.errorCount = self.dataIn.errorCount |
|
33 | self.dataOut.errorCount = self.dataIn.errorCount | |
34 | self.dataOut.useLocalTime = self.dataIn.useLocalTime |
|
34 | self.dataOut.useLocalTime = self.dataIn.useLocalTime | |
35 |
|
35 | |||
36 | self.dataOut.flagNoData = self.dataIn.flagNoData |
|
36 | self.dataOut.flagNoData = self.dataIn.flagNoData | |
37 | self.dataOut.data = self.dataIn.data |
|
37 | self.dataOut.data = self.dataIn.data | |
38 | self.dataOut.utctime = self.dataIn.utctime |
|
38 | self.dataOut.utctime = self.dataIn.utctime | |
39 | self.dataOut.channelList = self.dataIn.channelList |
|
39 | self.dataOut.channelList = self.dataIn.channelList | |
40 | #self.dataOut.timeInterval = self.dataIn.timeInterval |
|
40 | #self.dataOut.timeInterval = self.dataIn.timeInterval | |
41 | self.dataOut.heightList = self.dataIn.heightList |
|
41 | self.dataOut.heightList = self.dataIn.heightList | |
42 | self.dataOut.nProfiles = self.dataIn.nProfiles |
|
42 | self.dataOut.nProfiles = self.dataIn.nProfiles | |
43 |
|
43 | |||
44 | self.dataOut.nCohInt = self.dataIn.nCohInt |
|
44 | self.dataOut.nCohInt = self.dataIn.nCohInt | |
45 | self.dataOut.ippSeconds = self.dataIn.ippSeconds |
|
45 | self.dataOut.ippSeconds = self.dataIn.ippSeconds | |
46 | self.dataOut.frequency = self.dataIn.frequency |
|
46 | self.dataOut.frequency = self.dataIn.frequency | |
47 |
|
47 | |||
48 | self.dataOut.azimuth = self.dataIn.azimuth |
|
48 | self.dataOut.azimuth = self.dataIn.azimuth | |
49 | self.dataOut.zenith = self.dataIn.zenith |
|
49 | self.dataOut.zenith = self.dataIn.zenith | |
50 |
|
50 | |||
51 | self.dataOut.beam.codeList = self.dataIn.beam.codeList |
|
51 | self.dataOut.beam.codeList = self.dataIn.beam.codeList | |
52 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList |
|
52 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList | |
53 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList |
|
53 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList | |
54 |
|
54 | |||
55 |
|
55 | |||
56 | class selectChannels(Operation): |
|
56 | class selectChannels(Operation): | |
57 |
|
57 | |||
58 | def run(self, dataOut, channelList): |
|
58 | def run(self, dataOut, channelList): | |
59 |
|
59 | |||
60 | channelIndexList = [] |
|
60 | channelIndexList = [] | |
61 | self.dataOut = dataOut |
|
61 | self.dataOut = dataOut | |
62 | for channel in channelList: |
|
62 | for channel in channelList: | |
63 | if channel not in self.dataOut.channelList: |
|
63 | if channel not in self.dataOut.channelList: | |
64 | raise ValueError("Channel %d is not in %s" %(channel, str(self.dataOut.channelList))) |
|
64 | raise ValueError("Channel %d is not in %s" %(channel, str(self.dataOut.channelList))) | |
65 |
|
65 | |||
66 | index = self.dataOut.channelList.index(channel) |
|
66 | index = self.dataOut.channelList.index(channel) | |
67 | channelIndexList.append(index) |
|
67 | channelIndexList.append(index) | |
68 | self.selectChannelsByIndex(channelIndexList) |
|
68 | self.selectChannelsByIndex(channelIndexList) | |
69 | return self.dataOut |
|
69 | return self.dataOut | |
70 |
|
70 | |||
71 | def selectChannelsByIndex(self, channelIndexList): |
|
71 | def selectChannelsByIndex(self, channelIndexList): | |
72 | """ |
|
72 | """ | |
73 | Selecciona un bloque de datos en base a canales segun el channelIndexList |
|
73 | Selecciona un bloque de datos en base a canales segun el channelIndexList | |
74 |
|
74 | |||
75 | Input: |
|
75 | Input: | |
76 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] |
|
76 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] | |
77 |
|
77 | |||
78 | Affected: |
|
78 | Affected: | |
79 | self.dataOut.data |
|
79 | self.dataOut.data | |
80 | self.dataOut.channelIndexList |
|
80 | self.dataOut.channelIndexList | |
81 | self.dataOut.nChannels |
|
81 | self.dataOut.nChannels | |
82 | self.dataOut.m_ProcessingHeader.totalSpectra |
|
82 | self.dataOut.m_ProcessingHeader.totalSpectra | |
83 | self.dataOut.systemHeaderObj.numChannels |
|
83 | self.dataOut.systemHeaderObj.numChannels | |
84 | self.dataOut.m_ProcessingHeader.blockSize |
|
84 | self.dataOut.m_ProcessingHeader.blockSize | |
85 |
|
85 | |||
86 | Return: |
|
86 | Return: | |
87 | None |
|
87 | None | |
88 | """ |
|
88 | """ | |
89 |
|
89 | |||
90 | for channelIndex in channelIndexList: |
|
90 | for channelIndex in channelIndexList: | |
91 | if channelIndex not in self.dataOut.channelIndexList: |
|
91 | if channelIndex not in self.dataOut.channelIndexList: | |
92 | raise ValueError("The value %d in channelIndexList is not valid" %channelIndex) |
|
92 | raise ValueError("The value %d in channelIndexList is not valid" %channelIndex) | |
93 |
|
93 | |||
94 | if self.dataOut.type == 'Voltage': |
|
94 | if self.dataOut.type == 'Voltage': | |
95 | if self.dataOut.flagDataAsBlock: |
|
95 | if self.dataOut.flagDataAsBlock: | |
96 | """ |
|
96 | """ | |
97 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
97 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
98 | """ |
|
98 | """ | |
99 | data = self.dataOut.data[channelIndexList,:,:] |
|
99 | data = self.dataOut.data[channelIndexList,:,:] | |
100 | else: |
|
100 | else: | |
101 | data = self.dataOut.data[channelIndexList,:] |
|
101 | data = self.dataOut.data[channelIndexList,:] | |
102 |
|
102 | |||
103 | self.dataOut.data = data |
|
103 | self.dataOut.data = data | |
104 | # self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] |
|
104 | # self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] | |
105 | self.dataOut.channelList = range(len(channelIndexList)) |
|
105 | self.dataOut.channelList = range(len(channelIndexList)) | |
106 |
|
106 | |||
107 | elif self.dataOut.type == 'Spectra': |
|
107 | elif self.dataOut.type == 'Spectra': | |
108 | data_spc = self.dataOut.data_spc[channelIndexList, :] |
|
108 | data_spc = self.dataOut.data_spc[channelIndexList, :] | |
109 | data_dc = self.dataOut.data_dc[channelIndexList, :] |
|
109 | data_dc = self.dataOut.data_dc[channelIndexList, :] | |
110 |
|
110 | |||
111 | self.dataOut.data_spc = data_spc |
|
111 | self.dataOut.data_spc = data_spc | |
112 | self.dataOut.data_dc = data_dc |
|
112 | self.dataOut.data_dc = data_dc | |
113 |
|
113 | |||
114 | # self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] |
|
114 | # self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] | |
115 | self.dataOut.channelList = range(len(channelIndexList)) |
|
115 | self.dataOut.channelList = range(len(channelIndexList)) | |
116 | self.__selectPairsByChannel(channelIndexList) |
|
116 | self.__selectPairsByChannel(channelIndexList) | |
117 |
|
117 | |||
118 | return 1 |
|
118 | return 1 | |
119 |
|
119 | |||
120 | def __selectPairsByChannel(self, channelList=None): |
|
120 | def __selectPairsByChannel(self, channelList=None): | |
121 |
|
121 | |||
122 | if channelList == None: |
|
122 | if channelList == None: | |
123 | return |
|
123 | return | |
124 |
|
124 | |||
125 | pairsIndexListSelected = [] |
|
125 | pairsIndexListSelected = [] | |
126 | for pairIndex in self.dataOut.pairsIndexList: |
|
126 | for pairIndex in self.dataOut.pairsIndexList: | |
127 | # First pair |
|
127 | # First pair | |
128 | if self.dataOut.pairsList[pairIndex][0] not in channelList: |
|
128 | if self.dataOut.pairsList[pairIndex][0] not in channelList: | |
129 | continue |
|
129 | continue | |
130 | # Second pair |
|
130 | # Second pair | |
131 | if self.dataOut.pairsList[pairIndex][1] not in channelList: |
|
131 | if self.dataOut.pairsList[pairIndex][1] not in channelList: | |
132 | continue |
|
132 | continue | |
133 |
|
133 | |||
134 | pairsIndexListSelected.append(pairIndex) |
|
134 | pairsIndexListSelected.append(pairIndex) | |
135 |
|
135 | |||
136 | if not pairsIndexListSelected: |
|
136 | if not pairsIndexListSelected: | |
137 | self.dataOut.data_cspc = None |
|
137 | self.dataOut.data_cspc = None | |
138 | self.dataOut.pairsList = [] |
|
138 | self.dataOut.pairsList = [] | |
139 | return |
|
139 | return | |
140 |
|
140 | |||
141 | self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected] |
|
141 | self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected] | |
142 | self.dataOut.pairsList = [self.dataOut.pairsList[i] |
|
142 | self.dataOut.pairsList = [self.dataOut.pairsList[i] | |
143 | for i in pairsIndexListSelected] |
|
143 | for i in pairsIndexListSelected] | |
144 |
|
144 | |||
145 | return |
|
145 | return | |
146 |
|
146 | |||
147 | class selectHeights(Operation): |
|
147 | class selectHeights(Operation): | |
148 |
|
148 | |||
149 | def run(self, dataOut, minHei=None, maxHei=None): |
|
149 | def run(self, dataOut, minHei=None, maxHei=None, minIndex=None, maxIndex=None): | |
150 | """ |
|
150 | """ | |
151 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango |
|
151 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango | |
152 | minHei <= height <= maxHei |
|
152 | minHei <= height <= maxHei | |
153 |
|
153 | |||
154 | Input: |
|
154 | Input: | |
155 | minHei : valor minimo de altura a considerar |
|
155 | minHei : valor minimo de altura a considerar | |
156 | maxHei : valor maximo de altura a considerar |
|
156 | maxHei : valor maximo de altura a considerar | |
157 |
|
157 | |||
158 | Affected: |
|
158 | Affected: | |
159 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex |
|
159 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex | |
160 |
|
160 | |||
161 | Return: |
|
161 | Return: | |
162 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
162 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
163 | """ |
|
163 | """ | |
164 |
|
164 | |||
165 | self.dataOut = dataOut |
|
165 | self.dataOut = dataOut | |
166 |
|
166 | |||
167 |
if minHei |
|
167 | if minHei and maxHei: | |
168 | minHei = self.dataOut.heightList[0] |
|
|||
169 |
|
168 | |||
170 | if maxHei == None: |
|
169 | if (minHei < self.dataOut.heightList[0]): | |
171 |
|
|
170 | minHei = self.dataOut.heightList[0] | |
172 |
|
171 | |||
173 |
if (m |
|
172 | if (maxHei > self.dataOut.heightList[-1]): | |
174 |
|
|
173 | maxHei = self.dataOut.heightList[-1] | |
175 |
|
174 | |||
176 | if (maxHei > self.dataOut.heightList[-1]): |
|
175 | minIndex = 0 | |
177 | maxHei = self.dataOut.heightList[-1] |
|
176 | maxIndex = 0 | |
178 |
|
177 | heights = self.dataOut.heightList | ||
179 | minIndex = 0 |
|
|||
180 | maxIndex = 0 |
|
|||
181 | heights = self.dataOut.heightList |
|
|||
182 |
|
178 | |||
183 | inda = numpy.where(heights >= minHei) |
|
179 | inda = numpy.where(heights >= minHei) | |
184 | indb = numpy.where(heights <= maxHei) |
|
180 | indb = numpy.where(heights <= maxHei) | |
185 |
|
181 | |||
186 | try: |
|
182 | try: | |
187 | minIndex = inda[0][0] |
|
183 | minIndex = inda[0][0] | |
188 | except: |
|
184 | except: | |
189 | minIndex = 0 |
|
185 | minIndex = 0 | |
190 |
|
186 | |||
191 | try: |
|
187 | try: | |
192 | maxIndex = indb[0][-1] |
|
188 | maxIndex = indb[0][-1] | |
193 | except: |
|
189 | except: | |
194 | maxIndex = len(heights) |
|
190 | maxIndex = len(heights) | |
195 |
|
191 | |||
196 | self.selectHeightsByIndex(minIndex, maxIndex) |
|
192 | self.selectHeightsByIndex(minIndex, maxIndex) | |
197 |
|
193 | |||
198 | return self.dataOut |
|
194 | return self.dataOut | |
199 |
|
195 | |||
200 | def selectHeightsByIndex(self, minIndex, maxIndex): |
|
196 | def selectHeightsByIndex(self, minIndex, maxIndex): | |
201 | """ |
|
197 | """ | |
202 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango |
|
198 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango | |
203 | minIndex <= index <= maxIndex |
|
199 | minIndex <= index <= maxIndex | |
204 |
|
200 | |||
205 | Input: |
|
201 | Input: | |
206 | minIndex : valor de indice minimo de altura a considerar |
|
202 | minIndex : valor de indice minimo de altura a considerar | |
207 | maxIndex : valor de indice maximo de altura a considerar |
|
203 | maxIndex : valor de indice maximo de altura a considerar | |
208 |
|
204 | |||
209 | Affected: |
|
205 | Affected: | |
210 | self.dataOut.data |
|
206 | self.dataOut.data | |
211 | self.dataOut.heightList |
|
207 | self.dataOut.heightList | |
212 |
|
208 | |||
213 | Return: |
|
209 | Return: | |
214 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
210 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
215 | """ |
|
211 | """ | |
216 |
|
212 | |||
217 | if self.dataOut.type == 'Voltage': |
|
213 | if self.dataOut.type == 'Voltage': | |
218 | if (minIndex < 0) or (minIndex > maxIndex): |
|
214 | if (minIndex < 0) or (minIndex > maxIndex): | |
219 | raise ValueError("Height index range (%d,%d) is not valid" % (minIndex, maxIndex)) |
|
215 | raise ValueError("Height index range (%d,%d) is not valid" % (minIndex, maxIndex)) | |
220 |
|
216 | |||
221 | if (maxIndex >= self.dataOut.nHeights): |
|
217 | if (maxIndex >= self.dataOut.nHeights): | |
222 | maxIndex = self.dataOut.nHeights |
|
218 | maxIndex = self.dataOut.nHeights | |
223 |
|
219 | |||
224 | #voltage |
|
220 | #voltage | |
225 | if self.dataOut.flagDataAsBlock: |
|
221 | if self.dataOut.flagDataAsBlock: | |
226 | """ |
|
222 | """ | |
227 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
223 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
228 | """ |
|
224 | """ | |
229 | data = self.dataOut.data[:,:, minIndex:maxIndex] |
|
225 | data = self.dataOut.data[:,:, minIndex:maxIndex] | |
230 | else: |
|
226 | else: | |
231 | data = self.dataOut.data[:, minIndex:maxIndex] |
|
227 | data = self.dataOut.data[:, minIndex:maxIndex] | |
232 |
|
228 | |||
233 | # firstHeight = self.dataOut.heightList[minIndex] |
|
229 | # firstHeight = self.dataOut.heightList[minIndex] | |
234 |
|
230 | |||
235 | self.dataOut.data = data |
|
231 | self.dataOut.data = data | |
236 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex] |
|
232 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex] | |
237 |
|
233 | |||
238 | if self.dataOut.nHeights <= 1: |
|
234 | if self.dataOut.nHeights <= 1: | |
239 | raise ValueError("selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights)) |
|
235 | raise ValueError("selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights)) | |
240 | elif self.dataOut.type == 'Spectra': |
|
236 | elif self.dataOut.type == 'Spectra': | |
241 | if (minIndex < 0) or (minIndex > maxIndex): |
|
237 | if (minIndex < 0) or (minIndex > maxIndex): | |
242 | raise ValueError("Error selecting heights: Index range (%d,%d) is not valid" % ( |
|
238 | raise ValueError("Error selecting heights: Index range (%d,%d) is not valid" % ( | |
243 | minIndex, maxIndex)) |
|
239 | minIndex, maxIndex)) | |
244 |
|
240 | |||
245 | if (maxIndex >= self.dataOut.nHeights): |
|
241 | if (maxIndex >= self.dataOut.nHeights): | |
246 | maxIndex = self.dataOut.nHeights - 1 |
|
242 | maxIndex = self.dataOut.nHeights - 1 | |
247 |
|
243 | |||
248 | # Spectra |
|
244 | # Spectra | |
249 | data_spc = self.dataOut.data_spc[:, :, minIndex:maxIndex + 1] |
|
245 | data_spc = self.dataOut.data_spc[:, :, minIndex:maxIndex + 1] | |
250 |
|
246 | |||
251 | data_cspc = None |
|
247 | data_cspc = None | |
252 | if self.dataOut.data_cspc is not None: |
|
248 | if self.dataOut.data_cspc is not None: | |
253 | data_cspc = self.dataOut.data_cspc[:, :, minIndex:maxIndex + 1] |
|
249 | data_cspc = self.dataOut.data_cspc[:, :, minIndex:maxIndex + 1] | |
254 |
|
250 | |||
255 | data_dc = None |
|
251 | data_dc = None | |
256 | if self.dataOut.data_dc is not None: |
|
252 | if self.dataOut.data_dc is not None: | |
257 | data_dc = self.dataOut.data_dc[:, minIndex:maxIndex + 1] |
|
253 | data_dc = self.dataOut.data_dc[:, minIndex:maxIndex + 1] | |
258 |
|
254 | |||
259 | self.dataOut.data_spc = data_spc |
|
255 | self.dataOut.data_spc = data_spc | |
260 | self.dataOut.data_cspc = data_cspc |
|
256 | self.dataOut.data_cspc = data_cspc | |
261 | self.dataOut.data_dc = data_dc |
|
257 | self.dataOut.data_dc = data_dc | |
262 |
|
258 | |||
263 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex + 1] |
|
259 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex + 1] | |
264 |
|
260 | |||
265 | return 1 |
|
261 | return 1 | |
266 |
|
262 | |||
267 |
|
263 | |||
268 | class filterByHeights(Operation): |
|
264 | class filterByHeights(Operation): | |
269 |
|
265 | |||
270 | def run(self, dataOut, window): |
|
266 | def run(self, dataOut, window): | |
271 |
|
267 | |||
272 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
268 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
273 |
|
269 | |||
274 | if window == None: |
|
270 | if window == None: | |
275 | window = (dataOut.radarControllerHeaderObj.txA/dataOut.radarControllerHeaderObj.nBaud) / deltaHeight |
|
271 | window = (dataOut.radarControllerHeaderObj.txA/dataOut.radarControllerHeaderObj.nBaud) / deltaHeight | |
276 |
|
272 | |||
277 | newdelta = deltaHeight * window |
|
273 | newdelta = deltaHeight * window | |
278 | r = dataOut.nHeights % window |
|
274 | r = dataOut.nHeights % window | |
279 | newheights = (dataOut.nHeights-r)/window |
|
275 | newheights = (dataOut.nHeights-r)/window | |
280 |
|
276 | |||
281 | if newheights <= 1: |
|
277 | if newheights <= 1: | |
282 | raise ValueError("filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(dataOut.nHeights, window)) |
|
278 | raise ValueError("filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(dataOut.nHeights, window)) | |
283 |
|
279 | |||
284 | if dataOut.flagDataAsBlock: |
|
280 | if dataOut.flagDataAsBlock: | |
285 | """ |
|
281 | """ | |
286 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
282 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
287 | """ |
|
283 | """ | |
288 | buffer = dataOut.data[:, :, 0:int(dataOut.nHeights-r)] |
|
284 | buffer = dataOut.data[:, :, 0:int(dataOut.nHeights-r)] | |
289 | buffer = buffer.reshape(dataOut.nChannels, dataOut.nProfiles, int(dataOut.nHeights/window), window) |
|
285 | buffer = buffer.reshape(dataOut.nChannels, dataOut.nProfiles, int(dataOut.nHeights/window), window) | |
290 | buffer = numpy.sum(buffer,3) |
|
286 | buffer = numpy.sum(buffer,3) | |
291 |
|
287 | |||
292 | else: |
|
288 | else: | |
293 | buffer = dataOut.data[:,0:int(dataOut.nHeights-r)] |
|
289 | buffer = dataOut.data[:,0:int(dataOut.nHeights-r)] | |
294 | buffer = buffer.reshape(dataOut.nChannels,int(dataOut.nHeights/window),int(window)) |
|
290 | buffer = buffer.reshape(dataOut.nChannels,int(dataOut.nHeights/window),int(window)) | |
295 | buffer = numpy.sum(buffer,2) |
|
291 | buffer = numpy.sum(buffer,2) | |
296 |
|
292 | |||
297 | dataOut.data = buffer |
|
293 | dataOut.data = buffer | |
298 | dataOut.heightList = dataOut.heightList[0] + numpy.arange( newheights )*newdelta |
|
294 | dataOut.heightList = dataOut.heightList[0] + numpy.arange( newheights )*newdelta | |
299 | dataOut.windowOfFilter = window |
|
295 | dataOut.windowOfFilter = window | |
300 |
|
296 | |||
301 | return dataOut |
|
297 | return dataOut | |
302 |
|
298 | |||
303 |
|
299 | |||
304 | class setH0(Operation): |
|
300 | class setH0(Operation): | |
305 |
|
301 | |||
306 | def run(self, dataOut, h0, deltaHeight = None): |
|
302 | def run(self, dataOut, h0, deltaHeight = None): | |
307 |
|
303 | |||
308 | if not deltaHeight: |
|
304 | if not deltaHeight: | |
309 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
305 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
310 |
|
306 | |||
311 | nHeights = dataOut.nHeights |
|
307 | nHeights = dataOut.nHeights | |
312 |
|
308 | |||
313 | newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight |
|
309 | newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight | |
314 |
|
310 | |||
315 | dataOut.heightList = newHeiRange |
|
311 | dataOut.heightList = newHeiRange | |
316 |
|
312 | |||
317 | return dataOut |
|
313 | return dataOut | |
318 |
|
314 | |||
319 |
|
315 | |||
320 | class deFlip(Operation): |
|
316 | class deFlip(Operation): | |
321 |
|
317 | |||
322 | def run(self, dataOut, channelList = []): |
|
318 | def run(self, dataOut, channelList = []): | |
323 |
|
319 | |||
324 | data = dataOut.data.copy() |
|
320 | data = dataOut.data.copy() | |
325 |
|
321 | |||
326 | if dataOut.flagDataAsBlock: |
|
322 | if dataOut.flagDataAsBlock: | |
327 | flip = self.flip |
|
323 | flip = self.flip | |
328 | profileList = list(range(dataOut.nProfiles)) |
|
324 | profileList = list(range(dataOut.nProfiles)) | |
329 |
|
325 | |||
330 | if not channelList: |
|
326 | if not channelList: | |
331 | for thisProfile in profileList: |
|
327 | for thisProfile in profileList: | |
332 | data[:,thisProfile,:] = data[:,thisProfile,:]*flip |
|
328 | data[:,thisProfile,:] = data[:,thisProfile,:]*flip | |
333 | flip *= -1.0 |
|
329 | flip *= -1.0 | |
334 | else: |
|
330 | else: | |
335 | for thisChannel in channelList: |
|
331 | for thisChannel in channelList: | |
336 | if thisChannel not in dataOut.channelList: |
|
332 | if thisChannel not in dataOut.channelList: | |
337 | continue |
|
333 | continue | |
338 |
|
334 | |||
339 | for thisProfile in profileList: |
|
335 | for thisProfile in profileList: | |
340 | data[thisChannel,thisProfile,:] = data[thisChannel,thisProfile,:]*flip |
|
336 | data[thisChannel,thisProfile,:] = data[thisChannel,thisProfile,:]*flip | |
341 | flip *= -1.0 |
|
337 | flip *= -1.0 | |
342 |
|
338 | |||
343 | self.flip = flip |
|
339 | self.flip = flip | |
344 |
|
340 | |||
345 | else: |
|
341 | else: | |
346 | if not channelList: |
|
342 | if not channelList: | |
347 | data[:,:] = data[:,:]*self.flip |
|
343 | data[:,:] = data[:,:]*self.flip | |
348 | else: |
|
344 | else: | |
349 | for thisChannel in channelList: |
|
345 | for thisChannel in channelList: | |
350 | if thisChannel not in dataOut.channelList: |
|
346 | if thisChannel not in dataOut.channelList: | |
351 | continue |
|
347 | continue | |
352 |
|
348 | |||
353 | data[thisChannel,:] = data[thisChannel,:]*self.flip |
|
349 | data[thisChannel,:] = data[thisChannel,:]*self.flip | |
354 |
|
350 | |||
355 | self.flip *= -1. |
|
351 | self.flip *= -1. | |
356 |
|
352 | |||
357 | dataOut.data = data |
|
353 | dataOut.data = data | |
358 |
|
354 | |||
359 | return dataOut |
|
355 | return dataOut | |
360 |
|
356 | |||
361 |
|
357 | |||
362 | class setAttribute(Operation): |
|
358 | class setAttribute(Operation): | |
363 | ''' |
|
359 | ''' | |
364 | Set an arbitrary attribute(s) to dataOut |
|
360 | Set an arbitrary attribute(s) to dataOut | |
365 | ''' |
|
361 | ''' | |
366 |
|
362 | |||
367 | def __init__(self): |
|
363 | def __init__(self): | |
368 |
|
364 | |||
369 | Operation.__init__(self) |
|
365 | Operation.__init__(self) | |
370 | self._ready = False |
|
366 | self._ready = False | |
371 |
|
367 | |||
372 | def run(self, dataOut, **kwargs): |
|
368 | def run(self, dataOut, **kwargs): | |
373 |
|
369 | |||
374 | for key, value in kwargs.items(): |
|
370 | for key, value in kwargs.items(): | |
375 | setattr(dataOut, key, value) |
|
371 | setattr(dataOut, key, value) | |
376 |
|
372 | |||
377 | return dataOut |
|
373 | return dataOut | |
378 |
|
374 | |||
379 |
|
375 | |||
380 | @MPDecorator |
|
376 | @MPDecorator | |
381 | class printAttribute(Operation): |
|
377 | class printAttribute(Operation): | |
382 | ''' |
|
378 | ''' | |
383 | Print an arbitrary attribute of dataOut |
|
379 | Print an arbitrary attribute of dataOut | |
384 | ''' |
|
380 | ''' | |
385 |
|
381 | |||
386 | def __init__(self): |
|
382 | def __init__(self): | |
387 |
|
383 | |||
388 | Operation.__init__(self) |
|
384 | Operation.__init__(self) | |
389 |
|
385 | |||
390 | def run(self, dataOut, attributes): |
|
386 | def run(self, dataOut, attributes): | |
391 |
|
387 | |||
392 | if isinstance(attributes, str): |
|
388 | if isinstance(attributes, str): | |
393 | attributes = [attributes] |
|
389 | attributes = [attributes] | |
394 | for attr in attributes: |
|
390 | for attr in attributes: | |
395 | if hasattr(dataOut, attr): |
|
391 | if hasattr(dataOut, attr): | |
396 | log.log(getattr(dataOut, attr), attr) |
|
392 | log.log(getattr(dataOut, attr), attr) | |
397 |
|
393 | |||
398 |
|
394 | |||
399 | class interpolateHeights(Operation): |
|
395 | class interpolateHeights(Operation): | |
400 |
|
396 | |||
401 | def run(self, dataOut, topLim, botLim): |
|
397 | def run(self, dataOut, topLim, botLim): | |
402 | #69 al 72 para julia |
|
398 | #69 al 72 para julia | |
403 | #82-84 para meteoros |
|
399 | #82-84 para meteoros | |
404 | if len(numpy.shape(dataOut.data))==2: |
|
400 | if len(numpy.shape(dataOut.data))==2: | |
405 | sampInterp = (dataOut.data[:,botLim-1] + dataOut.data[:,topLim+1])/2 |
|
401 | sampInterp = (dataOut.data[:,botLim-1] + dataOut.data[:,topLim+1])/2 | |
406 | sampInterp = numpy.transpose(numpy.tile(sampInterp,(topLim-botLim + 1,1))) |
|
402 | sampInterp = numpy.transpose(numpy.tile(sampInterp,(topLim-botLim + 1,1))) | |
407 | #dataOut.data[:,botLim:limSup+1] = sampInterp |
|
403 | #dataOut.data[:,botLim:limSup+1] = sampInterp | |
408 | dataOut.data[:,botLim:topLim+1] = sampInterp |
|
404 | dataOut.data[:,botLim:topLim+1] = sampInterp | |
409 | else: |
|
405 | else: | |
410 | nHeights = dataOut.data.shape[2] |
|
406 | nHeights = dataOut.data.shape[2] | |
411 | x = numpy.hstack((numpy.arange(botLim),numpy.arange(topLim+1,nHeights))) |
|
407 | x = numpy.hstack((numpy.arange(botLim),numpy.arange(topLim+1,nHeights))) | |
412 | y = dataOut.data[:,:,list(range(botLim))+list(range(topLim+1,nHeights))] |
|
408 | y = dataOut.data[:,:,list(range(botLim))+list(range(topLim+1,nHeights))] | |
413 | f = interpolate.interp1d(x, y, axis = 2) |
|
409 | f = interpolate.interp1d(x, y, axis = 2) | |
414 | xnew = numpy.arange(botLim,topLim+1) |
|
410 | xnew = numpy.arange(botLim,topLim+1) | |
415 | ynew = f(xnew) |
|
411 | ynew = f(xnew) | |
416 | dataOut.data[:,:,botLim:topLim+1] = ynew |
|
412 | dataOut.data[:,:,botLim:topLim+1] = ynew | |
417 |
|
413 | |||
418 | return dataOut |
|
414 | return dataOut | |
419 |
|
415 | |||
420 |
|
416 | |||
421 | class CohInt(Operation): |
|
417 | class CohInt(Operation): | |
422 |
|
418 | |||
423 | isConfig = False |
|
419 | isConfig = False | |
424 | __profIndex = 0 |
|
420 | __profIndex = 0 | |
425 | __byTime = False |
|
421 | __byTime = False | |
426 | __initime = None |
|
422 | __initime = None | |
427 | __lastdatatime = None |
|
423 | __lastdatatime = None | |
428 | __integrationtime = None |
|
424 | __integrationtime = None | |
429 | __buffer = None |
|
425 | __buffer = None | |
430 | __bufferStride = [] |
|
426 | __bufferStride = [] | |
431 | __dataReady = False |
|
427 | __dataReady = False | |
432 | __profIndexStride = 0 |
|
428 | __profIndexStride = 0 | |
433 | __dataToPutStride = False |
|
429 | __dataToPutStride = False | |
434 | n = None |
|
430 | n = None | |
435 |
|
431 | |||
436 | def __init__(self, **kwargs): |
|
432 | def __init__(self, **kwargs): | |
437 |
|
433 | |||
438 | Operation.__init__(self, **kwargs) |
|
434 | Operation.__init__(self, **kwargs) | |
439 |
|
435 | |||
440 | def setup(self, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False): |
|
436 | def setup(self, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False): | |
441 | """ |
|
437 | """ | |
442 | Set the parameters of the integration class. |
|
438 | Set the parameters of the integration class. | |
443 |
|
439 | |||
444 | Inputs: |
|
440 | Inputs: | |
445 |
|
441 | |||
446 | n : Number of coherent integrations |
|
442 | n : Number of coherent integrations | |
447 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work |
|
443 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work | |
448 | overlapping : |
|
444 | overlapping : | |
449 | """ |
|
445 | """ | |
450 |
|
446 | |||
451 | self.__initime = None |
|
447 | self.__initime = None | |
452 | self.__lastdatatime = 0 |
|
448 | self.__lastdatatime = 0 | |
453 | self.__buffer = None |
|
449 | self.__buffer = None | |
454 | self.__dataReady = False |
|
450 | self.__dataReady = False | |
455 | self.byblock = byblock |
|
451 | self.byblock = byblock | |
456 | self.stride = stride |
|
452 | self.stride = stride | |
457 |
|
453 | |||
458 | if n == None and timeInterval == None: |
|
454 | if n == None and timeInterval == None: | |
459 | raise ValueError("n or timeInterval should be specified ...") |
|
455 | raise ValueError("n or timeInterval should be specified ...") | |
460 |
|
456 | |||
461 | if n != None: |
|
457 | if n != None: | |
462 | self.n = n |
|
458 | self.n = n | |
463 | self.__byTime = False |
|
459 | self.__byTime = False | |
464 | else: |
|
460 | else: | |
465 | self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line |
|
461 | self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line | |
466 | self.n = 9999 |
|
462 | self.n = 9999 | |
467 | self.__byTime = True |
|
463 | self.__byTime = True | |
468 |
|
464 | |||
469 | if overlapping: |
|
465 | if overlapping: | |
470 | self.__withOverlapping = True |
|
466 | self.__withOverlapping = True | |
471 | self.__buffer = None |
|
467 | self.__buffer = None | |
472 | else: |
|
468 | else: | |
473 | self.__withOverlapping = False |
|
469 | self.__withOverlapping = False | |
474 | self.__buffer = 0 |
|
470 | self.__buffer = 0 | |
475 |
|
471 | |||
476 | self.__profIndex = 0 |
|
472 | self.__profIndex = 0 | |
477 |
|
473 | |||
478 | def putData(self, data): |
|
474 | def putData(self, data): | |
479 |
|
475 | |||
480 | """ |
|
476 | """ | |
481 | Add a profile to the __buffer and increase in one the __profileIndex |
|
477 | Add a profile to the __buffer and increase in one the __profileIndex | |
482 |
|
478 | |||
483 | """ |
|
479 | """ | |
484 |
|
480 | |||
485 | if not self.__withOverlapping: |
|
481 | if not self.__withOverlapping: | |
486 | self.__buffer += data.copy() |
|
482 | self.__buffer += data.copy() | |
487 | self.__profIndex += 1 |
|
483 | self.__profIndex += 1 | |
488 | return |
|
484 | return | |
489 |
|
485 | |||
490 | #Overlapping data |
|
486 | #Overlapping data | |
491 | nChannels, nHeis = data.shape |
|
487 | nChannels, nHeis = data.shape | |
492 | data = numpy.reshape(data, (1, nChannels, nHeis)) |
|
488 | data = numpy.reshape(data, (1, nChannels, nHeis)) | |
493 |
|
489 | |||
494 | #If the buffer is empty then it takes the data value |
|
490 | #If the buffer is empty then it takes the data value | |
495 | if self.__buffer is None: |
|
491 | if self.__buffer is None: | |
496 | self.__buffer = data |
|
492 | self.__buffer = data | |
497 | self.__profIndex += 1 |
|
493 | self.__profIndex += 1 | |
498 | return |
|
494 | return | |
499 |
|
495 | |||
500 | #If the buffer length is lower than n then stakcing the data value |
|
496 | #If the buffer length is lower than n then stakcing the data value | |
501 | if self.__profIndex < self.n: |
|
497 | if self.__profIndex < self.n: | |
502 | self.__buffer = numpy.vstack((self.__buffer, data)) |
|
498 | self.__buffer = numpy.vstack((self.__buffer, data)) | |
503 | self.__profIndex += 1 |
|
499 | self.__profIndex += 1 | |
504 | return |
|
500 | return | |
505 |
|
501 | |||
506 | #If the buffer length is equal to n then replacing the last buffer value with the data value |
|
502 | #If the buffer length is equal to n then replacing the last buffer value with the data value | |
507 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) |
|
503 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) | |
508 | self.__buffer[self.n-1] = data |
|
504 | self.__buffer[self.n-1] = data | |
509 | self.__profIndex = self.n |
|
505 | self.__profIndex = self.n | |
510 | return |
|
506 | return | |
511 |
|
507 | |||
512 |
|
508 | |||
513 | def pushData(self): |
|
509 | def pushData(self): | |
514 | """ |
|
510 | """ | |
515 | Return the sum of the last profiles and the profiles used in the sum. |
|
511 | Return the sum of the last profiles and the profiles used in the sum. | |
516 |
|
512 | |||
517 | Affected: |
|
513 | Affected: | |
518 |
|
514 | |||
519 | self.__profileIndex |
|
515 | self.__profileIndex | |
520 |
|
516 | |||
521 | """ |
|
517 | """ | |
522 |
|
518 | |||
523 | if not self.__withOverlapping: |
|
519 | if not self.__withOverlapping: | |
524 | data = self.__buffer |
|
520 | data = self.__buffer | |
525 | n = self.__profIndex |
|
521 | n = self.__profIndex | |
526 |
|
522 | |||
527 | self.__buffer = 0 |
|
523 | self.__buffer = 0 | |
528 | self.__profIndex = 0 |
|
524 | self.__profIndex = 0 | |
529 |
|
525 | |||
530 | return data, n |
|
526 | return data, n | |
531 |
|
527 | |||
532 | #Integration with Overlapping |
|
528 | #Integration with Overlapping | |
533 | data = numpy.sum(self.__buffer, axis=0) |
|
529 | data = numpy.sum(self.__buffer, axis=0) | |
534 | # print data |
|
530 | # print data | |
535 | # raise |
|
531 | # raise | |
536 | n = self.__profIndex |
|
532 | n = self.__profIndex | |
537 |
|
533 | |||
538 | return data, n |
|
534 | return data, n | |
539 |
|
535 | |||
540 | def byProfiles(self, data): |
|
536 | def byProfiles(self, data): | |
541 |
|
537 | |||
542 | self.__dataReady = False |
|
538 | self.__dataReady = False | |
543 | avgdata = None |
|
539 | avgdata = None | |
544 | # n = None |
|
540 | # n = None | |
545 | # print data |
|
541 | # print data | |
546 | # raise |
|
542 | # raise | |
547 | self.putData(data) |
|
543 | self.putData(data) | |
548 |
|
544 | |||
549 | if self.__profIndex == self.n: |
|
545 | if self.__profIndex == self.n: | |
550 | avgdata, n = self.pushData() |
|
546 | avgdata, n = self.pushData() | |
551 | self.__dataReady = True |
|
547 | self.__dataReady = True | |
552 |
|
548 | |||
553 | return avgdata |
|
549 | return avgdata | |
554 |
|
550 | |||
555 | def byTime(self, data, datatime): |
|
551 | def byTime(self, data, datatime): | |
556 |
|
552 | |||
557 | self.__dataReady = False |
|
553 | self.__dataReady = False | |
558 | avgdata = None |
|
554 | avgdata = None | |
559 | n = None |
|
555 | n = None | |
560 |
|
556 | |||
561 | self.putData(data) |
|
557 | self.putData(data) | |
562 |
|
558 | |||
563 | if (datatime - self.__initime) >= self.__integrationtime: |
|
559 | if (datatime - self.__initime) >= self.__integrationtime: | |
564 | avgdata, n = self.pushData() |
|
560 | avgdata, n = self.pushData() | |
565 | self.n = n |
|
561 | self.n = n | |
566 | self.__dataReady = True |
|
562 | self.__dataReady = True | |
567 |
|
563 | |||
568 | return avgdata |
|
564 | return avgdata | |
569 |
|
565 | |||
570 | def integrateByStride(self, data, datatime): |
|
566 | def integrateByStride(self, data, datatime): | |
571 | # print data |
|
567 | # print data | |
572 | if self.__profIndex == 0: |
|
568 | if self.__profIndex == 0: | |
573 | self.__buffer = [[data.copy(), datatime]] |
|
569 | self.__buffer = [[data.copy(), datatime]] | |
574 | else: |
|
570 | else: | |
575 | self.__buffer.append([data.copy(),datatime]) |
|
571 | self.__buffer.append([data.copy(),datatime]) | |
576 | self.__profIndex += 1 |
|
572 | self.__profIndex += 1 | |
577 | self.__dataReady = False |
|
573 | self.__dataReady = False | |
578 |
|
574 | |||
579 | if self.__profIndex == self.n * self.stride : |
|
575 | if self.__profIndex == self.n * self.stride : | |
580 | self.__dataToPutStride = True |
|
576 | self.__dataToPutStride = True | |
581 | self.__profIndexStride = 0 |
|
577 | self.__profIndexStride = 0 | |
582 | self.__profIndex = 0 |
|
578 | self.__profIndex = 0 | |
583 | self.__bufferStride = [] |
|
579 | self.__bufferStride = [] | |
584 | for i in range(self.stride): |
|
580 | for i in range(self.stride): | |
585 | current = self.__buffer[i::self.stride] |
|
581 | current = self.__buffer[i::self.stride] | |
586 | data = numpy.sum([t[0] for t in current], axis=0) |
|
582 | data = numpy.sum([t[0] for t in current], axis=0) | |
587 | avgdatatime = numpy.average([t[1] for t in current]) |
|
583 | avgdatatime = numpy.average([t[1] for t in current]) | |
588 | # print data |
|
584 | # print data | |
589 | self.__bufferStride.append((data, avgdatatime)) |
|
585 | self.__bufferStride.append((data, avgdatatime)) | |
590 |
|
586 | |||
591 | if self.__dataToPutStride: |
|
587 | if self.__dataToPutStride: | |
592 | self.__dataReady = True |
|
588 | self.__dataReady = True | |
593 | self.__profIndexStride += 1 |
|
589 | self.__profIndexStride += 1 | |
594 | if self.__profIndexStride == self.stride: |
|
590 | if self.__profIndexStride == self.stride: | |
595 | self.__dataToPutStride = False |
|
591 | self.__dataToPutStride = False | |
596 | # print self.__bufferStride[self.__profIndexStride - 1] |
|
592 | # print self.__bufferStride[self.__profIndexStride - 1] | |
597 | # raise |
|
593 | # raise | |
598 | return self.__bufferStride[self.__profIndexStride - 1] |
|
594 | return self.__bufferStride[self.__profIndexStride - 1] | |
599 |
|
595 | |||
600 |
|
596 | |||
601 | return None, None |
|
597 | return None, None | |
602 |
|
598 | |||
603 | def integrate(self, data, datatime=None): |
|
599 | def integrate(self, data, datatime=None): | |
604 |
|
600 | |||
605 | if self.__initime == None: |
|
601 | if self.__initime == None: | |
606 | self.__initime = datatime |
|
602 | self.__initime = datatime | |
607 |
|
603 | |||
608 | if self.__byTime: |
|
604 | if self.__byTime: | |
609 | avgdata = self.byTime(data, datatime) |
|
605 | avgdata = self.byTime(data, datatime) | |
610 | else: |
|
606 | else: | |
611 | avgdata = self.byProfiles(data) |
|
607 | avgdata = self.byProfiles(data) | |
612 |
|
608 | |||
613 |
|
609 | |||
614 | self.__lastdatatime = datatime |
|
610 | self.__lastdatatime = datatime | |
615 |
|
611 | |||
616 | if avgdata is None: |
|
612 | if avgdata is None: | |
617 | return None, None |
|
613 | return None, None | |
618 |
|
614 | |||
619 | avgdatatime = self.__initime |
|
615 | avgdatatime = self.__initime | |
620 |
|
616 | |||
621 | deltatime = datatime - self.__lastdatatime |
|
617 | deltatime = datatime - self.__lastdatatime | |
622 |
|
618 | |||
623 | if not self.__withOverlapping: |
|
619 | if not self.__withOverlapping: | |
624 | self.__initime = datatime |
|
620 | self.__initime = datatime | |
625 | else: |
|
621 | else: | |
626 | self.__initime += deltatime |
|
622 | self.__initime += deltatime | |
627 |
|
623 | |||
628 | return avgdata, avgdatatime |
|
624 | return avgdata, avgdatatime | |
629 |
|
625 | |||
630 | def integrateByBlock(self, dataOut): |
|
626 | def integrateByBlock(self, dataOut): | |
631 |
|
627 | |||
632 | times = int(dataOut.data.shape[1]/self.n) |
|
628 | times = int(dataOut.data.shape[1]/self.n) | |
633 | avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex) |
|
629 | avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex) | |
634 |
|
630 | |||
635 | id_min = 0 |
|
631 | id_min = 0 | |
636 | id_max = self.n |
|
632 | id_max = self.n | |
637 |
|
633 | |||
638 | for i in range(times): |
|
634 | for i in range(times): | |
639 | junk = dataOut.data[:,id_min:id_max,:] |
|
635 | junk = dataOut.data[:,id_min:id_max,:] | |
640 | avgdata[:,i,:] = junk.sum(axis=1) |
|
636 | avgdata[:,i,:] = junk.sum(axis=1) | |
641 | id_min += self.n |
|
637 | id_min += self.n | |
642 | id_max += self.n |
|
638 | id_max += self.n | |
643 |
|
639 | |||
644 | timeInterval = dataOut.ippSeconds*self.n |
|
640 | timeInterval = dataOut.ippSeconds*self.n | |
645 | avgdatatime = (times - 1) * timeInterval + dataOut.utctime |
|
641 | avgdatatime = (times - 1) * timeInterval + dataOut.utctime | |
646 | self.__dataReady = True |
|
642 | self.__dataReady = True | |
647 | return avgdata, avgdatatime |
|
643 | return avgdata, avgdatatime | |
648 |
|
644 | |||
649 | def run(self, dataOut, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False, **kwargs): |
|
645 | def run(self, dataOut, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False, **kwargs): | |
650 |
|
646 | |||
651 | if not self.isConfig: |
|
647 | if not self.isConfig: | |
652 | self.setup(n=n, stride=stride, timeInterval=timeInterval, overlapping=overlapping, byblock=byblock, **kwargs) |
|
648 | self.setup(n=n, stride=stride, timeInterval=timeInterval, overlapping=overlapping, byblock=byblock, **kwargs) | |
653 | self.isConfig = True |
|
649 | self.isConfig = True | |
654 |
|
650 | |||
655 | if dataOut.flagDataAsBlock: |
|
651 | if dataOut.flagDataAsBlock: | |
656 | """ |
|
652 | """ | |
657 | Si la data es leida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
653 | Si la data es leida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
658 | """ |
|
654 | """ | |
659 | avgdata, avgdatatime = self.integrateByBlock(dataOut) |
|
655 | avgdata, avgdatatime = self.integrateByBlock(dataOut) | |
660 | dataOut.nProfiles /= self.n |
|
656 | dataOut.nProfiles /= self.n | |
661 | else: |
|
657 | else: | |
662 | if stride is None: |
|
658 | if stride is None: | |
663 | avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime) |
|
659 | avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime) | |
664 | else: |
|
660 | else: | |
665 | avgdata, avgdatatime = self.integrateByStride(dataOut.data, dataOut.utctime) |
|
661 | avgdata, avgdatatime = self.integrateByStride(dataOut.data, dataOut.utctime) | |
666 |
|
662 | |||
667 |
|
663 | |||
668 | # dataOut.timeInterval *= n |
|
664 | # dataOut.timeInterval *= n | |
669 | dataOut.flagNoData = True |
|
665 | dataOut.flagNoData = True | |
670 |
|
666 | |||
671 | if self.__dataReady: |
|
667 | if self.__dataReady: | |
672 | dataOut.data = avgdata |
|
668 | dataOut.data = avgdata | |
673 | if not dataOut.flagCohInt: |
|
669 | if not dataOut.flagCohInt: | |
674 | dataOut.nCohInt *= self.n |
|
670 | dataOut.nCohInt *= self.n | |
675 | dataOut.flagCohInt = True |
|
671 | dataOut.flagCohInt = True | |
676 | dataOut.utctime = avgdatatime |
|
672 | dataOut.utctime = avgdatatime | |
677 | # print avgdata, avgdatatime |
|
673 | # print avgdata, avgdatatime | |
678 | # raise |
|
674 | # raise | |
679 | # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt |
|
675 | # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt | |
680 | dataOut.flagNoData = False |
|
676 | dataOut.flagNoData = False | |
681 | return dataOut |
|
677 | return dataOut | |
682 |
|
678 | |||
683 | class Decoder(Operation): |
|
679 | class Decoder(Operation): | |
684 |
|
680 | |||
685 | isConfig = False |
|
681 | isConfig = False | |
686 | __profIndex = 0 |
|
682 | __profIndex = 0 | |
687 |
|
683 | |||
688 | code = None |
|
684 | code = None | |
689 |
|
685 | |||
690 | nCode = None |
|
686 | nCode = None | |
691 | nBaud = None |
|
687 | nBaud = None | |
692 |
|
688 | |||
693 | def __init__(self, **kwargs): |
|
689 | def __init__(self, **kwargs): | |
694 |
|
690 | |||
695 | Operation.__init__(self, **kwargs) |
|
691 | Operation.__init__(self, **kwargs) | |
696 |
|
692 | |||
697 | self.times = None |
|
693 | self.times = None | |
698 | self.osamp = None |
|
694 | self.osamp = None | |
699 | # self.__setValues = False |
|
695 | # self.__setValues = False | |
700 | self.isConfig = False |
|
696 | self.isConfig = False | |
701 | self.setupReq = False |
|
697 | self.setupReq = False | |
702 | def setup(self, code, osamp, dataOut): |
|
698 | def setup(self, code, osamp, dataOut): | |
703 |
|
699 | |||
704 | self.__profIndex = 0 |
|
700 | self.__profIndex = 0 | |
705 |
|
701 | |||
706 | self.code = code |
|
702 | self.code = code | |
707 |
|
703 | |||
708 | self.nCode = len(code) |
|
704 | self.nCode = len(code) | |
709 | self.nBaud = len(code[0]) |
|
705 | self.nBaud = len(code[0]) | |
710 |
|
706 | |||
711 | if (osamp != None) and (osamp >1): |
|
707 | if (osamp != None) and (osamp >1): | |
712 | self.osamp = osamp |
|
708 | self.osamp = osamp | |
713 | self.code = numpy.repeat(code, repeats=self.osamp, axis=1) |
|
709 | self.code = numpy.repeat(code, repeats=self.osamp, axis=1) | |
714 | self.nBaud = self.nBaud*self.osamp |
|
710 | self.nBaud = self.nBaud*self.osamp | |
715 |
|
711 | |||
716 | self.__nChannels = dataOut.nChannels |
|
712 | self.__nChannels = dataOut.nChannels | |
717 | self.__nProfiles = dataOut.nProfiles |
|
713 | self.__nProfiles = dataOut.nProfiles | |
718 | self.__nHeis = dataOut.nHeights |
|
714 | self.__nHeis = dataOut.nHeights | |
719 |
|
715 | |||
720 | if self.__nHeis < self.nBaud: |
|
716 | if self.__nHeis < self.nBaud: | |
721 | raise ValueError('Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)) |
|
717 | raise ValueError('Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)) | |
722 |
|
718 | |||
723 | #Frequency |
|
719 | #Frequency | |
724 | __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex) |
|
720 | __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex) | |
725 |
|
721 | |||
726 | __codeBuffer[:,0:self.nBaud] = self.code |
|
722 | __codeBuffer[:,0:self.nBaud] = self.code | |
727 |
|
723 | |||
728 | self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1)) |
|
724 | self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1)) | |
729 |
|
725 | |||
730 | if dataOut.flagDataAsBlock: |
|
726 | if dataOut.flagDataAsBlock: | |
731 |
|
727 | |||
732 | self.ndatadec = self.__nHeis #- self.nBaud + 1 |
|
728 | self.ndatadec = self.__nHeis #- self.nBaud + 1 | |
733 |
|
729 | |||
734 | self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex) |
|
730 | self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex) | |
735 |
|
731 | |||
736 | else: |
|
732 | else: | |
737 |
|
733 | |||
738 | #Time |
|
734 | #Time | |
739 | self.ndatadec = self.__nHeis #- self.nBaud + 1 |
|
735 | self.ndatadec = self.__nHeis #- self.nBaud + 1 | |
740 |
|
736 | |||
741 | self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex) |
|
737 | self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex) | |
742 |
|
738 | |||
743 | def __convolutionInFreq(self, data): |
|
739 | def __convolutionInFreq(self, data): | |
744 |
|
740 | |||
745 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) |
|
741 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) | |
746 |
|
742 | |||
747 | fft_data = numpy.fft.fft(data, axis=1) |
|
743 | fft_data = numpy.fft.fft(data, axis=1) | |
748 |
|
744 | |||
749 | conv = fft_data*fft_code |
|
745 | conv = fft_data*fft_code | |
750 |
|
746 | |||
751 | data = numpy.fft.ifft(conv,axis=1) |
|
747 | data = numpy.fft.ifft(conv,axis=1) | |
752 |
|
748 | |||
753 | return data |
|
749 | return data | |
754 |
|
750 | |||
755 | def __convolutionInFreqOpt(self, data): |
|
751 | def __convolutionInFreqOpt(self, data): | |
756 |
|
752 | |||
757 | raise NotImplementedError |
|
753 | raise NotImplementedError | |
758 |
|
754 | |||
759 | def __convolutionInTime(self, data): |
|
755 | def __convolutionInTime(self, data): | |
760 |
|
756 | |||
761 | code = self.code[self.__profIndex] |
|
757 | code = self.code[self.__profIndex] | |
762 | for i in range(self.__nChannels): |
|
758 | for i in range(self.__nChannels): | |
763 | self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='full')[self.nBaud-1:] |
|
759 | self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='full')[self.nBaud-1:] | |
764 |
|
760 | |||
765 | return self.datadecTime |
|
761 | return self.datadecTime | |
766 |
|
762 | |||
767 | def __convolutionByBlockInTime(self, data): |
|
763 | def __convolutionByBlockInTime(self, data): | |
768 |
|
764 | |||
769 | repetitions = int(self.__nProfiles / self.nCode) |
|
765 | repetitions = int(self.__nProfiles / self.nCode) | |
770 | junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize)) |
|
766 | junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize)) | |
771 | junk = junk.flatten() |
|
767 | junk = junk.flatten() | |
772 | code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud)) |
|
768 | code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud)) | |
773 | profilesList = range(self.__nProfiles) |
|
769 | profilesList = range(self.__nProfiles) | |
774 |
|
770 | |||
775 | for i in range(self.__nChannels): |
|
771 | for i in range(self.__nChannels): | |
776 | for j in profilesList: |
|
772 | for j in profilesList: | |
777 | self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:] |
|
773 | self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:] | |
778 | return self.datadecTime |
|
774 | return self.datadecTime | |
779 |
|
775 | |||
780 | def __convolutionByBlockInFreq(self, data): |
|
776 | def __convolutionByBlockInFreq(self, data): | |
781 |
|
777 | |||
782 | raise NotImplementedError("Decoder by frequency fro Blocks not implemented") |
|
778 | raise NotImplementedError("Decoder by frequency fro Blocks not implemented") | |
783 |
|
779 | |||
784 |
|
780 | |||
785 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) |
|
781 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) | |
786 |
|
782 | |||
787 | fft_data = numpy.fft.fft(data, axis=2) |
|
783 | fft_data = numpy.fft.fft(data, axis=2) | |
788 |
|
784 | |||
789 | conv = fft_data*fft_code |
|
785 | conv = fft_data*fft_code | |
790 |
|
786 | |||
791 | data = numpy.fft.ifft(conv,axis=2) |
|
787 | data = numpy.fft.ifft(conv,axis=2) | |
792 |
|
788 | |||
793 | return data |
|
789 | return data | |
794 |
|
790 | |||
795 |
|
791 | |||
796 | def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None): |
|
792 | def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None): | |
797 |
|
793 | |||
798 | if dataOut.flagDecodeData: |
|
794 | if dataOut.flagDecodeData: | |
799 | print("This data is already decoded, recoding again ...") |
|
795 | print("This data is already decoded, recoding again ...") | |
800 |
|
796 | |||
801 | if not self.isConfig: |
|
797 | if not self.isConfig: | |
802 |
|
798 | |||
803 | if code is None: |
|
799 | if code is None: | |
804 | if dataOut.code is None: |
|
800 | if dataOut.code is None: | |
805 | raise ValueError("Code could not be read from %s instance. Enter a value in Code parameter" %dataOut.type) |
|
801 | raise ValueError("Code could not be read from %s instance. Enter a value in Code parameter" %dataOut.type) | |
806 |
|
802 | |||
807 | code = dataOut.code |
|
803 | code = dataOut.code | |
808 | else: |
|
804 | else: | |
809 | code = numpy.array(code).reshape(nCode,nBaud) |
|
805 | code = numpy.array(code).reshape(nCode,nBaud) | |
810 | self.setup(code, osamp, dataOut) |
|
806 | self.setup(code, osamp, dataOut) | |
811 |
|
807 | |||
812 | self.isConfig = True |
|
808 | self.isConfig = True | |
813 |
|
809 | |||
814 | if mode == 3: |
|
810 | if mode == 3: | |
815 | sys.stderr.write("Decoder Warning: mode=%d is not valid, using mode=0\n" %mode) |
|
811 | sys.stderr.write("Decoder Warning: mode=%d is not valid, using mode=0\n" %mode) | |
816 |
|
812 | |||
817 | if times != None: |
|
813 | if times != None: | |
818 | sys.stderr.write("Decoder Warning: Argument 'times' in not used anymore\n") |
|
814 | sys.stderr.write("Decoder Warning: Argument 'times' in not used anymore\n") | |
819 |
|
815 | |||
820 | if self.code is None: |
|
816 | if self.code is None: | |
821 | print("Fail decoding: Code is not defined.") |
|
817 | print("Fail decoding: Code is not defined.") | |
822 | return |
|
818 | return | |
823 |
|
819 | |||
824 | self.__nProfiles = dataOut.nProfiles |
|
820 | self.__nProfiles = dataOut.nProfiles | |
825 | datadec = None |
|
821 | datadec = None | |
826 |
|
822 | |||
827 | if mode == 3: |
|
823 | if mode == 3: | |
828 | mode = 0 |
|
824 | mode = 0 | |
829 |
|
825 | |||
830 | if dataOut.flagDataAsBlock: |
|
826 | if dataOut.flagDataAsBlock: | |
831 | """ |
|
827 | """ | |
832 | Decoding when data have been read as block, |
|
828 | Decoding when data have been read as block, | |
833 | """ |
|
829 | """ | |
834 |
|
830 | |||
835 | if mode == 0: |
|
831 | if mode == 0: | |
836 | datadec = self.__convolutionByBlockInTime(dataOut.data) |
|
832 | datadec = self.__convolutionByBlockInTime(dataOut.data) | |
837 | if mode == 1: |
|
833 | if mode == 1: | |
838 | datadec = self.__convolutionByBlockInFreq(dataOut.data) |
|
834 | datadec = self.__convolutionByBlockInFreq(dataOut.data) | |
839 | else: |
|
835 | else: | |
840 | """ |
|
836 | """ | |
841 | Decoding when data have been read profile by profile |
|
837 | Decoding when data have been read profile by profile | |
842 | """ |
|
838 | """ | |
843 | if mode == 0: |
|
839 | if mode == 0: | |
844 | datadec = self.__convolutionInTime(dataOut.data) |
|
840 | datadec = self.__convolutionInTime(dataOut.data) | |
845 |
|
841 | |||
846 | if mode == 1: |
|
842 | if mode == 1: | |
847 | datadec = self.__convolutionInFreq(dataOut.data) |
|
843 | datadec = self.__convolutionInFreq(dataOut.data) | |
848 |
|
844 | |||
849 | if mode == 2: |
|
845 | if mode == 2: | |
850 | datadec = self.__convolutionInFreqOpt(dataOut.data) |
|
846 | datadec = self.__convolutionInFreqOpt(dataOut.data) | |
851 |
|
847 | |||
852 | if datadec is None: |
|
848 | if datadec is None: | |
853 | raise ValueError("Codification mode selected is not valid: mode=%d. Try selecting 0 or 1" %mode) |
|
849 | raise ValueError("Codification mode selected is not valid: mode=%d. Try selecting 0 or 1" %mode) | |
854 |
|
850 | |||
855 | dataOut.code = self.code |
|
851 | dataOut.code = self.code | |
856 | dataOut.nCode = self.nCode |
|
852 | dataOut.nCode = self.nCode | |
857 | dataOut.nBaud = self.nBaud |
|
853 | dataOut.nBaud = self.nBaud | |
858 |
|
854 | |||
859 | dataOut.data = datadec |
|
855 | dataOut.data = datadec | |
860 |
|
856 | |||
861 | dataOut.heightList = dataOut.heightList[0:datadec.shape[-1]] |
|
857 | dataOut.heightList = dataOut.heightList[0:datadec.shape[-1]] | |
862 |
|
858 | |||
863 | dataOut.flagDecodeData = True #asumo q la data esta decodificada |
|
859 | dataOut.flagDecodeData = True #asumo q la data esta decodificada | |
864 |
|
860 | |||
865 | if self.__profIndex == self.nCode-1: |
|
861 | if self.__profIndex == self.nCode-1: | |
866 | self.__profIndex = 0 |
|
862 | self.__profIndex = 0 | |
867 | return dataOut |
|
863 | return dataOut | |
868 |
|
864 | |||
869 | self.__profIndex += 1 |
|
865 | self.__profIndex += 1 | |
870 |
|
866 | |||
871 | return dataOut |
|
867 | return dataOut | |
872 | # dataOut.flagDeflipData = True #asumo q la data no esta sin flip |
|
868 | # dataOut.flagDeflipData = True #asumo q la data no esta sin flip | |
873 |
|
869 | |||
874 |
|
870 | |||
875 | class ProfileConcat(Operation): |
|
871 | class ProfileConcat(Operation): | |
876 |
|
872 | |||
877 | isConfig = False |
|
873 | isConfig = False | |
878 | buffer = None |
|
874 | buffer = None | |
879 |
|
875 | |||
880 | def __init__(self, **kwargs): |
|
876 | def __init__(self, **kwargs): | |
881 |
|
877 | |||
882 | Operation.__init__(self, **kwargs) |
|
878 | Operation.__init__(self, **kwargs) | |
883 | self.profileIndex = 0 |
|
879 | self.profileIndex = 0 | |
884 |
|
880 | |||
885 | def reset(self): |
|
881 | def reset(self): | |
886 | self.buffer = numpy.zeros_like(self.buffer) |
|
882 | self.buffer = numpy.zeros_like(self.buffer) | |
887 | self.start_index = 0 |
|
883 | self.start_index = 0 | |
888 | self.times = 1 |
|
884 | self.times = 1 | |
889 |
|
885 | |||
890 | def setup(self, data, m, n=1): |
|
886 | def setup(self, data, m, n=1): | |
891 | self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0])) |
|
887 | self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0])) | |
892 | self.nHeights = data.shape[1]#.nHeights |
|
888 | self.nHeights = data.shape[1]#.nHeights | |
893 | self.start_index = 0 |
|
889 | self.start_index = 0 | |
894 | self.times = 1 |
|
890 | self.times = 1 | |
895 |
|
891 | |||
896 | def concat(self, data): |
|
892 | def concat(self, data): | |
897 |
|
893 | |||
898 | self.buffer[:,self.start_index:self.nHeights*self.times] = data.copy() |
|
894 | self.buffer[:,self.start_index:self.nHeights*self.times] = data.copy() | |
899 | self.start_index = self.start_index + self.nHeights |
|
895 | self.start_index = self.start_index + self.nHeights | |
900 |
|
896 | |||
901 | def run(self, dataOut, m): |
|
897 | def run(self, dataOut, m): | |
902 | dataOut.flagNoData = True |
|
898 | dataOut.flagNoData = True | |
903 |
|
899 | |||
904 | if not self.isConfig: |
|
900 | if not self.isConfig: | |
905 | self.setup(dataOut.data, m, 1) |
|
901 | self.setup(dataOut.data, m, 1) | |
906 | self.isConfig = True |
|
902 | self.isConfig = True | |
907 |
|
903 | |||
908 | if dataOut.flagDataAsBlock: |
|
904 | if dataOut.flagDataAsBlock: | |
909 | raise ValueError("ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False") |
|
905 | raise ValueError("ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False") | |
910 |
|
906 | |||
911 | else: |
|
907 | else: | |
912 | self.concat(dataOut.data) |
|
908 | self.concat(dataOut.data) | |
913 | self.times += 1 |
|
909 | self.times += 1 | |
914 | if self.times > m: |
|
910 | if self.times > m: | |
915 | dataOut.data = self.buffer |
|
911 | dataOut.data = self.buffer | |
916 | self.reset() |
|
912 | self.reset() | |
917 | dataOut.flagNoData = False |
|
913 | dataOut.flagNoData = False | |
918 | # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas |
|
914 | # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas | |
919 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
915 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
920 | xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m |
|
916 | xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m | |
921 | dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight) |
|
917 | dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight) | |
922 | dataOut.ippSeconds *= m |
|
918 | dataOut.ippSeconds *= m | |
923 | return dataOut |
|
919 | return dataOut | |
924 |
|
920 | |||
925 | class ProfileSelector(Operation): |
|
921 | class ProfileSelector(Operation): | |
926 |
|
922 | |||
927 | profileIndex = None |
|
923 | profileIndex = None | |
928 | # Tamanho total de los perfiles |
|
924 | # Tamanho total de los perfiles | |
929 | nProfiles = None |
|
925 | nProfiles = None | |
930 |
|
926 | |||
931 | def __init__(self, **kwargs): |
|
927 | def __init__(self, **kwargs): | |
932 |
|
928 | |||
933 | Operation.__init__(self, **kwargs) |
|
929 | Operation.__init__(self, **kwargs) | |
934 | self.profileIndex = 0 |
|
930 | self.profileIndex = 0 | |
935 |
|
931 | |||
936 | def incProfileIndex(self): |
|
932 | def incProfileIndex(self): | |
937 |
|
933 | |||
938 | self.profileIndex += 1 |
|
934 | self.profileIndex += 1 | |
939 |
|
935 | |||
940 | if self.profileIndex >= self.nProfiles: |
|
936 | if self.profileIndex >= self.nProfiles: | |
941 | self.profileIndex = 0 |
|
937 | self.profileIndex = 0 | |
942 |
|
938 | |||
943 | def isThisProfileInRange(self, profileIndex, minIndex, maxIndex): |
|
939 | def isThisProfileInRange(self, profileIndex, minIndex, maxIndex): | |
944 |
|
940 | |||
945 | if profileIndex < minIndex: |
|
941 | if profileIndex < minIndex: | |
946 | return False |
|
942 | return False | |
947 |
|
943 | |||
948 | if profileIndex > maxIndex: |
|
944 | if profileIndex > maxIndex: | |
949 | return False |
|
945 | return False | |
950 |
|
946 | |||
951 | return True |
|
947 | return True | |
952 |
|
948 | |||
953 | def isThisProfileInList(self, profileIndex, profileList): |
|
949 | def isThisProfileInList(self, profileIndex, profileList): | |
954 |
|
950 | |||
955 | if profileIndex not in profileList: |
|
951 | if profileIndex not in profileList: | |
956 | return False |
|
952 | return False | |
957 |
|
953 | |||
958 | return True |
|
954 | return True | |
959 |
|
955 | |||
960 | def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None, nProfiles=None): |
|
956 | def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None, nProfiles=None): | |
961 |
|
957 | |||
962 | """ |
|
958 | """ | |
963 | ProfileSelector: |
|
959 | ProfileSelector: | |
964 |
|
960 | |||
965 | Inputs: |
|
961 | Inputs: | |
966 | profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8) |
|
962 | profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8) | |
967 |
|
963 | |||
968 | profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30) |
|
964 | profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30) | |
969 |
|
965 | |||
970 | rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256)) |
|
966 | rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256)) | |
971 |
|
967 | |||
972 | """ |
|
968 | """ | |
973 |
|
969 | |||
974 | if rangeList is not None: |
|
970 | if rangeList is not None: | |
975 | if type(rangeList[0]) not in (tuple, list): |
|
971 | if type(rangeList[0]) not in (tuple, list): | |
976 | rangeList = [rangeList] |
|
972 | rangeList = [rangeList] | |
977 |
|
973 | |||
978 | dataOut.flagNoData = True |
|
974 | dataOut.flagNoData = True | |
979 |
|
975 | |||
980 | if dataOut.flagDataAsBlock: |
|
976 | if dataOut.flagDataAsBlock: | |
981 | """ |
|
977 | """ | |
982 | data dimension = [nChannels, nProfiles, nHeis] |
|
978 | data dimension = [nChannels, nProfiles, nHeis] | |
983 | """ |
|
979 | """ | |
984 | if profileList != None: |
|
980 | if profileList != None: | |
985 | dataOut.data = dataOut.data[:,profileList,:] |
|
981 | dataOut.data = dataOut.data[:,profileList,:] | |
986 |
|
982 | |||
987 | if profileRangeList != None: |
|
983 | if profileRangeList != None: | |
988 | minIndex = profileRangeList[0] |
|
984 | minIndex = profileRangeList[0] | |
989 | maxIndex = profileRangeList[1] |
|
985 | maxIndex = profileRangeList[1] | |
990 | profileList = list(range(minIndex, maxIndex+1)) |
|
986 | profileList = list(range(minIndex, maxIndex+1)) | |
991 |
|
987 | |||
992 | dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:] |
|
988 | dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:] | |
993 |
|
989 | |||
994 | if rangeList != None: |
|
990 | if rangeList != None: | |
995 |
|
991 | |||
996 | profileList = [] |
|
992 | profileList = [] | |
997 |
|
993 | |||
998 | for thisRange in rangeList: |
|
994 | for thisRange in rangeList: | |
999 | minIndex = thisRange[0] |
|
995 | minIndex = thisRange[0] | |
1000 | maxIndex = thisRange[1] |
|
996 | maxIndex = thisRange[1] | |
1001 |
|
997 | |||
1002 | profileList.extend(list(range(minIndex, maxIndex+1))) |
|
998 | profileList.extend(list(range(minIndex, maxIndex+1))) | |
1003 |
|
999 | |||
1004 | dataOut.data = dataOut.data[:,profileList,:] |
|
1000 | dataOut.data = dataOut.data[:,profileList,:] | |
1005 |
|
1001 | |||
1006 | dataOut.nProfiles = len(profileList) |
|
1002 | dataOut.nProfiles = len(profileList) | |
1007 | dataOut.profileIndex = dataOut.nProfiles - 1 |
|
1003 | dataOut.profileIndex = dataOut.nProfiles - 1 | |
1008 | dataOut.flagNoData = False |
|
1004 | dataOut.flagNoData = False | |
1009 |
|
1005 | |||
1010 | return dataOut |
|
1006 | return dataOut | |
1011 |
|
1007 | |||
1012 | """ |
|
1008 | """ | |
1013 | data dimension = [nChannels, nHeis] |
|
1009 | data dimension = [nChannels, nHeis] | |
1014 | """ |
|
1010 | """ | |
1015 |
|
1011 | |||
1016 | if profileList != None: |
|
1012 | if profileList != None: | |
1017 |
|
1013 | |||
1018 | if self.isThisProfileInList(dataOut.profileIndex, profileList): |
|
1014 | if self.isThisProfileInList(dataOut.profileIndex, profileList): | |
1019 |
|
1015 | |||
1020 | self.nProfiles = len(profileList) |
|
1016 | self.nProfiles = len(profileList) | |
1021 | dataOut.nProfiles = self.nProfiles |
|
1017 | dataOut.nProfiles = self.nProfiles | |
1022 | dataOut.profileIndex = self.profileIndex |
|
1018 | dataOut.profileIndex = self.profileIndex | |
1023 | dataOut.flagNoData = False |
|
1019 | dataOut.flagNoData = False | |
1024 |
|
1020 | |||
1025 | self.incProfileIndex() |
|
1021 | self.incProfileIndex() | |
1026 | return dataOut |
|
1022 | return dataOut | |
1027 |
|
1023 | |||
1028 | if profileRangeList != None: |
|
1024 | if profileRangeList != None: | |
1029 |
|
1025 | |||
1030 | minIndex = profileRangeList[0] |
|
1026 | minIndex = profileRangeList[0] | |
1031 | maxIndex = profileRangeList[1] |
|
1027 | maxIndex = profileRangeList[1] | |
1032 |
|
1028 | |||
1033 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): |
|
1029 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): | |
1034 |
|
1030 | |||
1035 | self.nProfiles = maxIndex - minIndex + 1 |
|
1031 | self.nProfiles = maxIndex - minIndex + 1 | |
1036 | dataOut.nProfiles = self.nProfiles |
|
1032 | dataOut.nProfiles = self.nProfiles | |
1037 | dataOut.profileIndex = self.profileIndex |
|
1033 | dataOut.profileIndex = self.profileIndex | |
1038 | dataOut.flagNoData = False |
|
1034 | dataOut.flagNoData = False | |
1039 |
|
1035 | |||
1040 | self.incProfileIndex() |
|
1036 | self.incProfileIndex() | |
1041 | return dataOut |
|
1037 | return dataOut | |
1042 |
|
1038 | |||
1043 | if rangeList != None: |
|
1039 | if rangeList != None: | |
1044 |
|
1040 | |||
1045 | nProfiles = 0 |
|
1041 | nProfiles = 0 | |
1046 |
|
1042 | |||
1047 | for thisRange in rangeList: |
|
1043 | for thisRange in rangeList: | |
1048 | minIndex = thisRange[0] |
|
1044 | minIndex = thisRange[0] | |
1049 | maxIndex = thisRange[1] |
|
1045 | maxIndex = thisRange[1] | |
1050 |
|
1046 | |||
1051 | nProfiles += maxIndex - minIndex + 1 |
|
1047 | nProfiles += maxIndex - minIndex + 1 | |
1052 |
|
1048 | |||
1053 | for thisRange in rangeList: |
|
1049 | for thisRange in rangeList: | |
1054 |
|
1050 | |||
1055 | minIndex = thisRange[0] |
|
1051 | minIndex = thisRange[0] | |
1056 | maxIndex = thisRange[1] |
|
1052 | maxIndex = thisRange[1] | |
1057 |
|
1053 | |||
1058 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): |
|
1054 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): | |
1059 |
|
1055 | |||
1060 | self.nProfiles = nProfiles |
|
1056 | self.nProfiles = nProfiles | |
1061 | dataOut.nProfiles = self.nProfiles |
|
1057 | dataOut.nProfiles = self.nProfiles | |
1062 | dataOut.profileIndex = self.profileIndex |
|
1058 | dataOut.profileIndex = self.profileIndex | |
1063 | dataOut.flagNoData = False |
|
1059 | dataOut.flagNoData = False | |
1064 |
|
1060 | |||
1065 | self.incProfileIndex() |
|
1061 | self.incProfileIndex() | |
1066 |
|
1062 | |||
1067 | break |
|
1063 | break | |
1068 |
|
1064 | |||
1069 | return dataOut |
|
1065 | return dataOut | |
1070 |
|
1066 | |||
1071 |
|
1067 | |||
1072 | if beam != None: #beam is only for AMISR data |
|
1068 | if beam != None: #beam is only for AMISR data | |
1073 | if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]): |
|
1069 | if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]): | |
1074 | dataOut.flagNoData = False |
|
1070 | dataOut.flagNoData = False | |
1075 | dataOut.profileIndex = self.profileIndex |
|
1071 | dataOut.profileIndex = self.profileIndex | |
1076 |
|
1072 | |||
1077 | self.incProfileIndex() |
|
1073 | self.incProfileIndex() | |
1078 |
|
1074 | |||
1079 | return dataOut |
|
1075 | return dataOut | |
1080 |
|
1076 | |||
1081 | raise ValueError("ProfileSelector needs profileList, profileRangeList or rangeList parameter") |
|
1077 | raise ValueError("ProfileSelector needs profileList, profileRangeList or rangeList parameter") | |
1082 |
|
1078 | |||
1083 |
|
1079 | |||
1084 | class Reshaper(Operation): |
|
1080 | class Reshaper(Operation): | |
1085 |
|
1081 | |||
1086 | def __init__(self, **kwargs): |
|
1082 | def __init__(self, **kwargs): | |
1087 |
|
1083 | |||
1088 | Operation.__init__(self, **kwargs) |
|
1084 | Operation.__init__(self, **kwargs) | |
1089 |
|
1085 | |||
1090 | self.__buffer = None |
|
1086 | self.__buffer = None | |
1091 | self.__nitems = 0 |
|
1087 | self.__nitems = 0 | |
1092 |
|
1088 | |||
1093 | def __appendProfile(self, dataOut, nTxs): |
|
1089 | def __appendProfile(self, dataOut, nTxs): | |
1094 |
|
1090 | |||
1095 | if self.__buffer is None: |
|
1091 | if self.__buffer is None: | |
1096 | shape = (dataOut.nChannels, int(dataOut.nHeights/nTxs) ) |
|
1092 | shape = (dataOut.nChannels, int(dataOut.nHeights/nTxs) ) | |
1097 | self.__buffer = numpy.empty(shape, dtype = dataOut.data.dtype) |
|
1093 | self.__buffer = numpy.empty(shape, dtype = dataOut.data.dtype) | |
1098 |
|
1094 | |||
1099 | ini = dataOut.nHeights * self.__nitems |
|
1095 | ini = dataOut.nHeights * self.__nitems | |
1100 | end = ini + dataOut.nHeights |
|
1096 | end = ini + dataOut.nHeights | |
1101 |
|
1097 | |||
1102 | self.__buffer[:, ini:end] = dataOut.data |
|
1098 | self.__buffer[:, ini:end] = dataOut.data | |
1103 |
|
1099 | |||
1104 | self.__nitems += 1 |
|
1100 | self.__nitems += 1 | |
1105 |
|
1101 | |||
1106 | return int(self.__nitems*nTxs) |
|
1102 | return int(self.__nitems*nTxs) | |
1107 |
|
1103 | |||
1108 | def __getBuffer(self): |
|
1104 | def __getBuffer(self): | |
1109 |
|
1105 | |||
1110 | if self.__nitems == int(1./self.__nTxs): |
|
1106 | if self.__nitems == int(1./self.__nTxs): | |
1111 |
|
1107 | |||
1112 | self.__nitems = 0 |
|
1108 | self.__nitems = 0 | |
1113 |
|
1109 | |||
1114 | return self.__buffer.copy() |
|
1110 | return self.__buffer.copy() | |
1115 |
|
1111 | |||
1116 | return None |
|
1112 | return None | |
1117 |
|
1113 | |||
1118 | def __checkInputs(self, dataOut, shape, nTxs): |
|
1114 | def __checkInputs(self, dataOut, shape, nTxs): | |
1119 |
|
1115 | |||
1120 | if shape is None and nTxs is None: |
|
1116 | if shape is None and nTxs is None: | |
1121 | raise ValueError("Reshaper: shape of factor should be defined") |
|
1117 | raise ValueError("Reshaper: shape of factor should be defined") | |
1122 |
|
1118 | |||
1123 | if nTxs: |
|
1119 | if nTxs: | |
1124 | if nTxs < 0: |
|
1120 | if nTxs < 0: | |
1125 | raise ValueError("nTxs should be greater than 0") |
|
1121 | raise ValueError("nTxs should be greater than 0") | |
1126 |
|
1122 | |||
1127 | if nTxs < 1 and dataOut.nProfiles % (1./nTxs) != 0: |
|
1123 | if nTxs < 1 and dataOut.nProfiles % (1./nTxs) != 0: | |
1128 | raise ValueError("nProfiles= %d is not divisibled by (1./nTxs) = %f" %(dataOut.nProfiles, (1./nTxs))) |
|
1124 | raise ValueError("nProfiles= %d is not divisibled by (1./nTxs) = %f" %(dataOut.nProfiles, (1./nTxs))) | |
1129 |
|
1125 | |||
1130 | shape = [dataOut.nChannels, dataOut.nProfiles*nTxs, dataOut.nHeights/nTxs] |
|
1126 | shape = [dataOut.nChannels, dataOut.nProfiles*nTxs, dataOut.nHeights/nTxs] | |
1131 |
|
1127 | |||
1132 | return shape, nTxs |
|
1128 | return shape, nTxs | |
1133 |
|
1129 | |||
1134 | if len(shape) != 2 and len(shape) != 3: |
|
1130 | if len(shape) != 2 and len(shape) != 3: | |
1135 | raise ValueError("shape dimension should be equal to 2 or 3. shape = (nProfiles, nHeis) or (nChannels, nProfiles, nHeis). Actually shape = (%d, %d, %d)" %(dataOut.nChannels, dataOut.nProfiles, dataOut.nHeights)) |
|
1131 | raise ValueError("shape dimension should be equal to 2 or 3. shape = (nProfiles, nHeis) or (nChannels, nProfiles, nHeis). Actually shape = (%d, %d, %d)" %(dataOut.nChannels, dataOut.nProfiles, dataOut.nHeights)) | |
1136 |
|
1132 | |||
1137 | if len(shape) == 2: |
|
1133 | if len(shape) == 2: | |
1138 | shape_tuple = [dataOut.nChannels] |
|
1134 | shape_tuple = [dataOut.nChannels] | |
1139 | shape_tuple.extend(shape) |
|
1135 | shape_tuple.extend(shape) | |
1140 | else: |
|
1136 | else: | |
1141 | shape_tuple = list(shape) |
|
1137 | shape_tuple = list(shape) | |
1142 |
|
1138 | |||
1143 | nTxs = 1.0*shape_tuple[1]/dataOut.nProfiles |
|
1139 | nTxs = 1.0*shape_tuple[1]/dataOut.nProfiles | |
1144 |
|
1140 | |||
1145 | return shape_tuple, nTxs |
|
1141 | return shape_tuple, nTxs | |
1146 |
|
1142 | |||
1147 | def run(self, dataOut, shape=None, nTxs=None): |
|
1143 | def run(self, dataOut, shape=None, nTxs=None): | |
1148 |
|
1144 | |||
1149 | shape_tuple, self.__nTxs = self.__checkInputs(dataOut, shape, nTxs) |
|
1145 | shape_tuple, self.__nTxs = self.__checkInputs(dataOut, shape, nTxs) | |
1150 |
|
1146 | |||
1151 | dataOut.flagNoData = True |
|
1147 | dataOut.flagNoData = True | |
1152 | profileIndex = None |
|
1148 | profileIndex = None | |
1153 |
|
1149 | |||
1154 | if dataOut.flagDataAsBlock: |
|
1150 | if dataOut.flagDataAsBlock: | |
1155 |
|
1151 | |||
1156 | dataOut.data = numpy.reshape(dataOut.data, shape_tuple) |
|
1152 | dataOut.data = numpy.reshape(dataOut.data, shape_tuple) | |
1157 | dataOut.flagNoData = False |
|
1153 | dataOut.flagNoData = False | |
1158 |
|
1154 | |||
1159 | profileIndex = int(dataOut.nProfiles*self.__nTxs) - 1 |
|
1155 | profileIndex = int(dataOut.nProfiles*self.__nTxs) - 1 | |
1160 |
|
1156 | |||
1161 | else: |
|
1157 | else: | |
1162 |
|
1158 | |||
1163 | if self.__nTxs < 1: |
|
1159 | if self.__nTxs < 1: | |
1164 |
|
1160 | |||
1165 | self.__appendProfile(dataOut, self.__nTxs) |
|
1161 | self.__appendProfile(dataOut, self.__nTxs) | |
1166 | new_data = self.__getBuffer() |
|
1162 | new_data = self.__getBuffer() | |
1167 |
|
1163 | |||
1168 | if new_data is not None: |
|
1164 | if new_data is not None: | |
1169 | dataOut.data = new_data |
|
1165 | dataOut.data = new_data | |
1170 | dataOut.flagNoData = False |
|
1166 | dataOut.flagNoData = False | |
1171 |
|
1167 | |||
1172 | profileIndex = dataOut.profileIndex*nTxs |
|
1168 | profileIndex = dataOut.profileIndex*nTxs | |
1173 |
|
1169 | |||
1174 | else: |
|
1170 | else: | |
1175 | raise ValueError("nTxs should be greater than 0 and lower than 1, or use VoltageReader(..., getblock=True)") |
|
1171 | raise ValueError("nTxs should be greater than 0 and lower than 1, or use VoltageReader(..., getblock=True)") | |
1176 |
|
1172 | |||
1177 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1173 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1178 |
|
1174 | |||
1179 | dataOut.heightList = numpy.arange(dataOut.nHeights/self.__nTxs) * deltaHeight + dataOut.heightList[0] |
|
1175 | dataOut.heightList = numpy.arange(dataOut.nHeights/self.__nTxs) * deltaHeight + dataOut.heightList[0] | |
1180 |
|
1176 | |||
1181 | dataOut.nProfiles = int(dataOut.nProfiles*self.__nTxs) |
|
1177 | dataOut.nProfiles = int(dataOut.nProfiles*self.__nTxs) | |
1182 |
|
1178 | |||
1183 | dataOut.profileIndex = profileIndex |
|
1179 | dataOut.profileIndex = profileIndex | |
1184 |
|
1180 | |||
1185 | dataOut.ippSeconds /= self.__nTxs |
|
1181 | dataOut.ippSeconds /= self.__nTxs | |
1186 |
|
1182 | |||
1187 | return dataOut |
|
1183 | return dataOut | |
1188 |
|
1184 | |||
1189 | class SplitProfiles(Operation): |
|
1185 | class SplitProfiles(Operation): | |
1190 |
|
1186 | |||
1191 | def __init__(self, **kwargs): |
|
1187 | def __init__(self, **kwargs): | |
1192 |
|
1188 | |||
1193 | Operation.__init__(self, **kwargs) |
|
1189 | Operation.__init__(self, **kwargs) | |
1194 |
|
1190 | |||
1195 | def run(self, dataOut, n): |
|
1191 | def run(self, dataOut, n): | |
1196 |
|
1192 | |||
1197 | dataOut.flagNoData = True |
|
1193 | dataOut.flagNoData = True | |
1198 | profileIndex = None |
|
1194 | profileIndex = None | |
1199 |
|
1195 | |||
1200 | if dataOut.flagDataAsBlock: |
|
1196 | if dataOut.flagDataAsBlock: | |
1201 |
|
1197 | |||
1202 | #nchannels, nprofiles, nsamples |
|
1198 | #nchannels, nprofiles, nsamples | |
1203 | shape = dataOut.data.shape |
|
1199 | shape = dataOut.data.shape | |
1204 |
|
1200 | |||
1205 | if shape[2] % n != 0: |
|
1201 | if shape[2] % n != 0: | |
1206 | raise ValueError("Could not split the data, n=%d has to be multiple of %d" %(n, shape[2])) |
|
1202 | raise ValueError("Could not split the data, n=%d has to be multiple of %d" %(n, shape[2])) | |
1207 |
|
1203 | |||
1208 | new_shape = shape[0], shape[1]*n, int(shape[2]/n) |
|
1204 | new_shape = shape[0], shape[1]*n, int(shape[2]/n) | |
1209 |
|
1205 | |||
1210 | dataOut.data = numpy.reshape(dataOut.data, new_shape) |
|
1206 | dataOut.data = numpy.reshape(dataOut.data, new_shape) | |
1211 | dataOut.flagNoData = False |
|
1207 | dataOut.flagNoData = False | |
1212 |
|
1208 | |||
1213 | profileIndex = int(dataOut.nProfiles/n) - 1 |
|
1209 | profileIndex = int(dataOut.nProfiles/n) - 1 | |
1214 |
|
1210 | |||
1215 | else: |
|
1211 | else: | |
1216 |
|
1212 | |||
1217 | raise ValueError("Could not split the data when is read Profile by Profile. Use VoltageReader(..., getblock=True)") |
|
1213 | raise ValueError("Could not split the data when is read Profile by Profile. Use VoltageReader(..., getblock=True)") | |
1218 |
|
1214 | |||
1219 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1215 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1220 |
|
1216 | |||
1221 | dataOut.heightList = numpy.arange(dataOut.nHeights/n) * deltaHeight + dataOut.heightList[0] |
|
1217 | dataOut.heightList = numpy.arange(dataOut.nHeights/n) * deltaHeight + dataOut.heightList[0] | |
1222 |
|
1218 | |||
1223 | dataOut.nProfiles = int(dataOut.nProfiles*n) |
|
1219 | dataOut.nProfiles = int(dataOut.nProfiles*n) | |
1224 |
|
1220 | |||
1225 | dataOut.profileIndex = profileIndex |
|
1221 | dataOut.profileIndex = profileIndex | |
1226 |
|
1222 | |||
1227 | dataOut.ippSeconds /= n |
|
1223 | dataOut.ippSeconds /= n | |
1228 |
|
1224 | |||
1229 | return dataOut |
|
1225 | return dataOut | |
1230 |
|
1226 | |||
1231 | class CombineProfiles(Operation): |
|
1227 | class CombineProfiles(Operation): | |
1232 | def __init__(self, **kwargs): |
|
1228 | def __init__(self, **kwargs): | |
1233 |
|
1229 | |||
1234 | Operation.__init__(self, **kwargs) |
|
1230 | Operation.__init__(self, **kwargs) | |
1235 |
|
1231 | |||
1236 | self.__remData = None |
|
1232 | self.__remData = None | |
1237 | self.__profileIndex = 0 |
|
1233 | self.__profileIndex = 0 | |
1238 |
|
1234 | |||
1239 | def run(self, dataOut, n): |
|
1235 | def run(self, dataOut, n): | |
1240 |
|
1236 | |||
1241 | dataOut.flagNoData = True |
|
1237 | dataOut.flagNoData = True | |
1242 | profileIndex = None |
|
1238 | profileIndex = None | |
1243 |
|
1239 | |||
1244 | if dataOut.flagDataAsBlock: |
|
1240 | if dataOut.flagDataAsBlock: | |
1245 |
|
1241 | |||
1246 | #nchannels, nprofiles, nsamples |
|
1242 | #nchannels, nprofiles, nsamples | |
1247 | shape = dataOut.data.shape |
|
1243 | shape = dataOut.data.shape | |
1248 | new_shape = shape[0], shape[1]/n, shape[2]*n |
|
1244 | new_shape = shape[0], shape[1]/n, shape[2]*n | |
1249 |
|
1245 | |||
1250 | if shape[1] % n != 0: |
|
1246 | if shape[1] % n != 0: | |
1251 | raise ValueError("Could not split the data, n=%d has to be multiple of %d" %(n, shape[1])) |
|
1247 | raise ValueError("Could not split the data, n=%d has to be multiple of %d" %(n, shape[1])) | |
1252 |
|
1248 | |||
1253 | dataOut.data = numpy.reshape(dataOut.data, new_shape) |
|
1249 | dataOut.data = numpy.reshape(dataOut.data, new_shape) | |
1254 | dataOut.flagNoData = False |
|
1250 | dataOut.flagNoData = False | |
1255 |
|
1251 | |||
1256 | profileIndex = int(dataOut.nProfiles*n) - 1 |
|
1252 | profileIndex = int(dataOut.nProfiles*n) - 1 | |
1257 |
|
1253 | |||
1258 | else: |
|
1254 | else: | |
1259 |
|
1255 | |||
1260 | #nchannels, nsamples |
|
1256 | #nchannels, nsamples | |
1261 | if self.__remData is None: |
|
1257 | if self.__remData is None: | |
1262 | newData = dataOut.data |
|
1258 | newData = dataOut.data | |
1263 | else: |
|
1259 | else: | |
1264 | newData = numpy.concatenate((self.__remData, dataOut.data), axis=1) |
|
1260 | newData = numpy.concatenate((self.__remData, dataOut.data), axis=1) | |
1265 |
|
1261 | |||
1266 | self.__profileIndex += 1 |
|
1262 | self.__profileIndex += 1 | |
1267 |
|
1263 | |||
1268 | if self.__profileIndex < n: |
|
1264 | if self.__profileIndex < n: | |
1269 | self.__remData = newData |
|
1265 | self.__remData = newData | |
1270 | #continue |
|
1266 | #continue | |
1271 | return |
|
1267 | return | |
1272 |
|
1268 | |||
1273 | self.__profileIndex = 0 |
|
1269 | self.__profileIndex = 0 | |
1274 | self.__remData = None |
|
1270 | self.__remData = None | |
1275 |
|
1271 | |||
1276 | dataOut.data = newData |
|
1272 | dataOut.data = newData | |
1277 | dataOut.flagNoData = False |
|
1273 | dataOut.flagNoData = False | |
1278 |
|
1274 | |||
1279 | profileIndex = dataOut.profileIndex/n |
|
1275 | profileIndex = dataOut.profileIndex/n | |
1280 |
|
1276 | |||
1281 |
|
1277 | |||
1282 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1278 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1283 |
|
1279 | |||
1284 | dataOut.heightList = numpy.arange(dataOut.nHeights*n) * deltaHeight + dataOut.heightList[0] |
|
1280 | dataOut.heightList = numpy.arange(dataOut.nHeights*n) * deltaHeight + dataOut.heightList[0] | |
1285 |
|
1281 | |||
1286 | dataOut.nProfiles = int(dataOut.nProfiles/n) |
|
1282 | dataOut.nProfiles = int(dataOut.nProfiles/n) | |
1287 |
|
1283 | |||
1288 | dataOut.profileIndex = profileIndex |
|
1284 | dataOut.profileIndex = profileIndex | |
1289 |
|
1285 | |||
1290 | dataOut.ippSeconds *= n |
|
1286 | dataOut.ippSeconds *= n | |
1291 |
|
1287 | |||
1292 | return dataOut |
|
1288 | return dataOut | |
1293 |
|
1289 | |||
1294 | class PulsePairVoltage(Operation): |
|
1290 | class PulsePairVoltage(Operation): | |
1295 | ''' |
|
1291 | ''' | |
1296 | Function PulsePair(Signal Power, Velocity) |
|
1292 | Function PulsePair(Signal Power, Velocity) | |
1297 | The real component of Lag[0] provides Intensity Information |
|
1293 | The real component of Lag[0] provides Intensity Information | |
1298 | The imag component of Lag[1] Phase provides Velocity Information |
|
1294 | The imag component of Lag[1] Phase provides Velocity Information | |
1299 |
|
1295 | |||
1300 | Configuration Parameters: |
|
1296 | Configuration Parameters: | |
1301 | nPRF = Number of Several PRF |
|
1297 | nPRF = Number of Several PRF | |
1302 | theta = Degree Azimuth angel Boundaries |
|
1298 | theta = Degree Azimuth angel Boundaries | |
1303 |
|
1299 | |||
1304 | Input: |
|
1300 | Input: | |
1305 | self.dataOut |
|
1301 | self.dataOut | |
1306 | lag[N] |
|
1302 | lag[N] | |
1307 | Affected: |
|
1303 | Affected: | |
1308 | self.dataOut.spc |
|
1304 | self.dataOut.spc | |
1309 | ''' |
|
1305 | ''' | |
1310 | isConfig = False |
|
1306 | isConfig = False | |
1311 | __profIndex = 0 |
|
1307 | __profIndex = 0 | |
1312 | __initime = None |
|
1308 | __initime = None | |
1313 | __lastdatatime = None |
|
1309 | __lastdatatime = None | |
1314 | __buffer = None |
|
1310 | __buffer = None | |
1315 | noise = None |
|
1311 | noise = None | |
1316 | __dataReady = False |
|
1312 | __dataReady = False | |
1317 | n = None |
|
1313 | n = None | |
1318 | __nch = 0 |
|
1314 | __nch = 0 | |
1319 | __nHeis = 0 |
|
1315 | __nHeis = 0 | |
1320 | removeDC = False |
|
1316 | removeDC = False | |
1321 | ipp = None |
|
1317 | ipp = None | |
1322 | lambda_ = 0 |
|
1318 | lambda_ = 0 | |
1323 |
|
1319 | |||
1324 | def __init__(self,**kwargs): |
|
1320 | def __init__(self,**kwargs): | |
1325 | Operation.__init__(self,**kwargs) |
|
1321 | Operation.__init__(self,**kwargs) | |
1326 |
|
1322 | |||
1327 | def setup(self, dataOut, n = None, removeDC=False): |
|
1323 | def setup(self, dataOut, n = None, removeDC=False): | |
1328 | ''' |
|
1324 | ''' | |
1329 | n= Numero de PRF's de entrada |
|
1325 | n= Numero de PRF's de entrada | |
1330 | ''' |
|
1326 | ''' | |
1331 | self.__initime = None |
|
1327 | self.__initime = None | |
1332 | self.__lastdatatime = 0 |
|
1328 | self.__lastdatatime = 0 | |
1333 | self.__dataReady = False |
|
1329 | self.__dataReady = False | |
1334 | self.__buffer = 0 |
|
1330 | self.__buffer = 0 | |
1335 | self.__profIndex = 0 |
|
1331 | self.__profIndex = 0 | |
1336 | self.noise = None |
|
1332 | self.noise = None | |
1337 | self.__nch = dataOut.nChannels |
|
1333 | self.__nch = dataOut.nChannels | |
1338 | self.__nHeis = dataOut.nHeights |
|
1334 | self.__nHeis = dataOut.nHeights | |
1339 | self.removeDC = removeDC |
|
1335 | self.removeDC = removeDC | |
1340 | self.lambda_ = 3.0e8/(9345.0e6) |
|
1336 | self.lambda_ = 3.0e8/(9345.0e6) | |
1341 | self.ippSec = dataOut.ippSeconds |
|
1337 | self.ippSec = dataOut.ippSeconds | |
1342 | self.nCohInt = dataOut.nCohInt |
|
1338 | self.nCohInt = dataOut.nCohInt | |
1343 | print("IPPseconds",dataOut.ippSeconds) |
|
1339 | print("IPPseconds",dataOut.ippSeconds) | |
1344 |
|
1340 | |||
1345 | print("ELVALOR DE n es:", n) |
|
1341 | print("ELVALOR DE n es:", n) | |
1346 | if n == None: |
|
1342 | if n == None: | |
1347 | raise ValueError("n should be specified.") |
|
1343 | raise ValueError("n should be specified.") | |
1348 |
|
1344 | |||
1349 | if n != None: |
|
1345 | if n != None: | |
1350 | if n<2: |
|
1346 | if n<2: | |
1351 | raise ValueError("n should be greater than 2") |
|
1347 | raise ValueError("n should be greater than 2") | |
1352 |
|
1348 | |||
1353 | self.n = n |
|
1349 | self.n = n | |
1354 | self.__nProf = n |
|
1350 | self.__nProf = n | |
1355 |
|
1351 | |||
1356 | self.__buffer = numpy.zeros((dataOut.nChannels, |
|
1352 | self.__buffer = numpy.zeros((dataOut.nChannels, | |
1357 | n, |
|
1353 | n, | |
1358 | dataOut.nHeights), |
|
1354 | dataOut.nHeights), | |
1359 | dtype='complex') |
|
1355 | dtype='complex') | |
1360 |
|
1356 | |||
1361 | def putData(self,data): |
|
1357 | def putData(self,data): | |
1362 | ''' |
|
1358 | ''' | |
1363 | Add a profile to he __buffer and increase in one the __profiel Index |
|
1359 | Add a profile to he __buffer and increase in one the __profiel Index | |
1364 | ''' |
|
1360 | ''' | |
1365 | self.__buffer[:,self.__profIndex,:]= data |
|
1361 | self.__buffer[:,self.__profIndex,:]= data | |
1366 | self.__profIndex += 1 |
|
1362 | self.__profIndex += 1 | |
1367 | return |
|
1363 | return | |
1368 |
|
1364 | |||
1369 | def pushData(self,dataOut): |
|
1365 | def pushData(self,dataOut): | |
1370 | ''' |
|
1366 | ''' | |
1371 | Return the PULSEPAIR and the profiles used in the operation |
|
1367 | Return the PULSEPAIR and the profiles used in the operation | |
1372 | Affected : self.__profileIndex |
|
1368 | Affected : self.__profileIndex | |
1373 | ''' |
|
1369 | ''' | |
1374 | #----------------- Remove DC----------------------------------- |
|
1370 | #----------------- Remove DC----------------------------------- | |
1375 | if self.removeDC==True: |
|
1371 | if self.removeDC==True: | |
1376 | mean = numpy.mean(self.__buffer,1) |
|
1372 | mean = numpy.mean(self.__buffer,1) | |
1377 | tmp = mean.reshape(self.__nch,1,self.__nHeis) |
|
1373 | tmp = mean.reshape(self.__nch,1,self.__nHeis) | |
1378 | dc= numpy.tile(tmp,[1,self.__nProf,1]) |
|
1374 | dc= numpy.tile(tmp,[1,self.__nProf,1]) | |
1379 | self.__buffer = self.__buffer - dc |
|
1375 | self.__buffer = self.__buffer - dc | |
1380 | #------------------Calculo de Potencia ------------------------ |
|
1376 | #------------------Calculo de Potencia ------------------------ | |
1381 | pair0 = self.__buffer*numpy.conj(self.__buffer) |
|
1377 | pair0 = self.__buffer*numpy.conj(self.__buffer) | |
1382 | pair0 = pair0.real |
|
1378 | pair0 = pair0.real | |
1383 | lag_0 = numpy.sum(pair0,1) |
|
1379 | lag_0 = numpy.sum(pair0,1) | |
1384 | #------------------Calculo de Ruido x canal-------------------- |
|
1380 | #------------------Calculo de Ruido x canal-------------------- | |
1385 | self.noise = numpy.zeros(self.__nch) |
|
1381 | self.noise = numpy.zeros(self.__nch) | |
1386 | for i in range(self.__nch): |
|
1382 | for i in range(self.__nch): | |
1387 | daux = numpy.sort(pair0[i,:,:],axis= None) |
|
1383 | daux = numpy.sort(pair0[i,:,:],axis= None) | |
1388 | self.noise[i]=hildebrand_sekhon( daux ,self.nCohInt) |
|
1384 | self.noise[i]=hildebrand_sekhon( daux ,self.nCohInt) | |
1389 |
|
1385 | |||
1390 | self.noise = self.noise.reshape(self.__nch,1) |
|
1386 | self.noise = self.noise.reshape(self.__nch,1) | |
1391 | self.noise = numpy.tile(self.noise,[1,self.__nHeis]) |
|
1387 | self.noise = numpy.tile(self.noise,[1,self.__nHeis]) | |
1392 | noise_buffer = self.noise.reshape(self.__nch,1,self.__nHeis) |
|
1388 | noise_buffer = self.noise.reshape(self.__nch,1,self.__nHeis) | |
1393 | noise_buffer = numpy.tile(noise_buffer,[1,self.__nProf,1]) |
|
1389 | noise_buffer = numpy.tile(noise_buffer,[1,self.__nProf,1]) | |
1394 | #------------------ Potencia recibida= P , Potencia senal = S , Ruido= N-- |
|
1390 | #------------------ Potencia recibida= P , Potencia senal = S , Ruido= N-- | |
1395 | #------------------ P= S+N ,P=lag_0/N --------------------------------- |
|
1391 | #------------------ P= S+N ,P=lag_0/N --------------------------------- | |
1396 | #-------------------- Power -------------------------------------------------- |
|
1392 | #-------------------- Power -------------------------------------------------- | |
1397 | data_power = lag_0/(self.n*self.nCohInt) |
|
1393 | data_power = lag_0/(self.n*self.nCohInt) | |
1398 | #------------------ Senal --------------------------------------------------- |
|
1394 | #------------------ Senal --------------------------------------------------- | |
1399 | data_intensity = pair0 - noise_buffer |
|
1395 | data_intensity = pair0 - noise_buffer | |
1400 | data_intensity = numpy.sum(data_intensity,axis=1)*(self.n*self.nCohInt)#*self.nCohInt) |
|
1396 | data_intensity = numpy.sum(data_intensity,axis=1)*(self.n*self.nCohInt)#*self.nCohInt) | |
1401 | #data_intensity = (lag_0-self.noise*self.n)*(self.n*self.nCohInt) |
|
1397 | #data_intensity = (lag_0-self.noise*self.n)*(self.n*self.nCohInt) | |
1402 | for i in range(self.__nch): |
|
1398 | for i in range(self.__nch): | |
1403 | for j in range(self.__nHeis): |
|
1399 | for j in range(self.__nHeis): | |
1404 | if data_intensity[i][j] < 0: |
|
1400 | if data_intensity[i][j] < 0: | |
1405 | data_intensity[i][j] = numpy.min(numpy.absolute(data_intensity[i][j])) |
|
1401 | data_intensity[i][j] = numpy.min(numpy.absolute(data_intensity[i][j])) | |
1406 |
|
1402 | |||
1407 | #----------------- Calculo de Frecuencia y Velocidad doppler-------- |
|
1403 | #----------------- Calculo de Frecuencia y Velocidad doppler-------- | |
1408 | pair1 = self.__buffer[:,:-1,:]*numpy.conjugate(self.__buffer[:,1:,:]) |
|
1404 | pair1 = self.__buffer[:,:-1,:]*numpy.conjugate(self.__buffer[:,1:,:]) | |
1409 | lag_1 = numpy.sum(pair1,1) |
|
1405 | lag_1 = numpy.sum(pair1,1) | |
1410 | data_freq = (-1/(2.0*math.pi*self.ippSec*self.nCohInt))*numpy.angle(lag_1) |
|
1406 | data_freq = (-1/(2.0*math.pi*self.ippSec*self.nCohInt))*numpy.angle(lag_1) | |
1411 | data_velocity = (self.lambda_/2.0)*data_freq |
|
1407 | data_velocity = (self.lambda_/2.0)*data_freq | |
1412 |
|
1408 | |||
1413 | #---------------- Potencia promedio estimada de la Senal----------- |
|
1409 | #---------------- Potencia promedio estimada de la Senal----------- | |
1414 | lag_0 = lag_0/self.n |
|
1410 | lag_0 = lag_0/self.n | |
1415 | S = lag_0-self.noise |
|
1411 | S = lag_0-self.noise | |
1416 |
|
1412 | |||
1417 | #---------------- Frecuencia Doppler promedio --------------------- |
|
1413 | #---------------- Frecuencia Doppler promedio --------------------- | |
1418 | lag_1 = lag_1/(self.n-1) |
|
1414 | lag_1 = lag_1/(self.n-1) | |
1419 | R1 = numpy.abs(lag_1) |
|
1415 | R1 = numpy.abs(lag_1) | |
1420 |
|
1416 | |||
1421 | #---------------- Calculo del SNR---------------------------------- |
|
1417 | #---------------- Calculo del SNR---------------------------------- | |
1422 | data_snrPP = S/self.noise |
|
1418 | data_snrPP = S/self.noise | |
1423 | for i in range(self.__nch): |
|
1419 | for i in range(self.__nch): | |
1424 | for j in range(self.__nHeis): |
|
1420 | for j in range(self.__nHeis): | |
1425 | if data_snrPP[i][j] < 1.e-20: |
|
1421 | if data_snrPP[i][j] < 1.e-20: | |
1426 | data_snrPP[i][j] = 1.e-20 |
|
1422 | data_snrPP[i][j] = 1.e-20 | |
1427 |
|
1423 | |||
1428 | #----------------- Calculo del ancho espectral ---------------------- |
|
1424 | #----------------- Calculo del ancho espectral ---------------------- | |
1429 | L = S/R1 |
|
1425 | L = S/R1 | |
1430 | L = numpy.where(L<0,1,L) |
|
1426 | L = numpy.where(L<0,1,L) | |
1431 | L = numpy.log(L) |
|
1427 | L = numpy.log(L) | |
1432 | tmp = numpy.sqrt(numpy.absolute(L)) |
|
1428 | tmp = numpy.sqrt(numpy.absolute(L)) | |
1433 | data_specwidth = (self.lambda_/(2*math.sqrt(2)*math.pi*self.ippSec*self.nCohInt))*tmp*numpy.sign(L) |
|
1429 | data_specwidth = (self.lambda_/(2*math.sqrt(2)*math.pi*self.ippSec*self.nCohInt))*tmp*numpy.sign(L) | |
1434 | n = self.__profIndex |
|
1430 | n = self.__profIndex | |
1435 |
|
1431 | |||
1436 | self.__buffer = numpy.zeros((self.__nch, self.__nProf,self.__nHeis), dtype='complex') |
|
1432 | self.__buffer = numpy.zeros((self.__nch, self.__nProf,self.__nHeis), dtype='complex') | |
1437 | self.__profIndex = 0 |
|
1433 | self.__profIndex = 0 | |
1438 | return data_power,data_intensity,data_velocity,data_snrPP,data_specwidth,n |
|
1434 | return data_power,data_intensity,data_velocity,data_snrPP,data_specwidth,n | |
1439 |
|
1435 | |||
1440 |
|
1436 | |||
1441 | def pulsePairbyProfiles(self,dataOut): |
|
1437 | def pulsePairbyProfiles(self,dataOut): | |
1442 |
|
1438 | |||
1443 | self.__dataReady = False |
|
1439 | self.__dataReady = False | |
1444 | data_power = None |
|
1440 | data_power = None | |
1445 | data_intensity = None |
|
1441 | data_intensity = None | |
1446 | data_velocity = None |
|
1442 | data_velocity = None | |
1447 | data_specwidth = None |
|
1443 | data_specwidth = None | |
1448 | data_snrPP = None |
|
1444 | data_snrPP = None | |
1449 | self.putData(data=dataOut.data) |
|
1445 | self.putData(data=dataOut.data) | |
1450 | if self.__profIndex == self.n: |
|
1446 | if self.__profIndex == self.n: | |
1451 | data_power,data_intensity, data_velocity,data_snrPP,data_specwidth, n = self.pushData(dataOut=dataOut) |
|
1447 | data_power,data_intensity, data_velocity,data_snrPP,data_specwidth, n = self.pushData(dataOut=dataOut) | |
1452 | self.__dataReady = True |
|
1448 | self.__dataReady = True | |
1453 |
|
1449 | |||
1454 | return data_power, data_intensity, data_velocity, data_snrPP, data_specwidth |
|
1450 | return data_power, data_intensity, data_velocity, data_snrPP, data_specwidth | |
1455 |
|
1451 | |||
1456 |
|
1452 | |||
1457 | def pulsePairOp(self, dataOut, datatime= None): |
|
1453 | def pulsePairOp(self, dataOut, datatime= None): | |
1458 |
|
1454 | |||
1459 | if self.__initime == None: |
|
1455 | if self.__initime == None: | |
1460 | self.__initime = datatime |
|
1456 | self.__initime = datatime | |
1461 | data_power, data_intensity, data_velocity, data_snrPP, data_specwidth = self.pulsePairbyProfiles(dataOut) |
|
1457 | data_power, data_intensity, data_velocity, data_snrPP, data_specwidth = self.pulsePairbyProfiles(dataOut) | |
1462 | self.__lastdatatime = datatime |
|
1458 | self.__lastdatatime = datatime | |
1463 |
|
1459 | |||
1464 | if data_power is None: |
|
1460 | if data_power is None: | |
1465 | return None, None, None,None,None,None |
|
1461 | return None, None, None,None,None,None | |
1466 |
|
1462 | |||
1467 | avgdatatime = self.__initime |
|
1463 | avgdatatime = self.__initime | |
1468 | deltatime = datatime - self.__lastdatatime |
|
1464 | deltatime = datatime - self.__lastdatatime | |
1469 | self.__initime = datatime |
|
1465 | self.__initime = datatime | |
1470 |
|
1466 | |||
1471 | return data_power, data_intensity, data_velocity, data_snrPP, data_specwidth, avgdatatime |
|
1467 | return data_power, data_intensity, data_velocity, data_snrPP, data_specwidth, avgdatatime | |
1472 |
|
1468 | |||
1473 | def run(self, dataOut,n = None,removeDC= False, overlapping= False,**kwargs): |
|
1469 | def run(self, dataOut,n = None,removeDC= False, overlapping= False,**kwargs): | |
1474 |
|
1470 | |||
1475 | if not self.isConfig: |
|
1471 | if not self.isConfig: | |
1476 | self.setup(dataOut = dataOut, n = n , removeDC=removeDC , **kwargs) |
|
1472 | self.setup(dataOut = dataOut, n = n , removeDC=removeDC , **kwargs) | |
1477 | self.isConfig = True |
|
1473 | self.isConfig = True | |
1478 | data_power, data_intensity, data_velocity,data_snrPP,data_specwidth, avgdatatime = self.pulsePairOp(dataOut, dataOut.utctime) |
|
1474 | data_power, data_intensity, data_velocity,data_snrPP,data_specwidth, avgdatatime = self.pulsePairOp(dataOut, dataOut.utctime) | |
1479 | dataOut.flagNoData = True |
|
1475 | dataOut.flagNoData = True | |
1480 |
|
1476 | |||
1481 | if self.__dataReady: |
|
1477 | if self.__dataReady: | |
1482 | dataOut.nCohInt *= self.n |
|
1478 | dataOut.nCohInt *= self.n | |
1483 | dataOut.dataPP_POW = data_intensity # S |
|
1479 | dataOut.dataPP_POW = data_intensity # S | |
1484 | dataOut.dataPP_POWER = data_power # P |
|
1480 | dataOut.dataPP_POWER = data_power # P | |
1485 | dataOut.dataPP_DOP = data_velocity |
|
1481 | dataOut.dataPP_DOP = data_velocity | |
1486 | dataOut.dataPP_SNR = data_snrPP |
|
1482 | dataOut.dataPP_SNR = data_snrPP | |
1487 | dataOut.dataPP_WIDTH = data_specwidth |
|
1483 | dataOut.dataPP_WIDTH = data_specwidth | |
1488 | dataOut.PRFbyAngle = self.n #numero de PRF*cada angulo rotado que equivale a un tiempo. |
|
1484 | dataOut.PRFbyAngle = self.n #numero de PRF*cada angulo rotado que equivale a un tiempo. | |
1489 | dataOut.utctime = avgdatatime |
|
1485 | dataOut.utctime = avgdatatime | |
1490 | dataOut.flagNoData = False |
|
1486 | dataOut.flagNoData = False | |
1491 | return dataOut |
|
1487 | return dataOut | |
1492 |
|
1488 | |||
1493 |
|
1489 | |||
1494 |
|
1490 | |||
1495 | # import collections |
|
1491 | # import collections | |
1496 | # from scipy.stats import mode |
|
1492 | # from scipy.stats import mode | |
1497 | # |
|
1493 | # | |
1498 | # class Synchronize(Operation): |
|
1494 | # class Synchronize(Operation): | |
1499 | # |
|
1495 | # | |
1500 | # isConfig = False |
|
1496 | # isConfig = False | |
1501 | # __profIndex = 0 |
|
1497 | # __profIndex = 0 | |
1502 | # |
|
1498 | # | |
1503 | # def __init__(self, **kwargs): |
|
1499 | # def __init__(self, **kwargs): | |
1504 | # |
|
1500 | # | |
1505 | # Operation.__init__(self, **kwargs) |
|
1501 | # Operation.__init__(self, **kwargs) | |
1506 | # # self.isConfig = False |
|
1502 | # # self.isConfig = False | |
1507 | # self.__powBuffer = None |
|
1503 | # self.__powBuffer = None | |
1508 | # self.__startIndex = 0 |
|
1504 | # self.__startIndex = 0 | |
1509 | # self.__pulseFound = False |
|
1505 | # self.__pulseFound = False | |
1510 | # |
|
1506 | # | |
1511 | # def __findTxPulse(self, dataOut, channel=0, pulse_with = None): |
|
1507 | # def __findTxPulse(self, dataOut, channel=0, pulse_with = None): | |
1512 | # |
|
1508 | # | |
1513 | # #Read data |
|
1509 | # #Read data | |
1514 | # |
|
1510 | # | |
1515 | # powerdB = dataOut.getPower(channel = channel) |
|
1511 | # powerdB = dataOut.getPower(channel = channel) | |
1516 | # noisedB = dataOut.getNoise(channel = channel)[0] |
|
1512 | # noisedB = dataOut.getNoise(channel = channel)[0] | |
1517 | # |
|
1513 | # | |
1518 | # self.__powBuffer.extend(powerdB.flatten()) |
|
1514 | # self.__powBuffer.extend(powerdB.flatten()) | |
1519 | # |
|
1515 | # | |
1520 | # dataArray = numpy.array(self.__powBuffer) |
|
1516 | # dataArray = numpy.array(self.__powBuffer) | |
1521 | # |
|
1517 | # | |
1522 | # filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same") |
|
1518 | # filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same") | |
1523 | # |
|
1519 | # | |
1524 | # maxValue = numpy.nanmax(filteredPower) |
|
1520 | # maxValue = numpy.nanmax(filteredPower) | |
1525 | # |
|
1521 | # | |
1526 | # if maxValue < noisedB + 10: |
|
1522 | # if maxValue < noisedB + 10: | |
1527 | # #No se encuentra ningun pulso de transmision |
|
1523 | # #No se encuentra ningun pulso de transmision | |
1528 | # return None |
|
1524 | # return None | |
1529 | # |
|
1525 | # | |
1530 | # maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0] |
|
1526 | # maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0] | |
1531 | # |
|
1527 | # | |
1532 | # if len(maxValuesIndex) < 2: |
|
1528 | # if len(maxValuesIndex) < 2: | |
1533 | # #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX |
|
1529 | # #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX | |
1534 | # return None |
|
1530 | # return None | |
1535 | # |
|
1531 | # | |
1536 | # phasedMaxValuesIndex = maxValuesIndex - self.__nSamples |
|
1532 | # phasedMaxValuesIndex = maxValuesIndex - self.__nSamples | |
1537 | # |
|
1533 | # | |
1538 | # #Seleccionar solo valores con un espaciamiento de nSamples |
|
1534 | # #Seleccionar solo valores con un espaciamiento de nSamples | |
1539 | # pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex) |
|
1535 | # pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex) | |
1540 | # |
|
1536 | # | |
1541 | # if len(pulseIndex) < 2: |
|
1537 | # if len(pulseIndex) < 2: | |
1542 | # #Solo se encontro un pulso de transmision con ancho mayor a 1 |
|
1538 | # #Solo se encontro un pulso de transmision con ancho mayor a 1 | |
1543 | # return None |
|
1539 | # return None | |
1544 | # |
|
1540 | # | |
1545 | # spacing = pulseIndex[1:] - pulseIndex[:-1] |
|
1541 | # spacing = pulseIndex[1:] - pulseIndex[:-1] | |
1546 | # |
|
1542 | # | |
1547 | # #remover senales que se distancien menos de 10 unidades o muestras |
|
1543 | # #remover senales que se distancien menos de 10 unidades o muestras | |
1548 | # #(No deberian existir IPP menor a 10 unidades) |
|
1544 | # #(No deberian existir IPP menor a 10 unidades) | |
1549 | # |
|
1545 | # | |
1550 | # realIndex = numpy.where(spacing > 10 )[0] |
|
1546 | # realIndex = numpy.where(spacing > 10 )[0] | |
1551 | # |
|
1547 | # | |
1552 | # if len(realIndex) < 2: |
|
1548 | # if len(realIndex) < 2: | |
1553 | # #Solo se encontro un pulso de transmision con ancho mayor a 1 |
|
1549 | # #Solo se encontro un pulso de transmision con ancho mayor a 1 | |
1554 | # return None |
|
1550 | # return None | |
1555 | # |
|
1551 | # | |
1556 | # #Eliminar pulsos anchos (deja solo la diferencia entre IPPs) |
|
1552 | # #Eliminar pulsos anchos (deja solo la diferencia entre IPPs) | |
1557 | # realPulseIndex = pulseIndex[realIndex] |
|
1553 | # realPulseIndex = pulseIndex[realIndex] | |
1558 | # |
|
1554 | # | |
1559 | # period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0] |
|
1555 | # period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0] | |
1560 | # |
|
1556 | # | |
1561 | # print "IPP = %d samples" %period |
|
1557 | # print "IPP = %d samples" %period | |
1562 | # |
|
1558 | # | |
1563 | # self.__newNSamples = dataOut.nHeights #int(period) |
|
1559 | # self.__newNSamples = dataOut.nHeights #int(period) | |
1564 | # self.__startIndex = int(realPulseIndex[0]) |
|
1560 | # self.__startIndex = int(realPulseIndex[0]) | |
1565 | # |
|
1561 | # | |
1566 | # return 1 |
|
1562 | # return 1 | |
1567 | # |
|
1563 | # | |
1568 | # |
|
1564 | # | |
1569 | # def setup(self, nSamples, nChannels, buffer_size = 4): |
|
1565 | # def setup(self, nSamples, nChannels, buffer_size = 4): | |
1570 | # |
|
1566 | # | |
1571 | # self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float), |
|
1567 | # self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float), | |
1572 | # maxlen = buffer_size*nSamples) |
|
1568 | # maxlen = buffer_size*nSamples) | |
1573 | # |
|
1569 | # | |
1574 | # bufferList = [] |
|
1570 | # bufferList = [] | |
1575 | # |
|
1571 | # | |
1576 | # for i in range(nChannels): |
|
1572 | # for i in range(nChannels): | |
1577 | # bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN, |
|
1573 | # bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN, | |
1578 | # maxlen = buffer_size*nSamples) |
|
1574 | # maxlen = buffer_size*nSamples) | |
1579 | # |
|
1575 | # | |
1580 | # bufferList.append(bufferByChannel) |
|
1576 | # bufferList.append(bufferByChannel) | |
1581 | # |
|
1577 | # | |
1582 | # self.__nSamples = nSamples |
|
1578 | # self.__nSamples = nSamples | |
1583 | # self.__nChannels = nChannels |
|
1579 | # self.__nChannels = nChannels | |
1584 | # self.__bufferList = bufferList |
|
1580 | # self.__bufferList = bufferList | |
1585 | # |
|
1581 | # | |
1586 | # def run(self, dataOut, channel = 0): |
|
1582 | # def run(self, dataOut, channel = 0): | |
1587 | # |
|
1583 | # | |
1588 | # if not self.isConfig: |
|
1584 | # if not self.isConfig: | |
1589 | # nSamples = dataOut.nHeights |
|
1585 | # nSamples = dataOut.nHeights | |
1590 | # nChannels = dataOut.nChannels |
|
1586 | # nChannels = dataOut.nChannels | |
1591 | # self.setup(nSamples, nChannels) |
|
1587 | # self.setup(nSamples, nChannels) | |
1592 | # self.isConfig = True |
|
1588 | # self.isConfig = True | |
1593 | # |
|
1589 | # | |
1594 | # #Append new data to internal buffer |
|
1590 | # #Append new data to internal buffer | |
1595 | # for thisChannel in range(self.__nChannels): |
|
1591 | # for thisChannel in range(self.__nChannels): | |
1596 | # bufferByChannel = self.__bufferList[thisChannel] |
|
1592 | # bufferByChannel = self.__bufferList[thisChannel] | |
1597 | # bufferByChannel.extend(dataOut.data[thisChannel]) |
|
1593 | # bufferByChannel.extend(dataOut.data[thisChannel]) | |
1598 | # |
|
1594 | # | |
1599 | # if self.__pulseFound: |
|
1595 | # if self.__pulseFound: | |
1600 | # self.__startIndex -= self.__nSamples |
|
1596 | # self.__startIndex -= self.__nSamples | |
1601 | # |
|
1597 | # | |
1602 | # #Finding Tx Pulse |
|
1598 | # #Finding Tx Pulse | |
1603 | # if not self.__pulseFound: |
|
1599 | # if not self.__pulseFound: | |
1604 | # indexFound = self.__findTxPulse(dataOut, channel) |
|
1600 | # indexFound = self.__findTxPulse(dataOut, channel) | |
1605 | # |
|
1601 | # | |
1606 | # if indexFound == None: |
|
1602 | # if indexFound == None: | |
1607 | # dataOut.flagNoData = True |
|
1603 | # dataOut.flagNoData = True | |
1608 | # return |
|
1604 | # return | |
1609 | # |
|
1605 | # | |
1610 | # self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex) |
|
1606 | # self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex) | |
1611 | # self.__pulseFound = True |
|
1607 | # self.__pulseFound = True | |
1612 | # self.__startIndex = indexFound |
|
1608 | # self.__startIndex = indexFound | |
1613 | # |
|
1609 | # | |
1614 | # #If pulse was found ... |
|
1610 | # #If pulse was found ... | |
1615 | # for thisChannel in range(self.__nChannels): |
|
1611 | # for thisChannel in range(self.__nChannels): | |
1616 | # bufferByChannel = self.__bufferList[thisChannel] |
|
1612 | # bufferByChannel = self.__bufferList[thisChannel] | |
1617 | # #print self.__startIndex |
|
1613 | # #print self.__startIndex | |
1618 | # x = numpy.array(bufferByChannel) |
|
1614 | # x = numpy.array(bufferByChannel) | |
1619 | # self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples] |
|
1615 | # self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples] | |
1620 | # |
|
1616 | # | |
1621 | # deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1617 | # deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1622 | # dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight |
|
1618 | # dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight | |
1623 | # # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6 |
|
1619 | # # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6 | |
1624 | # |
|
1620 | # | |
1625 | # dataOut.data = self.__arrayBuffer |
|
1621 | # dataOut.data = self.__arrayBuffer | |
1626 | # |
|
1622 | # | |
1627 | # self.__startIndex += self.__newNSamples |
|
1623 | # self.__startIndex += self.__newNSamples | |
1628 | # |
|
1624 | # | |
1629 | # return |
|
1625 | # return |
General Comments 0
You need to be logged in to leave comments.
Login now