##// END OF EJS Templates
Python 2to3, Spectra (all operations) working
Python 2to3, Spectra (all operations) working

File last commit:

r1167:1f521b07c958
r1167:1f521b07c958
Show More
jroproc_amisr.py
142 lines | 4.3 KiB | text/x-python | PythonLexer
Daniel Valdez
AMISR modules to read hdf5 files and link to SignalChain Objects...
r491 '''
@author: Daniel Suarez
'''
Daniel Valdez
ProfileToChannels this is a new Operation to get data with dimensions [nchannels,nsamples]
r501 import numpy
George Yong
Python 2to3, Spectra (all operations) working
r1167 from .jroproc_base import ProcessingUnit, Operation
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 from schainpy.model.data.jroamisr import AMISR
Daniel Valdez
AMISR modules to read hdf5 files and link to SignalChain Objects...
r491
class AMISRProc(ProcessingUnit):
José Chávez
kwargs restantes. Templates y changelog actualizado
r1080 def __init__(self, **kwargs):
ProcessingUnit.__init__(self, **kwargs)
Daniel Valdez
AMISR modules to read hdf5 files and link to SignalChain Objects...
r491 self.objectDict = {}
self.dataOut = AMISR()
def run(self):
if self.dataIn.type == 'AMISR':
self.dataOut.copy(self.dataIn)
class PrintInfo(Operation):
José Chávez
kwargs restantes. Templates y changelog actualizado
r1080 def __init__(self, **kwargs):
Operation.__init__(self, **kwargs)
Daniel Valdez
Bug fixed: AMISR Reader filling with zeros at the begining of the processing....
r497 self.__isPrinted = False
Daniel Valdez
AMISR modules to read hdf5 files and link to SignalChain Objects...
r491
def run(self, dataOut):
Daniel Valdez
Bug fixed: AMISR Reader filling with zeros at the begining of the processing....
r497 if not self.__isPrinted:
George Yong
Python 2to3, Spectra (all operations) working
r1167 print('Number of Records by File: %d'%dataOut.nRecords)
print('Number of Pulses: %d'%dataOut.nProfiles)
print('Number of Pulses by Frame: %d'%dataOut.npulseByFrame)
print('Number of Samples by Pulse: %d'%len(dataOut.heightList))
print('Ipp Seconds: %f'%dataOut.ippSeconds)
print('Number of Beams: %d'%dataOut.nBeams)
print('BeamCodes:')
beamStrList = ['Beam %d -> Code=%d, azimuth=%2.2f, zenith=%2.2f, gain=%2.2f'%(k,v[0],v[1],v[2],v[3]) for k,v in list(dataOut.beamCodeDict.items())]
Daniel Valdez
Bug fixed: AMISR Reader filling with zeros at the begining of the processing....
r497 for b in beamStrList:
George Yong
Python 2to3, Spectra (all operations) working
r1167 print(b)
Daniel Valdez
Bug fixed: AMISR Reader filling with zeros at the begining of the processing....
r497 self.__isPrinted = True
return
Daniel Valdez
AMISR modules to read hdf5 files and link to SignalChain Objects...
r491
class BeamSelector(Operation):
profileIndex = None
nProfiles = None
José Chávez
kwargs restantes. Templates y changelog actualizado
r1080 def __init__(self, **kwargs):
Operation.__init__(self, **kwargs)
Daniel Valdez
AMISR modules to read hdf5 files and link to SignalChain Objects...
r491 self.profileIndex = 0
Daniel Valdez
Bug Fixed: Index List for AMISR Beams ...
r504 self.__isConfig = False
Daniel Valdez
AMISR modules to read hdf5 files and link to SignalChain Objects...
r491
def incIndex(self):
self.profileIndex += 1
if self.profileIndex >= self.nProfiles:
self.profileIndex = 0
def isProfileInRange(self, minIndex, maxIndex):
if self.profileIndex < minIndex:
return False
if self.profileIndex > maxIndex:
return False
return True
def isProfileInList(self, profileList):
if self.profileIndex not in profileList:
return False
return True
def run(self, dataOut, beam=None):
dataOut.flagNoData = True
Daniel Valdez
Bug Fixed: Index List for AMISR Beams ...
r504
if not(self.__isConfig):
self.nProfiles = dataOut.nProfiles
self.profileIndex = dataOut.profileIndex
self.__isConfig = True
Daniel Valdez
AMISR modules to read hdf5 files and link to SignalChain Objects...
r491
if beam != None:
if self.isProfileInList(dataOut.beamRangeDict[beam]):
Daniel Valdez
Filtering AMISR files for Datetime Range...
r499 beamInfo = dataOut.beamCodeDict[beam]
dataOut.azimuth = beamInfo[1]
dataOut.zenith = beamInfo[2]
dataOut.gain = beamInfo[3]
Daniel Valdez
AMISR modules to read hdf5 files and link to SignalChain Objects...
r491 dataOut.flagNoData = False
self.incIndex()
return 1
else:
George Yong
Python 2to3, Spectra (all operations) working
r1167 raise ValueError("BeamSelector needs beam value")
Daniel Valdez
AMISR modules to read hdf5 files and link to SignalChain Objects...
r491
Daniel Valdez
ProfileToChannels this is a new Operation to get data with dimensions [nchannels,nsamples]
r501 return 0
class ProfileToChannels(Operation):
José Chávez
kwargs restantes. Templates y changelog actualizado
r1080 def __init__(self, **kwargs):
Operation.__init__(self, **kwargs)
Daniel Valdez
ProfileToChannels this is a new Operation to get data with dimensions [nchannels,nsamples]
r501 self.__isConfig = False
self.__counter_chan = 0
self.buffer = None
Daniel Valdez
Bug Fixed: Azimuth,Elevation values were not assign correctly
r505 def isProfileInList(self, profileList):
if self.profileIndex not in profileList:
return False
return True
Daniel Valdez
ProfileToChannels this is a new Operation to get data with dimensions [nchannels,nsamples]
r501
def run(self, dataOut):
dataOut.flagNoData = True
if not(self.__isConfig):
George Yong
Python 2to3, Spectra (all operations) working
r1167 nchannels = len(list(dataOut.beamRangeDict.keys()))
Daniel Valdez
ProfileToChannels this is a new Operation to get data with dimensions [nchannels,nsamples]
r501 nsamples = dataOut.nHeights
self.buffer = numpy.zeros((nchannels, nsamples), dtype = 'complex128')
Daniel Valdez
Bug Fixed: Azimuth,Elevation values were not assign correctly
r505 dataOut.beam.codeList = [dataOut.beamCodeDict[x][0] for x in range(nchannels)]
dataOut.beam.azimuthList = [dataOut.beamCodeDict[x][1] for x in range(nchannels)]
dataOut.beam.zenithList = [dataOut.beamCodeDict[x][2] for x in range(nchannels)]
Daniel Valdez
ProfileToChannels this is a new Operation to get data with dimensions [nchannels,nsamples]
r501 self.__isConfig = True
for i in range(self.buffer.shape[0]):
if dataOut.profileIndex in dataOut.beamRangeDict[i]:
self.buffer[i,:] = dataOut.data
break
Daniel Valdez
Bug Fixed: Azimuth,Elevation values were not assign correctly
r505
Daniel Valdez
ProfileToChannels this is a new Operation to get data with dimensions [nchannels,nsamples]
r501 self.__counter_chan += 1
if self.__counter_chan >= self.buffer.shape[0]:
self.__counter_chan = 0
dataOut.data = self.buffer.copy()
George Yong
Python 2to3, Spectra (all operations) working
r1167 dataOut.channelList = list(range(self.buffer.shape[0]))
Daniel Valdez
ProfileToChannels this is a new Operation to get data with dimensions [nchannels,nsamples]
r501 self.__isConfig = False
dataOut.flagNoData = False
pass