##// END OF EJS Templates
Bug Fixed: Azimuth,Elevation values were not assign correctly
Daniel Valdez -
r505:6a621bd35e98
parent child
Show More
@@ -1,136 +1,141
1 '''
1 '''
2 @author: Daniel Suarez
2 @author: Daniel Suarez
3 '''
3 '''
4 import numpy
4 import numpy
5 from jroproc_base import ProcessingUnit, Operation
5 from jroproc_base import ProcessingUnit, Operation
6 from model.data.jroamisr import AMISR
6 from model.data.jroamisr import AMISR
7
7
8 class AMISRProc(ProcessingUnit):
8 class AMISRProc(ProcessingUnit):
9 def __init__(self):
9 def __init__(self):
10 ProcessingUnit.__init__(self)
10 ProcessingUnit.__init__(self)
11 self.objectDict = {}
11 self.objectDict = {}
12 self.dataOut = AMISR()
12 self.dataOut = AMISR()
13
13
14 def run(self):
14 def run(self):
15 if self.dataIn.type == 'AMISR':
15 if self.dataIn.type == 'AMISR':
16 self.dataOut.copy(self.dataIn)
16 self.dataOut.copy(self.dataIn)
17
17
18
18
19 class PrintInfo(Operation):
19 class PrintInfo(Operation):
20 def __init__(self):
20 def __init__(self):
21 self.__isPrinted = False
21 self.__isPrinted = False
22
22
23 def run(self, dataOut):
23 def run(self, dataOut):
24
24
25 if not self.__isPrinted:
25 if not self.__isPrinted:
26 print 'Number of Records by File: %d'%dataOut.nRecords
26 print 'Number of Records by File: %d'%dataOut.nRecords
27 print 'Number of Pulses: %d'%dataOut.nProfiles
27 print 'Number of Pulses: %d'%dataOut.nProfiles
28 print 'Number of Pulses by Frame: %d'%dataOut.npulseByFrame
28 print 'Number of Pulses by Frame: %d'%dataOut.npulseByFrame
29 print 'Number of Samples by Pulse: %d'%len(dataOut.heightList)
29 print 'Number of Samples by Pulse: %d'%len(dataOut.heightList)
30 print 'Ipp Seconds: %f'%dataOut.ippSeconds
30 print 'Ipp Seconds: %f'%dataOut.ippSeconds
31 print 'Number of Beams: %d'%dataOut.nBeams
31 print 'Number of Beams: %d'%dataOut.nBeams
32 print 'BeamCodes:'
32 print 'BeamCodes:'
33 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 dataOut.beamCodeDict.items()]
33 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 dataOut.beamCodeDict.items()]
34 for b in beamStrList:
34 for b in beamStrList:
35 print b
35 print b
36 self.__isPrinted = True
36 self.__isPrinted = True
37
37
38 return
38 return
39
39
40
40
41 class BeamSelector(Operation):
41 class BeamSelector(Operation):
42 profileIndex = None
42 profileIndex = None
43 nProfiles = None
43 nProfiles = None
44
44
45 def __init__(self):
45 def __init__(self):
46
46
47 self.profileIndex = 0
47 self.profileIndex = 0
48 self.__isConfig = False
48 self.__isConfig = False
49
49
50 def incIndex(self):
50 def incIndex(self):
51 self.profileIndex += 1
51 self.profileIndex += 1
52
52
53 if self.profileIndex >= self.nProfiles:
53 if self.profileIndex >= self.nProfiles:
54 self.profileIndex = 0
54 self.profileIndex = 0
55
55
56 def isProfileInRange(self, minIndex, maxIndex):
56 def isProfileInRange(self, minIndex, maxIndex):
57
57
58 if self.profileIndex < minIndex:
58 if self.profileIndex < minIndex:
59 return False
59 return False
60
60
61 if self.profileIndex > maxIndex:
61 if self.profileIndex > maxIndex:
62 return False
62 return False
63
63
64 return True
64 return True
65
65
66 def isProfileInList(self, profileList):
66 def isProfileInList(self, profileList):
67
67
68 if self.profileIndex not in profileList:
68 if self.profileIndex not in profileList:
69 return False
69 return False
70
70
71 return True
71 return True
72
72
73 def run(self, dataOut, beam=None):
73 def run(self, dataOut, beam=None):
74
74
75 dataOut.flagNoData = True
75 dataOut.flagNoData = True
76
76
77 if not(self.__isConfig):
77 if not(self.__isConfig):
78
78
79 self.nProfiles = dataOut.nProfiles
79 self.nProfiles = dataOut.nProfiles
80 self.profileIndex = dataOut.profileIndex
80 self.profileIndex = dataOut.profileIndex
81 self.__isConfig = True
81 self.__isConfig = True
82
82
83 if beam != None:
83 if beam != None:
84 if self.isProfileInList(dataOut.beamRangeDict[beam]):
84 if self.isProfileInList(dataOut.beamRangeDict[beam]):
85 beamInfo = dataOut.beamCodeDict[beam]
85 beamInfo = dataOut.beamCodeDict[beam]
86 dataOut.azimuth = beamInfo[1]
86 dataOut.azimuth = beamInfo[1]
87 dataOut.zenith = beamInfo[2]
87 dataOut.zenith = beamInfo[2]
88 dataOut.gain = beamInfo[3]
88 dataOut.gain = beamInfo[3]
89 dataOut.flagNoData = False
89 dataOut.flagNoData = False
90
90
91 self.incIndex()
91 self.incIndex()
92 return 1
92 return 1
93
93
94 else:
94 else:
95 raise ValueError, "BeamSelector needs beam value"
95 raise ValueError, "BeamSelector needs beam value"
96
96
97 return 0
97 return 0
98
98
99 class ProfileToChannels(Operation):
99 class ProfileToChannels(Operation):
100
100
101 def __init__(self):
101 def __init__(self):
102 self.__isConfig = False
102 self.__isConfig = False
103 self.__counter_chan = 0
103 self.__counter_chan = 0
104 self.buffer = None
104 self.buffer = None
105
105
106 def isProfileInList(self, profileList):
107
108 if self.profileIndex not in profileList:
109 return False
110
111 return True
106
112
107 def run(self, dataOut):
113 def run(self, dataOut):
108
114
109 dataOut.flagNoData = True
115 dataOut.flagNoData = True
110
116
111 if not(self.__isConfig):
117 if not(self.__isConfig):
112 nchannels = len(dataOut.beamRangeDict.keys())
118 nchannels = len(dataOut.beamRangeDict.keys())
113 nsamples = dataOut.nHeights
119 nsamples = dataOut.nHeights
114 self.buffer = numpy.zeros((nchannels, nsamples), dtype = 'complex128')
120 self.buffer = numpy.zeros((nchannels, nsamples), dtype = 'complex128')
121 dataOut.beam.codeList = [dataOut.beamCodeDict[x][0] for x in range(nchannels)]
122 dataOut.beam.azimuthList = [dataOut.beamCodeDict[x][1] for x in range(nchannels)]
123 dataOut.beam.zenithList = [dataOut.beamCodeDict[x][2] for x in range(nchannels)]
115 self.__isConfig = True
124 self.__isConfig = True
116
125
117 for i in range(self.buffer.shape[0]):
126 for i in range(self.buffer.shape[0]):
118 if dataOut.profileIndex in dataOut.beamRangeDict[i]:
127 if dataOut.profileIndex in dataOut.beamRangeDict[i]:
119 self.buffer[i,:] = dataOut.data
128 self.buffer[i,:] = dataOut.data
120 if len(dataOut.beam.codeList) < self.buffer.shape[0]:
121 beamInfo = dataOut.beamCodeDict[i]
122 dataOut.beam.codeList.append(beamInfo[0])
123 dataOut.beam.azimuthList.append(beamInfo[1])
124 dataOut.beam.zenithList.append(beamInfo[2])
125 break
129 break
126
130
131
127 self.__counter_chan += 1
132 self.__counter_chan += 1
128
133
129 if self.__counter_chan >= self.buffer.shape[0]:
134 if self.__counter_chan >= self.buffer.shape[0]:
130 self.__counter_chan = 0
135 self.__counter_chan = 0
131 dataOut.data = self.buffer.copy()
136 dataOut.data = self.buffer.copy()
132 dataOut.channelList = range(self.buffer.shape[0])
137 dataOut.channelList = range(self.buffer.shape[0])
133 self.__isConfig = False
138 self.__isConfig = False
134 dataOut.flagNoData = False
139 dataOut.flagNoData = False
135 pass
140 pass
136 No newline at end of file
141
General Comments 0
You need to be logged in to leave comments. Login now