@@ -1,530 +1,541 | |||
|
1 | 1 | ''' |
|
2 | 2 | |
|
3 | 3 | $Author$ |
|
4 | 4 | $Id$ |
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | 7 | import os, sys |
|
8 | 8 | import numpy |
|
9 | 9 | import time |
|
10 | 10 | import datetime |
|
11 | 11 | path = os.path.split(os.getcwd())[0] |
|
12 | 12 | sys.path.append(path) |
|
13 | 13 | |
|
14 | 14 | from Data.JROData import SpectraHeis |
|
15 | 15 | from IO.SpectraIO import SpectraWriter |
|
16 |
|
|
|
16 | from Graphics.schainPlotTypes import ScopeFigure, SpcFigure | |
|
17 | 17 | #from JRONoise import Noise |
|
18 | 18 | |
|
19 | 19 | class SpectraProcessor: |
|
20 | 20 | ''' |
|
21 | 21 | classdocs |
|
22 | 22 | ''' |
|
23 | 23 | |
|
24 | 24 | dataInObj = None |
|
25 | 25 | |
|
26 | 26 | dataOutObj = None |
|
27 | 27 | |
|
28 | 28 | noiseObj = None |
|
29 | 29 | |
|
30 | 30 | integratorObjList = [] |
|
31 | 31 | |
|
32 | 32 | writerObjList = [] |
|
33 | 33 | |
|
34 | 34 | integratorObjIndex = None |
|
35 | 35 | |
|
36 | 36 | writerObjIndex = None |
|
37 | 37 | |
|
38 | 38 | profIndex = 0 # Se emplea cuando el objeto de entrada es un Voltage |
|
39 | 39 | |
|
40 | 40 | |
|
41 | 41 | def __init__(self): |
|
42 | 42 | ''' |
|
43 | 43 | Constructor |
|
44 | 44 | ''' |
|
45 | 45 | |
|
46 | 46 | self.integratorObjIndex = None |
|
47 | 47 | self.writerObjIndex = None |
|
48 | 48 | self.plotObjIndex = None |
|
49 | 49 | self.integratorOst = [] |
|
50 | 50 | self.plotObjList = [] |
|
51 | 51 | self.noiseObj = bjList = [] |
|
52 | 52 | self.writerObjLiNone |
|
53 | 53 | self.buffer = None |
|
54 | 54 | self.profIndex = 0 |
|
55 | 55 | |
|
56 | 56 | def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairList=None): |
|
57 | 57 | |
|
58 | 58 | if dataInObj == None: |
|
59 | 59 | raise ValueError, "This SpectraProcessor.setup() function needs dataInObj input variable" |
|
60 | 60 | |
|
61 | 61 | if dataInObj.type == "Voltage": |
|
62 | 62 | if nFFTPoints == None: |
|
63 | 63 | raise ValueError, "This SpectraProcessor.setup() function needs nFFTPoints input variable" |
|
64 | 64 | else: |
|
65 | 65 | nFFTPoints = dataInObj.nFFTPoints |
|
66 | 66 | |
|
67 | 67 | self.dataInObj = dataInObj |
|
68 | 68 | |
|
69 | 69 | if dataOutObj == None: |
|
70 | 70 | dataOutObj = Spectra() |
|
71 | 71 | |
|
72 | 72 | self.dataOutObj = dataOutObj |
|
73 | 73 | |
|
74 | 74 | return self.dataOutObj |
|
75 | 75 | |
|
76 | 76 | def init(self): |
|
77 | 77 | |
|
78 | 78 | self.integratorObjIndex = 0 |
|
79 | 79 | self.writerObjIndex = 0 |
|
80 | 80 | self.plotObjIndex = 0 |
|
81 | 81 | if self.dataInObj.type == "Voltage": |
|
82 | 82 | |
|
83 | 83 | if self.buffer == None: |
|
84 | 84 | self.buffer = numpy.zeros((self.nChannels, |
|
85 | 85 | self.nFFTPoints, |
|
86 | 86 | self.dataInObj.nHeights), |
|
87 | 87 | dtype='complex') |
|
88 | 88 | |
|
89 | 89 | self.buffer[:,self.profIndex,:] = self.dataInObj.data |
|
90 | 90 | self.profIndex += 1 |
|
91 | 91 | |
|
92 | 92 | if self.profIndex == self.nFFTPoints: |
|
93 | 93 | self.__getFft() |
|
94 | 94 | self.dataOutObj.flagNoData = False |
|
95 | 95 | |
|
96 | 96 | self.buffer = None |
|
97 | 97 | self.profIndex = 0 |
|
98 | 98 | return |
|
99 | 99 | |
|
100 | 100 | self.dataOutObj.flagNoData = True |
|
101 | 101 | |
|
102 | 102 | return |
|
103 | 103 | |
|
104 | 104 | #Other kind of data |
|
105 | 105 | if self.dataInObj.type == "Spectra": |
|
106 | 106 | self.dataOutObj.copy(self.dataInObj) |
|
107 | 107 | self.dataOutObj.flagNoData = False |
|
108 | 108 | return |
|
109 | 109 | |
|
110 | 110 | raise ValueError, "The dtype is not valid" |
|
111 | 111 | |
|
112 | 112 | def __getFft(self): |
|
113 | 113 | """ |
|
114 | 114 | Convierte valores de Voltaje a Spectra |
|
115 | 115 | |
|
116 | 116 | Affected: |
|
117 | 117 | self.dataOutObj.data_spc |
|
118 | 118 | self.dataOutObj.data_cspc |
|
119 | 119 | self.dataOutObj.data_dc |
|
120 | 120 | self.dataOutObj.heightList |
|
121 | 121 | self.dataOutObj.m_BasicHeader |
|
122 | 122 | self.dataOutObj.m_ProcessingHeader |
|
123 | 123 | self.dataOutObj.radarControllerHeaderObj |
|
124 | 124 | self.dataOutObj.systemHeaderObj |
|
125 | 125 | self.profIndex |
|
126 | 126 | self.buffer |
|
127 | 127 | self.dataOutObj.flagNoData |
|
128 | 128 | self.dataOutObj.dtype |
|
129 | 129 | self.dataOutObj.nPairs |
|
130 | 130 | self.dataOutObj.nChannels |
|
131 | 131 | self.dataOutObj.nProfiles |
|
132 | 132 | self.dataOutObj.systemHeaderObj.numChannels |
|
133 | 133 | self.dataOutObj.m_ProcessingHeader.totalSpectra |
|
134 | 134 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock |
|
135 | 135 | self.dataOutObj.m_ProcessingHeader.numHeights |
|
136 | 136 | self.dataOutObj.m_ProcessingHeader.spectraComb |
|
137 | 137 | self.dataOutObj.m_ProcessingHeader.shif_fft |
|
138 | 138 | """ |
|
139 | 139 | |
|
140 | 140 | if self.dataInObj.flagNoData: |
|
141 | 141 | return 0 |
|
142 | 142 | |
|
143 | 143 | fft_volt = numpy.fft.fft(self.buffer,axis=1) |
|
144 | 144 | dc = fft_volt[:,0,:] |
|
145 | 145 | |
|
146 | 146 | #calculo de self-spectra |
|
147 | 147 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) |
|
148 | 148 | spc = fft_volt * numpy.conjugate(fft_volt) |
|
149 | 149 | spc = spc.real |
|
150 | 150 | |
|
151 | 151 | blocksize = 0 |
|
152 | 152 | blocksize += dc.size |
|
153 | 153 | blocksize += spc.size |
|
154 | 154 | |
|
155 | 155 | cspc = None |
|
156 | 156 | pairIndex = 0 |
|
157 | 157 | if self.pairList != None: |
|
158 | 158 | #calculo de cross-spectra |
|
159 | 159 | cspc = numpy.zeros((self.nPairs, self.nFFTPoints, self.nHeights), dtype='complex') |
|
160 | 160 | for pair in self.pairList: |
|
161 | 161 | cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])) |
|
162 | 162 | pairIndex += 1 |
|
163 | 163 | blocksize += cspc.size |
|
164 | 164 | |
|
165 | 165 | self.dataOutObj.data_spc = spc |
|
166 | 166 | self.dataOutObj.data_cspc = cspc |
|
167 | 167 | self.dataOutObj.data_dc = dc |
|
168 | 168 | self.dataOutObj.m_ProcessingHeader.blockSize = blocksize |
|
169 | 169 | self.dataOutObj.m_BasicHeader.utc = self.dataInObj.m_BasicHeader.utc |
|
170 | 170 | |
|
171 | 171 | # self.getNoise() |
|
172 | 172 | |
|
173 | 173 | def addWriter(self, wrpath, blocksPerFile): |
|
174 | 174 | objWriter = SpectraWriter(self.dataOutObj) |
|
175 | 175 | objWriter.setup(wrpath, blocksPerFile) |
|
176 | 176 | self.writerObjList.append(objWriter) |
|
177 | 177 | |
|
178 | 178 | def addIntegrator(self,N,timeInterval): |
|
179 | 179 | |
|
180 | 180 | objIncohInt = IncoherentIntegration(N,timeInterval) |
|
181 | 181 | self.integratorObjList.append(objIncohInt) |
|
182 | 182 | |
|
183 | 183 | def addSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): |
|
184 | 184 | spcObj = SpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
185 | 185 | self.plotObjList.append(spcObj) |
|
186 | 186 | |
|
187 | 187 | def plotSpc(self, idfigure=None, |
|
188 | 188 | xmin=None, |
|
189 | 189 | xmax=None, |
|
190 | 190 | ymin=None, |
|
191 | 191 | ymax=None, |
|
192 | 192 | minvalue=None, |
|
193 | 193 | maxvalue=None, |
|
194 | 194 | wintitle='', |
|
195 | 195 | driver='plplot', |
|
196 | 196 | colormap='br_greeen', |
|
197 | 197 | colorbar=True, |
|
198 | 198 | showprofile=False, |
|
199 | 199 | save=False, |
|
200 | 200 | gpath=None): |
|
201 | 201 | |
|
202 | 202 | if self.dataOutObj.flagNoData: |
|
203 | 203 | return 0 |
|
204 | 204 | |
|
205 | 205 | nframes = len(self.dataOutObj.channelList) |
|
206 | 206 | |
|
207 | 207 | if len(self.plotObjList) <= self.plotObjIndex: |
|
208 | 208 | self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
209 | 209 | |
|
210 | 210 | x = numpy.arange(self.dataOutObj.nFFTPoints) |
|
211 | 211 | |
|
212 | 212 | y = self.dataOutObj.heightList |
|
213 | 213 | |
|
214 | 214 | channelList = self.dataOutObj.channelList |
|
215 | 215 | |
|
216 | 216 | data = 10.*numpy.log10(self.dataOutObj.data_spc[channelList,:,:]) |
|
217 | 217 | # noisedB = 10.*numpy.log10(noise) |
|
218 | 218 | noisedB = numpy.arange(len(channelList)+1) |
|
219 | 219 | noisedB = noisedB *1.2 |
|
220 | 220 | titleList = [] |
|
221 | 221 | for i in range(len(noisedB)): |
|
222 | 222 | title = "%.2f"%noisedB[i] |
|
223 | 223 | titleList.append(title) |
|
224 | 224 | |
|
225 | 225 | thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.dataUtcTime) |
|
226 | 226 | dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
227 | 227 | figuretitle = "Spc Radar Data: %s"%dateTime |
|
228 | 228 | |
|
229 | 229 | cleardata = True |
|
230 | 230 | |
|
231 | 231 | plotObj = self.plotObjList[self.plotObjIndex] |
|
232 | 232 | |
|
233 | 233 | plotObj.plotPcolor(data, |
|
234 | 234 | x, |
|
235 | 235 | y, |
|
236 | 236 | channelList, |
|
237 | 237 | xmin, |
|
238 | 238 | xmax, |
|
239 | 239 | ymin, |
|
240 | 240 | ymax, |
|
241 | 241 | minvalue, |
|
242 | 242 | maxvalue, |
|
243 | 243 | figuretitle, |
|
244 | 244 | None, |
|
245 | 245 | save, |
|
246 | 246 | gpath, |
|
247 | 247 | cleardata, |
|
248 | 248 | titleList) |
|
249 | 249 | |
|
250 | 250 | self.plotObjIndex += 1 |
|
251 | 251 | |
|
252 | 252 | |
|
253 | 253 | def writeData(self, wrpath, blocksPerFile): |
|
254 | 254 | if self.dataOutObj.flagNoData: |
|
255 | 255 | return 0 |
|
256 | 256 | |
|
257 | 257 | if len(self.writerObjList) <= self.writerObjIndex: |
|
258 | 258 | self.addWriter(wrpath, blocksPerFile) |
|
259 | 259 | |
|
260 | 260 | self.writerObjList[self.writerObjIndex].putData() |
|
261 | 261 | |
|
262 | 262 | self.writerObjIndex += 1 |
|
263 | 263 | |
|
264 | 264 | def integrator(self, N=None, timeInterval=None): |
|
265 | 265 | |
|
266 | 266 | if self.dataOutObj.flagNoData: |
|
267 | 267 | return 0 |
|
268 | 268 | |
|
269 | 269 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
270 | 270 | self.addIntegrator(N,timeInterval) |
|
271 | 271 | |
|
272 | 272 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
273 | 273 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc) |
|
274 | 274 | |
|
275 | 275 | if myIncohIntObj.isReady: |
|
276 | 276 | self.dataOutObj.data_spc = myIncohIntObj.data |
|
277 | 277 | self.dataOutObj.nAvg = myIncohIntObj.navg |
|
278 | 278 | self.dataOutObj.m_ProcessingHeader.incoherentInt = self.dataInObj.m_ProcessingHeader.incoherentInt*myIncohIntObj.navg |
|
279 | 279 | self.dataOutObj.flagNoData = False |
|
280 | 280 | |
|
281 | 281 | """Calcular el ruido""" |
|
282 | 282 | self.getNoise() |
|
283 | 283 | else: |
|
284 | 284 | self.dataOutObj.flagNoData = True |
|
285 | 285 | |
|
286 | 286 | self.integratorObjIndex += 1 |
|
287 | 287 | |
|
288 | 288 | |
|
289 | 289 | class SpectraHeisProcessor: |
|
290 | 290 | |
|
291 | 291 | def __init__(self): |
|
292 | 292 | |
|
293 | 293 | self.integratorObjIndex = None |
|
294 | 294 | self.writerObjIndex = None |
|
295 |
self.plot |
|
|
295 | self.plotObjIndex = None | |
|
296 | 296 | self.integratorObjList = [] |
|
297 | 297 | self.writerObjList = [] |
|
298 |
self.plot |
|
|
298 | self.plotObjList = [] | |
|
299 | 299 | #self.noiseObj = Noise() |
|
300 | 300 | |
|
301 | 301 | def setup(self, dataInObj, dataOutObj=None, nFFTPoints=None, pairList=None): |
|
302 | 302 | |
|
303 | 303 | if nFFTPoints == None: |
|
304 | 304 | nFFTPoints = self.dataInObj.nHeights |
|
305 | 305 | |
|
306 | 306 | self.dataInObj = dataInObj |
|
307 | 307 | |
|
308 | 308 | if dataOutObj == None: |
|
309 | 309 | dataOutObj = SpectraHeis() |
|
310 | 310 | |
|
311 | 311 | self.dataOutObj = dataOutObj |
|
312 | # self.noiseObj = Noise() | |
|
313 | ||
|
314 | ########################################## | |
|
315 | self.nFFTPoints = nFFTPoints | |
|
316 | self.nChannels = self.dataInObj.nChannels | |
|
317 | self.nHeights = self.dataInObj.nHeights | |
|
318 | self.pairList = pairList | |
|
319 | ||
|
320 | if pairList != None: | |
|
321 | self.nPairs = len(pairList) | |
|
322 | else: | |
|
323 | self.nPairs = 0 | |
|
324 | ||
|
325 | self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy() | |
|
326 | self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy() | |
|
327 | ||
|
328 | self.dataOutObj.type = "SpectraHeis" | |
|
329 | ||
|
330 | self.dataOutObj.dtype = self.dataInObj.dtype | |
|
331 | ||
|
332 | self.dataOutObj.nChannels = self.nChannels | |
|
333 | ||
|
334 | self.dataOutObj.nHeights = self.nHeights | |
|
335 | ||
|
336 | self.dataOutObj.nProfiles = self.nFFTPoints | |
|
337 | ||
|
338 | self.dataOutObj.heightList = None | |
|
339 | ||
|
340 | self.dataOutObj.channelList = None | |
|
341 | ||
|
342 | self.dataOutObj.channelIndexList = None | |
|
343 | ||
|
344 | self.dataOutObj.flagNoData = False | |
|
345 | ||
|
346 | self.dataOutObj.flagTimeBlock = False | |
|
347 | ||
|
348 | self.dataOutObj.dataUtcTime = None | |
|
349 | ||
|
350 | self.dataOutObj.nCode = None | |
|
351 | ||
|
352 | self.dataOutObj.nBaud = None | |
|
353 | ||
|
354 | self.dataOutObj.code = None | |
|
355 | ||
|
356 | self.dataOutObj.flagDecodeData = True #asumo q la data esta decodificada | |
|
357 | ||
|
358 | self.dataOutObj.flagDeflipData = True #asumo q la data esta sin flip | |
|
359 | ||
|
360 | self.dataOutObj.flagShiftFFT = False | |
|
361 | ||
|
362 | self.dataOutObj.ippSeconds = None | |
|
363 | ||
|
364 | self.dataOutObjdata_spc = None | |
|
365 | ||
|
366 | self.dataOutObjdata_cspc = None | |
|
367 | ||
|
368 | self.dataOutObjdata_dc = None | |
|
369 | ||
|
370 | self.dataOutObjnFFTPoints = None | |
|
371 | ||
|
372 | self.dataOutObjnPairs = None | |
|
373 | ||
|
374 | self.dataOutObjpairsList = None | |
|
375 | ||
|
376 | 312 | |
|
377 | 313 | return self.dataOutObj |
|
378 | 314 | |
|
379 | 315 | def init(self): |
|
380 | 316 | self.integratorObjIndex = 0 |
|
381 | 317 | self.writerObjIndex = 0 |
|
382 |
self.plot |
|
|
318 | self.plotObjIndex = 0 | |
|
383 | 319 | |
|
384 | 320 | if self.dataInObj.type == "Voltage": |
|
385 | 321 | self.__getFft() |
|
322 | self.__updateFromObj() | |
|
386 | 323 | self.dataOutObj.flagNoData = False |
|
387 | 324 | return |
|
388 | 325 | |
|
389 | 326 | #Other kind of data |
|
390 | 327 | if self.dataInObj.type == "SpectraHeis": |
|
391 | 328 | self.dataOutObj.copy(self.dataInObj) |
|
392 | 329 | self.dataOutObj.flagNoData = False |
|
393 | 330 | return |
|
394 | 331 | |
|
395 | 332 | raise ValueError, "The type is not valid" |
|
396 | 333 | |
|
334 | def __updateFromObj(self): | |
|
335 | self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy() | |
|
336 | self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy() | |
|
337 | self.dataOutObj.channelList = self.dataInObj.channelList | |
|
338 | self.dataOutObj.heightList = self.dataInObj.heightList | |
|
339 | self.dataOutObj.dtype = self.dataInObj.dtype | |
|
340 | self.dataOutObj.nHeights = self.dataInObj.nHeights | |
|
341 | self.dataOutObj.nChannels = self.dataInObj.nChannels | |
|
342 | self.dataOutObj.nBaud = self.dataInObj.nBaud | |
|
343 | self.dataOutObj.nCode = self.dataInObj.nCode | |
|
344 | self.dataOutObj.code = self.dataInObj.code | |
|
345 | self.dataOutObj.nProfiles = 1 | |
|
346 | self.dataOutObj.nFFTPoints = self.dataInObj.nHeights | |
|
347 | self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList | |
|
348 | self.dataOutObj.flagNoData = self.dataInObj.flagNoData | |
|
349 | self.dataOutObj.flagTimeBlock = self.dataInObj.flagTimeBlock | |
|
350 | self.dataOutObj.dataUtcTime = self.dataInObj.dataUtcTime | |
|
351 | self.dataOutObj.flagDecodeData = self.dataInObj.flagDecodeData #asumo q la data esta decodificada | |
|
352 | self.dataOutObj.flagDeflipData = self.dataInObj.flagDeflipData #asumo q la data esta sin flip | |
|
353 | self.dataOutObj.flagShiftFFT = self.dataInObj.flagShiftFFT | |
|
354 | self.dataOutObj.nIncohInt = 1 | |
|
355 | ||
|
397 | 356 | def __getFft(self): |
|
398 | 357 | if self.dataInObj.flagNoData: |
|
399 | 358 | return 0 |
|
400 | 359 | |
|
401 | 360 | fft_volt = numpy.fft.fft(self.dataInObj.data, axis=1) |
|
402 | 361 | #print fft_volt |
|
403 | 362 | #calculo de self-spectra |
|
404 | 363 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) |
|
405 | 364 | |
|
406 | 365 | spc = numpy.abs(fft_volt * numpy.conjugate(fft_volt)) |
|
407 | 366 | self.dataOutObj.data_spc = spc |
|
408 | #print spc | |
|
409 | 367 | |
|
410 | 368 | def getSpectra(self): |
|
411 | 369 | |
|
412 | 370 | return self.dataOutObj.data_spc |
|
413 | 371 | |
|
414 | 372 | def getFrecuencies(self): |
|
415 | 373 | |
|
416 | 374 | print self.nFFTPoints |
|
417 | 375 | return numpy.arange(int(self.nFFTPoints)) |
|
418 | 376 | |
|
419 | 377 | def addIntegrator(self,N,timeInterval): |
|
420 | 378 | objIncohInt = IncoherentIntegration(N,timeInterval) |
|
421 | 379 | self.integratorObjList.append(objIncohInt) |
|
422 | 380 | |
|
423 | 381 | def integrator(self, N=None, timeInterval=None): |
|
424 | 382 | if self.dataOutObj.flagNoData: |
|
425 | 383 | return 0 |
|
426 | 384 | |
|
427 | 385 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
428 | 386 | self.addIntegrator(N,timeInterval) |
|
429 | 387 | |
|
430 | 388 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
431 |
myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj. |
|
|
389 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.dataUtcTime) | |
|
432 | 390 | |
|
433 | 391 | if myIncohIntObj.isReady: |
|
434 | 392 | self.dataOutObj.data_spc = myIncohIntObj.data |
|
435 |
self.dataOutObj.n |
|
|
436 | self.dataOutObj.m_ProcessingHeader.incoherentInt *= myIncohIntObj.navg | |
|
437 | #print "myIncohIntObj.navg: ",myIncohIntObj.navg | |
|
393 | self.dataOutObj.nIncohInt = self.dataOutObj.nIncohInt*myIncohIntObj.navg | |
|
438 | 394 | self.dataOutObj.flagNoData = False |
|
439 | 395 | |
|
440 | 396 | #self.getNoise(type="hildebrand",parm=myIncohIntObj.navg) |
|
441 | 397 | # self.getNoise(type="sort", parm=16) |
|
442 | 398 | |
|
443 | 399 | else: |
|
444 | 400 | self.dataOutObj.flagNoData = True |
|
445 | 401 | |
|
446 | 402 | self.integratorObjIndex += 1 |
|
447 | 403 | |
|
448 | 404 | |
|
405 | def addScope(self, idfigure, nframes, wintitle, driver): | |
|
406 | if idfigure==None: | |
|
407 | idfigure = self.plotObjIndex | |
|
408 | ||
|
409 | scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver) | |
|
410 | self.plotObjList.append(scopeObj) | |
|
411 | ||
|
412 | def plotScope(self, | |
|
413 | idfigure=None, | |
|
414 | minvalue=None, | |
|
415 | maxvalue=None, | |
|
416 | xmin=None, | |
|
417 | xmax=None, | |
|
418 | wintitle='', | |
|
419 | driver='plplot', | |
|
420 | save=False, | |
|
421 | gpath=None, | |
|
422 | titleList=None, | |
|
423 | xlabelList=None, | |
|
424 | ylabelList=None): | |
|
425 | ||
|
426 | if self.dataOutObj.flagNoData: | |
|
427 | return 0 | |
|
428 | ||
|
429 | nframes = len(self.dataOutObj.channelList) | |
|
430 | ||
|
431 | if len(self.plotObjList) <= self.plotObjIndex: | |
|
432 | self.addScope(idfigure, nframes, wintitle, driver) | |
|
433 | ||
|
434 | ||
|
435 | data1D = self.dataOutObj.data_spc | |
|
436 | ||
|
437 | x = numpy.arange(self.dataOutObj.nHeights) | |
|
438 | ||
|
439 | thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.dataUtcTime) | |
|
440 | ||
|
441 | dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
|
442 | date = "%s"%(thisDatetime.strftime("%d-%b-%Y")) | |
|
443 | ||
|
444 | figureTitle = "Scope Plot Radar Data: " + date | |
|
445 | ||
|
446 | plotObj = self.plotObjList[self.plotObjIndex] | |
|
447 | ||
|
448 | plotObj.plot1DArray(data1D, | |
|
449 | x, | |
|
450 | self.dataOutObj.channelList, | |
|
451 | xmin, | |
|
452 | xmax, | |
|
453 | minvalue, | |
|
454 | maxvalue, | |
|
455 | figureTitle, | |
|
456 | save, | |
|
457 | gpath) | |
|
458 | ||
|
459 | self.plotObjIndex += 1 | |
|
449 | 460 | |
|
450 | 461 | class IncoherentIntegration: |
|
451 | 462 | |
|
452 | 463 | integ_counter = None |
|
453 | 464 | data = None |
|
454 | 465 | navg = None |
|
455 | 466 | buffer = None |
|
456 | 467 | nIncohInt = None |
|
457 | 468 | |
|
458 | 469 | def __init__(self, N = None, timeInterval = None): |
|
459 | 470 | """ |
|
460 | 471 | N |
|
461 | 472 | timeInterval - interval time [min], integer value |
|
462 | 473 | """ |
|
463 | 474 | |
|
464 | 475 | self.data = None |
|
465 | 476 | self.navg = None |
|
466 | 477 | self.buffer = None |
|
467 | 478 | self.timeOut = None |
|
468 | 479 | self.exitCondition = False |
|
469 | 480 | self.isReady = False |
|
470 | 481 | self.nIncohInt = N |
|
471 | 482 | self.integ_counter = 0 |
|
472 | 483 | if timeInterval!=None: |
|
473 | 484 | self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line |
|
474 | 485 | |
|
475 | 486 | if ((timeInterval==None) and (N==None)): |
|
476 | 487 | print 'N = None ; timeInterval = None' |
|
477 | 488 | sys.exit(0) |
|
478 | 489 | elif timeInterval == None: |
|
479 | 490 | self.timeFlag = False |
|
480 | 491 | else: |
|
481 | 492 | self.timeFlag = True |
|
482 | 493 | |
|
483 | 494 | |
|
484 | 495 | def exe(self,data,timeOfData): |
|
485 | 496 | """ |
|
486 | 497 | data |
|
487 | 498 | |
|
488 | 499 | timeOfData [seconds] |
|
489 | 500 | """ |
|
490 | 501 | |
|
491 | 502 | if self.timeFlag: |
|
492 | 503 | if self.timeOut == None: |
|
493 | 504 | self.timeOut = timeOfData + self.timeIntervalInSeconds |
|
494 | 505 | |
|
495 | 506 | if timeOfData < self.timeOut: |
|
496 | 507 | if self.buffer == None: |
|
497 | 508 | self.buffer = data |
|
498 | 509 | else: |
|
499 | 510 | self.buffer = self.buffer + data |
|
500 | 511 | self.integ_counter += 1 |
|
501 | 512 | else: |
|
502 | 513 | self.exitCondition = True |
|
503 | 514 | |
|
504 | 515 | else: |
|
505 | 516 | if self.integ_counter < self.nIncohInt: |
|
506 | 517 | if self.buffer == None: |
|
507 | 518 | self.buffer = data |
|
508 | 519 | else: |
|
509 | 520 | self.buffer = self.buffer + data |
|
510 | 521 | |
|
511 | 522 | self.integ_counter += 1 |
|
512 | 523 | |
|
513 | 524 | if self.integ_counter == self.nIncohInt: |
|
514 | 525 | self.exitCondition = True |
|
515 | 526 | |
|
516 | 527 | if self.exitCondition: |
|
517 | 528 | self.data = self.buffer |
|
518 | 529 | self.navg = self.integ_counter |
|
519 | 530 | self.isReady = True |
|
520 | 531 | self.buffer = None |
|
521 | 532 | self.timeOut = None |
|
522 | 533 | self.integ_counter = 0 |
|
523 | 534 | self.exitCondition = False |
|
524 | 535 | |
|
525 | 536 | if self.timeFlag: |
|
526 | 537 | self.buffer = data |
|
527 | 538 | self.timeOut = timeOfData + self.timeIntervalInSeconds |
|
528 | 539 | else: |
|
529 | 540 | self.isReady = False |
|
530 | 541 | No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now