@@ -1,696 +1,696 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Feb 7, 2012 |
|
2 | Created on Feb 7, 2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 | import os, sys |
|
7 | import os, sys | |
8 | import numpy |
|
8 | import numpy | |
9 | import time |
|
9 | import time | |
10 |
|
10 | |||
11 | path = os.path.split(os.getcwd())[0] |
|
11 | path = os.path.split(os.getcwd())[0] | |
12 | sys.path.append(path) |
|
12 | sys.path.append(path) | |
13 |
|
13 | |||
14 | from Model.Spectra import Spectra |
|
14 | from Model.Spectra import Spectra | |
15 | from IO.SpectraIO import SpectraWriter |
|
15 | from IO.SpectraIO import SpectraWriter | |
16 | from Graphics.SpectraPlot import Spectrum |
|
16 | from Graphics.SpectraPlot import Spectrum | |
17 | from JRONoise import Noise |
|
17 | from JRONoise import Noise | |
18 |
|
18 | |||
19 | class SpectraProcessor: |
|
19 | class SpectraProcessor: | |
20 | ''' |
|
20 | ''' | |
21 | classdocs |
|
21 | classdocs | |
22 | ''' |
|
22 | ''' | |
23 |
|
23 | |||
24 | dataInObj = None |
|
24 | dataInObj = None | |
25 |
|
25 | |||
26 | dataOutObj = None |
|
26 | dataOutObj = None | |
27 |
|
27 | |||
28 | noiseObj = None |
|
28 | noiseObj = None | |
29 |
|
29 | |||
30 | integratorObjList = [] |
|
30 | integratorObjList = [] | |
31 |
|
31 | |||
32 | decoderObjList = [] |
|
32 | decoderObjList = [] | |
33 |
|
33 | |||
34 | writerObjList = [] |
|
34 | writerObjList = [] | |
35 |
|
35 | |||
36 | plotterObjList = [] |
|
36 | plotterObjList = [] | |
37 |
|
37 | |||
38 | integratorObjIndex = None |
|
38 | integratorObjIndex = None | |
39 |
|
39 | |||
40 | decoderObjIndex = None |
|
40 | decoderObjIndex = None | |
41 |
|
41 | |||
42 | writerObjIndex = None |
|
42 | writerObjIndex = None | |
43 |
|
43 | |||
44 | plotterObjIndex = None |
|
44 | plotterObjIndex = None | |
45 |
|
45 | |||
46 | buffer = None |
|
46 | buffer = None | |
47 |
|
47 | |||
48 | profIndex = 0 |
|
48 | profIndex = 0 | |
49 |
|
49 | |||
50 | nFFTPoints = None |
|
50 | nFFTPoints = None | |
51 |
|
51 | |||
52 | nChannels = None |
|
52 | nChannels = None | |
53 |
|
53 | |||
54 | nHeights = None |
|
54 | nHeights = None | |
55 |
|
55 | |||
56 | nPairs = None |
|
56 | nPairs = None | |
57 |
|
57 | |||
58 | pairList = None |
|
58 | pairList = None | |
59 |
|
59 | |||
60 |
|
60 | |||
61 | def __init__(self): |
|
61 | def __init__(self): | |
62 | ''' |
|
62 | ''' | |
63 | Constructor |
|
63 | Constructor | |
64 | ''' |
|
64 | ''' | |
65 |
|
65 | |||
66 | self.integratorObjIndex = None |
|
66 | self.integratorObjIndex = None | |
67 | self.decoderObjIndex = None |
|
67 | self.decoderObjIndex = None | |
68 | self.writerObjIndex = None |
|
68 | self.writerObjIndex = None | |
69 | self.plotterObjIndex = None |
|
69 | self.plotterObjIndex = None | |
70 |
|
70 | |||
71 | self.integratorObjList = [] |
|
71 | self.integratorObjList = [] | |
72 | self.decoderObjList = [] |
|
72 | self.decoderObjList = [] | |
73 | self.writerObjList = [] |
|
73 | self.writerObjList = [] | |
74 | self.plotterObjList = [] |
|
74 | self.plotterObjList = [] | |
75 |
|
75 | |||
76 |
self.noiseObj = No |
|
76 | self.noiseObj = None | |
77 | self.buffer = None |
|
77 | self.buffer = None | |
78 | self.profIndex = 0 |
|
78 | self.profIndex = 0 | |
79 |
|
79 | |||
80 | def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairList=None): |
|
80 | def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairList=None): | |
81 |
|
81 | |||
82 | if dataInObj == None: |
|
82 | if dataInObj == None: | |
83 | raise ValueError, "" |
|
83 | raise ValueError, "" | |
84 |
|
84 | |||
85 | if nFFTPoints == None: |
|
85 | if nFFTPoints == None: | |
86 | raise ValueError, "" |
|
86 | raise ValueError, "" | |
87 |
|
87 | |||
88 | self.dataInObj = dataInObj |
|
88 | self.dataInObj = dataInObj | |
89 |
|
89 | |||
90 | if dataOutObj == None: |
|
90 | if dataOutObj == None: | |
91 | dataOutObj = Spectra() |
|
91 | dataOutObj = Spectra() | |
92 |
|
92 | |||
93 | self.dataOutObj = dataOutObj |
|
93 | self.dataOutObj = dataOutObj | |
94 | self.noiseObj = Noise() |
|
94 | self.noiseObj = Noise() | |
95 |
|
95 | |||
96 | ########################################## |
|
96 | ########################################## | |
97 | self.nFFTPoints = nFFTPoints |
|
97 | self.nFFTPoints = nFFTPoints | |
98 | self.nChannels = self.dataInObj.nChannels |
|
98 | self.nChannels = self.dataInObj.nChannels | |
99 | self.nHeights = self.dataInObj.nHeights |
|
99 | self.nHeights = self.dataInObj.nHeights | |
100 | self.pairList = pairList |
|
100 | self.pairList = pairList | |
101 | if pairList != None: |
|
101 | if pairList != None: | |
102 | self.nPairs = len(pairList) |
|
102 | self.nPairs = len(pairList) | |
103 | else: |
|
103 | else: | |
104 | self.nPairs = 0 |
|
104 | self.nPairs = 0 | |
105 |
|
105 | |||
106 | self.dataOutObj.heightList = self.dataInObj.heightList |
|
106 | self.dataOutObj.heightList = self.dataInObj.heightList | |
107 | self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList |
|
107 | self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList | |
108 | self.dataOutObj.m_BasicHeader = self.dataInObj.m_BasicHeader.copy() |
|
108 | self.dataOutObj.m_BasicHeader = self.dataInObj.m_BasicHeader.copy() | |
109 | self.dataOutObj.m_ProcessingHeader = self.dataInObj.m_ProcessingHeader.copy() |
|
109 | self.dataOutObj.m_ProcessingHeader = self.dataInObj.m_ProcessingHeader.copy() | |
110 | self.dataOutObj.m_RadarControllerHeader = self.dataInObj.m_RadarControllerHeader.copy() |
|
110 | self.dataOutObj.m_RadarControllerHeader = self.dataInObj.m_RadarControllerHeader.copy() | |
111 | self.dataOutObj.m_SystemHeader = self.dataInObj.m_SystemHeader.copy() |
|
111 | self.dataOutObj.m_SystemHeader = self.dataInObj.m_SystemHeader.copy() | |
112 |
|
112 | |||
113 | self.dataOutObj.dataType = self.dataInObj.dataType |
|
113 | self.dataOutObj.dataType = self.dataInObj.dataType | |
114 | self.dataOutObj.nPairs = self.nPairs |
|
114 | self.dataOutObj.nPairs = self.nPairs | |
115 | self.dataOutObj.nChannels = self.nChannels |
|
115 | self.dataOutObj.nChannels = self.nChannels | |
116 | self.dataOutObj.nProfiles = self.nFFTPoints |
|
116 | self.dataOutObj.nProfiles = self.nFFTPoints | |
117 | self.dataOutObj.nHeights = self.nHeights |
|
117 | self.dataOutObj.nHeights = self.nHeights | |
118 | self.dataOutObj.nFFTPoints = self.nFFTPoints |
|
118 | self.dataOutObj.nFFTPoints = self.nFFTPoints | |
119 | #self.dataOutObj.data = None |
|
119 | #self.dataOutObj.data = None | |
120 |
|
120 | |||
121 | self.dataOutObj.m_SystemHeader.numChannels = self.nChannels |
|
121 | self.dataOutObj.m_SystemHeader.numChannels = self.nChannels | |
122 | self.dataOutObj.m_SystemHeader.nProfiles = self.nFFTPoints |
|
122 | self.dataOutObj.m_SystemHeader.nProfiles = self.nFFTPoints | |
123 |
|
123 | |||
124 | self.dataOutObj.m_ProcessingHeader.totalSpectra = self.nChannels + self.nPairs |
|
124 | self.dataOutObj.m_ProcessingHeader.totalSpectra = self.nChannels + self.nPairs | |
125 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock = self.nFFTPoints |
|
125 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock = self.nFFTPoints | |
126 | self.dataOutObj.m_ProcessingHeader.numHeights = self.nHeights |
|
126 | self.dataOutObj.m_ProcessingHeader.numHeights = self.nHeights | |
127 | self.dataOutObj.m_ProcessingHeader.shif_fft = True |
|
127 | self.dataOutObj.m_ProcessingHeader.shif_fft = True | |
128 |
|
128 | |||
129 | spectraComb = numpy.zeros( (self.nChannels+self.nPairs)*2,numpy.dtype('u1')) |
|
129 | spectraComb = numpy.zeros( (self.nChannels+self.nPairs)*2,numpy.dtype('u1')) | |
130 | k = 0 |
|
130 | k = 0 | |
131 | for i in range( 0,self.nChannels*2,2 ): |
|
131 | for i in range( 0,self.nChannels*2,2 ): | |
132 | spectraComb[i] = k |
|
132 | spectraComb[i] = k | |
133 | spectraComb[i+1] = k |
|
133 | spectraComb[i+1] = k | |
134 | k += 1 |
|
134 | k += 1 | |
135 |
|
135 | |||
136 | k *= 2 |
|
136 | k *= 2 | |
137 |
|
137 | |||
138 | if self.pairList != None: |
|
138 | if self.pairList != None: | |
139 |
|
139 | |||
140 | for pair in self.pairList: |
|
140 | for pair in self.pairList: | |
141 | spectraComb[k] = pair[0] |
|
141 | spectraComb[k] = pair[0] | |
142 | spectraComb[k+1] = pair[1] |
|
142 | spectraComb[k+1] = pair[1] | |
143 | k += 2 |
|
143 | k += 2 | |
144 |
|
144 | |||
145 | self.dataOutObj.m_ProcessingHeader.spectraComb = spectraComb |
|
145 | self.dataOutObj.m_ProcessingHeader.spectraComb = spectraComb | |
146 |
|
146 | |||
147 | return self.dataOutObj |
|
147 | return self.dataOutObj | |
148 |
|
148 | |||
149 | def init(self): |
|
149 | def init(self): | |
150 |
|
150 | |||
151 | self.integratorObjIndex = 0 |
|
151 | self.integratorObjIndex = 0 | |
152 | self.decoderObjIndex = 0 |
|
152 | self.decoderObjIndex = 0 | |
153 | self.writerObjIndex = 0 |
|
153 | self.writerObjIndex = 0 | |
154 | self.plotterObjIndex = 0 |
|
154 | self.plotterObjIndex = 0 | |
155 |
|
155 | |||
156 | if self.dataInObj.type == "Voltage": |
|
156 | if self.dataInObj.type == "Voltage": | |
157 |
|
157 | |||
158 | if self.buffer == None: |
|
158 | if self.buffer == None: | |
159 | self.buffer = numpy.zeros((self.nChannels, |
|
159 | self.buffer = numpy.zeros((self.nChannels, | |
160 | self.nFFTPoints, |
|
160 | self.nFFTPoints, | |
161 | self.nHeights), |
|
161 | self.nHeights), | |
162 | dtype='complex') |
|
162 | dtype='complex') | |
163 |
|
163 | |||
164 | self.buffer[:,self.profIndex,:] = self.dataInObj.data |
|
164 | self.buffer[:,self.profIndex,:] = self.dataInObj.data | |
165 | self.profIndex += 1 |
|
165 | self.profIndex += 1 | |
166 |
|
166 | |||
167 | if self.profIndex == self.nFFTPoints: |
|
167 | if self.profIndex == self.nFFTPoints: | |
168 | self.__getFft() |
|
168 | self.__getFft() | |
169 | self.dataOutObj.flagNoData = False |
|
169 | self.dataOutObj.flagNoData = False | |
170 |
|
170 | |||
171 | self.buffer = None |
|
171 | self.buffer = None | |
172 | self.profIndex = 0 |
|
172 | self.profIndex = 0 | |
173 | return |
|
173 | return | |
174 |
|
174 | |||
175 | self.dataOutObj.flagNoData = True |
|
175 | self.dataOutObj.flagNoData = True | |
176 |
|
176 | |||
177 | return |
|
177 | return | |
178 |
|
178 | |||
179 | #Other kind of data |
|
179 | #Other kind of data | |
180 | if self.dataInObj.type == "Spectra": |
|
180 | if self.dataInObj.type == "Spectra": | |
181 | self.dataOutObj.copy(self.dataInObj) |
|
181 | self.dataOutObj.copy(self.dataInObj) | |
182 | self.dataOutObj.flagNoData = False |
|
182 | self.dataOutObj.flagNoData = False | |
183 | return |
|
183 | return | |
184 |
|
184 | |||
185 | raise ValueError, "The datatype is not valid" |
|
185 | raise ValueError, "The datatype is not valid" | |
186 |
|
186 | |||
187 | def __getFft(self): |
|
187 | def __getFft(self): | |
188 | """ |
|
188 | """ | |
189 | Convierte valores de Voltaje a Spectra |
|
189 | Convierte valores de Voltaje a Spectra | |
190 |
|
190 | |||
191 | Affected: |
|
191 | Affected: | |
192 | self.dataOutObj.data_spc |
|
192 | self.dataOutObj.data_spc | |
193 | self.dataOutObj.data_cspc |
|
193 | self.dataOutObj.data_cspc | |
194 | self.dataOutObj.data_dc |
|
194 | self.dataOutObj.data_dc | |
195 | self.dataOutObj.heightList |
|
195 | self.dataOutObj.heightList | |
196 | self.dataOutObj.m_BasicHeader |
|
196 | self.dataOutObj.m_BasicHeader | |
197 | self.dataOutObj.m_ProcessingHeader |
|
197 | self.dataOutObj.m_ProcessingHeader | |
198 | self.dataOutObj.m_RadarControllerHeader |
|
198 | self.dataOutObj.m_RadarControllerHeader | |
199 | self.dataOutObj.m_SystemHeader |
|
199 | self.dataOutObj.m_SystemHeader | |
200 | self.profIndex |
|
200 | self.profIndex | |
201 | self.buffer |
|
201 | self.buffer | |
202 | self.dataOutObj.flagNoData |
|
202 | self.dataOutObj.flagNoData | |
203 | self.dataOutObj.dataType |
|
203 | self.dataOutObj.dataType | |
204 | self.dataOutObj.nPairs |
|
204 | self.dataOutObj.nPairs | |
205 | self.dataOutObj.nChannels |
|
205 | self.dataOutObj.nChannels | |
206 | self.dataOutObj.nProfiles |
|
206 | self.dataOutObj.nProfiles | |
207 | self.dataOutObj.m_SystemHeader.numChannels |
|
207 | self.dataOutObj.m_SystemHeader.numChannels | |
208 | self.dataOutObj.m_ProcessingHeader.totalSpectra |
|
208 | self.dataOutObj.m_ProcessingHeader.totalSpectra | |
209 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock |
|
209 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock | |
210 | self.dataOutObj.m_ProcessingHeader.numHeights |
|
210 | self.dataOutObj.m_ProcessingHeader.numHeights | |
211 | self.dataOutObj.m_ProcessingHeader.spectraComb |
|
211 | self.dataOutObj.m_ProcessingHeader.spectraComb | |
212 | self.dataOutObj.m_ProcessingHeader.shif_fft |
|
212 | self.dataOutObj.m_ProcessingHeader.shif_fft | |
213 | """ |
|
213 | """ | |
214 |
|
214 | |||
215 | if self.dataInObj.flagNoData: |
|
215 | if self.dataInObj.flagNoData: | |
216 | return 0 |
|
216 | return 0 | |
217 |
|
217 | |||
218 | fft_volt = numpy.fft.fft(self.buffer,axis=1) |
|
218 | fft_volt = numpy.fft.fft(self.buffer,axis=1) | |
219 | dc = fft_volt[:,0,:] |
|
219 | dc = fft_volt[:,0,:] | |
220 |
|
220 | |||
221 | #calculo de self-spectra |
|
221 | #calculo de self-spectra | |
222 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) |
|
222 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) | |
223 | spc = fft_volt * numpy.conjugate(fft_volt) |
|
223 | spc = fft_volt * numpy.conjugate(fft_volt) | |
224 | spc = spc.real |
|
224 | spc = spc.real | |
225 |
|
225 | |||
226 | blocksize = 0 |
|
226 | blocksize = 0 | |
227 | blocksize += dc.size |
|
227 | blocksize += dc.size | |
228 | blocksize += spc.size |
|
228 | blocksize += spc.size | |
229 |
|
229 | |||
230 | cspc = None |
|
230 | cspc = None | |
231 | pairIndex = 0 |
|
231 | pairIndex = 0 | |
232 | if self.pairList != None: |
|
232 | if self.pairList != None: | |
233 | #calculo de cross-spectra |
|
233 | #calculo de cross-spectra | |
234 | cspc = numpy.zeros((self.nPairs, self.nFFTPoints, self.nHeights), dtype='complex') |
|
234 | cspc = numpy.zeros((self.nPairs, self.nFFTPoints, self.nHeights), dtype='complex') | |
235 | for pair in self.pairList: |
|
235 | for pair in self.pairList: | |
236 | cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])) |
|
236 | cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])) | |
237 | pairIndex += 1 |
|
237 | pairIndex += 1 | |
238 | blocksize += cspc.size |
|
238 | blocksize += cspc.size | |
239 |
|
239 | |||
240 | self.dataOutObj.data_spc = spc |
|
240 | self.dataOutObj.data_spc = spc | |
241 | self.dataOutObj.data_cspc = cspc |
|
241 | self.dataOutObj.data_cspc = cspc | |
242 | self.dataOutObj.data_dc = dc |
|
242 | self.dataOutObj.data_dc = dc | |
243 | self.dataOutObj.m_ProcessingHeader.blockSize = blocksize |
|
243 | self.dataOutObj.m_ProcessingHeader.blockSize = blocksize | |
244 | self.dataOutObj.m_BasicHeader.utc = self.dataInObj.m_BasicHeader.utc |
|
244 | self.dataOutObj.m_BasicHeader.utc = self.dataInObj.m_BasicHeader.utc | |
245 |
|
245 | |||
246 | # self.getNoise() |
|
246 | # self.getNoise() | |
247 |
|
247 | |||
248 | def addWriter(self,wrpath): |
|
248 | def addWriter(self,wrpath): | |
249 | objWriter = SpectraWriter(self.dataOutObj) |
|
249 | objWriter = SpectraWriter(self.dataOutObj) | |
250 | objWriter.setup(wrpath) |
|
250 | objWriter.setup(wrpath) | |
251 | self.writerObjList.append(objWriter) |
|
251 | self.writerObjList.append(objWriter) | |
252 |
|
252 | |||
253 | def addPlotter(self,index=None): |
|
253 | def addPlotter(self,index=None): | |
254 | if index==None: |
|
254 | if index==None: | |
255 | index = self.plotterObjIndex |
|
255 | index = self.plotterObjIndex | |
256 |
|
256 | |||
257 | plotObj = Spectrum(self.dataOutObj, index) |
|
257 | plotObj = Spectrum(self.dataOutObj, index) | |
258 | self.plotterObjList.append(plotObj) |
|
258 | self.plotterObjList.append(plotObj) | |
259 |
|
259 | |||
260 | def addIntegrator(self,N,timeInterval): |
|
260 | def addIntegrator(self,N,timeInterval): | |
261 |
|
261 | |||
262 | objIncohInt = IncoherentIntegration(N,timeInterval) |
|
262 | objIncohInt = IncoherentIntegration(N,timeInterval) | |
263 | self.integratorObjList.append(objIncohInt) |
|
263 | self.integratorObjList.append(objIncohInt) | |
264 |
|
264 | |||
265 | def writeData(self, wrpath): |
|
265 | def writeData(self, wrpath): | |
266 | if self.dataOutObj.flagNoData: |
|
266 | if self.dataOutObj.flagNoData: | |
267 | return 0 |
|
267 | return 0 | |
268 |
|
268 | |||
269 | if len(self.writerObjList) <= self.writerObjIndex: |
|
269 | if len(self.writerObjList) <= self.writerObjIndex: | |
270 | self.addWriter(wrpath) |
|
270 | self.addWriter(wrpath) | |
271 |
|
271 | |||
272 | self.writerObjList[self.writerObjIndex].putData() |
|
272 | self.writerObjList[self.writerObjIndex].putData() | |
273 |
|
273 | |||
274 | self.writerObjIndex += 1 |
|
274 | self.writerObjIndex += 1 | |
275 |
|
275 | |||
276 | def plotData(self, |
|
276 | def plotData(self, | |
277 | xmin=None, |
|
277 | xmin=None, | |
278 | xmax=None, |
|
278 | xmax=None, | |
279 | ymin=None, |
|
279 | ymin=None, | |
280 | ymax=None, |
|
280 | ymax=None, | |
281 | zmin=None, |
|
281 | zmin=None, | |
282 | zmax=None, |
|
282 | zmax=None, | |
283 | titleList=None, |
|
283 | titleList=None, | |
284 | xlabelList=None, |
|
284 | xlabelList=None, | |
285 | ylabelList=None, |
|
285 | ylabelList=None, | |
286 | winTitle='', |
|
286 | winTitle='', | |
287 | colormap="br_green", |
|
287 | colormap="br_green", | |
288 | showColorbar=False, |
|
288 | showColorbar=False, | |
289 | showPowerProfile=False, |
|
289 | showPowerProfile=False, | |
290 | XAxisAsTime=False, |
|
290 | XAxisAsTime=False, | |
291 | save=False, |
|
291 | save=False, | |
292 | index=None, |
|
292 | index=None, | |
293 | channelList=[]): |
|
293 | channelList=[]): | |
294 |
|
294 | |||
295 | if self.dataOutObj.flagNoData: |
|
295 | if self.dataOutObj.flagNoData: | |
296 | return 0 |
|
296 | return 0 | |
297 |
|
297 | |||
298 | if len(self.plotterObjList) <= self.plotterObjIndex: |
|
298 | if len(self.plotterObjList) <= self.plotterObjIndex: | |
299 | self.addPlotter(index) |
|
299 | self.addPlotter(index) | |
300 |
|
300 | |||
301 | self.plotterObjList[self.plotterObjIndex].plotData(xmin, |
|
301 | self.plotterObjList[self.plotterObjIndex].plotData(xmin, | |
302 | xmax, |
|
302 | xmax, | |
303 | ymin, |
|
303 | ymin, | |
304 | ymax, |
|
304 | ymax, | |
305 | zmin, |
|
305 | zmin, | |
306 | zmax, |
|
306 | zmax, | |
307 | titleList, |
|
307 | titleList, | |
308 | xlabelList, |
|
308 | xlabelList, | |
309 | ylabelList, |
|
309 | ylabelList, | |
310 | winTitle, |
|
310 | winTitle, | |
311 | colormap, |
|
311 | colormap, | |
312 | showColorbar, |
|
312 | showColorbar, | |
313 | showPowerProfile, |
|
313 | showPowerProfile, | |
314 | XAxisAsTime, |
|
314 | XAxisAsTime, | |
315 | save, |
|
315 | save, | |
316 | channelList) |
|
316 | channelList) | |
317 |
|
317 | |||
318 | self.plotterObjIndex += 1 |
|
318 | self.plotterObjIndex += 1 | |
319 |
|
319 | |||
320 | def integrator(self, N=None, timeInterval=None): |
|
320 | def integrator(self, N=None, timeInterval=None): | |
321 |
|
321 | |||
322 | if self.dataOutObj.flagNoData: |
|
322 | if self.dataOutObj.flagNoData: | |
323 | return 0 |
|
323 | return 0 | |
324 |
|
324 | |||
325 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
325 | if len(self.integratorObjList) <= self.integratorObjIndex: | |
326 | self.addIntegrator(N,timeInterval) |
|
326 | self.addIntegrator(N,timeInterval) | |
327 |
|
327 | |||
328 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
328 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] | |
329 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc) |
|
329 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc) | |
330 |
|
330 | |||
331 | if myIncohIntObj.isReady: |
|
331 | if myIncohIntObj.isReady: | |
332 | self.dataOutObj.data_spc = myIncohIntObj.data |
|
332 | self.dataOutObj.data_spc = myIncohIntObj.data | |
333 | self.dataOutObj.nAvg = myIncohIntObj.navg |
|
333 | self.dataOutObj.nAvg = myIncohIntObj.navg | |
334 |
self.dataOutObj.m_ProcessingHeader.incoherentInt |
|
334 | self.dataOutObj.m_ProcessingHeader.incoherentInt = self.dataInObj.m_ProcessingHeader.incoherentInt*myIncohIntObj.navg | |
335 | #print "myIncohIntObj.navg: ",myIncohIntObj.navg |
|
335 | #print "myIncohIntObj.navg: ",myIncohIntObj.navg | |
336 | self.dataOutObj.flagNoData = False |
|
336 | self.dataOutObj.flagNoData = False | |
337 |
|
337 | |||
338 | """Calcular el ruido""" |
|
338 | """Calcular el ruido""" | |
339 | self.getNoise() |
|
339 | self.getNoise() | |
340 | else: |
|
340 | else: | |
341 | self.dataOutObj.flagNoData = True |
|
341 | self.dataOutObj.flagNoData = True | |
342 |
|
342 | |||
343 | self.integratorObjIndex += 1 |
|
343 | self.integratorObjIndex += 1 | |
344 |
|
344 | |||
345 |
|
345 | |||
346 |
|
346 | |||
347 | def removeDC(self, type): |
|
347 | def removeDC(self, type): | |
348 |
|
348 | |||
349 | if self.dataOutObj.flagNoData: |
|
349 | if self.dataOutObj.flagNoData: | |
350 | return 0 |
|
350 | return 0 | |
351 |
|
351 | |||
352 | def removeInterference(self): |
|
352 | def removeInterference(self): | |
353 |
|
353 | |||
354 | if self.dataOutObj.flagNoData: |
|
354 | if self.dataOutObj.flagNoData: | |
355 | return 0 |
|
355 | return 0 | |
356 |
|
356 | |||
357 | def removeSatellites(self): |
|
357 | def removeSatellites(self): | |
358 |
|
358 | |||
359 | if self.dataOutObj.flagNoData: |
|
359 | if self.dataOutObj.flagNoData: | |
360 | return 0 |
|
360 | return 0 | |
361 |
|
361 | |||
362 | def getNoise(self, type="hildebrand", parm=None): |
|
362 | def getNoise(self, type="hildebrand", parm=None): | |
363 |
|
363 | |||
364 | if parm == None: |
|
364 | if parm == None: | |
365 | parm =self.dataOutObj.m_ProcessingHeader.incoherentInt |
|
365 | parm =self.dataOutObj.m_ProcessingHeader.incoherentInt | |
366 |
|
366 | |||
367 | self.noiseObj.setNoise(self.dataOutObj.data_spc) |
|
367 | self.noiseObj.setNoise(self.dataOutObj.data_spc) | |
368 |
|
368 | |||
369 | if type == "hildebrand": |
|
369 | if type == "hildebrand": | |
370 | noise = self.noiseObj.byHildebrand(parm) |
|
370 | noise = self.noiseObj.byHildebrand(parm) | |
371 |
|
371 | |||
372 | if type == "window": |
|
372 | if type == "window": | |
373 | noise = self.noiseObj.byWindow(parm) |
|
373 | noise = self.noiseObj.byWindow(parm) | |
374 |
|
374 | |||
375 | if type == "sort": |
|
375 | if type == "sort": | |
376 | noise = self.noiseObj.bySort(parm) |
|
376 | noise = self.noiseObj.bySort(parm) | |
377 |
|
377 | |||
378 | self.dataOutObj.noise = noise |
|
378 | self.dataOutObj.noise = noise | |
379 | # print 10*numpy.log10(noise) |
|
379 | # print 10*numpy.log10(noise) | |
380 |
|
380 | |||
381 | def selectChannels(self, channelList, pairList=[]): |
|
381 | def selectChannels(self, channelList, pairList=[]): | |
382 |
|
382 | |||
383 | channelIndexList = [] |
|
383 | channelIndexList = [] | |
384 |
|
384 | |||
385 | for channel in channelList: |
|
385 | for channel in channelList: | |
386 | if channel in self.dataOutObj.channelList: |
|
386 | if channel in self.dataOutObj.channelList: | |
387 | index = self.dataOutObj.channelList.index(channel) |
|
387 | index = self.dataOutObj.channelList.index(channel) | |
388 | channelIndexList.append(index) |
|
388 | channelIndexList.append(index) | |
389 |
|
389 | |||
390 | pairIndexList = [] |
|
390 | pairIndexList = [] | |
391 |
|
391 | |||
392 | for pair in pairList: |
|
392 | for pair in pairList: | |
393 | if pair in self.dataOutObj.pairList: |
|
393 | if pair in self.dataOutObj.pairList: | |
394 | index = self.dataOutObj.pairList.index(pair) |
|
394 | index = self.dataOutObj.pairList.index(pair) | |
395 | pairIndexList.append(index) |
|
395 | pairIndexList.append(index) | |
396 |
|
396 | |||
397 | self.selectChannelsByIndex(channelIndexList, pairIndexList) |
|
397 | self.selectChannelsByIndex(channelIndexList, pairIndexList) | |
398 |
|
398 | |||
399 | def selectChannelsByIndex(self, channelIndexList, pairIndexList=[]): |
|
399 | def selectChannelsByIndex(self, channelIndexList, pairIndexList=[]): | |
400 | """ |
|
400 | """ | |
401 | Selecciona un bloque de datos en base a canales y pares segun el |
|
401 | Selecciona un bloque de datos en base a canales y pares segun el | |
402 | channelIndexList y el pairIndexList |
|
402 | channelIndexList y el pairIndexList | |
403 |
|
403 | |||
404 | Input: |
|
404 | Input: | |
405 | channelIndexList : lista de indices de los canales a seleccionar por ej. |
|
405 | channelIndexList : lista de indices de los canales a seleccionar por ej. | |
406 |
|
406 | |||
407 | Si tenemos los canales |
|
407 | Si tenemos los canales | |
408 |
|
408 | |||
409 | self.channelList = (2,3,5,7) |
|
409 | self.channelList = (2,3,5,7) | |
410 |
|
410 | |||
411 | y deseamos escoger los canales (3,7) |
|
411 | y deseamos escoger los canales (3,7) | |
412 | entonces colocaremos el parametro |
|
412 | entonces colocaremos el parametro | |
413 |
|
413 | |||
414 | channelndexList = (1,3) |
|
414 | channelndexList = (1,3) | |
415 |
|
415 | |||
416 | pairIndexList : tupla de indice depares que se desea selecionar por ej. |
|
416 | pairIndexList : tupla de indice depares que se desea selecionar por ej. | |
417 |
|
417 | |||
418 | Si tenemos los pares : |
|
418 | Si tenemos los pares : | |
419 |
|
419 | |||
420 | ( (0,1), (0,2), (1,3), (2,5) ) |
|
420 | ( (0,1), (0,2), (1,3), (2,5) ) | |
421 |
|
421 | |||
422 | y deseamos seleccionar los pares ((0,2), (2,5)) |
|
422 | y deseamos seleccionar los pares ((0,2), (2,5)) | |
423 | entonces colocaremos el parametro |
|
423 | entonces colocaremos el parametro | |
424 |
|
424 | |||
425 | pairIndexList = (1,3) |
|
425 | pairIndexList = (1,3) | |
426 |
|
426 | |||
427 | Affected: |
|
427 | Affected: | |
428 | self.dataOutObj.data_spc |
|
428 | self.dataOutObj.data_spc | |
429 | self.dataOutObj.data_cspc |
|
429 | self.dataOutObj.data_cspc | |
430 | self.dataOutObj.data_dc |
|
430 | self.dataOutObj.data_dc | |
431 | self.dataOutObj.nChannels |
|
431 | self.dataOutObj.nChannels | |
432 | self.dataOutObj.nPairs |
|
432 | self.dataOutObj.nPairs | |
433 | self.dataOutObj.m_ProcessingHeader.spectraComb |
|
433 | self.dataOutObj.m_ProcessingHeader.spectraComb | |
434 | self.dataOutObj.m_SystemHeader.numChannels |
|
434 | self.dataOutObj.m_SystemHeader.numChannels | |
435 |
|
435 | |||
436 | self.dataOutObj.noise |
|
436 | self.dataOutObj.noise | |
437 | Return: |
|
437 | Return: | |
438 | None |
|
438 | None | |
439 | """ |
|
439 | """ | |
440 |
|
440 | |||
441 | if self.dataOutObj.flagNoData: |
|
441 | if self.dataOutObj.flagNoData: | |
442 | return 0 |
|
442 | return 0 | |
443 |
|
443 | |||
444 | if pairIndexList == []: |
|
444 | if pairIndexList == []: | |
445 | pairIndexList = numpy.arange(len(self.dataOutObj.pairList)) |
|
445 | pairIndexList = numpy.arange(len(self.dataOutObj.pairList)) | |
446 |
|
446 | |||
447 | nChannels = len(channelIndexList) |
|
447 | nChannels = len(channelIndexList) | |
448 | nPairs = len(pairIndexList) |
|
448 | nPairs = len(pairIndexList) | |
449 |
|
449 | |||
450 | blocksize = 0 |
|
450 | blocksize = 0 | |
451 | #self spectra |
|
451 | #self spectra | |
452 | spc = self.dataOutObj.data_spc[channelIndexList,:,:] |
|
452 | spc = self.dataOutObj.data_spc[channelIndexList,:,:] | |
453 | blocksize += spc.size |
|
453 | blocksize += spc.size | |
454 |
|
454 | |||
455 | cspc = None |
|
455 | cspc = None | |
456 | if pairIndexList != []: |
|
456 | if pairIndexList != []: | |
457 | cspc = self.dataOutObj.data_cspc[pairIndexList,:,:] |
|
457 | cspc = self.dataOutObj.data_cspc[pairIndexList,:,:] | |
458 | blocksize += cspc.size |
|
458 | blocksize += cspc.size | |
459 |
|
459 | |||
460 | #DC channel |
|
460 | #DC channel | |
461 | dc = None |
|
461 | dc = None | |
462 | if self.dataOutObj.m_ProcessingHeader.flag_dc: |
|
462 | if self.dataOutObj.m_ProcessingHeader.flag_dc: | |
463 | dc = self.dataOutObj.data_dc[channelIndexList,:] |
|
463 | dc = self.dataOutObj.data_dc[channelIndexList,:] | |
464 | blocksize += dc.size |
|
464 | blocksize += dc.size | |
465 |
|
465 | |||
466 | #Almacenar las combinaciones de canales y cros espectros |
|
466 | #Almacenar las combinaciones de canales y cros espectros | |
467 |
|
467 | |||
468 | spectraComb = numpy.zeros( (nChannels+nPairs)*2,numpy.dtype('u1')) |
|
468 | spectraComb = numpy.zeros( (nChannels+nPairs)*2,numpy.dtype('u1')) | |
469 | i = 0 |
|
469 | i = 0 | |
470 | for spcChannel in channelIndexList: |
|
470 | for spcChannel in channelIndexList: | |
471 | spectraComb[i] = spcChannel |
|
471 | spectraComb[i] = spcChannel | |
472 | spectraComb[i+1] = spcChannel |
|
472 | spectraComb[i+1] = spcChannel | |
473 | i += 2 |
|
473 | i += 2 | |
474 |
|
474 | |||
475 | if pairList != None: |
|
475 | if pairList != None: | |
476 | for pair in pairList: |
|
476 | for pair in pairList: | |
477 | spectraComb[i] = pair[0] |
|
477 | spectraComb[i] = pair[0] | |
478 | spectraComb[i+1] = pair[1] |
|
478 | spectraComb[i+1] = pair[1] | |
479 | i += 2 |
|
479 | i += 2 | |
480 |
|
480 | |||
481 | ####### |
|
481 | ####### | |
482 |
|
482 | |||
483 | self.dataOutObj.data_spc = spc |
|
483 | self.dataOutObj.data_spc = spc | |
484 | self.dataOutObj.data_cspc = cspc |
|
484 | self.dataOutObj.data_cspc = cspc | |
485 | self.dataOutObj.data_dc = dc |
|
485 | self.dataOutObj.data_dc = dc | |
486 | self.dataOutObj.nChannels = nChannels |
|
486 | self.dataOutObj.nChannels = nChannels | |
487 | self.dataOutObj.nPairs = nPairs |
|
487 | self.dataOutObj.nPairs = nPairs | |
488 |
|
488 | |||
489 | self.dataOutObj.channelIndexList = channelIndexList |
|
489 | self.dataOutObj.channelIndexList = channelIndexList | |
490 |
|
490 | |||
491 | self.dataOutObj.m_ProcessingHeader.spectraComb = spectraComb |
|
491 | self.dataOutObj.m_ProcessingHeader.spectraComb = spectraComb | |
492 | self.dataOutObj.m_ProcessingHeader.totalSpectra = nChannels + nPairs |
|
492 | self.dataOutObj.m_ProcessingHeader.totalSpectra = nChannels + nPairs | |
493 | self.dataOutObj.m_SystemHeader.numChannels = nChannels |
|
493 | self.dataOutObj.m_SystemHeader.numChannels = nChannels | |
494 | self.dataOutObj.nChannels = nChannels |
|
494 | self.dataOutObj.nChannels = nChannels | |
495 | self.dataOutObj.m_ProcessingHeader.blockSize = blocksize |
|
495 | self.dataOutObj.m_ProcessingHeader.blockSize = blocksize | |
496 |
|
496 | |||
497 | if cspc == None: |
|
497 | if cspc == None: | |
498 | self.dataOutObj.m_ProcessingHeader.flag_dc = False |
|
498 | self.dataOutObj.m_ProcessingHeader.flag_dc = False | |
499 | if dc == None: |
|
499 | if dc == None: | |
500 | self.dataOutObj.m_ProcessingHeader.flag_cpsc = False |
|
500 | self.dataOutObj.m_ProcessingHeader.flag_cpsc = False | |
501 |
|
501 | |||
502 | def selectHeightsByValue(self, minHei, maxHei): |
|
502 | def selectHeightsByValue(self, minHei, maxHei): | |
503 | """ |
|
503 | """ | |
504 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango |
|
504 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango | |
505 | minHei <= height <= maxHei |
|
505 | minHei <= height <= maxHei | |
506 |
|
506 | |||
507 | Input: |
|
507 | Input: | |
508 | minHei : valor minimo de altura a considerar |
|
508 | minHei : valor minimo de altura a considerar | |
509 | maxHei : valor maximo de altura a considerar |
|
509 | maxHei : valor maximo de altura a considerar | |
510 |
|
510 | |||
511 | Affected: |
|
511 | Affected: | |
512 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex |
|
512 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex | |
513 |
|
513 | |||
514 | Return: |
|
514 | Return: | |
515 | None |
|
515 | None | |
516 | """ |
|
516 | """ | |
517 |
|
517 | |||
518 | if self.dataOutObj.flagNoData: |
|
518 | if self.dataOutObj.flagNoData: | |
519 | return 0 |
|
519 | return 0 | |
520 |
|
520 | |||
521 | if (minHei < self.dataOutObj.heightList[0]) or (minHei > maxHei): |
|
521 | if (minHei < self.dataOutObj.heightList[0]) or (minHei > maxHei): | |
522 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) |
|
522 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) | |
523 |
|
523 | |||
524 | if (maxHei > self.dataOutObj.heightList[-1]): |
|
524 | if (maxHei > self.dataOutObj.heightList[-1]): | |
525 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) |
|
525 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) | |
526 |
|
526 | |||
527 | minIndex = 0 |
|
527 | minIndex = 0 | |
528 | maxIndex = 0 |
|
528 | maxIndex = 0 | |
529 | data = self.dataOutObj.heightList |
|
529 | data = self.dataOutObj.heightList | |
530 |
|
530 | |||
531 | for i,val in enumerate(data): |
|
531 | for i,val in enumerate(data): | |
532 | if val < minHei: |
|
532 | if val < minHei: | |
533 | continue |
|
533 | continue | |
534 | else: |
|
534 | else: | |
535 | minIndex = i; |
|
535 | minIndex = i; | |
536 | break |
|
536 | break | |
537 |
|
537 | |||
538 | for i,val in enumerate(data): |
|
538 | for i,val in enumerate(data): | |
539 | if val <= maxHei: |
|
539 | if val <= maxHei: | |
540 | maxIndex = i; |
|
540 | maxIndex = i; | |
541 | else: |
|
541 | else: | |
542 | break |
|
542 | break | |
543 |
|
543 | |||
544 | self.selectHeightsByIndex(minIndex, maxIndex) |
|
544 | self.selectHeightsByIndex(minIndex, maxIndex) | |
545 |
|
545 | |||
546 | def selectHeightsByIndex(self, minIndex, maxIndex): |
|
546 | def selectHeightsByIndex(self, minIndex, maxIndex): | |
547 | """ |
|
547 | """ | |
548 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango |
|
548 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango | |
549 | minIndex <= index <= maxIndex |
|
549 | minIndex <= index <= maxIndex | |
550 |
|
550 | |||
551 | Input: |
|
551 | Input: | |
552 | minIndex : valor minimo de altura a considerar |
|
552 | minIndex : valor minimo de altura a considerar | |
553 | maxIndex : valor maximo de altura a considerar |
|
553 | maxIndex : valor maximo de altura a considerar | |
554 |
|
554 | |||
555 | Affected: |
|
555 | Affected: | |
556 | self.dataOutObj.data_spc |
|
556 | self.dataOutObj.data_spc | |
557 | self.dataOutObj.data_cspc |
|
557 | self.dataOutObj.data_cspc | |
558 | self.dataOutObj.data_dc |
|
558 | self.dataOutObj.data_dc | |
559 | self.dataOutObj.heightList |
|
559 | self.dataOutObj.heightList | |
560 | self.dataOutObj.nHeights |
|
560 | self.dataOutObj.nHeights | |
561 | self.dataOutObj.m_ProcessingHeader.numHeights |
|
561 | self.dataOutObj.m_ProcessingHeader.numHeights | |
562 | self.dataOutObj.m_ProcessingHeader.blockSize |
|
562 | self.dataOutObj.m_ProcessingHeader.blockSize | |
563 | self.dataOutObj.m_ProcessingHeader.firstHeight |
|
563 | self.dataOutObj.m_ProcessingHeader.firstHeight | |
564 | self.dataOutObj.m_RadarControllerHeader.numHeights |
|
564 | self.dataOutObj.m_RadarControllerHeader.numHeights | |
565 |
|
565 | |||
566 | Return: |
|
566 | Return: | |
567 | None |
|
567 | None | |
568 | """ |
|
568 | """ | |
569 |
|
569 | |||
570 | if self.dataOutObj.flagNoData: |
|
570 | if self.dataOutObj.flagNoData: | |
571 | return 0 |
|
571 | return 0 | |
572 |
|
572 | |||
573 | if (minIndex < 0) or (minIndex > maxIndex): |
|
573 | if (minIndex < 0) or (minIndex > maxIndex): | |
574 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
574 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) | |
575 |
|
575 | |||
576 | if (maxIndex >= self.dataOutObj.nHeights): |
|
576 | if (maxIndex >= self.dataOutObj.nHeights): | |
577 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
577 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) | |
578 |
|
578 | |||
579 | nChannels = self.dataOutObj.nChannels |
|
579 | nChannels = self.dataOutObj.nChannels | |
580 | nPairs = self.dataOutObj.nPairs |
|
580 | nPairs = self.dataOutObj.nPairs | |
581 | nProfiles = self.dataOutObj.nProfiles |
|
581 | nProfiles = self.dataOutObj.nProfiles | |
582 | dataType = self.dataOutObj.dataType |
|
582 | dataType = self.dataOutObj.dataType | |
583 | nHeights = maxIndex - minIndex + 1 |
|
583 | nHeights = maxIndex - minIndex + 1 | |
584 | blockSize = 0 |
|
584 | blockSize = 0 | |
585 |
|
585 | |||
586 | #self spectra |
|
586 | #self spectra | |
587 | spc = self.dataOutObj.data_spc[:,:,minIndex:maxIndex+1] |
|
587 | spc = self.dataOutObj.data_spc[:,:,minIndex:maxIndex+1] | |
588 | blockSize += spc.size |
|
588 | blockSize += spc.size | |
589 |
|
589 | |||
590 | #cross spectra |
|
590 | #cross spectra | |
591 | cspc = None |
|
591 | cspc = None | |
592 | if self.dataOutObj.data_cspc != None: |
|
592 | if self.dataOutObj.data_cspc != None: | |
593 | cspc = self.dataOutObj.data_cspc[:,:,minIndex:maxIndex+1] |
|
593 | cspc = self.dataOutObj.data_cspc[:,:,minIndex:maxIndex+1] | |
594 | blockSize += cspc.size |
|
594 | blockSize += cspc.size | |
595 |
|
595 | |||
596 | #DC channel |
|
596 | #DC channel | |
597 | dc = self.dataOutObj.data_dc[:,minIndex:maxIndex+1] |
|
597 | dc = self.dataOutObj.data_dc[:,minIndex:maxIndex+1] | |
598 | blockSize += dc.size |
|
598 | blockSize += dc.size | |
599 |
|
599 | |||
600 | self.dataOutObj.data_spc = spc |
|
600 | self.dataOutObj.data_spc = spc | |
601 | if cspc != None: |
|
601 | if cspc != None: | |
602 | self.dataOutObj.data_cspc = cspc |
|
602 | self.dataOutObj.data_cspc = cspc | |
603 | self.dataOutObj.data_dc = dc |
|
603 | self.dataOutObj.data_dc = dc | |
604 |
|
604 | |||
605 | firstHeight = self.dataOutObj.heightList[minIndex] |
|
605 | firstHeight = self.dataOutObj.heightList[minIndex] | |
606 |
|
606 | |||
607 | self.dataOutObj.nHeights = nHeights |
|
607 | self.dataOutObj.nHeights = nHeights | |
608 | self.dataOutObj.m_ProcessingHeader.blockSize = blockSize |
|
608 | self.dataOutObj.m_ProcessingHeader.blockSize = blockSize | |
609 | self.dataOutObj.m_ProcessingHeader.numHeights = nHeights |
|
609 | self.dataOutObj.m_ProcessingHeader.numHeights = nHeights | |
610 | self.dataOutObj.m_ProcessingHeader.firstHeight = firstHeight |
|
610 | self.dataOutObj.m_ProcessingHeader.firstHeight = firstHeight | |
611 | self.dataOutObj.m_RadarControllerHeader.numHeights = nHeights |
|
611 | self.dataOutObj.m_RadarControllerHeader.numHeights = nHeights | |
612 |
|
612 | |||
613 | self.dataOutObj.heightList = self.dataOutObj.heightList[minIndex:maxIndex+1] |
|
613 | self.dataOutObj.heightList = self.dataOutObj.heightList[minIndex:maxIndex+1] | |
614 |
|
614 | |||
615 |
|
615 | |||
616 | class IncoherentIntegration: |
|
616 | class IncoherentIntegration: | |
617 |
|
617 | |||
618 | integ_counter = None |
|
618 | integ_counter = None | |
619 | data = None |
|
619 | data = None | |
620 | navg = None |
|
620 | navg = None | |
621 | buffer = None |
|
621 | buffer = None | |
622 | nIncohInt = None |
|
622 | nIncohInt = None | |
623 |
|
623 | |||
624 | def __init__(self, N = None, timeInterval = None): |
|
624 | def __init__(self, N = None, timeInterval = None): | |
625 | """ |
|
625 | """ | |
626 | N |
|
626 | N | |
627 | timeInterval - interval time [min], integer value |
|
627 | timeInterval - interval time [min], integer value | |
628 | """ |
|
628 | """ | |
629 |
|
629 | |||
630 | self.data = None |
|
630 | self.data = None | |
631 | self.navg = None |
|
631 | self.navg = None | |
632 | self.buffer = None |
|
632 | self.buffer = None | |
633 | self.timeOut = None |
|
633 | self.timeOut = None | |
634 | self.exitCondition = False |
|
634 | self.exitCondition = False | |
635 | self.isReady = False |
|
635 | self.isReady = False | |
636 | self.nIncohInt = N |
|
636 | self.nIncohInt = N | |
637 | self.integ_counter = 0 |
|
637 | self.integ_counter = 0 | |
638 | if timeInterval!=None: |
|
638 | if timeInterval!=None: | |
639 | self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line |
|
639 | self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line | |
640 |
|
640 | |||
641 | if ((timeInterval==None) and (N==None)): |
|
641 | if ((timeInterval==None) and (N==None)): | |
642 | print 'N = None ; timeInterval = None' |
|
642 | print 'N = None ; timeInterval = None' | |
643 | sys.exit(0) |
|
643 | sys.exit(0) | |
644 | elif timeInterval == None: |
|
644 | elif timeInterval == None: | |
645 | self.timeFlag = False |
|
645 | self.timeFlag = False | |
646 | else: |
|
646 | else: | |
647 | self.timeFlag = True |
|
647 | self.timeFlag = True | |
648 |
|
648 | |||
649 |
|
649 | |||
650 | def exe(self,data,timeOfData): |
|
650 | def exe(self,data,timeOfData): | |
651 | """ |
|
651 | """ | |
652 | data |
|
652 | data | |
653 |
|
653 | |||
654 | timeOfData [seconds] |
|
654 | timeOfData [seconds] | |
655 | """ |
|
655 | """ | |
656 |
|
656 | |||
657 | if self.timeFlag: |
|
657 | if self.timeFlag: | |
658 | if self.timeOut == None: |
|
658 | if self.timeOut == None: | |
659 | self.timeOut = timeOfData + self.timeIntervalInSeconds |
|
659 | self.timeOut = timeOfData + self.timeIntervalInSeconds | |
660 |
|
660 | |||
661 | if timeOfData < self.timeOut: |
|
661 | if timeOfData < self.timeOut: | |
662 | if self.buffer == None: |
|
662 | if self.buffer == None: | |
663 | self.buffer = data |
|
663 | self.buffer = data | |
664 | else: |
|
664 | else: | |
665 | self.buffer = self.buffer + data |
|
665 | self.buffer = self.buffer + data | |
666 | self.integ_counter += 1 |
|
666 | self.integ_counter += 1 | |
667 | else: |
|
667 | else: | |
668 | self.exitCondition = True |
|
668 | self.exitCondition = True | |
669 |
|
669 | |||
670 | else: |
|
670 | else: | |
671 | if self.integ_counter < self.nIncohInt: |
|
671 | if self.integ_counter < self.nIncohInt: | |
672 | if self.buffer == None: |
|
672 | if self.buffer == None: | |
673 | self.buffer = data |
|
673 | self.buffer = data | |
674 | else: |
|
674 | else: | |
675 | self.buffer = self.buffer + data |
|
675 | self.buffer = self.buffer + data | |
676 |
|
676 | |||
677 | self.integ_counter += 1 |
|
677 | self.integ_counter += 1 | |
678 |
|
678 | |||
679 | if self.integ_counter == self.nIncohInt: |
|
679 | if self.integ_counter == self.nIncohInt: | |
680 | self.exitCondition = True |
|
680 | self.exitCondition = True | |
681 |
|
681 | |||
682 | if self.exitCondition: |
|
682 | if self.exitCondition: | |
683 | self.data = self.buffer |
|
683 | self.data = self.buffer | |
684 | self.navg = self.integ_counter |
|
684 | self.navg = self.integ_counter | |
685 | self.isReady = True |
|
685 | self.isReady = True | |
686 | self.buffer = None |
|
686 | self.buffer = None | |
687 | self.timeOut = None |
|
687 | self.timeOut = None | |
688 | self.integ_counter = 0 |
|
688 | self.integ_counter = 0 | |
689 | self.exitCondition = False |
|
689 | self.exitCondition = False | |
690 |
|
690 | |||
691 | if self.timeFlag: |
|
691 | if self.timeFlag: | |
692 | self.buffer = data |
|
692 | self.buffer = data | |
693 | self.timeOut = timeOfData + self.timeIntervalInSeconds |
|
693 | self.timeOut = timeOfData + self.timeIntervalInSeconds | |
694 | else: |
|
694 | else: | |
695 | self.isReady = False |
|
695 | self.isReady = False | |
696 | No newline at end of file |
|
696 |
General Comments 0
You need to be logged in to leave comments.
Login now