@@ -1,377 +1,416 | |||||
1 | ''' |
|
1 | ''' | |
2 |
|
2 | |||
3 | $Author$ |
|
3 | $Author$ | |
4 | $Id$ |
|
4 | $Id$ | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import os |
|
7 | import os | |
8 | import sys |
|
8 | import sys | |
9 | import numpy |
|
9 | import numpy | |
10 | import datetime |
|
10 | import datetime | |
11 | import time |
|
11 | import time | |
12 |
|
12 | |||
13 | path = os.path.split(os.getcwd())[0] |
|
13 | path = os.path.split(os.getcwd())[0] | |
14 | sys.path.append(path) |
|
14 | sys.path.append(path) | |
15 |
|
15 | |||
16 | from Data.JROData import Voltage |
|
16 | from Data.JROData import Voltage | |
17 | from IO.VoltageIO import VoltageWriter |
|
17 | from IO.VoltageIO import VoltageWriter | |
18 | from Graphics.schainPlotTypes import ScopeFigure, RTIFigure |
|
18 | from Graphics.schainPlotTypes import ScopeFigure, RTIFigure | |
19 |
|
19 | |||
20 | class VoltageProcessor: |
|
20 | class VoltageProcessor: | |
21 |
|
21 | |||
22 | dataInObj = None |
|
22 | dataInObj = None | |
23 | dataOutObj = None |
|
23 | dataOutObj = None | |
24 | integratorObjIndex = None |
|
24 | integratorObjIndex = None | |
25 | writerObjIndex = None |
|
25 | writerObjIndex = None | |
26 | integratorObjList = None |
|
26 | integratorObjList = None | |
27 | writerObjList = None |
|
27 | writerObjList = None | |
28 |
|
28 | |||
29 | def __init__(self): |
|
29 | def __init__(self): | |
30 | self.integratorObjIndex = None |
|
30 | self.integratorObjIndex = None | |
31 | self.writerObjIndex = None |
|
31 | self.writerObjIndex = None | |
32 | self.plotObjIndex = None |
|
32 | self.plotObjIndex = None | |
33 | self.integratorObjList = [] |
|
33 | self.integratorObjList = [] | |
34 | self.writerObjList = [] |
|
34 | self.writerObjList = [] | |
35 | self.plotObjList = [] |
|
35 | self.plotObjList = [] | |
36 |
|
36 | |||
37 | def setup(self,dataInObj=None,dataOutObj=None): |
|
37 | def setup(self,dataInObj=None,dataOutObj=None): | |
38 | self.dataInObj = dataInObj |
|
38 | self.dataInObj = dataInObj | |
39 |
|
39 | |||
40 | if self.dataOutObj == None: |
|
40 | if self.dataOutObj == None: | |
41 | dataOutObj = Voltage() |
|
41 | dataOutObj = Voltage() | |
42 |
|
42 | |||
43 | self.dataOutObj = dataOutObj |
|
43 | self.dataOutObj = dataOutObj | |
44 |
|
44 | |||
45 | return self.dataOutObj |
|
45 | return self.dataOutObj | |
46 |
|
46 | |||
47 | def init(self): |
|
47 | def init(self): | |
48 | self.integratorObjIndex = 0 |
|
48 | self.integratorObjIndex = 0 | |
49 | self.writerObjIndex = 0 |
|
49 | self.writerObjIndex = 0 | |
50 | self.plotObjIndex = 0 |
|
50 | self.plotObjIndex = 0 | |
51 |
|
51 | |||
52 | if not(self.dataInObj.flagNoData): |
|
52 | if not(self.dataInObj.flagNoData): | |
53 | self.dataOutObj.copy(self.dataInObj) |
|
53 | self.dataOutObj.copy(self.dataInObj) | |
54 | # No necesita copiar en cada init() los atributos de dataInObj |
|
54 | # No necesita copiar en cada init() los atributos de dataInObj | |
55 | # la copia deberia hacerse por cada nuevo bloque de datos |
|
55 | # la copia deberia hacerse por cada nuevo bloque de datos | |
56 |
|
56 | |||
57 | def addRti(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): |
|
57 | def addRti(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): | |
58 | rtiObj = RTIFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
58 | rtiObj = RTIFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
59 | self.plotObjList.append(rtiObj) |
|
59 | self.plotObjList.append(rtiObj) | |
60 |
|
60 | |||
61 | def plotRti(self, idfigure=None, |
|
61 | def plotRti(self, idfigure=None, | |
62 | starttime=None, |
|
62 | starttime=None, | |
63 | endtime=None, |
|
63 | endtime=None, | |
64 | rangemin=None, |
|
64 | rangemin=None, | |
65 | rangemax=None, |
|
65 | rangemax=None, | |
66 | minvalue=None, |
|
66 | minvalue=None, | |
67 | maxvalue=None, |
|
67 | maxvalue=None, | |
68 | wintitle='', |
|
68 | wintitle='', | |
69 | driver='plplot', |
|
69 | driver='plplot', | |
70 | colormap='br_greeen', |
|
70 | colormap='br_greeen', | |
71 | colorbar=True, |
|
71 | colorbar=True, | |
72 | showprofile=False, |
|
72 | showprofile=False, | |
73 | xrangestep=None, |
|
73 | xrangestep=None, | |
74 | save=False, |
|
74 | save=False, | |
75 | gpath=None): |
|
75 | gpath=None): | |
76 |
|
76 | |||
77 | if self.dataOutObj.flagNoData: |
|
77 | if self.dataOutObj.flagNoData: | |
78 | return 0 |
|
78 | return 0 | |
79 |
|
79 | |||
80 | nframes = len(self.dataOutObj.channelList) |
|
80 | nframes = len(self.dataOutObj.channelList) | |
81 |
|
81 | |||
82 | if len(self.plotObjList) <= self.plotObjIndex: |
|
82 | if len(self.plotObjList) <= self.plotObjIndex: | |
83 | self.addRti(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
83 | self.addRti(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
84 |
|
84 | |||
85 | data = self.dataOutObj.data * numpy.conjugate(self.dataOutObj.data) |
|
85 | data = self.dataOutObj.data * numpy.conjugate(self.dataOutObj.data) | |
86 | data = 10*numpy.log10(data.real) |
|
86 | data = 10*numpy.log10(data.real) | |
87 |
|
87 | |||
88 | # currenttime = self.dataOutObj.utctime |
|
88 | # currenttime = self.dataOutObj.utctime | |
89 | # if timezone == "lt": |
|
89 | # if timezone == "lt": | |
90 | currenttime = self.dataOutObj.utctime - time.timezone |
|
90 | currenttime = self.dataOutObj.utctime - time.timezone | |
91 |
|
91 | |||
92 | range = self.dataOutObj.heightList |
|
92 | range = self.dataOutObj.heightList | |
93 |
|
93 | |||
94 | channelList = self.dataOutObj.channelList |
|
94 | channelList = self.dataOutObj.channelList | |
95 |
|
95 | |||
96 | thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) |
|
96 | thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) | |
97 | dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
97 | dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
98 | date = "%s"%(thisdatetime.strftime("%d-%b-%Y")) |
|
98 | date = "%s"%(thisdatetime.strftime("%d-%b-%Y")) | |
99 |
|
99 | print thisdatetime | ||
100 | figuretitle = "RTI Plot Radar Data" #+ date |
|
100 | figuretitle = "RTI Plot Radar Data" #+ date | |
101 |
|
101 | |||
102 | plotObj = self.plotObjList[self.plotObjIndex] |
|
102 | plotObj = self.plotObjList[self.plotObjIndex] | |
103 |
|
103 | |||
104 | cleardata = False |
|
104 | cleardata = False | |
105 |
|
105 | |||
106 | deltax = self.dataOutObj.timeInterval |
|
106 | deltax = self.dataOutObj.timeInterval | |
107 |
|
107 | |||
108 | plotObj.plotPcolor(data=data, |
|
108 | plotObj.plotPcolor(data=data, | |
109 | x=currenttime, |
|
109 | x=currenttime, | |
110 | y=range, |
|
110 | y=range, | |
111 | channelList=channelList, |
|
111 | channelList=channelList, | |
112 | xmin=starttime, |
|
112 | xmin=starttime, | |
113 | xmax=endtime, |
|
113 | xmax=endtime, | |
114 | ymin=rangemin, |
|
114 | ymin=rangemin, | |
115 | ymax=rangemax, |
|
115 | ymax=rangemax, | |
116 | minvalue=minvalue, |
|
116 | minvalue=minvalue, | |
117 | maxvalue=maxvalue, |
|
117 | maxvalue=maxvalue, | |
118 | figuretitle=figuretitle, |
|
118 | figuretitle=figuretitle, | |
119 | xrangestep=xrangestep, |
|
119 | xrangestep=xrangestep, | |
120 | deltax=deltax, |
|
120 | deltax=deltax, | |
121 | save=save, |
|
121 | save=save, | |
122 | gpath=gpath, |
|
122 | gpath=gpath, | |
123 | cleardata=cleardata) |
|
123 | cleardata=cleardata) | |
124 |
|
124 | |||
125 |
|
125 | |||
126 | self.plotObjIndex += 1 |
|
126 | self.plotObjIndex += 1 | |
127 |
|
127 | |||
128 | def addScope(self, idfigure, nframes, wintitle, driver): |
|
128 | def addScope(self, idfigure, nframes, wintitle, driver): | |
129 | if idfigure==None: |
|
129 | if idfigure==None: | |
130 | idfigure = self.plotObjIndex |
|
130 | idfigure = self.plotObjIndex | |
131 |
|
131 | |||
132 | scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver) |
|
132 | scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver) | |
133 | self.plotObjList.append(scopeObj) |
|
133 | self.plotObjList.append(scopeObj) | |
134 |
|
134 | |||
135 | def plotScope(self, |
|
135 | def plotScope(self, | |
136 | idfigure=None, |
|
136 | idfigure=None, | |
137 | minvalue=None, |
|
137 | minvalue=None, | |
138 | maxvalue=None, |
|
138 | maxvalue=None, | |
139 | xmin=None, |
|
139 | xmin=None, | |
140 | xmax=None, |
|
140 | xmax=None, | |
141 | wintitle='', |
|
141 | wintitle='', | |
142 | driver='plplot', |
|
142 | driver='plplot', | |
143 | save=False, |
|
143 | save=False, | |
144 | gpath=None, |
|
144 | gpath=None, | |
145 | titleList=None, |
|
145 | titleList=None, | |
146 | xlabelList=None, |
|
146 | xlabelList=None, | |
147 | ylabelList=None, |
|
147 | ylabelList=None, | |
148 | type="power"): |
|
148 | type="power"): | |
149 |
|
149 | |||
150 | if self.dataOutObj.flagNoData: |
|
150 | if self.dataOutObj.flagNoData: | |
151 | return 0 |
|
151 | return 0 | |
152 |
|
152 | |||
153 | nframes = len(self.dataOutObj.channelList) |
|
153 | nframes = len(self.dataOutObj.channelList) | |
154 |
|
154 | |||
155 | if len(self.plotObjList) <= self.plotObjIndex: |
|
155 | if len(self.plotObjList) <= self.plotObjIndex: | |
156 | self.addScope(idfigure, nframes, wintitle, driver) |
|
156 | self.addScope(idfigure, nframes, wintitle, driver) | |
157 |
|
157 | |||
158 |
|
158 | |||
159 | if type=="power": |
|
159 | if type=="power": | |
160 | data1D = self.dataOutObj.data * numpy.conjugate(self.dataOutObj.data) |
|
160 | data1D = self.dataOutObj.data * numpy.conjugate(self.dataOutObj.data) | |
161 | data1D = data1D.real |
|
161 | data1D = data1D.real | |
162 |
|
162 | |||
163 | if type =="iq": |
|
163 | if type =="iq": | |
164 | data1D = self.dataOutObj.data |
|
164 | data1D = self.dataOutObj.data | |
165 |
|
165 | |||
166 | thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) |
|
166 | thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) | |
167 |
|
167 | |||
168 | dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
168 | dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
169 | date = "%s"%(thisDatetime.strftime("%d-%b-%Y")) |
|
169 | date = "%s"%(thisDatetime.strftime("%d-%b-%Y")) | |
170 |
|
170 | |||
171 |
figure |
|
171 | figuretitle = "Scope Plot Radar Data: " + date | |
172 |
|
172 | |||
173 | plotObj = self.plotObjList[self.plotObjIndex] |
|
173 | plotObj = self.plotObjList[self.plotObjIndex] | |
174 |
|
174 | |||
175 | plotObj.plot1DArray(data1D=data1D, |
|
175 | plotObj.plot1DArray(data1D=data1D, | |
176 | x=self.dataOutObj.heightList, |
|
176 | x=self.dataOutObj.heightList, | |
177 | channelList=self.dataOutObj.channelList, |
|
177 | channelList=self.dataOutObj.channelList, | |
178 | xmin=xmin, |
|
178 | xmin=xmin, | |
179 | xmax=xmax, |
|
179 | xmax=xmax, | |
180 | minvalue=minvalue, |
|
180 | minvalue=minvalue, | |
181 | maxvalue=maxvalue, |
|
181 | maxvalue=maxvalue, | |
182 |
figure |
|
182 | figuretitle=figuretitle, | |
183 | save=save, |
|
183 | save=save, | |
184 | gpath=gpath) |
|
184 | gpath=gpath) | |
185 |
|
185 | |||
186 |
|
186 | |||
187 | self.plotObjIndex += 1 |
|
187 | self.plotObjIndex += 1 | |
188 |
|
188 | |||
189 |
|
189 | |||
190 | def addIntegrator(self, *args): |
|
190 | def addIntegrator(self, *args): | |
191 | objCohInt = CoherentIntegrator(*args) |
|
191 | objCohInt = CoherentIntegrator(*args) | |
192 | self.integratorObjList.append(objCohInt) |
|
192 | self.integratorObjList.append(objCohInt) | |
193 |
|
193 | |||
194 | def addWriter(self, *args): |
|
194 | def addWriter(self, *args): | |
195 | writerObj = VoltageWriter(self.dataOutObj) |
|
195 | writerObj = VoltageWriter(self.dataOutObj) | |
196 | writerObj.setup(*args) |
|
196 | writerObj.setup(*args) | |
197 | self.writerObjList.append(writerObj) |
|
197 | self.writerObjList.append(writerObj) | |
198 |
|
198 | |||
199 | def writeData(self, wrpath, blocksPerFile, profilesPerBlock): |
|
199 | def writeData(self, wrpath, blocksPerFile, profilesPerBlock): | |
200 |
|
200 | |||
201 | if self.dataOutObj.flagNoData: |
|
201 | if self.dataOutObj.flagNoData: | |
202 | return 0 |
|
202 | return 0 | |
203 |
|
203 | |||
204 | if len(self.writerObjList) <= self.writerObjIndex: |
|
204 | if len(self.writerObjList) <= self.writerObjIndex: | |
205 | self.addWriter(wrpath, blocksPerFile, profilesPerBlock) |
|
205 | self.addWriter(wrpath, blocksPerFile, profilesPerBlock) | |
206 |
|
206 | |||
207 | self.writerObjList[self.writerObjIndex].putData() |
|
207 | self.writerObjList[self.writerObjIndex].putData() | |
208 |
|
208 | |||
209 | self.writerObjIndex += 1 |
|
209 | self.writerObjIndex += 1 | |
210 |
|
210 | |||
211 | def integrator(self, nCohInt=None, timeInterval=None, overlapping=False): |
|
211 | def integrator(self, nCohInt=None, timeInterval=None, overlapping=False): | |
212 |
|
212 | |||
213 | if self.dataOutObj.flagNoData: |
|
213 | if self.dataOutObj.flagNoData: | |
214 | return 0 |
|
214 | return 0 | |
215 |
|
215 | |||
216 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
216 | if len(self.integratorObjList) <= self.integratorObjIndex: | |
217 | self.addIntegrator(nCohInt, timeInterval, overlapping) |
|
217 | self.addIntegrator(nCohInt, timeInterval, overlapping) | |
218 |
|
218 | |||
219 | myCohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
219 | myCohIntObj = self.integratorObjList[self.integratorObjIndex] | |
220 | myCohIntObj.exe(data = self.dataOutObj.data, datatime=None) |
|
220 | myCohIntObj.exe(data = self.dataOutObj.data, datatime=None) | |
221 |
|
221 | |||
|
222 | self.dataOutObj.timeInterval *= nCohInt | |||
222 | self.dataOutObj.flagNoData = True |
|
223 | self.dataOutObj.flagNoData = True | |
223 |
|
224 | |||
224 | if myCohIntObj.isReady: |
|
225 | if myCohIntObj.isReady: | |
225 | self.dataOutObj.flagNoData = False |
|
226 | self.dataOutObj.flagNoData = False | |
226 |
|
|
227 | ||
|
228 | def selectChannels(self, channelList): | |||
|
229 | ||||
|
230 | self.selectChannelsByIndex(channelList) | |||
|
231 | ||||
|
232 | def selectChannelsByIndex(self, channelIndexList): | |||
|
233 | """ | |||
|
234 | Selecciona un bloque de datos en base a canales segun el channelIndexList | |||
|
235 | ||||
|
236 | Input: | |||
|
237 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] | |||
|
238 | ||||
|
239 | Affected: | |||
|
240 | self.dataOutObj.data | |||
|
241 | self.dataOutObj.channelIndexList | |||
|
242 | self.dataOutObj.nChannels | |||
|
243 | self.dataOutObj.m_ProcessingHeader.totalSpectra | |||
|
244 | self.dataOutObj.systemHeaderObj.numChannels | |||
|
245 | self.dataOutObj.m_ProcessingHeader.blockSize | |||
|
246 | ||||
|
247 | Return: | |||
|
248 | None | |||
|
249 | """ | |||
|
250 | if self.dataOutObj.flagNoData: | |||
|
251 | return 0 | |||
|
252 | ||||
|
253 | for channel in channelIndexList: | |||
|
254 | if channel not in self.dataOutObj.channelIndexList: | |||
|
255 | raise ValueError, "The value %d in channelIndexList is not valid" %channel | |||
|
256 | ||||
|
257 | nChannels = len(channelIndexList) | |||
|
258 | ||||
|
259 | data = self.dataOutObj.data[channelIndexList,:] | |||
|
260 | ||||
|
261 | self.dataOutObj.data = data | |||
|
262 | self.dataOutObj.channelIndexList = channelIndexList | |||
|
263 | self.dataOutObj.channelList = [self.dataOutObj.channelList[i] for i in channelIndexList] | |||
|
264 | self.dataOutObj.nChannels = nChannels | |||
227 |
|
265 | |||
|
266 | return 1 | |||
228 |
|
267 | |||
229 | class CoherentIntegrator: |
|
268 | class CoherentIntegrator: | |
230 |
|
269 | |||
231 |
|
270 | |||
232 | __profIndex = 0 |
|
271 | __profIndex = 0 | |
233 | __withOverapping = False |
|
272 | __withOverapping = False | |
234 |
|
273 | |||
235 | __isByTime = False |
|
274 | __isByTime = False | |
236 | __initime = None |
|
275 | __initime = None | |
237 | __integrationtime = None |
|
276 | __integrationtime = None | |
238 |
|
277 | |||
239 | __buffer = None |
|
278 | __buffer = None | |
240 |
|
279 | |||
241 | isReady = False |
|
280 | isReady = False | |
242 | nCohInt = None |
|
281 | nCohInt = None | |
243 |
|
282 | |||
244 |
|
283 | |||
245 | def __init__(self, nCohInt=None, timeInterval=None, overlapping=False): |
|
284 | def __init__(self, nCohInt=None, timeInterval=None, overlapping=False): | |
246 |
|
285 | |||
247 | """ |
|
286 | """ | |
248 | Set the parameters of the integration class. |
|
287 | Set the parameters of the integration class. | |
249 |
|
288 | |||
250 | Inputs: |
|
289 | Inputs: | |
251 |
|
290 | |||
252 | nCohInt : Number of coherent integrations |
|
291 | nCohInt : Number of coherent integrations | |
253 | timeInterval : Time of integration. If nCohInt is selected this parameter does not work |
|
292 | timeInterval : Time of integration. If nCohInt is selected this parameter does not work | |
254 | overlapping : |
|
293 | overlapping : | |
255 |
|
294 | |||
256 | """ |
|
295 | """ | |
257 |
|
296 | |||
258 | self.__buffer = None |
|
297 | self.__buffer = None | |
259 | self.isReady = False |
|
298 | self.isReady = False | |
260 |
|
299 | |||
261 | if nCohInt == None and timeInterval == None: |
|
300 | if nCohInt == None and timeInterval == None: | |
262 | raise ValueError, "nCohInt or timeInterval should be specified ..." |
|
301 | raise ValueError, "nCohInt or timeInterval should be specified ..." | |
263 |
|
302 | |||
264 | if nCohInt != None: |
|
303 | if nCohInt != None: | |
265 | self.nCohInt = nCohInt |
|
304 | self.nCohInt = nCohInt | |
266 | self.__isByTime = False |
|
305 | self.__isByTime = False | |
267 | else: |
|
306 | else: | |
268 | self.__integrationtime = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line |
|
307 | self.__integrationtime = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line | |
269 | self.__isByTime = True |
|
308 | self.__isByTime = True | |
270 |
|
309 | |||
271 | if overlapping: |
|
310 | if overlapping: | |
272 | self.__withOverapping = True |
|
311 | self.__withOverapping = True | |
273 | self.__buffer = None |
|
312 | self.__buffer = None | |
274 | else: |
|
313 | else: | |
275 | self.__withOverapping = False |
|
314 | self.__withOverapping = False | |
276 | self.__buffer = 0 |
|
315 | self.__buffer = 0 | |
277 |
|
316 | |||
278 | self.__profIndex = 0 |
|
317 | self.__profIndex = 0 | |
279 |
|
318 | |||
280 | def putData(self, data): |
|
319 | def putData(self, data): | |
281 |
|
320 | |||
282 | """ |
|
321 | """ | |
283 | Add a profile to the __buffer and increase in one the __profileIndex |
|
322 | Add a profile to the __buffer and increase in one the __profileIndex | |
284 |
|
323 | |||
285 | """ |
|
324 | """ | |
286 | if not self.__withOverapping: |
|
325 | if not self.__withOverapping: | |
287 | self.__buffer += data |
|
326 | self.__buffer += data | |
288 | self.__profIndex += 1 |
|
327 | self.__profIndex += 1 | |
289 | return |
|
328 | return | |
290 |
|
329 | |||
291 | #Overlapping data |
|
330 | #Overlapping data | |
292 | nChannels, nHeis = data.shape |
|
331 | nChannels, nHeis = data.shape | |
293 | data = numpy.reshape(data, (1, nChannels, nHeis)) |
|
332 | data = numpy.reshape(data, (1, nChannels, nHeis)) | |
294 |
|
333 | |||
295 | if self.__buffer == None: |
|
334 | if self.__buffer == None: | |
296 | self.__buffer = data |
|
335 | self.__buffer = data | |
297 | self.__profIndex += 1 |
|
336 | self.__profIndex += 1 | |
298 | return |
|
337 | return | |
299 |
|
338 | |||
300 | if self.__profIndex < self.nCohInt: |
|
339 | if self.__profIndex < self.nCohInt: | |
301 | self.__buffer = numpy.vstack((self.__buffer, data)) |
|
340 | self.__buffer = numpy.vstack((self.__buffer, data)) | |
302 | self.__profIndex += 1 |
|
341 | self.__profIndex += 1 | |
303 | return |
|
342 | return | |
304 |
|
343 | |||
305 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) |
|
344 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) | |
306 | self.__buffer[self.nCohInt-1] = data |
|
345 | self.__buffer[self.nCohInt-1] = data | |
307 | #self.__profIndex = self.nCohInt |
|
346 | #self.__profIndex = self.nCohInt | |
308 | return |
|
347 | return | |
309 |
|
348 | |||
310 |
|
349 | |||
311 | def pushData(self): |
|
350 | def pushData(self): | |
312 | """ |
|
351 | """ | |
313 | Return the sum of the last profiles and the profiles used in the sum. |
|
352 | Return the sum of the last profiles and the profiles used in the sum. | |
314 |
|
353 | |||
315 | Affected: |
|
354 | Affected: | |
316 |
|
355 | |||
317 | self.__profileIndex |
|
356 | self.__profileIndex | |
318 |
|
357 | |||
319 | """ |
|
358 | """ | |
320 |
|
359 | |||
321 | if not self.__withOverapping: |
|
360 | if not self.__withOverapping: | |
322 | data = self.__buffer |
|
361 | data = self.__buffer | |
323 | nCohInt = self.__profIndex |
|
362 | nCohInt = self.__profIndex | |
324 |
|
363 | |||
325 | self.__buffer = 0 |
|
364 | self.__buffer = 0 | |
326 | self.__profIndex = 0 |
|
365 | self.__profIndex = 0 | |
327 |
|
366 | |||
328 | return data, nCohInt |
|
367 | return data, nCohInt | |
329 |
|
368 | |||
330 | #Overlapping data |
|
369 | #Overlapping data | |
331 | data = numpy.sum(self.__buffer, axis=0) |
|
370 | data = numpy.sum(self.__buffer, axis=0) | |
332 | nCohInt = self.__profIndex |
|
371 | nCohInt = self.__profIndex | |
333 |
|
372 | |||
334 | return data, nCohInt |
|
373 | return data, nCohInt | |
335 |
|
374 | |||
336 | def byProfiles(self, data): |
|
375 | def byProfiles(self, data): | |
337 |
|
376 | |||
338 | self.isReady = False |
|
377 | self.isReady = False | |
339 | avg_data = None |
|
378 | avg_data = None | |
340 |
|
379 | |||
341 | self.putData(data) |
|
380 | self.putData(data) | |
342 |
|
381 | |||
343 | if self.__profIndex == self.nCohInt: |
|
382 | if self.__profIndex == self.nCohInt: | |
344 | avg_data, nCohInt = self.pushData() |
|
383 | avg_data, nCohInt = self.pushData() | |
345 | self.isReady = True |
|
384 | self.isReady = True | |
346 |
|
385 | |||
347 | return avg_data |
|
386 | return avg_data | |
348 |
|
387 | |||
349 | def byTime(self, data, datatime): |
|
388 | def byTime(self, data, datatime): | |
350 |
|
389 | |||
351 | self.isReady = False |
|
390 | self.isReady = False | |
352 | avg_data = None |
|
391 | avg_data = None | |
353 |
|
392 | |||
354 | if self.__initime == None: |
|
393 | if self.__initime == None: | |
355 | self.__initime = datatime |
|
394 | self.__initime = datatime | |
356 |
|
395 | |||
357 | self.putData(data) |
|
396 | self.putData(data) | |
358 |
|
397 | |||
359 | if (datatime - self.__initime) >= self.__integrationtime: |
|
398 | if (datatime - self.__initime) >= self.__integrationtime: | |
360 | avg_data, nCohInt = self.pushData() |
|
399 | avg_data, nCohInt = self.pushData() | |
361 | self.nCohInt = nCohInt |
|
400 | self.nCohInt = nCohInt | |
362 | self.isReady = True |
|
401 | self.isReady = True | |
363 |
|
402 | |||
364 | return avg_data |
|
403 | return avg_data | |
365 |
|
404 | |||
366 | def exe(self, data, datatime=None): |
|
405 | def exe(self, data, datatime=None): | |
367 |
|
406 | |||
368 | if not self.__isByTime: |
|
407 | if not self.__isByTime: | |
369 | avg_data = self.byProfiles(data) |
|
408 | avg_data = self.byProfiles(data) | |
370 | else: |
|
409 | else: | |
371 | avg_data = self.byTime(data, datatime) |
|
410 | avg_data = self.byTime(data, datatime) | |
372 |
|
411 | |||
373 | self.data = avg_data |
|
412 | self.data = avg_data | |
374 |
|
413 | |||
375 | return avg_data |
|
414 | return avg_data | |
376 |
|
415 | |||
377 |
|
416 |
General Comments 0
You need to be logged in to leave comments.
Login now