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