@@ -201,6 +201,8 class JROData(GenericData): | |||
|
201 | 201 | |
|
202 | 202 | beam = Beam() |
|
203 | 203 | |
|
204 | profileIndex = None | |
|
205 | ||
|
204 | 206 | def __init__(self): |
|
205 | 207 | |
|
206 | 208 | raise ValueError, "This class has not been implemented" |
@@ -363,6 +365,8 class Voltage(JROData): | |||
|
363 | 365 | |
|
364 | 366 | self.flagDataAsBlock = False #Asumo que la data es leida perfil a perfil |
|
365 | 367 | |
|
368 | self.profileIndex = 0 | |
|
369 | ||
|
366 | 370 | def getNoisebyHildebrand(self): |
|
367 | 371 | """ |
|
368 | 372 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
@@ -420,6 +424,8 class Spectra(JROData): | |||
|
420 | 424 | |
|
421 | 425 | ippFactor = None |
|
422 | 426 | |
|
427 | profileIndex = 0 | |
|
428 | ||
|
423 | 429 | def __init__(self): |
|
424 | 430 | ''' |
|
425 | 431 | Constructor |
@@ -609,6 +615,8 class SpectraHeis(Spectra): | |||
|
609 | 615 | self.utctime = None |
|
610 | 616 | |
|
611 | 617 | self.blocksize = None |
|
618 | ||
|
619 | self.profileIndex = 0 | |
|
612 | 620 | |
|
613 | 621 | def getNormFactor(self): |
|
614 | 622 | pwcode = 1 |
@@ -686,6 +694,8 class Fits: | |||
|
686 | 694 | |
|
687 | 695 | self.useLocalTime = True |
|
688 | 696 | |
|
697 | self.profileIndex = 0 | |
|
698 | ||
|
689 | 699 | # self.utctime = None |
|
690 | 700 | # self.timeZone = None |
|
691 | 701 | # self.ltctime = None |
@@ -378,6 +378,10 class JRODataReader(JRODataIO): | |||
|
378 | 378 | |
|
379 | 379 | profileIndex = None |
|
380 | 380 | |
|
381 | nTxs = 1 | |
|
382 | ||
|
383 | txIndex = None | |
|
384 | ||
|
381 | 385 | def __init__(self): |
|
382 | 386 | |
|
383 | 387 | """ |
@@ -937,7 +941,8 class JRODataReader(JRODataIO): | |||
|
937 | 941 | online = False, |
|
938 | 942 | delay = 60, |
|
939 | 943 | walk = True, |
|
940 |
getblock = False |
|
|
944 | getblock = False, | |
|
945 | nTxs = 1): | |
|
941 | 946 | |
|
942 | 947 | if path == None: |
|
943 | 948 | raise ValueError, "The path is not valid" |
@@ -995,6 +1000,7 class JRODataReader(JRODataIO): | |||
|
995 | 1000 | ext = ext.lower() |
|
996 | 1001 | self.ext = ext |
|
997 | 1002 | self.getByBlock = getblock |
|
1003 | self.nTxs = int(nTxs) | |
|
998 | 1004 | |
|
999 | 1005 | if not(self.setNextFile()): |
|
1000 | 1006 | if (startDate!=None) and (endDate!=None): |
@@ -153,6 +153,10 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
153 | 153 | self.blocksize = 0 |
|
154 | 154 | |
|
155 | 155 | self.dataOut = self.createObjByDefault() |
|
156 | ||
|
157 | self.nTxs = 1 | |
|
158 | ||
|
159 | self.txIndex = 0 | |
|
156 | 160 | |
|
157 | 161 | def createObjByDefault(self): |
|
158 | 162 | |
@@ -161,8 +165,10 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
161 | 165 | return dataObj |
|
162 | 166 | |
|
163 | 167 | def __hasNotDataInBuffer(self): |
|
168 | ||
|
164 | 169 | if self.profileIndex >= self.processingHeaderObj.profilesPerBlock: |
|
165 | 170 | return 1 |
|
171 | ||
|
166 | 172 | return 0 |
|
167 | 173 | |
|
168 | 174 | |
@@ -235,7 +241,8 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
235 | 241 | |
|
236 | 242 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() |
|
237 | 243 | |
|
238 | # self.dataOut.ippSeconds = self.ippSeconds | |
|
244 | if self.nTxs > 1: | |
|
245 | self.dataOut.radarControllerHeaderObj.ippSeconds /= self.nTxs | |
|
239 | 246 | |
|
240 | 247 | # self.dataOut.timeInterval = self.radarControllerHeaderObj.ippSeconds * self.processingHeaderObj.nCohInt |
|
241 | 248 | |
@@ -249,9 +256,12 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
249 | 256 | |
|
250 | 257 | self.dataOut.dtype = self.dtype |
|
251 | 258 | |
|
252 | self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock | |
|
259 | self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs | |
|
260 | ||
|
261 | if self.processingHeaderObj.nHeights % self.nTxs != 0: | |
|
262 | raise ValueError, "nTxs (%d) should be a multiple of nHeights (%d)" %(self.nTxs, self.processingHeaderObj.nHeights) | |
|
253 | 263 | |
|
254 | xf = self.processingHeaderObj.firstHeight + self.processingHeaderObj.nHeights*self.processingHeaderObj.deltaHeight | |
|
264 | xf = self.processingHeaderObj.firstHeight + int(self.processingHeaderObj.nHeights/self.nTxs)*self.processingHeaderObj.deltaHeight | |
|
255 | 265 | |
|
256 | 266 | self.dataOut.heightList = numpy.arange(self.processingHeaderObj.firstHeight, xf, self.processingHeaderObj.deltaHeight) |
|
257 | 267 | |
@@ -323,21 +333,52 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
323 | 333 | self.dataOut.flagNoData = True |
|
324 | 334 | return 0 |
|
325 | 335 | |
|
326 | if self.getByBlock: | |
|
336 | if not self.getByBlock: | |
|
337 | ||
|
338 | """ | |
|
339 | Return profile by profile | |
|
340 | ||
|
341 | If nTxs > 1 then one profile is divided by nTxs and number of total | |
|
342 | blocks is increased by nTxs (nProfiles *= nTxs) | |
|
343 | """ | |
|
344 | if self.nTxs == 1: | |
|
345 | self.dataOut.flagDataAsBlock = False | |
|
346 | self.dataOut.data = self.datablock[:,self.profileIndex,:] | |
|
347 | self.dataOut.profileIndex = self.profileIndex | |
|
348 | ||
|
349 | self.profileIndex += 1 | |
|
350 | ||
|
351 | else: | |
|
352 | self.dataOut.flagDataAsBlock = False | |
|
353 | ||
|
354 | iniHei_ForThisTx = (self.txIndex)*int(self.processingHeaderObj.nHeights/self.nTxs) | |
|
355 | endHei_ForThisTx = (self.txIndex+1)*int(self.processingHeaderObj.nHeights/self.nTxs) | |
|
356 | ||
|
357 | # print iniHei_ForThisTx, endHei_ForThisTx | |
|
358 | ||
|
359 | self.dataOut.data = self.datablock[:, self.profileIndex, iniHei_ForThisTx:endHei_ForThisTx] | |
|
360 | self.dataOut.profileIndex = self.profileIndex*self.nTxs + self.txIndex | |
|
361 | ||
|
362 | self.txIndex += 1 | |
|
363 | ||
|
364 | if self.txIndex == self.nTxs: | |
|
365 | self.txIndex = 0 | |
|
366 | self.profileIndex += 1 | |
|
367 | ||
|
368 | else: | |
|
369 | """ | |
|
370 | Return all block | |
|
371 | """ | |
|
327 | 372 | self.dataOut.flagDataAsBlock = True |
|
328 | 373 | self.dataOut.data = self.datablock |
|
329 | self.profileIndex = self.processingHeaderObj.profilesPerBlock | |
|
330 |
|
|
|
331 | self.dataOut.flagDataAsBlock = False | |
|
332 | self.dataOut.data = self.datablock[:,self.profileIndex,:] | |
|
333 | self.profileIndex += 1 | |
|
374 | self.dataOut.profileIndex = self.processingHeaderObj.profilesPerBlock - 1 | |
|
375 | ||
|
376 | self.profileIndex = self.processingHeaderObj.profilesPerBlock - 1 | |
|
334 | 377 | |
|
335 | 378 | self.dataOut.flagNoData = False |
|
336 | 379 | |
|
337 | 380 | self.getBasicHeader() |
|
338 | 381 | |
|
339 | ||
|
340 | ||
|
341 | 382 | self.dataOut.realtime = self.online |
|
342 | 383 | |
|
343 | 384 | return self.dataOut.data |
@@ -185,7 +185,7 class VoltageProc(ProcessingUnit): | |||
|
185 | 185 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
186 | 186 | |
|
187 | 187 | if (maxIndex >= self.dataOut.nHeights): |
|
188 |
maxIndex = self.dataOut.nHeights |
|
|
188 | maxIndex = self.dataOut.nHeights | |
|
189 | 189 | # raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
190 | 190 | |
|
191 | 191 | # nHeights = maxIndex - minIndex + 1 |
@@ -195,14 +195,14 class VoltageProc(ProcessingUnit): | |||
|
195 | 195 | """ |
|
196 | 196 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
197 | 197 | """ |
|
198 |
data = self.dataOut.data[:,minIndex:maxIndex |
|
|
198 | data = self.dataOut.data[:,minIndex:maxIndex,:] | |
|
199 | 199 | else: |
|
200 |
data = self.dataOut.data[:,minIndex:maxIndex |
|
|
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 |
self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex |
|
|
205 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex] | |
|
206 | 206 | |
|
207 | 207 | return 1 |
|
208 | 208 | |
@@ -539,7 +539,7 class Decoder(Operation): | |||
|
539 | 539 | |
|
540 | 540 | if dataOut.flagDataAsBlock: |
|
541 | 541 | |
|
542 | self.ndatadec = self.__nHeis - self.nBaud + 1 | |
|
542 | self.ndatadec = self.__nHeis #- self.nBaud + 1 | |
|
543 | 543 | |
|
544 | 544 | self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex) |
|
545 | 545 | |
@@ -551,7 +551,7 class Decoder(Operation): | |||
|
551 | 551 | |
|
552 | 552 | self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1)) |
|
553 | 553 | |
|
554 | self.ndatadec = self.__nHeis - self.nBaud + 1 | |
|
554 | self.ndatadec = self.__nHeis #- self.nBaud + 1 | |
|
555 | 555 | |
|
556 | 556 | self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex) |
|
557 | 557 | |
@@ -565,7 +565,7 class Decoder(Operation): | |||
|
565 | 565 | |
|
566 | 566 | data = numpy.fft.ifft(conv,axis=1) |
|
567 | 567 | |
|
568 |
datadec = data[:,: |
|
|
568 | datadec = data#[:,:] | |
|
569 | 569 | |
|
570 | 570 | return datadec |
|
571 | 571 | |
@@ -575,7 +575,7 class Decoder(Operation): | |||
|
575 | 575 | |
|
576 | 576 | data = cfunctions.decoder(fft_code, data) |
|
577 | 577 | |
|
578 |
datadec = data[:,: |
|
|
578 | datadec = data#[:,:] | |
|
579 | 579 | |
|
580 | 580 | return datadec |
|
581 | 581 | |
@@ -584,7 +584,7 class Decoder(Operation): | |||
|
584 | 584 | code = self.code[self.__profIndex] |
|
585 | 585 | |
|
586 | 586 | for i in range(self.__nChannels): |
|
587 |
self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode=' |
|
|
587 | self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='same') | |
|
588 | 588 | |
|
589 | 589 | return self.datadecTime |
|
590 | 590 | |
@@ -598,7 +598,7 class Decoder(Operation): | |||
|
598 | 598 | |
|
599 | 599 | for i in range(self.__nChannels): |
|
600 | 600 | for j in range(self.__nProfiles): |
|
601 |
self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode=' |
|
|
601 | self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='same') | |
|
602 | 602 | |
|
603 | 603 | return self.datadecTime |
|
604 | 604 | |
@@ -674,14 +674,14 class ProfileConcat(Operation): | |||
|
674 | 674 | |
|
675 | 675 | def setup(self, data, m, n=1): |
|
676 | 676 | self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0])) |
|
677 |
self. |
|
|
677 | self.nHeights = data.nHeights | |
|
678 | 678 | self.start_index = 0 |
|
679 | 679 | self.times = 1 |
|
680 | 680 | |
|
681 | 681 | def concat(self, data): |
|
682 | 682 | |
|
683 | 683 | self.buffer[:,self.start_index:self.profiles*self.times] = data.copy() |
|
684 |
self.start_index = self.start_index + self. |
|
|
684 | self.start_index = self.start_index + self.nHeights | |
|
685 | 685 | |
|
686 | 686 | def run(self, dataOut, m): |
|
687 | 687 | |
@@ -693,7 +693,7 class ProfileConcat(Operation): | |||
|
693 | 693 | |
|
694 | 694 | if dataOut.flagDataAsBlock: |
|
695 | 695 | |
|
696 |
raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profi |
|
|
696 | raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False" | |
|
697 | 697 | |
|
698 | 698 | else: |
|
699 | 699 | self.concat(dataOut.data) |
@@ -704,8 +704,9 class ProfileConcat(Operation): | |||
|
704 | 704 | dataOut.flagNoData = False |
|
705 | 705 | # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas |
|
706 | 706 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
707 |
xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * |
|
|
707 | xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m | |
|
708 | 708 | dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight) |
|
709 | dataOut.ippSeconds *= m | |
|
709 | 710 | |
|
710 | 711 | class ProfileSelector(Operation): |
|
711 | 712 | |
@@ -719,33 +720,41 class ProfileSelector(Operation): | |||
|
719 | 720 | self.profileIndex = 0 |
|
720 | 721 | |
|
721 | 722 | def incIndex(self): |
|
723 | ||
|
722 | 724 | self.profileIndex += 1 |
|
723 | 725 | |
|
724 | 726 | if self.profileIndex >= self.nProfiles: |
|
725 | 727 | self.profileIndex = 0 |
|
726 | 728 | |
|
727 | def isProfileInRange(self, minIndex, maxIndex): | |
|
729 | def isThisProfileInRange(self, profileIndex, minIndex, maxIndex): | |
|
728 | 730 | |
|
729 |
if |
|
|
731 | if profileIndex < minIndex: | |
|
730 | 732 | return False |
|
731 | 733 | |
|
732 |
if |
|
|
734 | if profileIndex > maxIndex: | |
|
733 | 735 | return False |
|
734 | 736 | |
|
735 | 737 | return True |
|
736 | 738 | |
|
737 | def isProfileInList(self, profileList): | |
|
739 | def isThisProfileInList(self, profileIndex, profileList): | |
|
738 | 740 | |
|
739 |
if |
|
|
741 | if profileIndex not in profileList: | |
|
740 | 742 | return False |
|
741 | 743 | |
|
742 | 744 | return True |
|
743 | 745 | |
|
744 | def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False): | |
|
746 | def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None): | |
|
745 | 747 | |
|
746 | 748 | """ |
|
747 | 749 | ProfileSelector: |
|
748 | 750 | |
|
751 | Inputs: | |
|
752 | profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8) | |
|
753 | ||
|
754 | profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30) | |
|
755 | ||
|
756 | rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256)) | |
|
757 | ||
|
749 | 758 | """ |
|
750 | 759 | |
|
751 | 760 | dataOut.flagNoData = True |
@@ -758,15 +767,16 class ProfileSelector(Operation): | |||
|
758 | 767 | if profileList != None: |
|
759 | 768 | dataOut.data = dataOut.data[:,profileList,:] |
|
760 | 769 | dataOut.nProfiles = len(profileList) |
|
770 | dataOut.profileIndex = dataOut.nProfiles - 1 | |
|
761 | 771 | else: |
|
762 |
|
|
|
763 |
|
|
|
764 | dataOut.data = dataOut.data[:,pmin:pmax+1,:] | |
|
765 | dataOut.nProfiles = pmax - pmin + 1 | |
|
766 | ||
|
772 | minIndex = profileRangeList[0] | |
|
773 | maxIndex = profileRangeList[1] | |
|
774 | ||
|
775 | dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:] | |
|
776 | dataOut.nProfiles = maxIndex - minIndex + 1 | |
|
777 | dataOut.profileIndex = dataOut.nProfiles - 1 | |
|
767 | 778 | |
|
768 | 779 | dataOut.flagNoData = False |
|
769 | self.profileIndex = 0 | |
|
770 | 780 | |
|
771 | 781 | return True |
|
772 | 782 | |
@@ -777,28 +787,65 class ProfileSelector(Operation): | |||
|
777 | 787 | """ |
|
778 | 788 | if profileList != None: |
|
779 | 789 | |
|
780 |
|
|
|
790 | dataOut.nProfiles = len(profileList) | |
|
791 | ||
|
792 | if self.isThisProfileInList(dataOut.profileIndex, profileList): | |
|
781 | 793 | dataOut.flagNoData = False |
|
794 | dataOut.profileIndex = self.profileIndex | |
|
782 | 795 | |
|
783 | self.incIndex() | |
|
784 |
return |
|
|
796 | self.incIndex() | |
|
797 | return True | |
|
785 | 798 | |
|
786 | 799 | |
|
787 | 800 | if profileRangeList != None: |
|
788 | 801 | |
|
789 | 802 | minIndex = profileRangeList[0] |
|
790 | 803 | maxIndex = profileRangeList[1] |
|
791 | if self.isProfileInRange(minIndex, maxIndex): | |
|
804 | ||
|
805 | dataOut.nProfiles = maxIndex - minIndex + 1 | |
|
806 | ||
|
807 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): | |
|
792 | 808 | dataOut.flagNoData = False |
|
809 | dataOut.profileIndex = self.profileIndex | |
|
793 | 810 | |
|
794 | self.incIndex() | |
|
795 |
return |
|
|
811 | self.incIndex() | |
|
812 | return True | |
|
796 | 813 | |
|
814 | if rangeList != None: | |
|
815 | ||
|
816 | nProfiles = 0 | |
|
817 | ||
|
818 | for thisRange in rangeList: | |
|
819 | minIndex = thisRange[0] | |
|
820 | maxIndex = thisRange[1] | |
|
821 | ||
|
822 | nProfiles += maxIndex - minIndex + 1 | |
|
823 | ||
|
824 | dataOut.nProfiles = nProfiles | |
|
825 | ||
|
826 | for thisRange in rangeList: | |
|
827 | ||
|
828 | minIndex = thisRange[0] | |
|
829 | maxIndex = thisRange[1] | |
|
830 | ||
|
831 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): | |
|
832 | ||
|
833 | # print "profileIndex = ", dataOut.profileIndex | |
|
834 | ||
|
835 | dataOut.flagNoData = False | |
|
836 | dataOut.profileIndex = self.profileIndex | |
|
837 | ||
|
838 | self.incIndex() | |
|
839 | break | |
|
840 | return True | |
|
841 | ||
|
842 | ||
|
797 | 843 | if beam != None: #beam is only for AMISR data |
|
798 | if self.isProfileInList(dataOut.beamRangeDict[beam]): | |
|
844 | if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]): | |
|
799 | 845 | dataOut.flagNoData = False |
|
846 | dataOut.profileIndex = self.profileIndex | |
|
800 | 847 | |
|
801 | self.incIndex() | |
|
848 | self.incIndex() | |
|
802 | 849 | return 1 |
|
803 | 850 | |
|
804 | 851 | raise ValueError, "ProfileSelector needs profileList or profileRangeList" |
@@ -838,4 +885,6 class Reshaper(Operation): | |||
|
838 | 885 | |
|
839 | 886 | dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight) |
|
840 | 887 | |
|
841 | dataOut.nProfiles = dataOut.data.shape[1] No newline at end of file | |
|
888 | dataOut.nProfiles = dataOut.data.shape[1] | |
|
889 | ||
|
890 | dataOut.ippSeconds *= factor No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now