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