##// END OF EJS Templates
antiguo comportamiento de cohint. Ej: 96 -> 24x4
José Chávez -
r1117:2d7be107f7bd
parent child
Show More
@@ -1,1321 +1,1319
1 1 import sys
2 2 import numpy
3 3 from scipy import interpolate
4 4 from schainpy import cSchain
5 5 from jroproc_base import ProcessingUnit, Operation
6 6 from schainpy.model.data.jrodata import Voltage
7 7 from time import time
8 8
9 9 class VoltageProc(ProcessingUnit):
10 10
11 11
12 12 def __init__(self, **kwargs):
13 13
14 14 ProcessingUnit.__init__(self, **kwargs)
15 15
16 16 # self.objectDict = {}
17 17 self.dataOut = Voltage()
18 18 self.flip = 1
19 19
20 20 def run(self):
21 21 if self.dataIn.type == 'AMISR':
22 22 self.__updateObjFromAmisrInput()
23 23
24 24 if self.dataIn.type == 'Voltage':
25 25 self.dataOut.copy(self.dataIn)
26 26
27 27 # self.dataOut.copy(self.dataIn)
28 28
29 29 def __updateObjFromAmisrInput(self):
30 30
31 31 self.dataOut.timeZone = self.dataIn.timeZone
32 32 self.dataOut.dstFlag = self.dataIn.dstFlag
33 33 self.dataOut.errorCount = self.dataIn.errorCount
34 34 self.dataOut.useLocalTime = self.dataIn.useLocalTime
35 35
36 36 self.dataOut.flagNoData = self.dataIn.flagNoData
37 37 self.dataOut.data = self.dataIn.data
38 38 self.dataOut.utctime = self.dataIn.utctime
39 39 self.dataOut.channelList = self.dataIn.channelList
40 40 # self.dataOut.timeInterval = self.dataIn.timeInterval
41 41 self.dataOut.heightList = self.dataIn.heightList
42 42 self.dataOut.nProfiles = self.dataIn.nProfiles
43 43
44 44 self.dataOut.nCohInt = self.dataIn.nCohInt
45 45 self.dataOut.ippSeconds = self.dataIn.ippSeconds
46 46 self.dataOut.frequency = self.dataIn.frequency
47 47
48 48 self.dataOut.azimuth = self.dataIn.azimuth
49 49 self.dataOut.zenith = self.dataIn.zenith
50 50
51 51 self.dataOut.beam.codeList = self.dataIn.beam.codeList
52 52 self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList
53 53 self.dataOut.beam.zenithList = self.dataIn.beam.zenithList
54 54 #
55 55 # pass#
56 56 #
57 57 # def init(self):
58 58 #
59 59 #
60 60 # if self.dataIn.type == 'AMISR':
61 61 # self.__updateObjFromAmisrInput()
62 62 #
63 63 # if self.dataIn.type == 'Voltage':
64 64 # self.dataOut.copy(self.dataIn)
65 65 # # No necesita copiar en cada init() los atributos de dataIn
66 66 # # la copia deberia hacerse por cada nuevo bloque de datos
67 67
68 68 def selectChannels(self, channelList):
69 69
70 70 channelIndexList = []
71 71
72 72 for channel in channelList:
73 73 if channel not in self.dataOut.channelList:
74 74 raise ValueError, "Channel %d is not in %s" %(channel, str(self.dataOut.channelList))
75 75
76 76 index = self.dataOut.channelList.index(channel)
77 77 channelIndexList.append(index)
78 78
79 79 self.selectChannelsByIndex(channelIndexList)
80 80
81 81 def selectChannelsByIndex(self, channelIndexList):
82 82 """
83 83 Selecciona un bloque de datos en base a canales segun el channelIndexList
84 84
85 85 Input:
86 86 channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7]
87 87
88 88 Affected:
89 89 self.dataOut.data
90 90 self.dataOut.channelIndexList
91 91 self.dataOut.nChannels
92 92 self.dataOut.m_ProcessingHeader.totalSpectra
93 93 self.dataOut.systemHeaderObj.numChannels
94 94 self.dataOut.m_ProcessingHeader.blockSize
95 95
96 96 Return:
97 97 None
98 98 """
99 99
100 100 for channelIndex in channelIndexList:
101 101 if channelIndex not in self.dataOut.channelIndexList:
102 102 print channelIndexList
103 103 raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex
104 104
105 105 if self.dataOut.flagDataAsBlock:
106 106 """
107 107 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
108 108 """
109 109 data = self.dataOut.data[channelIndexList,:,:]
110 110 else:
111 111 data = self.dataOut.data[channelIndexList,:]
112 112
113 113 self.dataOut.data = data
114 114 self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList]
115 115 # self.dataOut.nChannels = nChannels
116 116
117 117 return 1
118 118
119 119 def selectHeights(self, minHei=None, maxHei=None):
120 120 """
121 121 Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango
122 122 minHei <= height <= maxHei
123 123
124 124 Input:
125 125 minHei : valor minimo de altura a considerar
126 126 maxHei : valor maximo de altura a considerar
127 127
128 128 Affected:
129 129 Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex
130 130
131 131 Return:
132 132 1 si el metodo se ejecuto con exito caso contrario devuelve 0
133 133 """
134 134
135 135 if minHei == None:
136 136 minHei = self.dataOut.heightList[0]
137 137
138 138 if maxHei == None:
139 139 maxHei = self.dataOut.heightList[-1]
140 140
141 141 if (minHei < self.dataOut.heightList[0]):
142 142 minHei = self.dataOut.heightList[0]
143 143
144 144 if (maxHei > self.dataOut.heightList[-1]):
145 145 maxHei = self.dataOut.heightList[-1]
146 146
147 147 minIndex = 0
148 148 maxIndex = 0
149 149 heights = self.dataOut.heightList
150 150
151 151 inda = numpy.where(heights >= minHei)
152 152 indb = numpy.where(heights <= maxHei)
153 153
154 154 try:
155 155 minIndex = inda[0][0]
156 156 except:
157 157 minIndex = 0
158 158
159 159 try:
160 160 maxIndex = indb[0][-1]
161 161 except:
162 162 maxIndex = len(heights)
163 163
164 164 self.selectHeightsByIndex(minIndex, maxIndex)
165 165
166 166 return 1
167 167
168 168
169 169 def selectHeightsByIndex(self, minIndex, maxIndex):
170 170 """
171 171 Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango
172 172 minIndex <= index <= maxIndex
173 173
174 174 Input:
175 175 minIndex : valor de indice minimo de altura a considerar
176 176 maxIndex : valor de indice maximo de altura a considerar
177 177
178 178 Affected:
179 179 self.dataOut.data
180 180 self.dataOut.heightList
181 181
182 182 Return:
183 183 1 si el metodo se ejecuto con exito caso contrario devuelve 0
184 184 """
185 185
186 186 if (minIndex < 0) or (minIndex > maxIndex):
187 187 raise ValueError, "Height index range (%d,%d) is not valid" % (minIndex, maxIndex)
188 188
189 189 if (maxIndex >= self.dataOut.nHeights):
190 190 maxIndex = self.dataOut.nHeights
191 191
192 192 #voltage
193 193 if self.dataOut.flagDataAsBlock:
194 194 """
195 195 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
196 196 """
197 197 data = self.dataOut.data[:,:, minIndex:maxIndex]
198 198 else:
199 199 data = self.dataOut.data[:, minIndex:maxIndex]
200 200
201 201 # firstHeight = self.dataOut.heightList[minIndex]
202 202
203 203 self.dataOut.data = data
204 204 self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex]
205 205
206 206 if self.dataOut.nHeights <= 1:
207 207 raise ValueError, "selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights)
208 208
209 209 return 1
210 210
211 211
212 212 def filterByHeights(self, window):
213 213
214 214 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
215 215
216 216 if window == None:
217 217 window = (self.dataOut.radarControllerHeaderObj.txA/self.dataOut.radarControllerHeaderObj.nBaud) / deltaHeight
218 218
219 219 newdelta = deltaHeight * window
220 220 r = self.dataOut.nHeights % window
221 221 newheights = (self.dataOut.nHeights-r)/window
222 222
223 223 if newheights <= 1:
224 224 raise ValueError, "filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(self.dataOut.nHeights, window)
225 225
226 226 if self.dataOut.flagDataAsBlock:
227 227 """
228 228 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
229 229 """
230 230 buffer = self.dataOut.data[:, :, 0:self.dataOut.nHeights-r]
231 231 buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nProfiles,self.dataOut.nHeights/window,window)
232 232 buffer = numpy.sum(buffer,3)
233 233
234 234 else:
235 235 buffer = self.dataOut.data[:,0:self.dataOut.nHeights-r]
236 236 buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nHeights/window,window)
237 237 buffer = numpy.sum(buffer,2)
238 238
239 239 self.dataOut.data = buffer
240 240 self.dataOut.heightList = self.dataOut.heightList[0] + numpy.arange( newheights )*newdelta
241 241 self.dataOut.windowOfFilter = window
242 242
243 243 def setH0(self, h0, deltaHeight = None):
244 244
245 245 if not deltaHeight:
246 246 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
247 247
248 248 nHeights = self.dataOut.nHeights
249 249
250 250 newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight
251 251
252 252 self.dataOut.heightList = newHeiRange
253 253
254 254 def deFlip(self, channelList = []):
255 255
256 256 data = self.dataOut.data.copy()
257 257
258 258 if self.dataOut.flagDataAsBlock:
259 259 flip = self.flip
260 260 profileList = range(self.dataOut.nProfiles)
261 261
262 262 if not channelList:
263 263 for thisProfile in profileList:
264 264 data[:,thisProfile,:] = data[:,thisProfile,:]*flip
265 265 flip *= -1.0
266 266 else:
267 267 for thisChannel in channelList:
268 268 if thisChannel not in self.dataOut.channelList:
269 269 continue
270 270
271 271 for thisProfile in profileList:
272 272 data[thisChannel,thisProfile,:] = data[thisChannel,thisProfile,:]*flip
273 273 flip *= -1.0
274 274
275 275 self.flip = flip
276 276
277 277 else:
278 278 if not channelList:
279 279 data[:,:] = data[:,:]*self.flip
280 280 else:
281 281 for thisChannel in channelList:
282 282 if thisChannel not in self.dataOut.channelList:
283 283 continue
284 284
285 285 data[thisChannel,:] = data[thisChannel,:]*self.flip
286 286
287 287 self.flip *= -1.
288 288
289 289 self.dataOut.data = data
290 290
291 291 def setRadarFrequency(self, frequency=None):
292 292
293 293 if frequency != None:
294 294 self.dataOut.frequency = frequency
295 295
296 296 return 1
297 297
298 298 def interpolateHeights(self, topLim, botLim):
299 299 #69 al 72 para julia
300 300 #82-84 para meteoros
301 301 if len(numpy.shape(self.dataOut.data))==2:
302 302 sampInterp = (self.dataOut.data[:,botLim-1] + self.dataOut.data[:,topLim+1])/2
303 303 sampInterp = numpy.transpose(numpy.tile(sampInterp,(topLim-botLim + 1,1)))
304 304 #self.dataOut.data[:,botLim:limSup+1] = sampInterp
305 305 self.dataOut.data[:,botLim:topLim+1] = sampInterp
306 306 else:
307 307 nHeights = self.dataOut.data.shape[2]
308 308 x = numpy.hstack((numpy.arange(botLim),numpy.arange(topLim+1,nHeights)))
309 309 y = self.dataOut.data[:,:,range(botLim)+range(topLim+1,nHeights)]
310 310 f = interpolate.interp1d(x, y, axis = 2)
311 311 xnew = numpy.arange(botLim,topLim+1)
312 312 ynew = f(xnew)
313 313
314 314 self.dataOut.data[:,:,botLim:topLim+1] = ynew
315 315
316 316 # import collections
317 317
318 318 class CohInt(Operation):
319 319
320 320 isConfig = False
321 321 __profIndex = 0
322 322 __byTime = False
323 323 __initime = None
324 324 __lastdatatime = None
325 325 __integrationtime = None
326 326 __buffer = None
327 327 __bufferStride = []
328 328 __dataReady = False
329 329 __profIndexStride = 0
330 330 __dataToPutStride = False
331 331 n = None
332 332
333 333 def __init__(self, **kwargs):
334 334
335 335 Operation.__init__(self, **kwargs)
336 336
337 337 # self.isConfig = False
338 338
339 339 def setup(self, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False):
340 340 """
341 341 Set the parameters of the integration class.
342 342
343 343 Inputs:
344 344
345 345 n : Number of coherent integrations
346 346 timeInterval : Time of integration. If the parameter "n" is selected this one does not work
347 347 overlapping :
348 348 """
349 349
350 350 self.__initime = None
351 351 self.__lastdatatime = 0
352 352 self.__buffer = None
353 353 self.__dataReady = False
354 354 self.byblock = byblock
355 355 self.stride = stride
356 356
357 357 if n == None and timeInterval == None:
358 358 raise ValueError, "n or timeInterval should be specified ..."
359 359
360 360 if n != None:
361 361 self.n = n
362 362 self.__byTime = False
363 363 else:
364 364 self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line
365 365 self.n = 9999
366 366 self.__byTime = True
367 367
368 368 if overlapping:
369 369 self.__withOverlapping = True
370 370 self.__buffer = None
371 371 else:
372 372 self.__withOverlapping = False
373 373 self.__buffer = 0
374 374
375 375 self.__profIndex = 0
376 376
377 377 def putData(self, data):
378 378
379 379 """
380 380 Add a profile to the __buffer and increase in one the __profileIndex
381 381
382 382 """
383 383
384 384 if not self.__withOverlapping:
385 385 self.__buffer += data.copy()
386 386 self.__profIndex += 1
387 387 return
388 388
389 389 #Overlapping data
390 390 nChannels, nHeis = data.shape
391 391 data = numpy.reshape(data, (1, nChannels, nHeis))
392 392
393 393 #If the buffer is empty then it takes the data value
394 394 if self.__buffer is None:
395 395 self.__buffer = data
396 396 self.__profIndex += 1
397 397 return
398 398
399 399 #If the buffer length is lower than n then stakcing the data value
400 400 if self.__profIndex < self.n:
401 401 self.__buffer = numpy.vstack((self.__buffer, data))
402 402 self.__profIndex += 1
403 403 return
404 404
405 405 #If the buffer length is equal to n then replacing the last buffer value with the data value
406 406 self.__buffer = numpy.roll(self.__buffer, -1, axis=0)
407 407 self.__buffer[self.n-1] = data
408 408 self.__profIndex = self.n
409 409 return
410 410
411 411
412 412 def pushData(self):
413 413 """
414 414 Return the sum of the last profiles and the profiles used in the sum.
415 415
416 416 Affected:
417 417
418 418 self.__profileIndex
419 419
420 420 """
421 421
422 422 if not self.__withOverlapping:
423 423 data = self.__buffer
424 424 n = self.__profIndex
425 425
426 426 self.__buffer = 0
427 427 self.__profIndex = 0
428 428
429 429 return data, n
430 430
431 431 #Integration with Overlapping
432 432 data = numpy.sum(self.__buffer, axis=0)
433 433 # print data
434 434 # raise
435 435 n = self.__profIndex
436 436
437 437 return data, n
438 438
439 439 def byProfiles(self, data):
440 440
441 441 self.__dataReady = False
442 442 avgdata = None
443 443 # n = None
444 444 # print data
445 445 # raise
446 446 self.putData(data)
447 447
448 448 if self.__profIndex == self.n:
449 449 avgdata, n = self.pushData()
450 450 self.__dataReady = True
451 451
452 452 return avgdata
453 453
454 454 def byTime(self, data, datatime):
455 455
456 456 self.__dataReady = False
457 457 avgdata = None
458 458 n = None
459 459
460 460 self.putData(data)
461 461
462 462 if (datatime - self.__initime) >= self.__integrationtime:
463 463 avgdata, n = self.pushData()
464 464 self.n = n
465 465 self.__dataReady = True
466 466
467 467 return avgdata
468 468
469 469 def integrateByStride(self, data, datatime):
470 470 # print data
471 471 if self.__profIndex == 0:
472 472 self.__buffer = [[data.copy(), datatime]]
473 473 else:
474 self.__buffer.append([data.copy(), datatime])
474 self.__buffer.append([data.copy(),datatime])
475 475 self.__profIndex += 1
476 476 self.__dataReady = False
477 477
478 478 if self.__profIndex == self.n * self.stride :
479 479 self.__dataToPutStride = True
480 480 self.__profIndexStride = 0
481 481 self.__profIndex = 0
482 482 self.__bufferStride = []
483 483 for i in range(self.stride):
484 484 current = self.__buffer[i::self.stride]
485 485 data = numpy.sum([t[0] for t in current], axis=0)
486 486 avgdatatime = numpy.average([t[1] for t in current])
487 487 # print data
488 488 self.__bufferStride.append((data, avgdatatime))
489 489
490 490 if self.__dataToPutStride:
491 self.__dataReady = False
491 self.__dataReady = True
492 492 self.__profIndexStride += 1
493 493 if self.__profIndexStride == self.stride:
494 self.__dataReady = True
495 494 self.__dataToPutStride = False
496 self.__profIndexStride = 0
497 495 # print self.__bufferStride[self.__profIndexStride - 1]
498 496 # raise
499 return (numpy.sum([t[0] for t in self.__bufferStride], axis=0), numpy.average([t[1] for t in self.__bufferStride]))
497 return self.__bufferStride[self.__profIndexStride - 1]
500 498
501 499
502 500 return None, None
503 501
504 502 def integrate(self, data, datatime=None):
505 503
506 504 if self.__initime == None:
507 505 self.__initime = datatime
508 506
509 507 if self.__byTime:
510 508 avgdata = self.byTime(data, datatime)
511 509 else:
512 510 avgdata = self.byProfiles(data)
513 511
514 512
515 513 self.__lastdatatime = datatime
516 514
517 515 if avgdata is None:
518 516 return None, None
519 517
520 518 avgdatatime = self.__initime
521 519
522 520 deltatime = datatime - self.__lastdatatime
523 521
524 522 if not self.__withOverlapping:
525 523 self.__initime = datatime
526 524 else:
527 525 self.__initime += deltatime
528 526
529 527 return avgdata, avgdatatime
530 528
531 529 def integrateByBlock(self, dataOut):
532 530
533 531 times = int(dataOut.data.shape[1]/self.n)
534 532 avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex)
535 533
536 534 id_min = 0
537 535 id_max = self.n
538 536
539 537 for i in range(times):
540 538 junk = dataOut.data[:,id_min:id_max,:]
541 539 avgdata[:,i,:] = junk.sum(axis=1)
542 540 id_min += self.n
543 541 id_max += self.n
544 542
545 543 timeInterval = dataOut.ippSeconds*self.n
546 544 avgdatatime = (times - 1) * timeInterval + dataOut.utctime
547 545 self.__dataReady = True
548 546 return avgdata, avgdatatime
549 547
550 548 def run(self, dataOut, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False, **kwargs):
551 549 if not self.isConfig:
552 550 self.setup(n=n, stride=stride, timeInterval=timeInterval, overlapping=overlapping, byblock=byblock, **kwargs)
553 551 self.isConfig = True
554 552
555 553 if dataOut.flagDataAsBlock:
556 554 """
557 555 Si la data es leida por bloques, dimension = [nChannels, nProfiles, nHeis]
558 556 """
559 557 avgdata, avgdatatime = self.integrateByBlock(dataOut)
560 558 dataOut.nProfiles /= self.n
561 559 else:
562 560 if stride is None:
563 561 avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime)
564 562 else:
565 563 avgdata, avgdatatime = self.integrateByStride(dataOut.data, dataOut.utctime)
566 564
567 565
568 566 # dataOut.timeInterval *= n
569 567 dataOut.flagNoData = True
570 568
571 569 if self.__dataReady:
572 570 dataOut.data = avgdata
573 571 dataOut.nCohInt *= self.n
574 572 dataOut.utctime = avgdatatime
575 573 # print avgdata, avgdatatime
576 574 # raise
577 575 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt
578 576 dataOut.flagNoData = False
579 577
580 578 class Decoder(Operation):
581 579
582 580 isConfig = False
583 581 __profIndex = 0
584 582
585 583 code = None
586 584
587 585 nCode = None
588 586 nBaud = None
589 587
590 588 def __init__(self, **kwargs):
591 589
592 590 Operation.__init__(self, **kwargs)
593 591
594 592 self.times = None
595 593 self.osamp = None
596 594 # self.__setValues = False
597 595 self.isConfig = False
598 596
599 597 def setup(self, code, osamp, dataOut):
600 598
601 599 self.__profIndex = 0
602 600
603 601 self.code = code
604 602
605 603 self.nCode = len(code)
606 604 self.nBaud = len(code[0])
607 605
608 606 if (osamp != None) and (osamp >1):
609 607 self.osamp = osamp
610 608 self.code = numpy.repeat(code, repeats=self.osamp, axis=1)
611 609 self.nBaud = self.nBaud*self.osamp
612 610
613 611 self.__nChannels = dataOut.nChannels
614 612 self.__nProfiles = dataOut.nProfiles
615 613 self.__nHeis = dataOut.nHeights
616 614
617 615 if self.__nHeis < self.nBaud:
618 616 raise ValueError, 'Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
619 617
620 618 #Frequency
621 619 __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex)
622 620
623 621 __codeBuffer[:,0:self.nBaud] = self.code
624 622
625 623 self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1))
626 624
627 625 if dataOut.flagDataAsBlock:
628 626
629 627 self.ndatadec = self.__nHeis #- self.nBaud + 1
630 628
631 629 self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex)
632 630
633 631 else:
634 632
635 633 #Time
636 634 self.ndatadec = self.__nHeis #- self.nBaud + 1
637 635
638 636 self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex)
639 637
640 638 def __convolutionInFreq(self, data):
641 639
642 640 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
643 641
644 642 fft_data = numpy.fft.fft(data, axis=1)
645 643
646 644 conv = fft_data*fft_code
647 645
648 646 data = numpy.fft.ifft(conv,axis=1)
649 647
650 648 return data
651 649
652 650 def __convolutionInFreqOpt(self, data):
653 651
654 652 raise NotImplementedError
655 653
656 654 def __convolutionInTime(self, data):
657 655
658 656 code = self.code[self.__profIndex]
659 657 for i in range(self.__nChannels):
660 658 self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='full')[self.nBaud-1:]
661 659
662 660 return self.datadecTime
663 661
664 662 def __convolutionByBlockInTime(self, data):
665 663
666 664 repetitions = self.__nProfiles / self.nCode
667 665
668 666 junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize))
669 667 junk = junk.flatten()
670 668 code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud))
671 669 profilesList = xrange(self.__nProfiles)
672 670
673 671 for i in range(self.__nChannels):
674 672 for j in profilesList:
675 673 self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:]
676 674 return self.datadecTime
677 675
678 676 def __convolutionByBlockInFreq(self, data):
679 677
680 678 raise NotImplementedError, "Decoder by frequency fro Blocks not implemented"
681 679
682 680
683 681 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
684 682
685 683 fft_data = numpy.fft.fft(data, axis=2)
686 684
687 685 conv = fft_data*fft_code
688 686
689 687 data = numpy.fft.ifft(conv,axis=2)
690 688
691 689 return data
692 690
693 691
694 692 def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None):
695 693
696 694 if dataOut.flagDecodeData:
697 695 print "This data is already decoded, recoding again ..."
698 696
699 697 if not self.isConfig:
700 698
701 699 if code is None:
702 700 if dataOut.code is None:
703 701 raise ValueError, "Code could not be read from %s instance. Enter a value in Code parameter" %dataOut.type
704 702
705 703 code = dataOut.code
706 704 else:
707 705 code = numpy.array(code).reshape(nCode,nBaud)
708 706 self.setup(code, osamp, dataOut)
709 707
710 708 self.isConfig = True
711 709
712 710 if mode == 3:
713 711 sys.stderr.write("Decoder Warning: mode=%d is not valid, using mode=0\n" %mode)
714 712
715 713 if times != None:
716 714 sys.stderr.write("Decoder Warning: Argument 'times' in not used anymore\n")
717 715
718 716 if self.code is None:
719 717 print "Fail decoding: Code is not defined."
720 718 return
721 719
722 720 self.__nProfiles = dataOut.nProfiles
723 721 datadec = None
724 722
725 723 if mode == 3:
726 724 mode = 0
727 725
728 726 if dataOut.flagDataAsBlock:
729 727 """
730 728 Decoding when data have been read as block,
731 729 """
732 730
733 731 if mode == 0:
734 732 datadec = self.__convolutionByBlockInTime(dataOut.data)
735 733 if mode == 1:
736 734 datadec = self.__convolutionByBlockInFreq(dataOut.data)
737 735 else:
738 736 """
739 737 Decoding when data have been read profile by profile
740 738 """
741 739 if mode == 0:
742 740 datadec = self.__convolutionInTime(dataOut.data)
743 741
744 742 if mode == 1:
745 743 datadec = self.__convolutionInFreq(dataOut.data)
746 744
747 745 if mode == 2:
748 746 datadec = self.__convolutionInFreqOpt(dataOut.data)
749 747
750 748 if datadec is None:
751 749 raise ValueError, "Codification mode selected is not valid: mode=%d. Try selecting 0 or 1" %mode
752 750
753 751 dataOut.code = self.code
754 752 dataOut.nCode = self.nCode
755 753 dataOut.nBaud = self.nBaud
756 754
757 755 dataOut.data = datadec
758 756
759 757 dataOut.heightList = dataOut.heightList[0:datadec.shape[-1]]
760 758
761 759 dataOut.flagDecodeData = True #asumo q la data esta decodificada
762 760
763 761 if self.__profIndex == self.nCode-1:
764 762 self.__profIndex = 0
765 763 return 1
766 764
767 765 self.__profIndex += 1
768 766
769 767 return 1
770 768 # dataOut.flagDeflipData = True #asumo q la data no esta sin flip
771 769
772 770
773 771 class ProfileConcat(Operation):
774 772
775 773 isConfig = False
776 774 buffer = None
777 775
778 776 def __init__(self, **kwargs):
779 777
780 778 Operation.__init__(self, **kwargs)
781 779 self.profileIndex = 0
782 780
783 781 def reset(self):
784 782 self.buffer = numpy.zeros_like(self.buffer)
785 783 self.start_index = 0
786 784 self.times = 1
787 785
788 786 def setup(self, data, m, n=1):
789 787 self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0]))
790 788 self.nHeights = data.shape[1]#.nHeights
791 789 self.start_index = 0
792 790 self.times = 1
793 791
794 792 def concat(self, data):
795 793
796 794 self.buffer[:,self.start_index:self.nHeights*self.times] = data.copy()
797 795 self.start_index = self.start_index + self.nHeights
798 796
799 797 def run(self, dataOut, m):
800 798
801 799 dataOut.flagNoData = True
802 800
803 801 if not self.isConfig:
804 802 self.setup(dataOut.data, m, 1)
805 803 self.isConfig = True
806 804
807 805 if dataOut.flagDataAsBlock:
808 806 raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False"
809 807
810 808 else:
811 809 self.concat(dataOut.data)
812 810 self.times += 1
813 811 if self.times > m:
814 812 dataOut.data = self.buffer
815 813 self.reset()
816 814 dataOut.flagNoData = False
817 815 # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas
818 816 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
819 817 xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m
820 818 dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight)
821 819 dataOut.ippSeconds *= m
822 820
823 821 class ProfileSelector(Operation):
824 822
825 823 profileIndex = None
826 824 # Tamanho total de los perfiles
827 825 nProfiles = None
828 826
829 827 def __init__(self, **kwargs):
830 828
831 829 Operation.__init__(self, **kwargs)
832 830 self.profileIndex = 0
833 831
834 832 def incProfileIndex(self):
835 833
836 834 self.profileIndex += 1
837 835
838 836 if self.profileIndex >= self.nProfiles:
839 837 self.profileIndex = 0
840 838
841 839 def isThisProfileInRange(self, profileIndex, minIndex, maxIndex):
842 840
843 841 if profileIndex < minIndex:
844 842 return False
845 843
846 844 if profileIndex > maxIndex:
847 845 return False
848 846
849 847 return True
850 848
851 849 def isThisProfileInList(self, profileIndex, profileList):
852 850
853 851 if profileIndex not in profileList:
854 852 return False
855 853
856 854 return True
857 855
858 856 def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None, nProfiles=None):
859 857
860 858 """
861 859 ProfileSelector:
862 860
863 861 Inputs:
864 862 profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8)
865 863
866 864 profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30)
867 865
868 866 rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256))
869 867
870 868 """
871 869
872 870 if rangeList is not None:
873 871 if type(rangeList[0]) not in (tuple, list):
874 872 rangeList = [rangeList]
875 873
876 874 dataOut.flagNoData = True
877 875
878 876 if dataOut.flagDataAsBlock:
879 877 """
880 878 data dimension = [nChannels, nProfiles, nHeis]
881 879 """
882 880 if profileList != None:
883 881 dataOut.data = dataOut.data[:,profileList,:]
884 882
885 883 if profileRangeList != None:
886 884 minIndex = profileRangeList[0]
887 885 maxIndex = profileRangeList[1]
888 886 profileList = range(minIndex, maxIndex+1)
889 887
890 888 dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:]
891 889
892 890 if rangeList != None:
893 891
894 892 profileList = []
895 893
896 894 for thisRange in rangeList:
897 895 minIndex = thisRange[0]
898 896 maxIndex = thisRange[1]
899 897
900 898 profileList.extend(range(minIndex, maxIndex+1))
901 899
902 900 dataOut.data = dataOut.data[:,profileList,:]
903 901
904 902 dataOut.nProfiles = len(profileList)
905 903 dataOut.profileIndex = dataOut.nProfiles - 1
906 904 dataOut.flagNoData = False
907 905
908 906 return True
909 907
910 908 """
911 909 data dimension = [nChannels, nHeis]
912 910 """
913 911
914 912 if profileList != None:
915 913
916 914 if self.isThisProfileInList(dataOut.profileIndex, profileList):
917 915
918 916 self.nProfiles = len(profileList)
919 917 dataOut.nProfiles = self.nProfiles
920 918 dataOut.profileIndex = self.profileIndex
921 919 dataOut.flagNoData = False
922 920
923 921 self.incProfileIndex()
924 922 return True
925 923
926 924 if profileRangeList != None:
927 925
928 926 minIndex = profileRangeList[0]
929 927 maxIndex = profileRangeList[1]
930 928
931 929 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
932 930
933 931 self.nProfiles = maxIndex - minIndex + 1
934 932 dataOut.nProfiles = self.nProfiles
935 933 dataOut.profileIndex = self.profileIndex
936 934 dataOut.flagNoData = False
937 935
938 936 self.incProfileIndex()
939 937 return True
940 938
941 939 if rangeList != None:
942 940
943 941 nProfiles = 0
944 942
945 943 for thisRange in rangeList:
946 944 minIndex = thisRange[0]
947 945 maxIndex = thisRange[1]
948 946
949 947 nProfiles += maxIndex - minIndex + 1
950 948
951 949 for thisRange in rangeList:
952 950
953 951 minIndex = thisRange[0]
954 952 maxIndex = thisRange[1]
955 953
956 954 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
957 955
958 956 self.nProfiles = nProfiles
959 957 dataOut.nProfiles = self.nProfiles
960 958 dataOut.profileIndex = self.profileIndex
961 959 dataOut.flagNoData = False
962 960
963 961 self.incProfileIndex()
964 962
965 963 break
966 964
967 965 return True
968 966
969 967
970 968 if beam != None: #beam is only for AMISR data
971 969 if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]):
972 970 dataOut.flagNoData = False
973 971 dataOut.profileIndex = self.profileIndex
974 972
975 973 self.incProfileIndex()
976 974
977 975 return True
978 976
979 977 raise ValueError, "ProfileSelector needs profileList, profileRangeList or rangeList parameter"
980 978
981 979 return False
982 980
983 981 class Reshaper(Operation):
984 982
985 983 def __init__(self, **kwargs):
986 984
987 985 Operation.__init__(self, **kwargs)
988 986
989 987 self.__buffer = None
990 988 self.__nitems = 0
991 989
992 990 def __appendProfile(self, dataOut, nTxs):
993 991
994 992 if self.__buffer is None:
995 993 shape = (dataOut.nChannels, int(dataOut.nHeights/nTxs) )
996 994 self.__buffer = numpy.empty(shape, dtype = dataOut.data.dtype)
997 995
998 996 ini = dataOut.nHeights * self.__nitems
999 997 end = ini + dataOut.nHeights
1000 998
1001 999 self.__buffer[:, ini:end] = dataOut.data
1002 1000
1003 1001 self.__nitems += 1
1004 1002
1005 1003 return int(self.__nitems*nTxs)
1006 1004
1007 1005 def __getBuffer(self):
1008 1006
1009 1007 if self.__nitems == int(1./self.__nTxs):
1010 1008
1011 1009 self.__nitems = 0
1012 1010
1013 1011 return self.__buffer.copy()
1014 1012
1015 1013 return None
1016 1014
1017 1015 def __checkInputs(self, dataOut, shape, nTxs):
1018 1016
1019 1017 if shape is None and nTxs is None:
1020 1018 raise ValueError, "Reshaper: shape of factor should be defined"
1021 1019
1022 1020 if nTxs:
1023 1021 if nTxs < 0:
1024 1022 raise ValueError, "nTxs should be greater than 0"
1025 1023
1026 1024 if nTxs < 1 and dataOut.nProfiles % (1./nTxs) != 0:
1027 1025 raise ValueError, "nProfiles= %d is not divisibled by (1./nTxs) = %f" %(dataOut.nProfiles, (1./nTxs))
1028 1026
1029 1027 shape = [dataOut.nChannels, dataOut.nProfiles*nTxs, dataOut.nHeights/nTxs]
1030 1028
1031 1029 return shape, nTxs
1032 1030
1033 1031 if len(shape) != 2 and len(shape) != 3:
1034 1032 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)
1035 1033
1036 1034 if len(shape) == 2:
1037 1035 shape_tuple = [dataOut.nChannels]
1038 1036 shape_tuple.extend(shape)
1039 1037 else:
1040 1038 shape_tuple = list(shape)
1041 1039
1042 1040 nTxs = 1.0*shape_tuple[1]/dataOut.nProfiles
1043 1041
1044 1042 return shape_tuple, nTxs
1045 1043
1046 1044 def run(self, dataOut, shape=None, nTxs=None):
1047 1045
1048 1046 shape_tuple, self.__nTxs = self.__checkInputs(dataOut, shape, nTxs)
1049 1047
1050 1048 dataOut.flagNoData = True
1051 1049 profileIndex = None
1052 1050
1053 1051 if dataOut.flagDataAsBlock:
1054 1052
1055 1053 dataOut.data = numpy.reshape(dataOut.data, shape_tuple)
1056 1054 dataOut.flagNoData = False
1057 1055
1058 1056 profileIndex = int(dataOut.nProfiles*self.__nTxs) - 1
1059 1057
1060 1058 else:
1061 1059
1062 1060 if self.__nTxs < 1:
1063 1061
1064 1062 self.__appendProfile(dataOut, self.__nTxs)
1065 1063 new_data = self.__getBuffer()
1066 1064
1067 1065 if new_data is not None:
1068 1066 dataOut.data = new_data
1069 1067 dataOut.flagNoData = False
1070 1068
1071 1069 profileIndex = dataOut.profileIndex*nTxs
1072 1070
1073 1071 else:
1074 1072 raise ValueError, "nTxs should be greater than 0 and lower than 1, or use VoltageReader(..., getblock=True)"
1075 1073
1076 1074 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1077 1075
1078 1076 dataOut.heightList = numpy.arange(dataOut.nHeights/self.__nTxs) * deltaHeight + dataOut.heightList[0]
1079 1077
1080 1078 dataOut.nProfiles = int(dataOut.nProfiles*self.__nTxs)
1081 1079
1082 1080 dataOut.profileIndex = profileIndex
1083 1081
1084 1082 dataOut.ippSeconds /= self.__nTxs
1085 1083
1086 1084 class SplitProfiles(Operation):
1087 1085
1088 1086 def __init__(self, **kwargs):
1089 1087
1090 1088 Operation.__init__(self, **kwargs)
1091 1089
1092 1090 def run(self, dataOut, n):
1093 1091
1094 1092 dataOut.flagNoData = True
1095 1093 profileIndex = None
1096 1094
1097 1095 if dataOut.flagDataAsBlock:
1098 1096
1099 1097 #nchannels, nprofiles, nsamples
1100 1098 shape = dataOut.data.shape
1101 1099
1102 1100 if shape[2] % n != 0:
1103 1101 raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[2])
1104 1102
1105 1103 new_shape = shape[0], shape[1]*n, shape[2]/n
1106 1104
1107 1105 dataOut.data = numpy.reshape(dataOut.data, new_shape)
1108 1106 dataOut.flagNoData = False
1109 1107
1110 1108 profileIndex = int(dataOut.nProfiles/n) - 1
1111 1109
1112 1110 else:
1113 1111
1114 1112 raise ValueError, "Could not split the data when is read Profile by Profile. Use VoltageReader(..., getblock=True)"
1115 1113
1116 1114 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1117 1115
1118 1116 dataOut.heightList = numpy.arange(dataOut.nHeights/n) * deltaHeight + dataOut.heightList[0]
1119 1117
1120 1118 dataOut.nProfiles = int(dataOut.nProfiles*n)
1121 1119
1122 1120 dataOut.profileIndex = profileIndex
1123 1121
1124 1122 dataOut.ippSeconds /= n
1125 1123
1126 1124 class CombineProfiles(Operation):
1127 1125 def __init__(self, **kwargs):
1128 1126
1129 1127 Operation.__init__(self, **kwargs)
1130 1128
1131 1129 self.__remData = None
1132 1130 self.__profileIndex = 0
1133 1131
1134 1132 def run(self, dataOut, n):
1135 1133
1136 1134 dataOut.flagNoData = True
1137 1135 profileIndex = None
1138 1136
1139 1137 if dataOut.flagDataAsBlock:
1140 1138
1141 1139 #nchannels, nprofiles, nsamples
1142 1140 shape = dataOut.data.shape
1143 1141 new_shape = shape[0], shape[1]/n, shape[2]*n
1144 1142
1145 1143 if shape[1] % n != 0:
1146 1144 raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[1])
1147 1145
1148 1146 dataOut.data = numpy.reshape(dataOut.data, new_shape)
1149 1147 dataOut.flagNoData = False
1150 1148
1151 1149 profileIndex = int(dataOut.nProfiles*n) - 1
1152 1150
1153 1151 else:
1154 1152
1155 1153 #nchannels, nsamples
1156 1154 if self.__remData is None:
1157 1155 newData = dataOut.data
1158 1156 else:
1159 1157 newData = numpy.concatenate((self.__remData, dataOut.data), axis=1)
1160 1158
1161 1159 self.__profileIndex += 1
1162 1160
1163 1161 if self.__profileIndex < n:
1164 1162 self.__remData = newData
1165 1163 #continue
1166 1164 return
1167 1165
1168 1166 self.__profileIndex = 0
1169 1167 self.__remData = None
1170 1168
1171 1169 dataOut.data = newData
1172 1170 dataOut.flagNoData = False
1173 1171
1174 1172 profileIndex = dataOut.profileIndex/n
1175 1173
1176 1174
1177 1175 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1178 1176
1179 1177 dataOut.heightList = numpy.arange(dataOut.nHeights*n) * deltaHeight + dataOut.heightList[0]
1180 1178
1181 1179 dataOut.nProfiles = int(dataOut.nProfiles/n)
1182 1180
1183 1181 dataOut.profileIndex = profileIndex
1184 1182
1185 1183 dataOut.ippSeconds *= n
1186 1184
1187 1185 # import collections
1188 1186 # from scipy.stats import mode
1189 1187 #
1190 1188 # class Synchronize(Operation):
1191 1189 #
1192 1190 # isConfig = False
1193 1191 # __profIndex = 0
1194 1192 #
1195 1193 # def __init__(self, **kwargs):
1196 1194 #
1197 1195 # Operation.__init__(self, **kwargs)
1198 1196 # # self.isConfig = False
1199 1197 # self.__powBuffer = None
1200 1198 # self.__startIndex = 0
1201 1199 # self.__pulseFound = False
1202 1200 #
1203 1201 # def __findTxPulse(self, dataOut, channel=0, pulse_with = None):
1204 1202 #
1205 1203 # #Read data
1206 1204 #
1207 1205 # powerdB = dataOut.getPower(channel = channel)
1208 1206 # noisedB = dataOut.getNoise(channel = channel)[0]
1209 1207 #
1210 1208 # self.__powBuffer.extend(powerdB.flatten())
1211 1209 #
1212 1210 # dataArray = numpy.array(self.__powBuffer)
1213 1211 #
1214 1212 # filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same")
1215 1213 #
1216 1214 # maxValue = numpy.nanmax(filteredPower)
1217 1215 #
1218 1216 # if maxValue < noisedB + 10:
1219 1217 # #No se encuentra ningun pulso de transmision
1220 1218 # return None
1221 1219 #
1222 1220 # maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0]
1223 1221 #
1224 1222 # if len(maxValuesIndex) < 2:
1225 1223 # #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX
1226 1224 # return None
1227 1225 #
1228 1226 # phasedMaxValuesIndex = maxValuesIndex - self.__nSamples
1229 1227 #
1230 1228 # #Seleccionar solo valores con un espaciamiento de nSamples
1231 1229 # pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex)
1232 1230 #
1233 1231 # if len(pulseIndex) < 2:
1234 1232 # #Solo se encontro un pulso de transmision con ancho mayor a 1
1235 1233 # return None
1236 1234 #
1237 1235 # spacing = pulseIndex[1:] - pulseIndex[:-1]
1238 1236 #
1239 1237 # #remover senales que se distancien menos de 10 unidades o muestras
1240 1238 # #(No deberian existir IPP menor a 10 unidades)
1241 1239 #
1242 1240 # realIndex = numpy.where(spacing > 10 )[0]
1243 1241 #
1244 1242 # if len(realIndex) < 2:
1245 1243 # #Solo se encontro un pulso de transmision con ancho mayor a 1
1246 1244 # return None
1247 1245 #
1248 1246 # #Eliminar pulsos anchos (deja solo la diferencia entre IPPs)
1249 1247 # realPulseIndex = pulseIndex[realIndex]
1250 1248 #
1251 1249 # period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0]
1252 1250 #
1253 1251 # print "IPP = %d samples" %period
1254 1252 #
1255 1253 # self.__newNSamples = dataOut.nHeights #int(period)
1256 1254 # self.__startIndex = int(realPulseIndex[0])
1257 1255 #
1258 1256 # return 1
1259 1257 #
1260 1258 #
1261 1259 # def setup(self, nSamples, nChannels, buffer_size = 4):
1262 1260 #
1263 1261 # self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float),
1264 1262 # maxlen = buffer_size*nSamples)
1265 1263 #
1266 1264 # bufferList = []
1267 1265 #
1268 1266 # for i in range(nChannels):
1269 1267 # bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN,
1270 1268 # maxlen = buffer_size*nSamples)
1271 1269 #
1272 1270 # bufferList.append(bufferByChannel)
1273 1271 #
1274 1272 # self.__nSamples = nSamples
1275 1273 # self.__nChannels = nChannels
1276 1274 # self.__bufferList = bufferList
1277 1275 #
1278 1276 # def run(self, dataOut, channel = 0):
1279 1277 #
1280 1278 # if not self.isConfig:
1281 1279 # nSamples = dataOut.nHeights
1282 1280 # nChannels = dataOut.nChannels
1283 1281 # self.setup(nSamples, nChannels)
1284 1282 # self.isConfig = True
1285 1283 #
1286 1284 # #Append new data to internal buffer
1287 1285 # for thisChannel in range(self.__nChannels):
1288 1286 # bufferByChannel = self.__bufferList[thisChannel]
1289 1287 # bufferByChannel.extend(dataOut.data[thisChannel])
1290 1288 #
1291 1289 # if self.__pulseFound:
1292 1290 # self.__startIndex -= self.__nSamples
1293 1291 #
1294 1292 # #Finding Tx Pulse
1295 1293 # if not self.__pulseFound:
1296 1294 # indexFound = self.__findTxPulse(dataOut, channel)
1297 1295 #
1298 1296 # if indexFound == None:
1299 1297 # dataOut.flagNoData = True
1300 1298 # return
1301 1299 #
1302 1300 # self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex)
1303 1301 # self.__pulseFound = True
1304 1302 # self.__startIndex = indexFound
1305 1303 #
1306 1304 # #If pulse was found ...
1307 1305 # for thisChannel in range(self.__nChannels):
1308 1306 # bufferByChannel = self.__bufferList[thisChannel]
1309 1307 # #print self.__startIndex
1310 1308 # x = numpy.array(bufferByChannel)
1311 1309 # self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples]
1312 1310 #
1313 1311 # deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1314 1312 # dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight
1315 1313 # # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6
1316 1314 #
1317 1315 # dataOut.data = self.__arrayBuffer
1318 1316 #
1319 1317 # self.__startIndex += self.__newNSamples
1320 1318 #
1321 1319 # return
General Comments 0
You need to be logged in to leave comments. Login now