##// END OF EJS Templates
Bug fixed in Reshaper: factor variable should be a real value
Miguel Valdez -
r522:b46cf7c20599
parent child
Show More
@@ -1,758 +1,762
1 1 import numpy
2 2
3 3 from jroproc_base import ProcessingUnit, Operation
4 4 from model.data.jrodata import Voltage
5 5
6 6 class VoltageProc(ProcessingUnit):
7 7
8 8
9 9 def __init__(self):
10 10
11 11 ProcessingUnit.__init__(self)
12 12
13 13 # self.objectDict = {}
14 14 self.dataOut = Voltage()
15 15 self.flip = 1
16 16
17 17 def run(self):
18 18 if self.dataIn.type == 'AMISR':
19 19 self.__updateObjFromAmisrInput()
20 20
21 21 if self.dataIn.type == 'Voltage':
22 22 self.dataOut.copy(self.dataIn)
23 23
24 24 # self.dataOut.copy(self.dataIn)
25 25
26 26 def __updateObjFromAmisrInput(self):
27 27
28 28 self.dataOut.timeZone = self.dataIn.timeZone
29 29 self.dataOut.dstFlag = self.dataIn.dstFlag
30 30 self.dataOut.errorCount = self.dataIn.errorCount
31 31 self.dataOut.useLocalTime = self.dataIn.useLocalTime
32 32
33 33 self.dataOut.flagNoData = self.dataIn.flagNoData
34 34 self.dataOut.data = self.dataIn.data
35 35 self.dataOut.utctime = self.dataIn.utctime
36 36 self.dataOut.channelList = self.dataIn.channelList
37 37 self.dataOut.timeInterval = self.dataIn.timeInterval
38 38 self.dataOut.heightList = self.dataIn.heightList
39 39 self.dataOut.nProfiles = self.dataIn.nProfiles
40 40
41 41 self.dataOut.nCohInt = self.dataIn.nCohInt
42 42 self.dataOut.ippSeconds = self.dataIn.ippSeconds
43 43 self.dataOut.frequency = self.dataIn.frequency
44 44
45 45 self.dataOut.azimuth = self.dataIn.azimuth
46 46 self.dataOut.zenith = self.dataIn.zenith
47 47
48 48 self.dataOut.beam.codeList = self.dataIn.beam.codeList
49 49 self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList
50 50 self.dataOut.beam.zenithList = self.dataIn.beam.zenithList
51 51 #
52 52 # pass#
53 53 #
54 54 # def init(self):
55 55 #
56 56 #
57 57 # if self.dataIn.type == 'AMISR':
58 58 # self.__updateObjFromAmisrInput()
59 59 #
60 60 # if self.dataIn.type == 'Voltage':
61 61 # self.dataOut.copy(self.dataIn)
62 62 # # No necesita copiar en cada init() los atributos de dataIn
63 63 # # la copia deberia hacerse por cada nuevo bloque de datos
64 64
65 65 def selectChannels(self, channelList):
66 66
67 67 channelIndexList = []
68 68
69 69 for channel in channelList:
70 70 index = self.dataOut.channelList.index(channel)
71 71 channelIndexList.append(index)
72 72
73 73 self.selectChannelsByIndex(channelIndexList)
74 74
75 75 def selectChannelsByIndex(self, channelIndexList):
76 76 """
77 77 Selecciona un bloque de datos en base a canales segun el channelIndexList
78 78
79 79 Input:
80 80 channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7]
81 81
82 82 Affected:
83 83 self.dataOut.data
84 84 self.dataOut.channelIndexList
85 85 self.dataOut.nChannels
86 86 self.dataOut.m_ProcessingHeader.totalSpectra
87 87 self.dataOut.systemHeaderObj.numChannels
88 88 self.dataOut.m_ProcessingHeader.blockSize
89 89
90 90 Return:
91 91 None
92 92 """
93 93
94 94 for channelIndex in channelIndexList:
95 95 if channelIndex not in self.dataOut.channelIndexList:
96 96 print channelIndexList
97 97 raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex
98 98
99 99 # nChannels = len(channelIndexList)
100 100
101 101 data = self.dataOut.data[channelIndexList,:]
102 102
103 103 self.dataOut.data = data
104 104 self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList]
105 105 # self.dataOut.nChannels = nChannels
106 106
107 107 return 1
108 108
109 109 def selectHeights(self, minHei=None, maxHei=None):
110 110 """
111 111 Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango
112 112 minHei <= height <= maxHei
113 113
114 114 Input:
115 115 minHei : valor minimo de altura a considerar
116 116 maxHei : valor maximo de altura a considerar
117 117
118 118 Affected:
119 119 Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex
120 120
121 121 Return:
122 122 1 si el metodo se ejecuto con exito caso contrario devuelve 0
123 123 """
124 124
125 125 if minHei == None:
126 126 minHei = self.dataOut.heightList[0]
127 127
128 128 if maxHei == None:
129 129 maxHei = self.dataOut.heightList[-1]
130 130
131 131 if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei):
132 132 raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
133 133
134 134
135 135 if (maxHei > self.dataOut.heightList[-1]):
136 136 maxHei = self.dataOut.heightList[-1]
137 137 # raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
138 138
139 139 minIndex = 0
140 140 maxIndex = 0
141 141 heights = self.dataOut.heightList
142 142
143 143 inda = numpy.where(heights >= minHei)
144 144 indb = numpy.where(heights <= maxHei)
145 145
146 146 try:
147 147 minIndex = inda[0][0]
148 148 except:
149 149 minIndex = 0
150 150
151 151 try:
152 152 maxIndex = indb[0][-1]
153 153 except:
154 154 maxIndex = len(heights)
155 155
156 156 self.selectHeightsByIndex(minIndex, maxIndex)
157 157
158 158 return 1
159 159
160 160
161 161 def selectHeightsByIndex(self, minIndex, maxIndex):
162 162 """
163 163 Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango
164 164 minIndex <= index <= maxIndex
165 165
166 166 Input:
167 167 minIndex : valor de indice minimo de altura a considerar
168 168 maxIndex : valor de indice maximo de altura a considerar
169 169
170 170 Affected:
171 171 self.dataOut.data
172 172 self.dataOut.heightList
173 173
174 174 Return:
175 175 1 si el metodo se ejecuto con exito caso contrario devuelve 0
176 176 """
177 177
178 178 if (minIndex < 0) or (minIndex > maxIndex):
179 179 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
180 180
181 181 if (maxIndex >= self.dataOut.nHeights):
182 182 maxIndex = self.dataOut.nHeights-1
183 183 # raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
184 184
185 185 # nHeights = maxIndex - minIndex + 1
186 186
187 187 #voltage
188 188 data = self.dataOut.data[:,minIndex:maxIndex+1]
189 189
190 190 # firstHeight = self.dataOut.heightList[minIndex]
191 191
192 192 self.dataOut.data = data
193 193 self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex+1]
194 194
195 195 return 1
196 196
197 197
198 198 def filterByHeights(self, window, axis=1):
199 199 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
200 200
201 201 if window == None:
202 202 window = (self.dataOut.radarControllerHeaderObj.txA/self.dataOut.radarControllerHeaderObj.nBaud) / deltaHeight
203 203
204 204 newdelta = deltaHeight * window
205 205 r = self.dataOut.data.shape[axis] % window
206 206 if axis == 1:
207 207 buffer = self.dataOut.data[:,0:self.dataOut.data.shape[axis]-r]
208 208 buffer = buffer.reshape(self.dataOut.data.shape[0],self.dataOut.data.shape[axis]/window,window)
209 209 buffer = numpy.sum(buffer,axis+1)
210 210
211 211 elif axis == 2:
212 212 buffer = self.dataOut.data[:, :, 0:self.dataOut.data.shape[axis]-r]
213 213 buffer = buffer.reshape(self.dataOut.data.shape[0],self.dataOut.data.shape[1],self.dataOut.data.shape[axis]/window,window)
214 214 buffer = numpy.sum(buffer,axis+1)
215 215
216 216 else:
217 217 raise ValueError, "axis value should be 1 or 2, the input value %d is not valid" % (axis)
218 218
219 219 self.dataOut.data = buffer.copy()
220 220 self.dataOut.heightList = numpy.arange(self.dataOut.heightList[0],newdelta*(self.dataOut.nHeights-r)/window,newdelta)
221 221 self.dataOut.windowOfFilter = window
222 222
223 223 return 1
224 224
225 225 def deFlip(self):
226 226 self.dataOut.data *= self.flip
227 227 self.flip *= -1.
228 228
229 229 def setRadarFrequency(self, frequency=None):
230 230 if frequency != None:
231 231 self.dataOut.frequency = frequency
232 232
233 233 return 1
234 234
235 235 class CohInt(Operation):
236 236
237 237 isConfig = False
238 238
239 239 __profIndex = 0
240 240 __withOverapping = False
241 241
242 242 __byTime = False
243 243 __initime = None
244 244 __lastdatatime = None
245 245 __integrationtime = None
246 246
247 247 __buffer = None
248 248
249 249 __dataReady = False
250 250
251 251 n = None
252 252
253 253
254 254 def __init__(self):
255 255
256 256 Operation.__init__(self)
257 257
258 258 # self.isConfig = False
259 259
260 260 def setup(self, n=None, timeInterval=None, overlapping=False, byblock=False):
261 261 """
262 262 Set the parameters of the integration class.
263 263
264 264 Inputs:
265 265
266 266 n : Number of coherent integrations
267 267 timeInterval : Time of integration. If the parameter "n" is selected this one does not work
268 268 overlapping :
269 269
270 270 """
271 271
272 272 self.__initime = None
273 273 self.__lastdatatime = 0
274 274 self.__buffer = None
275 275 self.__dataReady = False
276 276 self.byblock = byblock
277 277
278 278 if n == None and timeInterval == None:
279 279 raise ValueError, "n or timeInterval should be specified ..."
280 280
281 281 if n != None:
282 282 self.n = n
283 283 self.__byTime = False
284 284 else:
285 285 self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line
286 286 self.n = 9999
287 287 self.__byTime = True
288 288
289 289 if overlapping:
290 290 self.__withOverapping = True
291 291 self.__buffer = None
292 292 else:
293 293 self.__withOverapping = False
294 294 self.__buffer = 0
295 295
296 296 self.__profIndex = 0
297 297
298 298 def putData(self, data):
299 299
300 300 """
301 301 Add a profile to the __buffer and increase in one the __profileIndex
302 302
303 303 """
304 304
305 305 if not self.__withOverapping:
306 306 self.__buffer += data.copy()
307 307 self.__profIndex += 1
308 308 return
309 309
310 310 #Overlapping data
311 311 nChannels, nHeis = data.shape
312 312 data = numpy.reshape(data, (1, nChannels, nHeis))
313 313
314 314 #If the buffer is empty then it takes the data value
315 315 if self.__buffer == None:
316 316 self.__buffer = data
317 317 self.__profIndex += 1
318 318 return
319 319
320 320 #If the buffer length is lower than n then stakcing the data value
321 321 if self.__profIndex < self.n:
322 322 self.__buffer = numpy.vstack((self.__buffer, data))
323 323 self.__profIndex += 1
324 324 return
325 325
326 326 #If the buffer length is equal to n then replacing the last buffer value with the data value
327 327 self.__buffer = numpy.roll(self.__buffer, -1, axis=0)
328 328 self.__buffer[self.n-1] = data
329 329 self.__profIndex = self.n
330 330 return
331 331
332 332
333 333 def pushData(self):
334 334 """
335 335 Return the sum of the last profiles and the profiles used in the sum.
336 336
337 337 Affected:
338 338
339 339 self.__profileIndex
340 340
341 341 """
342 342
343 343 if not self.__withOverapping:
344 344 data = self.__buffer
345 345 n = self.__profIndex
346 346
347 347 self.__buffer = 0
348 348 self.__profIndex = 0
349 349
350 350 return data, n
351 351
352 352 #Integration with Overlapping
353 353 data = numpy.sum(self.__buffer, axis=0)
354 354 n = self.__profIndex
355 355
356 356 return data, n
357 357
358 358 def byProfiles(self, data):
359 359
360 360 self.__dataReady = False
361 361 avgdata = None
362 362 # n = None
363 363
364 364 self.putData(data)
365 365
366 366 if self.__profIndex == self.n:
367 367
368 368 avgdata, n = self.pushData()
369 369 self.__dataReady = True
370 370
371 371 return avgdata
372 372
373 373 def byTime(self, data, datatime):
374 374
375 375 self.__dataReady = False
376 376 avgdata = None
377 377 n = None
378 378
379 379 self.putData(data)
380 380
381 381 if (datatime - self.__initime) >= self.__integrationtime:
382 382 avgdata, n = self.pushData()
383 383 self.n = n
384 384 self.__dataReady = True
385 385
386 386 return avgdata
387 387
388 388 def integrate(self, data, datatime=None):
389 389
390 390 if self.__initime == None:
391 391 self.__initime = datatime
392 392
393 393 if self.__byTime:
394 394 avgdata = self.byTime(data, datatime)
395 395 else:
396 396 avgdata = self.byProfiles(data)
397 397
398 398
399 399 self.__lastdatatime = datatime
400 400
401 401 if avgdata == None:
402 402 return None, None
403 403
404 404 avgdatatime = self.__initime
405 405
406 406 deltatime = datatime -self.__lastdatatime
407 407
408 408 if not self.__withOverapping:
409 409 self.__initime = datatime
410 410 else:
411 411 self.__initime += deltatime
412 412
413 413 return avgdata, avgdatatime
414 414
415 415 def integrateByBlock(self, dataOut):
416 416 times = int(dataOut.data.shape[1]/self.n)
417 417 avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex)
418 418
419 419 id_min = 0
420 420 id_max = self.n
421 421
422 422 for i in range(times):
423 423 junk = dataOut.data[:,id_min:id_max,:]
424 424 avgdata[:,i,:] = junk.sum(axis=1)
425 425 id_min += self.n
426 426 id_max += self.n
427 427
428 428 timeInterval = dataOut.ippSeconds*self.n
429 429 avgdatatime = (times - 1) * timeInterval + dataOut.utctime
430 430 self.__dataReady = True
431 431 return avgdata, avgdatatime
432 432
433 433 def run(self, dataOut, **kwargs):
434 434
435 435 if not self.isConfig:
436 436 self.setup(**kwargs)
437 437 self.isConfig = True
438 438
439 439 if self.byblock:
440 440 avgdata, avgdatatime = self.integrateByBlock(dataOut)
441 441 else:
442 442 avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime)
443 443
444 444 # dataOut.timeInterval *= n
445 445 dataOut.flagNoData = True
446 446
447 447 if self.__dataReady:
448 448 dataOut.data = avgdata
449 449 dataOut.nCohInt *= self.n
450 450 dataOut.utctime = avgdatatime
451 451 dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt
452 452 dataOut.flagNoData = False
453 453
454 454 class Decoder(Operation):
455 455
456 456 isConfig = False
457 457 __profIndex = 0
458 458
459 459 code = None
460 460
461 461 nCode = None
462 462 nBaud = None
463 463
464 464
465 465 def __init__(self):
466 466
467 467 Operation.__init__(self)
468 468
469 469 self.times = None
470 470 self.osamp = None
471 471 self.__setValues = False
472 472 # self.isConfig = False
473 473
474 474 def setup(self, code, shape, times, osamp):
475 475
476 476 self.__profIndex = 0
477 477
478 478 self.code = code
479 479
480 480 self.nCode = len(code)
481 481 self.nBaud = len(code[0])
482 482
483 483 if times != None:
484 484 self.times = times
485 485
486 486 if ((osamp != None) and (osamp >1)):
487 487 self.osamp = osamp
488 488 self.code = numpy.repeat(code, repeats=self.osamp,axis=1)
489 489 self.nBaud = self.nBaud*self.osamp
490 490
491 491 if len(shape) == 2:
492 492 self.__nChannels, self.__nHeis = shape
493 493
494 494 __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex)
495 495
496 496 __codeBuffer[:,0:self.nBaud] = self.code
497 497
498 498 self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1))
499 499
500 500 self.ndatadec = self.__nHeis - self.nBaud + 1
501 501
502 502 self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex)
503 503 else:
504 504 self.__nChannels, self.__nProfiles, self.__nHeis = shape
505 505
506 506 self.ndatadec = self.__nHeis - self.nBaud + 1
507 507
508 508 self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex)
509 509
510 510
511 511
512 512 def convolutionInFreq(self, data):
513 513
514 514 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
515 515
516 516 fft_data = numpy.fft.fft(data, axis=1)
517 517
518 518 conv = fft_data*fft_code
519 519
520 520 data = numpy.fft.ifft(conv,axis=1)
521 521
522 522 datadec = data[:,:-self.nBaud+1]
523 523
524 524 return datadec
525 525
526 526 def convolutionInFreqOpt(self, data):
527 527
528 528 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
529 529
530 530 data = cfunctions.decoder(fft_code, data)
531 531
532 532 datadec = data[:,:-self.nBaud+1]
533 533
534 534 return datadec
535 535
536 536 def convolutionInTime(self, data):
537 537
538 538 code = self.code[self.__profIndex]
539 539
540 540 for i in range(self.__nChannels):
541 541 self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='valid')
542 542
543 543 return self.datadecTime
544 544
545 545 def convolutionByBlockInTime(self, data):
546 546 junk = numpy.lib.stride_tricks.as_strided(self.code, (self.times, self.code.size), (0, self.code.itemsize))
547 547 junk = junk.flatten()
548 548 code_block = numpy.reshape(junk, (self.nCode*self.times,self.nBaud))
549 549
550 550 for i in range(self.__nChannels):
551 551 for j in range(self.__nProfiles):
552 552 self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='valid')
553 553
554 554 return self.datadecTime
555 555
556 556 def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, times=None, osamp=None):
557 557
558 558 if code == None:
559 559 code = dataOut.code
560 560 else:
561 561 code = numpy.array(code).reshape(nCode,nBaud)
562 562
563 563
564 564
565 565 if not self.isConfig:
566 566
567 567 self.setup(code, dataOut.data.shape, times, osamp)
568 568
569 569 dataOut.code = code
570 570 dataOut.nCode = nCode
571 571 dataOut.nBaud = nBaud
572 572 dataOut.radarControllerHeaderObj.code = code
573 573 dataOut.radarControllerHeaderObj.nCode = nCode
574 574 dataOut.radarControllerHeaderObj.nBaud = nBaud
575 575
576 576 self.isConfig = True
577 577
578 578 if mode == 0:
579 579 datadec = self.convolutionInTime(dataOut.data)
580 580
581 581 if mode == 1:
582 582 datadec = self.convolutionInFreq(dataOut.data)
583 583
584 584 if mode == 2:
585 585 datadec = self.convolutionInFreqOpt(dataOut.data)
586 586
587 587 if mode == 3:
588 588 datadec = self.convolutionByBlockInTime(dataOut.data)
589 589
590 590 if not(self.__setValues):
591 591 dataOut.code = self.code
592 592 dataOut.nCode = self.nCode
593 593 dataOut.nBaud = self.nBaud
594 594 dataOut.radarControllerHeaderObj.code = self.code
595 595 dataOut.radarControllerHeaderObj.nCode = self.nCode
596 596 dataOut.radarControllerHeaderObj.nBaud = self.nBaud
597 597 #self.__setValues = True
598 598
599 599 dataOut.data = datadec
600 600
601 601 dataOut.heightList = dataOut.heightList[0:self.ndatadec]
602 602
603 603 dataOut.flagDecodeData = True #asumo q la data no esta decodificada
604 604
605 605 if self.__profIndex == self.nCode-1:
606 606 self.__profIndex = 0
607 607 return 1
608 608
609 609 self.__profIndex += 1
610 610
611 611 return 1
612 612 # dataOut.flagDeflipData = True #asumo q la data no esta sin flip
613 613
614 614
615 615 class ProfileConcat(Operation):
616 616
617 617 isConfig = False
618 618 buffer = None
619 619
620 620 def __init__(self):
621 621
622 622 Operation.__init__(self)
623 623 self.profileIndex = 0
624 624
625 625 def reset(self):
626 626 self.buffer = numpy.zeros_like(self.buffer)
627 627 self.start_index = 0
628 628 self.times = 1
629 629
630 630 def setup(self, data, m, n=1):
631 631 self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0]))
632 632 self.profiles = data.shape[1]
633 633 self.start_index = 0
634 634 self.times = 1
635 635
636 636 def concat(self, data):
637 637
638 638 self.buffer[:,self.start_index:self.profiles*self.times] = data.copy()
639 639 self.start_index = self.start_index + self.profiles
640 640
641 641 def run(self, dataOut, m):
642 642
643 643 dataOut.flagNoData = True
644 644
645 645 if not self.isConfig:
646 646 self.setup(dataOut.data, m, 1)
647 647 self.isConfig = True
648 648
649 649 self.concat(dataOut.data)
650 650 self.times += 1
651 651 if self.times > m:
652 652 dataOut.data = self.buffer
653 653 self.reset()
654 654 dataOut.flagNoData = False
655 655 # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas
656 656 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
657 657 xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * 5
658 658 dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight)
659 659
660 660 class ProfileSelector(Operation):
661 661
662 662 profileIndex = None
663 663 # Tamanho total de los perfiles
664 664 nProfiles = None
665 665
666 666 def __init__(self):
667 667
668 668 Operation.__init__(self)
669 669 self.profileIndex = 0
670 670
671 671 def incIndex(self):
672 672 self.profileIndex += 1
673 673
674 674 if self.profileIndex >= self.nProfiles:
675 675 self.profileIndex = 0
676 676
677 677 def isProfileInRange(self, minIndex, maxIndex):
678 678
679 679 if self.profileIndex < minIndex:
680 680 return False
681 681
682 682 if self.profileIndex > maxIndex:
683 683 return False
684 684
685 685 return True
686 686
687 687 def isProfileInList(self, profileList):
688 688
689 689 if self.profileIndex not in profileList:
690 690 return False
691 691
692 692 return True
693 693
694 694 def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False):
695 695
696 696 dataOut.flagNoData = True
697 697 self.nProfiles = dataOut.nProfiles
698 698
699 699 if byblock:
700 700
701 701 if profileList != None:
702 702 dataOut.data = dataOut.data[:,profileList,:]
703 703 pass
704 704 else:
705 705 pmin = profileRangeList[0]
706 706 pmax = profileRangeList[1]
707 707 dataOut.data = dataOut.data[:,pmin:pmax+1,:]
708 708 dataOut.flagNoData = False
709 709 self.profileIndex = 0
710 710 return 1
711 711
712 712 if profileList != None:
713 713 if self.isProfileInList(profileList):
714 714 dataOut.flagNoData = False
715 715
716 716 self.incIndex()
717 717 return 1
718 718
719 719
720 720 elif profileRangeList != None:
721 721 minIndex = profileRangeList[0]
722 722 maxIndex = profileRangeList[1]
723 723 if self.isProfileInRange(minIndex, maxIndex):
724 724 dataOut.flagNoData = False
725 725
726 726 self.incIndex()
727 727 return 1
728 728 elif beam != None: #beam is only for AMISR data
729 729 if self.isProfileInList(dataOut.beamRangeDict[beam]):
730 730 dataOut.flagNoData = False
731 731
732 732 self.incIndex()
733 733 return 1
734 734
735 735 else:
736 736 raise ValueError, "ProfileSelector needs profileList or profileRangeList"
737 737
738 738 return 0
739 739
740 740
741 741
742 742 class Reshaper(Operation):
743
743 744 def __init__(self):
745
744 746 Operation.__init__(self)
745 self.updateNewHeights = False
747 self.updateNewHeights = True
746 748
747 749 def run(self, dataOut, shape):
750
748 751 shape_tuple = tuple(shape)
749 752 dataOut.data = numpy.reshape(dataOut.data, shape_tuple)
750 753 dataOut.flagNoData = False
751 754
752 if not(self.updateNewHeights):
755 if self.updateNewHeights:
756
753 757 old_nheights = dataOut.nHeights
754 758 new_nheights = dataOut.data.shape[2]
755 factor = new_nheights / old_nheights
759 factor = 1.0*new_nheights / old_nheights
756 760 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
757 761 xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * factor
758 762 dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight) No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now