##// END OF EJS Templates
Correccion en el ploteo de Graficos para efeciencia en consumo de memoria
Miguel Valdez -
r154:fd9b77bd6c94
parent child
Show More
@@ -1,393 +1,402
1 import numpy
1 import numpy
2 import datetime
2 import datetime
3 import time
3 import time
4 import os
4 import os
5 from schainPlotLib import Driver
5 from schainPlotLib import Driver
6
6
7 class Figure:
7 class Figure:
8
8
9 __isDriverOpen = False
9 __isDriverOpen = False
10 __isFigureOpen = False
10 __isFigureOpen = False
11 __isConfig = False
11 __isConfig = False
12
12
13 drvObj = None
13 drvObj = None
14 driver = None
14 driver = None
15 idfigure = None
15 idfigure = None
16 nframes = None
16 nframes = None
17 wintitle = None
17 wintitle = None
18 colormap = None
18 colormap = None
19 overplot = None
19 overplot = None
20 colorbar = None
20 colorbar = None
21
21
22 frameObjList = []
22 frameObjList = []
23
23
24 xw = None
24 xw = None
25 yw = None
25 yw = None
26
26
27 xmin = None
27 xmin = None
28 xmax = None
28 xmax = None
29 ymin = None
29 ymin = None
30 ymax = None
30 ymax = None
31
31
32 minvalue = None
32 minvalue = None
33 maxvalue = None
33 maxvalue = None
34 deltax = None
34 deltax = None
35 deltay = None
35 deltay = None
36
36
37
37
38 figuretitle = ""
38 figuretitle = ""
39 xrangestep = None
39 xrangestep = None
40
40
41 def __init__(self,idfigure, nframes, wintitle, xw=600, yw=800, overplot=0, driver='plplot', colormap=None, colorbar= True, *args):
41 def __init__(self,idfigure, nframes, wintitle, xw=600, yw=800, overplot=0, driver='plplot', colormap=None, colorbar= True, *args):
42
42
43 self.__isDriverOpen = False
43 self.__isDriverOpen = False
44 self.__isFigureOpen = False
44 self.__isFigureOpen = False
45 self.__isConfig = False
45 self.__isConfig = False
46
46
47 self.drvObj = Driver(driver, idfigure, xw, yw, wintitle, overplot, colormap, colorbar)
47 self.drvObj = Driver(driver, idfigure, xw, yw, wintitle, overplot, colormap, colorbar)
48 self.driver = driver
48 self.driver = driver
49 self.idfigure = idfigure
49 self.idfigure = idfigure
50 self.nframes = nframes
50 self.nframes = nframes
51 self.wintitle = wintitle
51 self.wintitle = wintitle
52 self.colormap = colormap
52 self.colormap = colormap
53 self.overplot = overplot
53 self.overplot = overplot
54 self.colorbar = colorbar
54 self.colorbar = colorbar
55
55
56 self.xw = xw
56 self.xw = xw
57 self.yw = yw
57 self.yw = yw
58
58
59 self.frameObjList = []
59 self.frameObjList = []
60
60
61 # self.showGraph1 = args[0]
61 # self.showGraph1 = args[0]
62 # self.showGraph2 = args[1]
62 # self.showGraph2 = args[1]
63
63
64 self.drvObj.driver.setFigure()
64 self.drvObj.driver.setFigure()
65 self.drvObj.driver.setColormap(colormap)
65 self.drvObj.driver.setColormap(colormap)
66
66
67 def __openDriver(self):
67 def __openDriver(self):
68
68
69 self.drvObj.driver.openDriver()
69 self.drvObj.driver.openDriver()
70
70
71 def __initFigure(self):
71 def __newPage(self):
72
72
73
74 self.drvObj.driver.openPage()
73 nrows, ncolumns = self.getSubplots()
75 nrows, ncolumns = self.getSubplots()
74 self.drvObj.driver.openFigure()
75 self.drvObj.driver.setFigTitle(self.figuretitle)
76 self.drvObj.driver.setFigTitle(self.figuretitle)
76 self.drvObj.driver.setSubPlots(nrows, ncolumns)
77 self.drvObj.driver.setSubPlots(nrows, ncolumns)
77
78
79 def __closePage(self):
80
81 self.drvObj.driver.closeFigure()
82
78 def selectFigure(self):
83 def selectFigure(self):
79
84
80 self.drvObj.driver.selectFigure()
85 self.drvObj.driver.selectFigure()
81
86
82 def __isOutOfXRange(self,x):
87 def __isOutOfXRange(self,x):
83 try:
88 try:
84 if ((x>=self.xmin) and (x<self.xmax)):
89 if ((x>=self.xmin) and (x<self.xmax)):
85 return 0
90 return 0
86 except:
91 except:
87 return 0
92 return 0
88
93
89 return 1
94 return 1
90
95
91 def changeXRange(self,x):
96 def changeXRange(self,x):
92
97
93 pass
98 pass
94
99
95 def __refresh(self):
100 def __refresh(self):
96 self.drvObj.driver.refresh()
101 self.drvObj.driver.refresh()
97
102
98 def createFrames(self):
103 def createFrames(self):
104
105 self.frameObjList = []
106
99 raise ValueError, "No implemented"
107 raise ValueError, "No implemented"
100
108
101 def save(self,filename):
109 def save(self,filename):
102
110
103 self.drvObj.driver.save(filename)
111 self.drvObj.driver.save(filename)
104
112
105 def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvalue=None, figuretitle=None, save=False, gpath='./'):
113 def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvalue=None, figuretitle=None, save=False, gpath='./'):
106
114
107 nx, ny = data1D.shape
115 nx, ny = data1D.shape
108
116
109 if channelList == None:
117 if channelList == None:
110 channelList = range(nx)
118 channelList = range(nx)
111
119
112 if x == None:
120 if x == None:
113 x = numpy.arange(data1D.size)
121 x = numpy.arange(data1D.size)
114
122
115 if figuretitle == None:
123 if figuretitle == None:
116 self.figuretitle = ""
124 self.figuretitle = ""
117 else:
125 else:
118 self.figuretitle = figuretitle
126 self.figuretitle = figuretitle
119
127
120 if not(self.__isDriverOpen):
128 if not(self.__isDriverOpen):
121 self.__openDriver()
129 self.__openDriver()
122 self.__isDriverOpen = True
130 self.__isDriverOpen = True
123
131
124 if not(self.__isConfig):
132 if not(self.__isConfig):
125 self.xmin = xmin
133 self.xmin = xmin
126 self.xmax = xmax
134 self.xmax = xmax
127 self.minvalue = minvalue
135 self.minvalue = minvalue
128 self.maxvalue = maxvalue
136 self.maxvalue = maxvalue
129
137
130 if self.xmin == None: self.xmin = numpy.min(x)
138 if self.xmin == None: self.xmin = numpy.min(x)
131 if self.xmax == None: self.xmax = numpy.max(x)
139 if self.xmax == None: self.xmax = numpy.max(x)
132 if self.minvalue == None: self.minvalue = numpy.min(data1D)
140 if self.minvalue == None: self.minvalue = numpy.min(data1D)
133 if self.maxvalue == None: self.maxvalue = numpy.max(data1D)
141 if self.maxvalue == None: self.maxvalue = numpy.max(data1D)
134
142
135 self.createFrames()
143 self.createFrames()
136 self.__isConfig = True
144 self.__isConfig = True
137
145
138 if not(self.__isOutOfXRange(x)):
146 if not(self.__isOutOfXRange(x)):
139 self.changeXRange(x)
147 self.changeXRange(x)
140
148
141 if self.__isFigureOpen:
149 if self.__isFigureOpen:
142 self.drvObj.driver.closePage()
150 self.drvObj.driver.closePage()
143 self.__isFigureOpen = False
151 self.__isFigureOpen = False
144
152
145 self.selectFigure()
153 self.selectFigure()
146 self.__initFigure()
154 self.__initFigure()
147
155
148 for channel in channelList:
156 for channel in channelList:
149 frameObj = self.frameObjList[channel]
157 frameObj = self.frameObjList[channel]
150 frameObj.init(xmin=self.xmin,
158 frameObj.init(xmin=self.xmin,
151 xmax=self.xmax,
159 xmax=self.xmax,
152 ymin=self.minvalue,
160 ymin=self.minvalue,
153 ymax=self.maxvalue,
161 ymax=self.maxvalue,
154 minvalue=self.minvalue,
162 minvalue=self.minvalue,
155 maxvalue=self.maxvalue)
163 maxvalue=self.maxvalue)
156
164
157 for channel in channelList:
165 for channel in channelList:
158 dataCh = data1D[channel,:]
166 dataCh = data1D[channel,:]
159 frameObj = self.frameObjList[channel]
167 frameObj = self.frameObjList[channel]
160 # frameObj.clearData()
168 # frameObj.clearData()
161 frameObj.plot(x, dataCh)
169 frameObj.plot(x, dataCh)
162
170
163 # frameObj.refresh()
171 # frameObj.refresh()
164 self.__refresh()
172 self.__refresh()
165
173
166
174
167
175
168 if save:
176 if save:
169 # self.colorplotObj.setFigure(indexPlot)
177 # self.colorplotObj.setFigure(indexPlot)
170
178
171 path = gpath
179 path = gpath
172 now = datetime.datetime.now()
180 now = datetime.datetime.now()
173 file = "scope_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond)
181 file = "scope_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond)
174 filename = os.path.join(path,file)
182 filename = os.path.join(path,file)
175 self.save(filename)
183 self.save(filename)
176
184
177
185 self.__closeFigure()
178
186
179
187
180 def plotPcolor(self,data,
188 def plotPcolor(self,data,
181 x=None,
189 x=None,
182 y=None,
190 y=None,
183 channelList=None,
191 channelList=None,
184 xmin=None,
192 xmin=None,
185 xmax=None,
193 xmax=None,
186 ymin=None,
194 ymin=None,
187 ymax=None,
195 ymax=None,
188 minvalue=None,
196 minvalue=None,
189 maxvalue=None,
197 maxvalue=None,
190 figuretitle=None,
198 figuretitle=None,
191 xrangestep=None,
199 xrangestep=None,
192 deltax=None,
200 deltax=None,
193 save=False,
201 save=False,
194 gpath='./',
202 gpath='./',
195 clearData=False,
203 clearData=False,
196 *args):
204 *args):
197
205
198
206
199 if figuretitle == None:
207 if figuretitle == None:
200 self.figuretitle = ""
208 self.figuretitle = ""
201 else:
209 else:
202 self.figuretitle = figuretitle
210 self.figuretitle = figuretitle
203
211
204
205
212
206 if not(self.__isDriverOpen):
213 if not(self.__isDriverOpen):
207 self.__openDriver()
214 self.__openDriver()
208 self.__isDriverOpen = True
215 self.__isDriverOpen = True
209
216
210 if not(self.__isConfig):
217 if not(self.__isConfig):
211
218
212 self.setParms(data,x,y,xmin,xmax,ymin,ymax,minvalue,maxvalue,xrangestep,deltax)
219 self.setParms(data,x,y,xmin,xmax,ymin,ymax,minvalue,maxvalue,xrangestep,deltax)
213
220
214 self.createFrames()
221 self.createFrames()
215 self.__isConfig = True
222 self.__isConfig = True
216
223
217 if (self.__isOutOfXRange(x)):
224 if (self.__isOutOfXRange(x)):
218
225
219 if not(self.changeXRange(x)):
226 if not(self.changeXRange(x)):
220 return 0
227 return 0
221
228
222 self.__isFigureOpen = False
229 self.__closeFigure()
230
231 self.selectFigure()
223
232
224 if not(self.__isFigureOpen):
233 if not(self.__isFigureOpen):
225
234 self.__newPage()
226
227 self.__initFigure()
228 self.__isFigureOpen = True
235 self.__isFigureOpen = True
229
236
230 for channel in channelList:
237 for channel in channelList:
231 if len(args) != 0: value = args[0][channel]
238 if len(args) != 0: value = args[0][channel]
232 else: value = args
239 else: value = args
233
240
234 frameObj = self.frameObjList[channel]
241 frameObj = self.frameObjList[channel]
235 frameObj.init(self.xmin,
242 frameObj.init(self.xmin,
236 self.xmax,
243 self.xmax,
237 self.ymin,
244 self.ymin,
238 self.ymax,
245 self.ymax,
239 self.minvalue,
246 self.minvalue,
240 self.maxvalue,
247 self.maxvalue,
241 self.deltax,
248 self.deltax,
242 self.deltay,
249 self.deltay,
243 self.colorbar,
250 self.colorbar,
244 value)
251 value)
245 self.selectFigure()
252
246
253
247 for channel in channelList:
254 for channel in channelList:
248 dataCh = data[channel,:]
255 dataCh = data[channel,:]
249 frameObj = self.frameObjList[channel]
256 frameObj = self.frameObjList[channel]
250 frameObj.plot(x, y, dataCh)
257 frameObj.plot(x, y, dataCh)
251
258
252
259
253 self.__refresh()
260 self.__refresh()
254 if clearData == True:
261 if clearData == True:
262 self.__closePage()
255 self.__isFigureOpen = False
263 self.__isFigureOpen = False
264
256
265
257
266
258
267
259 class Frame:
268 class Frame:
260
269
261 drvObj = None
270 drvObj = None
262 idFrame = None
271 idFrame = None
263 nplots = None
272 nplots = None
264 plotObjList = []
273 plotObjList = []
265 title = ""
274 title = ""
266
275
267 def __init__(self,drvObj, idframe):
276 def __init__(self,drvObj, idframe):
268
277
269 self.drvObj = drvObj
278 self.drvObj = drvObj
270 self.idframe = idframe
279 self.idframe = idframe
271 nplots = None
280 nplots = None
272 self.plotObjList = []
281 self.plotObjList = []
273
282
274 self.createPlots()
283 self.createPlots()
275
284
276 def createPlots(self):
285 def createPlots(self):
277 raise ValueError, "No implemented"
286 raise ValueError, "No implemented"
278
287
279 def getScreenPosMainPlot(self):
288 def getScreenPosMainPlot(self):
280 raise ValueError, "No implemented"
289 raise ValueError, "No implemented"
281
290
282 def getScreenPosGraph1(self):
291 def getScreenPosGraph1(self):
283 raise ValueError, "No implemented"
292 raise ValueError, "No implemented"
284
293
285 def getScreenPos(self, nplot):
294 def getScreenPos(self, nplot):
286
295
287 if nplot == 0:
296 if nplot == 0:
288 xi, yi, xw, yw = self.getScreenPosMainPlot()
297 xi, yi, xw, yw = self.getScreenPosMainPlot()
289
298
290 if nplot == 1:
299 if nplot == 1:
291 xi, yi, xw, yw = self.getScreenPosGraph1()
300 xi, yi, xw, yw = self.getScreenPosGraph1()
292
301
293 return xi, yi, xw, yw
302 return xi, yi, xw, yw
294
303
295
304
296 def init(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax=None, deltay=None, colorbar=False, *args):
305 def init(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax=None, deltay=None, colorbar=False, *args):
297
306
298 for plotObj in self.plotObjList:
307 for plotObj in self.plotObjList:
299 plotObj.setBox(xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax, deltay, colorbar, *args)
308 plotObj.setBox(xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax, deltay, colorbar, *args)
300 plotObj.plotBox()
309 plotObj.plotBox()
301
310
302
311
303
312
304 class Plot:
313 class Plot:
305
314
306 drvObj = None
315 drvObj = None
307 idframe = None
316 idframe = None
308 idplot = None
317 idplot = None
309 xi = None
318 xi = None
310 yi = None
319 yi = None
311 xw = None
320 xw = None
312 yw = None
321 yw = None
313
322
314 title = ""
323 title = ""
315 xlabel = ""
324 xlabel = ""
316 ylabel = ""
325 ylabel = ""
317 xaxisastime = None
326 xaxisastime = None
318 timefmt = None
327 timefmt = None
319 xopt = ""
328 xopt = ""
320 yopt = ""
329 yopt = ""
321 xpos = None
330 xpos = None
322 ypos = None
331 ypos = None
323 szchar = None
332 szchar = None
324 idframe = None
333 idframe = None
325 idplot = None
334 idplot = None
326 colorbar = None
335 colorbar = None
327 cbxpos = None
336 cbxpos = None
328 cbypos = None
337 cbypos = None
329
338
330 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw):
339 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw):
331
340
332 self.drvObj = drvObj
341 self.drvObj = drvObj
333 self.idframe = idframe
342 self.idframe = idframe
334 self.idplot = idplot
343 self.idplot = idplot
335 self.xi = xi
344 self.xi = xi
336 self.yi = yi
345 self.yi = yi
337 self.xw = xw
346 self.xw = xw
338 self.yw = yw
347 self.yw = yw
339
348
340
349
341 def plotBox(self):
350 def plotBox(self):
342
351
343 self.drvObj.driver.plotBox(self.idframe,
352 self.drvObj.driver.plotBox(self.idframe,
344 self.xpos,
353 self.xpos,
345 self.ypos,
354 self.ypos,
346 self.xmin,
355 self.xmin,
347 self.xmax,
356 self.xmax,
348 self.ymin,
357 self.ymin,
349 self.ymax,
358 self.ymax,
350 self.minvalue,
359 self.minvalue,
351 self.maxvalue,
360 self.maxvalue,
352 self.xopt,
361 self.xopt,
353 self.yopt,
362 self.yopt,
354 self.szchar,
363 self.szchar,
355 self.xaxisastime,
364 self.xaxisastime,
356 self.timefmt)
365 self.timefmt)
357
366
358 self.drvObj.driver.setPlotLabels(self.idframe, self.xlabel, self.ylabel, self.title)
367 self.drvObj.driver.setPlotLabels(self.idframe, self.xlabel, self.ylabel, self.title)
359
368
360 if self.colorbar:
369 if self.colorbar:
361 self.drvObj.driver.plotColorbar(self.minvalue, self.maxvalue, self.cbxpos,self.cbypos)
370 self.drvObj.driver.plotColorbar(self.minvalue, self.maxvalue, self.cbxpos,self.cbypos)
362
371
363 def plotPcolor(self, x, y, z, deltax, deltay, getGrid):
372 def plotPcolor(self, x, y, z, deltax, deltay, getGrid):
364
373
365 self.drvObj.driver.pcolor(self.idframe,
374 self.drvObj.driver.pcolor(self.idframe,
366 self.xpos,
375 self.xpos,
367 self.ypos,
376 self.ypos,
368 z,
377 z,
369 x,
378 x,
370 y,
379 y,
371 self.xmin,
380 self.xmin,
372 self.xmax,
381 self.xmax,
373 self.ymin,
382 self.ymin,
374 self.ymax,
383 self.ymax,
375 self.minvalue,
384 self.minvalue,
376 self.maxvalue,
385 self.maxvalue,
377 deltax,
386 deltax,
378 deltay,
387 deltay,
379 getGrid,
388 getGrid,
380 self.xaxisastime,
389 self.xaxisastime,
381 self.timefmt)
390 self.timefmt)
382
391
383 def plotBasicLine(self,x, y, color):
392 def plotBasicLine(self,x, y, color):
384 """
393 """
385 Inputs:
394 Inputs:
386 x:
395 x:
387
396
388 y:
397 y:
389
398
390 color:
399 color:
391 """
400 """
392 self.drvObj.driver.basicLine(self.idframe, self.xpos, self.ypos, x, y, self.xmin, self.xmax, self.ymin, self.ymax, color)
401 self.drvObj.driver.basicLine(self.idframe, self.xpos, self.ypos, x, y, self.xmin, self.xmax, self.ymin, self.ymax, color)
393 No newline at end of file
402
@@ -1,521 +1,530
1 import numpy
1 import numpy
2 import datetime
2 import datetime
3 import time
3 import time
4 from schainPlot import *
4 from schainPlot import *
5
5
6 class SpcFigure(Figure):
6 class SpcFigure(Figure):
7 overplot = 0
7 overplot = 0
8 xw = 800
8 xw = 800
9 yw = 650
9 yw = 650
10 showprofile = False
10 showprofile = False
11
11
12 def __init__(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile):
12 def __init__(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile):
13 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
13 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
14
14
15 self.showprofile = showprofile
15 self.showprofile = showprofile
16
16
17 def getSubplots(self):
17 def getSubplots(self):
18 ncolumns = int(numpy.sqrt(self.nframes)+0.9)
18 ncolumns = int(numpy.sqrt(self.nframes)+0.9)
19 nrows = int(self.nframes*1./ncolumns + 0.9)
19 nrows = int(self.nframes*1./ncolumns + 0.9)
20
20
21 return nrows, ncolumns
21 return nrows, ncolumns
22
22
23 def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
23 def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
24
24
25 if xmin == None: xmin = numpy.min(x)
25 if xmin == None: xmin = numpy.min(x)
26 if xmax == None: xmax = numpy.max(x)
26 if xmax == None: xmax = numpy.max(x)
27 if ymin == None: ymin = numpy.min(y)
27 if ymin == None: ymin = numpy.min(y)
28 if ymax == None: ymax = numpy.max(y)
28 if ymax == None: ymax = numpy.max(y)
29 if minvalue == None: minvalue = 20.
29 if minvalue == None: minvalue = 20.
30 if maxvalue == None: maxvalue = 90.
30 if maxvalue == None: maxvalue = 90.
31
31
32 self.xmin = xmin
32 self.xmin = xmin
33 self.xmax = xmax
33 self.xmax = xmax
34 self.minrange = ymin
34 self.minrange = ymin
35 self.maxrange = ymax
35 self.maxrange = ymax
36 self.ymin = ymin
36 self.ymin = ymin
37 self.ymax = ymax
37 self.ymax = ymax
38 self.minvalue = minvalue
38 self.minvalue = minvalue
39 self.maxvalue = maxvalue
39 self.maxvalue = maxvalue
40
40
41
41
42 def changeXRange(self, *args):
42 def changeXRange(self, *args):
43 pass
43 pass
44
44
45 def createFrames(self):
45 def createFrames(self):
46
47 self.frameObjList = []
48
46 for frame in range(self.nframes):
49 for frame in range(self.nframes):
47 frameObj = SpcFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile)
50 frameObj = SpcFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile)
48 self.frameObjList.append(frameObj)
51 self.frameObjList.append(frameObj)
49
52
50 class SpcFrame(Frame):
53 class SpcFrame(Frame):
51 def __init__(self,drvObj,idframe,colorbar,showprofile):
54 def __init__(self,drvObj,idframe,colorbar,showprofile):
52 self.drvObj = drvObj
55 self.drvObj = drvObj
53 self.idframe = idframe
56 self.idframe = idframe
54 self.nplots = 1
57 self.nplots = 1
55
58
56 if showprofile:
59 if showprofile:
57 self.nplots += 1
60 self.nplots += 1
58
61
59 self.colorbar = colorbar
62 self.colorbar = colorbar
60 self.showprofile = showprofile
63 self.showprofile = showprofile
61 self.createPlots()
64 self.createPlots()
62
65
63 def createPlots(self):
66 def createPlots(self):
64 plotObjList = []
67 plotObjList = []
65 idplot = 0
68 idplot = 0
66 xi, yi, xw, yw = self.getScreenPos(idplot)
69 xi, yi, xw, yw = self.getScreenPos(idplot)
67 plotObj = SpcPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar)
70 plotObj = SpcPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar)
68 plotObjList.append(plotObj)
71 plotObjList.append(plotObj)
69
72
70 if self.showprofile:
73 if self.showprofile:
71 idplot = 1
74 idplot = 1
72 xi, yi, xw, yw = self.getScreenPos(idplot)
75 xi, yi, xw, yw = self.getScreenPos(idplot)
73 type = "pwbox"
76 type = "pwbox"
74 title = ""
77 title = ""
75 xlabel = "dB"
78 xlabel = "dB"
76 ylabel = ""
79 ylabel = ""
77 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel)
80 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel)
78 plotObjList.append(plotObj)
81 plotObjList.append(plotObj)
79
82
80 self.plotObjList = plotObjList
83 self.plotObjList = plotObjList
81
84
82 def getScreenPosMainPlot(self):
85 def getScreenPosMainPlot(self):
83 xi = 0.15
86 xi = 0.15
84
87
85 if self.showprofile:
88 if self.showprofile:
86 xw = 0.65
89 xw = 0.65
87
90
88 else:
91 else:
89 xw = 0.75
92 xw = 0.75
90
93
91 if self.colorbar:
94 if self.colorbar:
92 xw = xw - 0.06
95 xw = xw - 0.06
93
96
94 yi = 0.20; yw = 0.75
97 yi = 0.20; yw = 0.75
95
98
96 return xi, yi, xw, yw
99 return xi, yi, xw, yw
97
100
98 def getScreenPosGraph1(self):
101 def getScreenPosGraph1(self):
99 if self.colorbar:
102 if self.colorbar:
100 xi = 0.65 + 0.08
103 xi = 0.65 + 0.08
101 else:
104 else:
102 xi = 0.75 + 0.05
105 xi = 0.75 + 0.05
103
106
104 xw = xi + 0.2
107 xw = xi + 0.2
105
108
106 yi = 0.2; yw = 0.75
109 yi = 0.2; yw = 0.75
107
110
108 return xi, yi, xw, yw
111 return xi, yi, xw, yw
109
112
110 def plot(self,x, y, data):
113 def plot(self,x, y, data):
111 plotObj = self.plotObjList[0]
114 plotObj = self.plotObjList[0]
112 plotObj.plot(x,y,data)
115 plotObj.plot(x,y,data)
113
116
114 if self.showprofile:
117 if self.showprofile:
115 plotObj = self.plotObjList[1]
118 plotObj = self.plotObjList[1]
116 plotObj.plot(data,y)
119 plotObj.plot(data,y)
117
120
118 class SpcPlot(Plot):
121 class SpcPlot(Plot):
119
122
120 getGrid = True
123 getGrid = True
121
124
122 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, colorbar):
125 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, colorbar):
123 self.drvObj = drvObj
126 self.drvObj = drvObj
124 self.idframe = idframe
127 self.idframe = idframe
125 self.idplot = idplot
128 self.idplot = idplot
126 self.xi = xi
129 self.xi = xi
127 self.yi = yi
130 self.yi = yi
128 self.xw = xw
131 self.xw = xw
129 self.yw = yw
132 self.yw = yw
130 self.colorbar = colorbar
133 self.colorbar = colorbar
131
134
132 if self.colorbar:
135 if self.colorbar:
133 cbxi = xw + 0.03
136 cbxi = xw + 0.03
134 cbxw = cbxi + 0.03
137 cbxw = cbxi + 0.03
135 cbyi = yi
138 cbyi = yi
136 cbyw = yw
139 cbyw = yw
137 self.cbxpos = [cbxi,cbxw]
140 self.cbxpos = [cbxi,cbxw]
138 self.cbypos = [cbyi,cbyw]
141 self.cbypos = [cbyi,cbyw]
139
142
140 self.xpos = [self.xi,self.xw]
143 self.xpos = [self.xi,self.xw]
141 self.ypos = [self.yi,self.yw]
144 self.ypos = [self.yi,self.yw]
142 self.xaxisastime = False
145 self.xaxisastime = False
143 self.timefmt = None
146 self.timefmt = None
144 self.xopt = "bcnst"
147 self.xopt = "bcnst"
145 self.yopt = "bcnstv"
148 self.yopt = "bcnstv"
146
149
147 self.szchar = 0.8
150 self.szchar = 0.8
148 self.strforchannel = "Channel %d"%self.idframe
151 self.strforchannel = "Channel %d"%self.idframe
149 self.xlabel = "m/s"
152 self.xlabel = "m/s"
150 self.ylabel = "Range (Km)"
153 self.ylabel = "Range (Km)"
151
154
152 def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
155 def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
153 self.xmin = xmin
156 self.xmin = xmin
154 self.xmax = xmax
157 self.xmax = xmax
155 self.ymin = ymin
158 self.ymin = ymin
156 self.ymax = ymax
159 self.ymax = ymax
157 self.minvalue = minvalue
160 self.minvalue = minvalue
158 self.maxvalue = maxvalue
161 self.maxvalue = maxvalue
159 self.colorbar = args[2]
162 self.colorbar = args[2]
160 self.title = "%s - %s"%(self.strforchannel,args[3])
163 self.title = "%s - %s"%(self.strforchannel,args[3])
161
164
162
165
163
166
164 def plot(self, x, y, data):
167 def plot(self, x, y, data):
165 z = data
168 z = data
166 deltax = None
169 deltax = None
167 deltay = None
170 deltay = None
168 self.plotPcolor(x, y, z, deltax, deltay, self.getGrid)
171 self.plotPcolor(x, y, z, deltax, deltay, self.getGrid)
169 self.getGrid = False
172 self.getGrid = False
170
173
171
174
172 class RTIFigure(Figure):
175 class RTIFigure(Figure):
173 overplot = 1
176 overplot = 1
174 xw = 700
177 xw = 700
175 yw = 650
178 yw = 650
176 showprofile = False
179 showprofile = False
177 starttime = None
180 starttime = None
178 endtime = None
181 endtime = None
179 minrange = None
182 minrange = None
180 maxrange = None
183 maxrange = None
181 minvalue = None
184 minvalue = None
182 maxvalue = None
185 maxvalue = None
183 xrangestepinsecs = None
186 xrangestepinsecs = None
184
187
185
188
186 def __init__(self, idfigure, nframes, wintitle, driver, colormap="br_green", colorbar= True, showprofile=False):
189 def __init__(self, idfigure, nframes, wintitle, driver, colormap="br_green", colorbar= True, showprofile=False):
187 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
190 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
188
191
189 self.showprofile = showprofile
192 self.showprofile = showprofile
190
193
191 def getSubplots(self):
194 def getSubplots(self):
192 nrows = self.nframes
195 nrows = self.nframes
193 ncolumns = 1
196 ncolumns = 1
194 return nrows, ncolumns
197 return nrows, ncolumns
195
198
196 def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, xrangestep, deltax):
199 def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, xrangestep, deltax):
197
200
198 self.starttime = xmin
201 self.starttime = xmin
199 self.endtime = xmax
202 self.endtime = xmax
200
203
201 cdatetime = datetime.datetime.utcfromtimestamp(x)
204 cdatetime = datetime.datetime.utcfromtimestamp(x)
202
205
203 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.starttime.hour,self.starttime.minute,self.starttime.second)
206 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.starttime.hour,self.starttime.minute,self.starttime.second)
204 if ((xrangestep == 0) or (xrangestep == None)):
207 if ((xrangestep == 0) or (xrangestep == None)):
205 maxdatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.endtime.hour,self.endtime.minute,self.endtime.second)
208 maxdatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.endtime.hour,self.endtime.minute,self.endtime.second)
206 self.xrangestepinsecs = time.mktime(maxdatetime.timetuple()) - time.mktime(mindatetime.timetuple())
209 self.xrangestepinsecs = time.mktime(maxdatetime.timetuple()) - time.mktime(mindatetime.timetuple())
207 npoints = 1000.
210 npoints = 1000.
208 if xrangestep == 1:
211 if xrangestep == 1:
209 maxdatetime = mindatetime + datetime.timedelta(hours=1)
212 maxdatetime = mindatetime + datetime.timedelta(hours=1)
210 self.xrangestepinsecs = 60*60.
213 self.xrangestepinsecs = 60*60.
211 npoints = 500.
214 npoints = 500.
212 if xrangestep == 2:
215 if xrangestep == 2:
213 maxdatetime = mindatetime + datetime.timedelta(minutes=1)
216 maxdatetime = mindatetime + datetime.timedelta(minutes=1)
214 self.xrangestepinsecs = 60.
217 self.xrangestepinsecs = 60.
215 npoints = 250.
218 npoints = 250.
216 if xrangestep == 3:
219 if xrangestep == 3:
217 maxdatetime = mindatetime + datetime.timedelta(seconds=1)
220 maxdatetime = mindatetime + datetime.timedelta(seconds=1)
218 self.xrangestepinsecs = 1.
221 self.xrangestepinsecs = 1.
219 npoints = 125.
222 npoints = 125.
220
223
221 xmin = time.mktime(mindatetime.timetuple())
224 xmin = time.mktime(mindatetime.timetuple())
222 xmax = time.mktime(maxdatetime.timetuple())
225 xmax = time.mktime(maxdatetime.timetuple())
223
226
224 deltax1 = (xmax-xmin) / npoints
227 deltax1 = (xmax-xmin) / npoints
225 # deltax = timeInterval
228 # deltax = timeInterval
226
229
227
230
228 if ymin == None: ymin = numpy.min(y)
231 if ymin == None: ymin = numpy.min(y)
229 if ymax == None: ymax = numpy.max(y)
232 if ymax == None: ymax = numpy.max(y)
230
233
231 if minvalue == None: minvalue = 0.
234 if minvalue == None: minvalue = 0.
232 if maxvalue == None: maxvalue = 50.
235 if maxvalue == None: maxvalue = 50.
233
236
234 self.xmin = xmin
237 self.xmin = xmin
235 self.xmax = xmax
238 self.xmax = xmax
236 self.minrange = ymin
239 self.minrange = ymin
237 self.maxrange = ymax
240 self.maxrange = ymax
238 self.ymin = ymin
241 self.ymin = ymin
239 self.ymax = ymax
242 self.ymax = ymax
240 self.minvalue = minvalue
243 self.minvalue = minvalue
241 self.maxvalue = maxvalue
244 self.maxvalue = maxvalue
242 self.xrangestep = xrangestep
245 self.xrangestep = xrangestep
243 self.deltax = deltax
246 self.deltax = deltax
244
247
245 def changeXRange(self,x):
248 def changeXRange(self,x):
246
249
247 cdatetime = datetime.datetime.utcfromtimestamp(x)
250 cdatetime = datetime.datetime.utcfromtimestamp(x)
248
251
249 if ((cdatetime.time()>=self.starttime) and (cdatetime.time()<self.endtime)):
252 if ((cdatetime.time()>=self.starttime) and (cdatetime.time()<self.endtime)):
250 if self.xrangestep == 1:
253 if self.xrangestep == 1:
251 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,self.starttime.minute,self.starttime.second)
254 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,self.starttime.minute,self.starttime.second)
252
255
253 if self.xrangestep == 2:
256 if self.xrangestep == 2:
254 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,self.starttime.second)
257 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,self.starttime.second)
255
258
256 if self.xrangestep == 3:
259 if self.xrangestep == 3:
257 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,cdatetime.second)
260 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,cdatetime.second)
258
261
259 self.xmin = time.mktime(mindatetime.timetuple()) - time.timezone
262 self.xmin = time.mktime(mindatetime.timetuple()) - time.timezone
260 self.xmax = self.xmin + self.xrangestepinsecs
263 self.xmax = self.xmin + self.xrangestepinsecs
261
264
262 self.figuretitle = "%s %s : %s"%(self.figuretitle,
265 self.figuretitle = "%s %s : %s"%(self.figuretitle,
263 datetime.datetime.utcfromtimestamp(self.xmin).strftime("%d-%b-%Y %H:%M:%S"),
266 datetime.datetime.utcfromtimestamp(self.xmin).strftime("%d-%b-%Y %H:%M:%S"),
264 datetime.datetime.utcfromtimestamp(self.xmax).strftime("%d-%b-%Y %H:%M:%S"))
267 datetime.datetime.utcfromtimestamp(self.xmax).strftime("%d-%b-%Y %H:%M:%S"))
265 return 1
268 return 1
266
269
267 return 0
270 return 0
268
271
269 def createFrames(self):
272 def createFrames(self):
273
274 self.frameObjList = []
275
270 for frame in range(self.nframes):
276 for frame in range(self.nframes):
271 frameObj = RTIFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile)
277 frameObj = RTIFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile)
272 self.frameObjList.append(frameObj)
278 self.frameObjList.append(frameObj)
273
279
274 class RTIFrame(Frame):
280 class RTIFrame(Frame):
275 def __init__(self,drvObj,idframe,colorbar,showprofile):
281 def __init__(self,drvObj,idframe,colorbar,showprofile):
276 self.drvObj = drvObj
282 self.drvObj = drvObj
277 self.idframe = idframe
283 self.idframe = idframe
278 self.nplots = 1
284 self.nplots = 1
279
285
280 if showprofile:
286 if showprofile:
281 self.nplots += 1
287 self.nplots += 1
282
288
283 self.colorbar = colorbar
289 self.colorbar = colorbar
284 self.showprofile = showprofile
290 self.showprofile = showprofile
285 self.createPlots()
291 self.createPlots()
286
292
287 def createPlots(self):
293 def createPlots(self):
288 plotObjList = []
294 plotObjList = []
289
295
290 idplot = 0
296 idplot = 0
291 xi, yi, xw, yw = self.getScreenPos(idplot)
297 xi, yi, xw, yw = self.getScreenPos(idplot)
292
298
293 plotObj = RTIPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar)
299 plotObj = RTIPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar)
294 plotObjList.append(plotObj)
300 plotObjList.append(plotObj)
295
301
296 if self.showprofile:
302 if self.showprofile:
297 idplot = 1
303 idplot = 1
298 xi, yi, xw, yw = self.getScreenPos(idplot)
304 xi, yi, xw, yw = self.getScreenPos(idplot)
299 type = "pwbox"
305 type = "pwbox"
300 title = ""
306 title = ""
301 xlabel = "dB"
307 xlabel = "dB"
302 ylabel = ""
308 ylabel = ""
303 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel)
309 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel)
304 plotObjList.append(plotObj)
310 plotObjList.append(plotObj)
305
311
306 self.plotObjList = plotObjList
312 self.plotObjList = plotObjList
307
313
308 def getScreenPosMainPlot(self):
314 def getScreenPosMainPlot(self):
309 xi = 0.07
315 xi = 0.07
310 if self.showprofile:
316 if self.showprofile:
311 xw = 0.65
317 xw = 0.65
312 else:
318 else:
313 xw = 0.9
319 xw = 0.9
314
320
315 if self.colorbar:
321 if self.colorbar:
316 xw = xw - 0.06
322 xw = xw - 0.06
317
323
318 yi = 0.20; yw = 0.75
324 yi = 0.20; yw = 0.75
319
325
320 return xi, yi, xw, yw
326 return xi, yi, xw, yw
321
327
322 def getScreenPosGraph1(self):
328 def getScreenPosGraph1(self):
323 if self.colorbar:
329 if self.colorbar:
324 xi = 0.65 + 0.08
330 xi = 0.65 + 0.08
325 else:
331 else:
326 xi = 0.9 + 0.05
332 xi = 0.9 + 0.05
327
333
328 xw = xi + 0.2
334 xw = xi + 0.2
329
335
330 yi = 0.2; yw = 0.75
336 yi = 0.2; yw = 0.75
331
337
332 return xi, yi, xw, yw
338 return xi, yi, xw, yw
333
339
334 def plot(self, currenttime, range, data):
340 def plot(self, currenttime, range, data):
335 plotObj = self.plotObjList[0]
341 plotObj = self.plotObjList[0]
336 plotObj.plot(currenttime,range,data)
342 plotObj.plot(currenttime,range,data)
337
343
338 if self.showprofile:
344 if self.showprofile:
339 plotObj = self.plotObjList[1]
345 plotObj = self.plotObjList[1]
340 plotObj.plot(data,range)
346 plotObj.plot(data,range)
341
347
342
348
343 class RTIPlot(Plot):
349 class RTIPlot(Plot):
344 deltax = None
350 deltax = None
345 deltay = None
351 deltay = None
346 xrange = [None,None]
352 xrange = [None,None]
347 xminpos = None
353 xminpos = None
348 xmaxpos = None
354 xmaxpos = None
349 xg = None
355 xg = None
350 yg = None
356 yg = None
351
357
352 def __init__(self,drvObj, idframe, idplot, xi, yi, xw, yw, colorbar):
358 def __init__(self,drvObj, idframe, idplot, xi, yi, xw, yw, colorbar):
353 self.drvObj = drvObj
359 self.drvObj = drvObj
354 self.idframe = idframe
360 self.idframe = idframe
355 self.idplot = idplot
361 self.idplot = idplot
356 self.xi = xi
362 self.xi = xi
357 self.yi = yi
363 self.yi = yi
358 self.xw = xw
364 self.xw = xw
359 self.yw = yw
365 self.yw = yw
360 self.colorbar = colorbar
366 self.colorbar = colorbar
361
367
362 if self.colorbar:
368 if self.colorbar:
363 cbxi = xw + 0.03
369 cbxi = xw + 0.03
364 cbxw = cbxi + 0.03
370 cbxw = cbxi + 0.03
365 cbyi = yi
371 cbyi = yi
366 cbyw = yw
372 cbyw = yw
367 self.cbxpos = [cbxi,cbxw]
373 self.cbxpos = [cbxi,cbxw]
368 self.cbypos = [cbyi,cbyw]
374 self.cbypos = [cbyi,cbyw]
369
375
370 self.xpos = [self.xi,self.xw]
376 self.xpos = [self.xi,self.xw]
371 self.ypos = [self.yi,self.yw]
377 self.ypos = [self.yi,self.yw]
372 self.xaxisastime = True
378 self.xaxisastime = True
373 self.timefmt = "%H:%M"
379 self.timefmt = "%H:%M"
374 self.xopt = "bcnstd"
380 self.xopt = "bcnstd"
375 self.yopt = "bcnstv"
381 self.yopt = "bcnstv"
376
382
377 self.szchar = 1.0
383 self.szchar = 1.0
378 self.title = "Channel %d"%self.idframe
384 self.title = "Channel %d"%self.idframe
379 self.xlabel = "Local Time"
385 self.xlabel = "Local Time"
380 self.ylabel = "Range (Km)"
386 self.ylabel = "Range (Km)"
381
387
382
388
383 def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax=None, deltay=None, colorbar=True, *args):
389 def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax=None, deltay=None, colorbar=True, *args):
384 self.xmin = xmin
390 self.xmin = xmin
385 self.xmax = xmax
391 self.xmax = xmax
386 self.ymin = ymin
392 self.ymin = ymin
387 self.ymax = ymax
393 self.ymax = ymax
388 self.minvalue = minvalue
394 self.minvalue = minvalue
389 self.maxvalue = maxvalue
395 self.maxvalue = maxvalue
390 self.deltax = deltax
396 self.deltax = deltax
391 self.deltay = deltay
397 self.deltay = deltay
392 self.colorbar = colorbar
398 self.colorbar = colorbar
393
399
394 def plot(self, currenttime, range, data):
400 def plot(self, currenttime, range, data):
395
401
396 if self.xmaxpos == None:
402 if self.xmaxpos == None:
397 self.xmaxpos = currenttime
403 self.xmaxpos = currenttime
398
404
399 # if currenttime >= self.xmaxpos:
405 # if currenttime >= self.xmaxpos:
400
406
401 self.xminpos = currenttime
407 self.xminpos = currenttime
402 self.xmaxpos = currenttime + self.deltax
408 self.xmaxpos = currenttime + self.deltax
403 x = [currenttime]
409 x = [currenttime]
404 y = range
410 y = range
405 z = numpy.reshape(data, (1,-1))
411 z = numpy.reshape(data, (1,-1))
406 getGrid = True
412 getGrid = True
407
413
408 self.plotPcolor(x, y, z, self.deltax, self.deltay, getGrid)
414 self.plotPcolor(x, y, z, self.deltax, self.deltay, getGrid)
409
415
410
416
411 class ScopeFigure(Figure):
417 class ScopeFigure(Figure):
412 overplot = 0
418 overplot = 0
413 xw = 700
419 xw = 700
414 yw = 650
420 yw = 650
415 colorbar = None
421 colorbar = None
416
422
417 def __init__(self,idfigure,nframes,wintitle,driver):
423 def __init__(self,idfigure,nframes,wintitle,driver):
418 colormap = None
424 colormap = None
419 colorbar = False
425 colorbar = False
420
426
421 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
427 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
422
428
423
429
424 def getSubplots(self):
430 def getSubplots(self):
425 nrows = self.nframes
431 nrows = self.nframes
426 ncolumns = 1
432 ncolumns = 1
427 return nrows, ncolumns
433 return nrows, ncolumns
428
434
429 def createFrames(self):
435 def createFrames(self):
436
437 self.frameObjList = []
438
430 for frame in range(self.nframes):
439 for frame in range(self.nframes):
431 frameObj = ScopeFrame(self.drvObj,frame + 1)
440 frameObj = ScopeFrame(self.drvObj,frame + 1)
432 self.frameObjList.append(frameObj)
441 self.frameObjList.append(frameObj)
433
442
434
443
435 class ScopeFrame(Frame):
444 class ScopeFrame(Frame):
436 # plotObjList = []
445 # plotObjList = []
437 xlabel = ""
446 xlabel = ""
438 ylabel = ""
447 ylabel = ""
439 title = ""
448 title = ""
440 def __init__(self,drvObj,idframe):
449 def __init__(self,drvObj,idframe):
441 self.drvObj = drvObj
450 self.drvObj = drvObj
442 self.idframe = idframe
451 self.idframe = idframe
443 self.nplots = 1 #nplots/frame
452 self.nplots = 1 #nplots/frame
444 self.createPlots()
453 self.createPlots()
445 # Frame.__init__(self, drvObj, idframe)
454 # Frame.__init__(self, drvObj, idframe)
446
455
447 def getScreenPosMainPlot(self):#cada Frame determina las coordenadas de los plots
456 def getScreenPosMainPlot(self):#cada Frame determina las coordenadas de los plots
448 xi = 0.08; xw = 0.9
457 xi = 0.08; xw = 0.9
449 yi = 0.20; yw = 0.75
458 yi = 0.20; yw = 0.75
450 return xi,yi,xw,yw
459 return xi,yi,xw,yw
451
460
452 def createPlots(self):
461 def createPlots(self):
453 plotObjList = []
462 plotObjList = []
454 for idplot in range(self.nplots):
463 for idplot in range(self.nplots):
455 xi, yi, xw, yw = self.getScreenPos(idplot)
464 xi, yi, xw, yw = self.getScreenPos(idplot)
456 type = "scopebox"
465 type = "scopebox"
457 title = "Channel %d"%self.idframe
466 title = "Channel %d"%self.idframe
458 xlabel = "range (Km)"
467 xlabel = "range (Km)"
459 ylabel = "intensity"
468 ylabel = "intensity"
460 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel)
469 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel)
461 plotObjList.append(plotObj)
470 plotObjList.append(plotObj)
462 self.plotObjList = plotObjList
471 self.plotObjList = plotObjList
463 # self.plotObjList.append(plotObj)
472 # self.plotObjList.append(plotObj)
464
473
465 def plot(self, x, y, z=None):
474 def plot(self, x, y, z=None):
466 for plotObj in self.plotObjList:
475 for plotObj in self.plotObjList:
467 plotObj.plot(x, y)
476 plotObj.plot(x, y)
468
477
469
478
470 class Plot1D(Plot):
479 class Plot1D(Plot):
471 # type, title, xlabel, ylabel
480 # type, title, xlabel, ylabel
472 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel):
481 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel):
473 self.drvObj = drvObj
482 self.drvObj = drvObj
474 self.idframe = idframe
483 self.idframe = idframe
475 self.idplot = idplot
484 self.idplot = idplot
476 self.xi = xi
485 self.xi = xi
477 self.yi = yi
486 self.yi = yi
478 self.xw = xw
487 self.xw = xw
479 self.yw = yw
488 self.yw = yw
480 self.xpos = [self.xi,self.xw]
489 self.xpos = [self.xi,self.xw]
481 self.ypos = [self.yi,self.yw]
490 self.ypos = [self.yi,self.yw]
482 self.xaxisastime = False
491 self.xaxisastime = False
483 self.timefmt = None
492 self.timefmt = None
484 self.xopt = "bcnst"
493 self.xopt = "bcnst"
485 self.yopt = "bcnstv"
494 self.yopt = "bcnstv"
486 self.szchar = 1.0
495 self.szchar = 1.0
487 self.type = type
496 self.type = type
488 self.title = title
497 self.title = title
489 self.xlabel = xlabel
498 self.xlabel = xlabel
490 self.ylabel = ylabel
499 self.ylabel = ylabel
491
500
492
501
493
502
494 def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
503 def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
495 if self.type == "pwbox":
504 if self.type == "pwbox":
496 self.xmin = minvalue
505 self.xmin = minvalue
497 self.xmax = maxvalue
506 self.xmax = maxvalue
498 self.ymin = ymin
507 self.ymin = ymin
499 self.ymax = ymax
508 self.ymax = ymax
500 self.minvalue = minvalue
509 self.minvalue = minvalue
501 self.maxvalue = maxvalue
510 self.maxvalue = maxvalue
502
511
503 else:
512 else:
504 self.xmin = xmin
513 self.xmin = xmin
505 self.xmax = xmax
514 self.xmax = xmax
506 self.ymin = ymin
515 self.ymin = ymin
507 self.ymax = ymax
516 self.ymax = ymax
508 self.minvalue = minvalue
517 self.minvalue = minvalue
509 self.maxvalue = maxvalue
518 self.maxvalue = maxvalue
510
519
511 self.colorbar = False
520 self.colorbar = False
512
521
513 def plot(self,x,y):
522 def plot(self,x,y):
514 if y.dtype == "complex128":
523 if y.dtype == "complex128":
515 color="blue"
524 color="blue"
516 self.plotBasicLine(x, y.real, color)
525 self.plotBasicLine(x, y.real, color)
517 color="red"
526 color="red"
518 self.plotBasicLine(x, y.imag, color)
527 self.plotBasicLine(x, y.imag, color)
519 else:
528 else:
520 color="blue"
529 color="blue"
521 self.plotBasicLine(x, y, color)
530 self.plotBasicLine(x, y, color)
@@ -1,596 +1,597
1 '''
1 '''
2
2
3 $Author$
3 $Author$
4 $Id$
4 $Id$
5 '''
5 '''
6
6
7 import os, sys
7 import os, sys
8 import numpy
8 import numpy
9 import time
9 import time
10 import datetime
10 import datetime
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 Data.JROData import Spectra, SpectraHeis
14 from Data.JROData import Spectra, SpectraHeis
15 from IO.SpectraIO import SpectraWriter
15 from IO.SpectraIO import SpectraWriter
16 from Graphics.schainPlotTypes import ScopeFigure, SpcFigure
16 from Graphics.schainPlotTypes import ScopeFigure, SpcFigure
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 writerObjList = []
32 writerObjList = []
33
33
34 integratorObjIndex = None
34 integratorObjIndex = None
35
35
36 writerObjIndex = None
36 writerObjIndex = None
37
37
38 profIndex = 0 # Se emplea cuando el objeto de entrada es un Voltage
38 profIndex = 0 # Se emplea cuando el objeto de entrada es un Voltage
39
39
40
40
41 def __init__(self):
41 def __init__(self):
42 '''
42 '''
43 Constructor
43 Constructor
44 '''
44 '''
45
45
46 self.integratorObjIndex = None
46 self.integratorObjIndex = None
47 self.writerObjIndex = None
47 self.writerObjIndex = None
48 self.plotObjIndex = None
48 self.plotObjIndex = None
49 self.integratorOst = []
49 self.integratorOst = []
50 self.plotObjList = []
50 self.plotObjList = []
51 self.noiseObj = []
51 self.noiseObj = []
52 self.writerObjList = []
52 self.writerObjList = []
53 self.buffer = None
53 self.buffer = None
54 self.profIndex = 0
54 self.profIndex = 0
55
55
56 def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairList=None):
56 def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairList=None):
57
57
58 if dataInObj == None:
58 if dataInObj == None:
59 raise ValueError, "This SpectraProcessor.setup() function needs dataInObj input variable"
59 raise ValueError, "This SpectraProcessor.setup() function needs dataInObj input variable"
60
60
61 if dataInObj.type == "Voltage":
61 if dataInObj.type == "Voltage":
62 if nFFTPoints == None:
62 if nFFTPoints == None:
63 raise ValueError, "This SpectraProcessor.setup() function needs nFFTPoints input variable"
63 raise ValueError, "This SpectraProcessor.setup() function needs nFFTPoints input variable"
64
64
65
65
66
66
67 if dataInObj.type == "Spectra":
67 if dataInObj.type == "Spectra":
68 if nFFTPoints != None:
68 if nFFTPoints != None:
69 raise ValueError, "The nFFTPoints cannot be selected to this object type"
69 raise ValueError, "The nFFTPoints cannot be selected to this object type"
70
70
71 nFFTPoints = dataInObj.nFFTPoints
71 nFFTPoints = dataInObj.nFFTPoints
72
72
73 if pairList == None:
73 if pairList == None:
74 pairList = self.dataInObj.pairList
74 pairList = self.dataInObj.pairList
75
75
76 if pairList == None:
76 if pairList == None:
77 nPairs = 0
77 nPairs = 0
78 else:
78 else:
79 nPairs = len(pairList)
79 nPairs = len(pairList)
80
80
81 self.dataInObj = dataInObj
81 self.dataInObj = dataInObj
82
82
83 if dataOutObj == None:
83 if dataOutObj == None:
84 dataOutObj = Spectra()
84 dataOutObj = Spectra()
85
85
86 self.dataOutObj = dataOutObj
86 self.dataOutObj = dataOutObj
87 self.dataOutObj.nFFTPoints = nFFTPoints
87 self.dataOutObj.nFFTPoints = nFFTPoints
88 self.dataOutObj.pairList = pairList
88 self.dataOutObj.pairList = pairList
89 self.dataOutObj.nPairs = nPairs
89 self.dataOutObj.nPairs = nPairs
90
90
91 return self.dataOutObj
91 return self.dataOutObj
92
92
93 def init(self):
93 def init(self):
94
94
95 self.dataOutObj.flagNoData = True
95 self.dataOutObj.flagNoData = True
96
96
97 if self.dataInObj.flagNoData:
97 if self.dataInObj.flagNoData:
98 return 0
98 return 0
99
99
100 self.integratorObjIndex = 0
100 self.integratorObjIndex = 0
101 self.writerObjIndex = 0
101 self.writerObjIndex = 0
102 self.plotObjIndex = 0
102 self.plotObjIndex = 0
103
103
104
104
105 if self.dataInObj.type == "Spectra":
105 if self.dataInObj.type == "Spectra":
106
106
107 self.dataOutObj.copy(self.dataInObj)
107 self.dataOutObj.copy(self.dataInObj)
108 self.dataOutObj.flagNoData = False
108 self.dataOutObj.flagNoData = False
109 return
109 return
110
110
111 if self.dataInObj.type == "Voltage":
111 if self.dataInObj.type == "Voltage":
112
112
113 if self.buffer == None:
113 if self.buffer == None:
114 self.buffer = numpy.zeros((self.dataInObj.nChannels,
114 self.buffer = numpy.zeros((self.dataInObj.nChannels,
115 self.dataOutObj.nFFTPoints,
115 self.dataOutObj.nFFTPoints,
116 self.dataInObj.nHeights),
116 self.dataInObj.nHeights),
117 dtype='complex')
117 dtype='complex')
118
118
119 self.buffer[:,self.profIndex,:] = self.dataInObj.data
119 self.buffer[:,self.profIndex,:] = self.dataInObj.data
120 self.profIndex += 1
120 self.profIndex += 1
121
121
122 if self.profIndex == self.dataOutObj.nFFTPoints:
122 if self.profIndex == self.dataOutObj.nFFTPoints:
123
123
124 self.__updateObjFromInput()
124 self.__updateObjFromInput()
125 self.__getFft()
125 self.__getFft()
126
126
127 self.dataOutObj.flagNoData = False
127 self.dataOutObj.flagNoData = False
128
128
129 self.buffer = None
129 self.buffer = None
130 self.profIndex = 0
130 self.profIndex = 0
131
131
132 return
132 return
133
133
134 #Other kind of data
134 #Other kind of data
135 raise ValueError, "The type object %(s) is not valid " %(self.dataOutObj.type)
135 raise ValueError, "The type object %(s) is not valid " %(self.dataOutObj.type)
136
136
137 def __getFft(self):
137 def __getFft(self):
138 """
138 """
139 Convierte valores de Voltaje a Spectra
139 Convierte valores de Voltaje a Spectra
140
140
141 Affected:
141 Affected:
142 self.dataOutObj.data_spc
142 self.dataOutObj.data_spc
143 self.dataOutObj.data_cspc
143 self.dataOutObj.data_cspc
144 self.dataOutObj.data_dc
144 self.dataOutObj.data_dc
145 self.dataOutObj.heightList
145 self.dataOutObj.heightList
146 self.dataOutObj.m_BasicHeader
146 self.dataOutObj.m_BasicHeader
147 self.dataOutObj.m_ProcessingHeader
147 self.dataOutObj.m_ProcessingHeader
148 self.dataOutObj.radarControllerHeaderObj
148 self.dataOutObj.radarControllerHeaderObj
149 self.dataOutObj.systemHeaderObj
149 self.dataOutObj.systemHeaderObj
150 self.profIndex
150 self.profIndex
151 self.buffer
151 self.buffer
152 self.dataOutObj.flagNoData
152 self.dataOutObj.flagNoData
153 self.dataOutObj.dtype
153 self.dataOutObj.dtype
154 self.dataOutObj.nPairs
154 self.dataOutObj.nPairs
155 self.dataOutObj.nChannels
155 self.dataOutObj.nChannels
156 self.dataOutObj.nProfiles
156 self.dataOutObj.nProfiles
157 self.dataOutObj.systemHeaderObj.numChannels
157 self.dataOutObj.systemHeaderObj.numChannels
158 self.dataOutObj.m_ProcessingHeader.totalSpectra
158 self.dataOutObj.m_ProcessingHeader.totalSpectra
159 self.dataOutObj.m_ProcessingHeader.profilesPerBlock
159 self.dataOutObj.m_ProcessingHeader.profilesPerBlock
160 self.dataOutObj.m_ProcessingHeader.numHeights
160 self.dataOutObj.m_ProcessingHeader.numHeights
161 self.dataOutObj.m_ProcessingHeader.spectraComb
161 self.dataOutObj.m_ProcessingHeader.spectraComb
162 self.dataOutObj.m_ProcessingHeader.shif_fft
162 self.dataOutObj.m_ProcessingHeader.shif_fft
163 """
163 """
164
164
165 fft_volt = numpy.fft.fft(self.buffer,axis=1)
165 fft_volt = numpy.fft.fft(self.buffer,axis=1)
166 dc = fft_volt[:,0,:]
166 dc = fft_volt[:,0,:]
167
167
168 #calculo de self-spectra
168 #calculo de self-spectra
169 fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,))
169 fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,))
170 spc = fft_volt * numpy.conjugate(fft_volt)
170 spc = fft_volt * numpy.conjugate(fft_volt)
171 spc = spc.real
171 spc = spc.real
172
172
173 blocksize = 0
173 blocksize = 0
174 blocksize += dc.size
174 blocksize += dc.size
175 blocksize += spc.size
175 blocksize += spc.size
176
176
177 cspc = None
177 cspc = None
178 pairIndex = 0
178 pairIndex = 0
179 if self.dataOutObj.pairList != None:
179 if self.dataOutObj.pairList != None:
180 #calculo de cross-spectra
180 #calculo de cross-spectra
181 cspc = numpy.zeros((self.dataOutObj.nPairs, self.dataOutObj.nFFTPoints, self.dataOutObj.nHeights), dtype='complex')
181 cspc = numpy.zeros((self.dataOutObj.nPairs, self.dataOutObj.nFFTPoints, self.dataOutObj.nHeights), dtype='complex')
182 for pair in self.pairList:
182 for pair in self.pairList:
183 cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:]))
183 cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:]))
184 pairIndex += 1
184 pairIndex += 1
185 blocksize += cspc.size
185 blocksize += cspc.size
186
186
187 self.dataOutObj.data_spc = spc
187 self.dataOutObj.data_spc = spc
188 self.dataOutObj.data_cspc = cspc
188 self.dataOutObj.data_cspc = cspc
189 self.dataOutObj.data_dc = dc
189 self.dataOutObj.data_dc = dc
190 self.dataOutObj.blockSize = blocksize
190 self.dataOutObj.blockSize = blocksize
191
191
192 # self.getNoise()
192 # self.getNoise()
193
193
194 def __updateObjFromInput(self):
194 def __updateObjFromInput(self):
195
195
196 self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy()
196 self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy()
197 self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy()
197 self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy()
198 self.dataOutObj.channelList = self.dataInObj.channelList
198 self.dataOutObj.channelList = self.dataInObj.channelList
199 self.dataOutObj.heightList = self.dataInObj.heightList
199 self.dataOutObj.heightList = self.dataInObj.heightList
200 self.dataOutObj.dtype = self.dataInObj.dtype
200 self.dataOutObj.dtype = self.dataInObj.dtype
201 self.dataOutObj.nHeights = self.dataInObj.nHeights
201 self.dataOutObj.nHeights = self.dataInObj.nHeights
202 self.dataOutObj.nChannels = self.dataInObj.nChannels
202 self.dataOutObj.nChannels = self.dataInObj.nChannels
203 self.dataOutObj.nBaud = self.dataInObj.nBaud
203 self.dataOutObj.nBaud = self.dataInObj.nBaud
204 self.dataOutObj.nCode = self.dataInObj.nCode
204 self.dataOutObj.nCode = self.dataInObj.nCode
205 self.dataOutObj.code = self.dataInObj.code
205 self.dataOutObj.code = self.dataInObj.code
206 self.dataOutObj.nProfiles = self.dataOutObj.nFFTPoints
206 self.dataOutObj.nProfiles = self.dataOutObj.nFFTPoints
207 self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList
207 self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList
208 self.dataOutObj.flagTimeBlock = self.dataInObj.flagTimeBlock
208 self.dataOutObj.flagTimeBlock = self.dataInObj.flagTimeBlock
209 self.dataOutObj.utctime = self.dataInObj.utctime
209 self.dataOutObj.utctime = self.dataInObj.utctime
210 self.dataOutObj.flagDecodeData = self.dataInObj.flagDecodeData #asumo q la data esta decodificada
210 self.dataOutObj.flagDecodeData = self.dataInObj.flagDecodeData #asumo q la data esta decodificada
211 self.dataOutObj.flagDeflipData = self.dataInObj.flagDeflipData #asumo q la data esta sin flip
211 self.dataOutObj.flagDeflipData = self.dataInObj.flagDeflipData #asumo q la data esta sin flip
212 self.dataOutObj.flagShiftFFT = self.dataInObj.flagShiftFFT
212 self.dataOutObj.flagShiftFFT = self.dataInObj.flagShiftFFT
213 self.dataOutObj.nIncohInt = 1
213 self.dataOutObj.nIncohInt = 1
214
214
215 def addWriter(self, wrpath, blocksPerFile):
215 def addWriter(self, wrpath, blocksPerFile):
216
216
217 objWriter = SpectraWriter(self.dataOutObj)
217 objWriter = SpectraWriter(self.dataOutObj)
218 objWriter.setup(wrpath, blocksPerFile)
218 objWriter.setup(wrpath, blocksPerFile)
219 self.writerObjList.append(objWriter)
219 self.writerObjList.append(objWriter)
220
220
221 def addIntegrator(self,N,timeInterval):
221 def addIntegrator(self,N,timeInterval):
222
222
223 objIncohInt = IncoherentIntegration(N,timeInterval)
223 objIncohInt = IncoherentIntegration(N,timeInterval)
224 self.integratorObjList.append(objIncohInt)
224 self.integratorObjList.append(objIncohInt)
225
225
226 def addSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile):
226 def addSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile):
227
227
228 spcObj = SpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile)
228 spcObj = SpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile)
229 self.plotObjList.append(spcObj)
229 self.plotObjList.append(spcObj)
230
230
231 def plotSpc(self, idfigure=None,
231 def plotSpc(self, idfigure=None,
232 xmin=None,
232 xmin=None,
233 xmax=None,
233 xmax=None,
234 ymin=None,
234 ymin=None,
235 ymax=None,
235 ymax=None,
236 minvalue=None,
236 minvalue=None,
237 maxvalue=None,
237 maxvalue=None,
238 wintitle='',
238 wintitle='',
239 driver='plplot',
239 driver='plplot',
240 colormap='br_green',
240 colormap='br_green',
241 colorbar=True,
241 colorbar=True,
242 showprofile=False,
242 showprofile=False,
243 save=False,
243 save=False,
244 gpath=None,
244 gpath=None,
245 channelList = None):
245 channelList = None):
246
246
247 if self.dataOutObj.flagNoData:
247 if self.dataOutObj.flagNoData:
248 return 0
248 return 0
249
249
250 if channelList == None:
250 if channelList == None:
251 channelList = self.dataOutObj.channelList
251 channelList = self.dataOutObj.channelList
252
252
253 nframes = len(channelList)
253 nframes = len(channelList)
254
254
255 if len(self.plotObjList) <= self.plotObjIndex:
255 if len(self.plotObjList) <= self.plotObjIndex:
256 self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile)
256 self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile)
257
257
258 x = numpy.arange(self.dataOutObj.nFFTPoints)
258 x = numpy.arange(self.dataOutObj.nFFTPoints)
259
259
260 y = self.dataOutObj.heightList
260 y = self.dataOutObj.heightList
261
261
262 data = 10.*numpy.log10(self.dataOutObj.data_spc[channelList,:,:])
262 data = 10.*numpy.log10(self.dataOutObj.data_spc[channelList,:,:])
263 # noisedB = 10.*numpy.log10(noise)
263 # noisedB = 10.*numpy.log10(noise)
264 noisedB = numpy.arange(len(channelList)+1)
264 noisedB = numpy.arange(len(channelList)+1)
265 noisedB = noisedB *1.2
265 noisedB = noisedB *1.2
266 titleList = []
266 titleList = []
267 for i in range(len(noisedB)):
267 for i in range(len(noisedB)):
268 title = "%.2f"%noisedB[i]
268 title = "%.2f"%noisedB[i]
269 titleList.append(title)
269 titleList.append(title)
270
270
271 thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime)
271 thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime)
272 dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S"))
272 dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S"))
273 figuretitle = "Spc Radar Data: %s"%dateTime
273 figuretitle = "Spc Radar Data: %s"%dateTime
274
274
275 cleardata = True
275 cleardata = True
276
276
277 plotObj = self.plotObjList[self.plotObjIndex]
277 plotObj = self.plotObjList[self.plotObjIndex]
278
278
279 plotObj.plotPcolor(data,
279 plotObj.plotPcolor(data,
280 x,
280 x=x,
281 y,
281 y=y,
282 channelList,
282 channelList=channelList,
283 xmin,
283 xmin=xmin,
284 xmax,
284 xmax=xmax,
285 ymin,
285 ymin=ymin,
286 ymax,
286 ymax=ymax,
287 minvalue,
287 minvalue=minvalue,
288 maxvalue,
288 maxvalue=maxvalue,
289 figuretitle,
289 figuretitle=figuretitle,
290 None,
290 xrangestep=None,
291 save,
291 deltax=None,
292 gpath,
292 save=False,
293 cleardata,
293 gpath='./',
294 titleList)
294 clearData=True
295 )
295
296
296 self.plotObjIndex += 1
297 self.plotObjIndex += 1
297
298
298
299
299 def writeData(self, wrpath, blocksPerFile):
300 def writeData(self, wrpath, blocksPerFile):
300
301
301 if self.dataOutObj.flagNoData:
302 if self.dataOutObj.flagNoData:
302 return 0
303 return 0
303
304
304 if len(self.writerObjList) <= self.writerObjIndex:
305 if len(self.writerObjList) <= self.writerObjIndex:
305 self.addWriter(wrpath, blocksPerFile)
306 self.addWriter(wrpath, blocksPerFile)
306
307
307 self.writerObjList[self.writerObjIndex].putData()
308 self.writerObjList[self.writerObjIndex].putData()
308
309
309 self.writerObjIndex += 1
310 self.writerObjIndex += 1
310
311
311 def integrator(self, N=None, timeInterval=None):
312 def integrator(self, N=None, timeInterval=None):
312
313
313 if self.dataOutObj.flagNoData:
314 if self.dataOutObj.flagNoData:
314 return 0
315 return 0
315
316
316 if len(self.integratorObjList) <= self.integratorObjIndex:
317 if len(self.integratorObjList) <= self.integratorObjIndex:
317 self.addIntegrator(N,timeInterval)
318 self.addIntegrator(N,timeInterval)
318
319
319 myIncohIntObj = self.integratorObjList[self.integratorObjIndex]
320 myIncohIntObj = self.integratorObjList[self.integratorObjIndex]
320 myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc)
321 myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc)
321
322
322 if myIncohIntObj.isReady:
323 if myIncohIntObj.isReady:
323 self.dataOutObj.data_spc = myIncohIntObj.data
324 self.dataOutObj.data_spc = myIncohIntObj.data
324 self.dataOutObj.nAvg = myIncohIntObj.navg
325 self.dataOutObj.nAvg = myIncohIntObj.navg
325 self.dataOutObj.m_ProcessingHeader.incoherentInt = self.dataInObj.m_ProcessingHeader.incoherentInt*myIncohIntObj.navg
326 self.dataOutObj.m_ProcessingHeader.incoherentInt = self.dataInObj.m_ProcessingHeader.incoherentInt*myIncohIntObj.navg
326 self.dataOutObj.flagNoData = False
327 self.dataOutObj.flagNoData = False
327
328
328 """Calcular el ruido"""
329 """Calcular el ruido"""
329 self.getNoise()
330 self.getNoise()
330 else:
331 else:
331 self.dataOutObj.flagNoData = True
332 self.dataOutObj.flagNoData = True
332
333
333 self.integratorObjIndex += 1
334 self.integratorObjIndex += 1
334
335
335
336
336 class SpectraHeisProcessor:
337 class SpectraHeisProcessor:
337
338
338 def __init__(self):
339 def __init__(self):
339
340
340 self.integratorObjIndex = None
341 self.integratorObjIndex = None
341 self.writerObjIndex = None
342 self.writerObjIndex = None
342 self.plotObjIndex = None
343 self.plotObjIndex = None
343 self.integratorObjList = []
344 self.integratorObjList = []
344 self.writerObjList = []
345 self.writerObjList = []
345 self.plotObjList = []
346 self.plotObjList = []
346 #self.noiseObj = Noise()
347 #self.noiseObj = Noise()
347
348
348 def setup(self, dataInObj, dataOutObj=None, nFFTPoints=None, pairList=None):
349 def setup(self, dataInObj, dataOutObj=None, nFFTPoints=None, pairList=None):
349
350
350 if nFFTPoints == None:
351 if nFFTPoints == None:
351 nFFTPoints = self.dataInObj.nHeights
352 nFFTPoints = self.dataInObj.nHeights
352
353
353 self.dataInObj = dataInObj
354 self.dataInObj = dataInObj
354
355
355 if dataOutObj == None:
356 if dataOutObj == None:
356 dataOutObj = SpectraHeis()
357 dataOutObj = SpectraHeis()
357
358
358 self.dataOutObj = dataOutObj
359 self.dataOutObj = dataOutObj
359
360
360 return self.dataOutObj
361 return self.dataOutObj
361
362
362 def init(self):
363 def init(self):
363
364
364 self.dataOutObj.flagNoData = True
365 self.dataOutObj.flagNoData = True
365
366
366 if self.dataInObj.flagNoData:
367 if self.dataInObj.flagNoData:
367 return 0
368 return 0
368
369
369 self.integratorObjIndex = 0
370 self.integratorObjIndex = 0
370 self.writerObjIndex = 0
371 self.writerObjIndex = 0
371 self.plotObjIndex = 0
372 self.plotObjIndex = 0
372
373
373 if self.dataInObj.type == "Voltage":
374 if self.dataInObj.type == "Voltage":
374 self.__updateObjFromInput()
375 self.__updateObjFromInput()
375 self.__getFft()
376 self.__getFft()
376 self.dataOutObj.flagNoData = False
377 self.dataOutObj.flagNoData = False
377 return
378 return
378
379
379 #Other kind of data
380 #Other kind of data
380 if self.dataInObj.type == "SpectraHeis":
381 if self.dataInObj.type == "SpectraHeis":
381 self.dataOutObj.copy(self.dataInObj)
382 self.dataOutObj.copy(self.dataInObj)
382 self.dataOutObj.flagNoData = False
383 self.dataOutObj.flagNoData = False
383 return
384 return
384
385
385 raise ValueError, "The type is not valid"
386 raise ValueError, "The type is not valid"
386
387
387 def __updateObjFromInput(self):
388 def __updateObjFromInput(self):
388
389
389 self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy()
390 self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy()
390 self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy()
391 self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy()
391 self.dataOutObj.channelList = self.dataInObj.channelList
392 self.dataOutObj.channelList = self.dataInObj.channelList
392 self.dataOutObj.heightList = self.dataInObj.heightList
393 self.dataOutObj.heightList = self.dataInObj.heightList
393 self.dataOutObj.dtype = self.dataInObj.dtype
394 self.dataOutObj.dtype = self.dataInObj.dtype
394 self.dataOutObj.nHeights = self.dataInObj.nHeights
395 self.dataOutObj.nHeights = self.dataInObj.nHeights
395 self.dataOutObj.nChannels = self.dataInObj.nChannels
396 self.dataOutObj.nChannels = self.dataInObj.nChannels
396 self.dataOutObj.nBaud = self.dataInObj.nBaud
397 self.dataOutObj.nBaud = self.dataInObj.nBaud
397 self.dataOutObj.nCode = self.dataInObj.nCode
398 self.dataOutObj.nCode = self.dataInObj.nCode
398 self.dataOutObj.code = self.dataInObj.code
399 self.dataOutObj.code = self.dataInObj.code
399 self.dataOutObj.nProfiles = 1
400 self.dataOutObj.nProfiles = 1
400 self.dataOutObj.nFFTPoints = self.dataInObj.nHeights
401 self.dataOutObj.nFFTPoints = self.dataInObj.nHeights
401 self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList
402 self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList
402 self.dataOutObj.flagNoData = self.dataInObj.flagNoData
403 self.dataOutObj.flagNoData = self.dataInObj.flagNoData
403 self.dataOutObj.flagTimeBlock = self.dataInObj.flagTimeBlock
404 self.dataOutObj.flagTimeBlock = self.dataInObj.flagTimeBlock
404 self.dataOutObj.utctime = self.dataInObj.utctime
405 self.dataOutObj.utctime = self.dataInObj.utctime
405 self.dataOutObj.flagDecodeData = self.dataInObj.flagDecodeData #asumo q la data esta decodificada
406 self.dataOutObj.flagDecodeData = self.dataInObj.flagDecodeData #asumo q la data esta decodificada
406 self.dataOutObj.flagDeflipData = self.dataInObj.flagDeflipData #asumo q la data esta sin flip
407 self.dataOutObj.flagDeflipData = self.dataInObj.flagDeflipData #asumo q la data esta sin flip
407 self.dataOutObj.flagShiftFFT = self.dataInObj.flagShiftFFT
408 self.dataOutObj.flagShiftFFT = self.dataInObj.flagShiftFFT
408 self.dataOutObj.nIncohInt = 1
409 self.dataOutObj.nIncohInt = 1
409
410
410 def __getFft(self):
411 def __getFft(self):
411
412
412 fft_volt = numpy.fft.fft(self.dataInObj.data, axis=1)
413 fft_volt = numpy.fft.fft(self.dataInObj.data, axis=1)
413 #print fft_volt
414 #print fft_volt
414 #calculo de self-spectra
415 #calculo de self-spectra
415 fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,))
416 fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,))
416
417
417 spc = numpy.abs(fft_volt * numpy.conjugate(fft_volt))
418 spc = numpy.abs(fft_volt * numpy.conjugate(fft_volt))
418 self.dataOutObj.data_spc = spc
419 self.dataOutObj.data_spc = spc
419
420
420 def getSpectra(self):
421 def getSpectra(self):
421
422
422 return self.dataOutObj.data_spc
423 return self.dataOutObj.data_spc
423
424
424 def getFrecuencies(self):
425 def getFrecuencies(self):
425
426
426 print self.nFFTPoints
427 print self.nFFTPoints
427 return numpy.arange(int(self.nFFTPoints))
428 return numpy.arange(int(self.nFFTPoints))
428
429
429 def addIntegrator(self,N,timeInterval):
430 def addIntegrator(self,N,timeInterval):
430
431
431 objIncohInt = IncoherentIntegration(N,timeInterval)
432 objIncohInt = IncoherentIntegration(N,timeInterval)
432 self.integratorObjList.append(objIncohInt)
433 self.integratorObjList.append(objIncohInt)
433
434
434 def integrator(self, N=None, timeInterval=None):
435 def integrator(self, N=None, timeInterval=None):
435
436
436 if self.dataOutObj.flagNoData:
437 if self.dataOutObj.flagNoData:
437 return 0
438 return 0
438
439
439 if len(self.integratorObjList) <= self.integratorObjIndex:
440 if len(self.integratorObjList) <= self.integratorObjIndex:
440 self.addIntegrator(N,timeInterval)
441 self.addIntegrator(N,timeInterval)
441
442
442 myIncohIntObj = self.integratorObjList[self.integratorObjIndex]
443 myIncohIntObj = self.integratorObjList[self.integratorObjIndex]
443 myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.utctime)
444 myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.utctime)
444
445
445 if myIncohIntObj.isReady:
446 if myIncohIntObj.isReady:
446 self.dataOutObj.data_spc = myIncohIntObj.data
447 self.dataOutObj.data_spc = myIncohIntObj.data
447 self.dataOutObj.nIncohInt = self.dataOutObj.nIncohInt*myIncohIntObj.navg
448 self.dataOutObj.nIncohInt = self.dataOutObj.nIncohInt*myIncohIntObj.navg
448 self.dataOutObj.flagNoData = False
449 self.dataOutObj.flagNoData = False
449
450
450 #self.getNoise(type="hildebrand",parm=myIncohIntObj.navg)
451 #self.getNoise(type="hildebrand",parm=myIncohIntObj.navg)
451 # self.getNoise(type="sort", parm=16)
452 # self.getNoise(type="sort", parm=16)
452
453
453 else:
454 else:
454 self.dataOutObj.flagNoData = True
455 self.dataOutObj.flagNoData = True
455
456
456 self.integratorObjIndex += 1
457 self.integratorObjIndex += 1
457
458
458
459
459 def addScope(self, idfigure, nframes, wintitle, driver):
460 def addScope(self, idfigure, nframes, wintitle, driver):
460
461
461 if idfigure==None:
462 if idfigure==None:
462 idfigure = self.plotObjIndex
463 idfigure = self.plotObjIndex
463
464
464 scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver)
465 scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver)
465 self.plotObjList.append(scopeObj)
466 self.plotObjList.append(scopeObj)
466
467
467 def plotScope(self,
468 def plotScope(self,
468 idfigure=None,
469 idfigure=None,
469 minvalue=None,
470 minvalue=None,
470 maxvalue=None,
471 maxvalue=None,
471 xmin=None,
472 xmin=None,
472 xmax=None,
473 xmax=None,
473 wintitle='',
474 wintitle='',
474 driver='plplot',
475 driver='plplot',
475 save=False,
476 save=False,
476 gpath=None,
477 gpath=None,
477 titleList=None,
478 titleList=None,
478 xlabelList=None,
479 xlabelList=None,
479 ylabelList=None):
480 ylabelList=None):
480
481
481 if self.dataOutObj.flagNoData:
482 if self.dataOutObj.flagNoData:
482 return 0
483 return 0
483
484
484 nframes = len(self.dataOutObj.channelList)
485 nframes = len(self.dataOutObj.channelList)
485
486
486 if len(self.plotObjList) <= self.plotObjIndex:
487 if len(self.plotObjList) <= self.plotObjIndex:
487 self.addScope(idfigure, nframes, wintitle, driver)
488 self.addScope(idfigure, nframes, wintitle, driver)
488
489
489
490
490 data1D = self.dataOutObj.data_spc
491 data1D = self.dataOutObj.data_spc
491
492
492 x = numpy.arange(self.dataOutObj.nHeights)
493 x = numpy.arange(self.dataOutObj.nHeights)
493
494
494 thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime)
495 thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime)
495
496
496 dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
497 dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
497 date = "%s"%(thisDatetime.strftime("%d-%b-%Y"))
498 date = "%s"%(thisDatetime.strftime("%d-%b-%Y"))
498
499
499 figureTitle = "Scope Plot Radar Data: " + date
500 figureTitle = "Scope Plot Radar Data: " + date
500
501
501 plotObj = self.plotObjList[self.plotObjIndex]
502 plotObj = self.plotObjList[self.plotObjIndex]
502
503
503 plotObj.plot1DArray(data1D,
504 plotObj.plot1DArray(data1D,
504 x,
505 x,
505 self.dataOutObj.channelList,
506 self.dataOutObj.channelList,
506 xmin,
507 xmin,
507 xmax,
508 xmax,
508 minvalue,
509 minvalue,
509 maxvalue,
510 maxvalue,
510 figureTitle,
511 figureTitle,
511 save,
512 save,
512 gpath)
513 gpath)
513
514
514 self.plotObjIndex += 1
515 self.plotObjIndex += 1
515
516
516 class IncoherentIntegration:
517 class IncoherentIntegration:
517
518
518 integ_counter = None
519 integ_counter = None
519 data = None
520 data = None
520 navg = None
521 navg = None
521 buffer = None
522 buffer = None
522 nIncohInt = None
523 nIncohInt = None
523
524
524 def __init__(self, N = None, timeInterval = None):
525 def __init__(self, N = None, timeInterval = None):
525 """
526 """
526 N
527 N
527 timeInterval - interval time [min], integer value
528 timeInterval - interval time [min], integer value
528 """
529 """
529
530
530 self.data = None
531 self.data = None
531 self.navg = None
532 self.navg = None
532 self.buffer = None
533 self.buffer = None
533 self.timeOut = None
534 self.timeOut = None
534 self.exitCondition = False
535 self.exitCondition = False
535 self.isReady = False
536 self.isReady = False
536 self.nIncohInt = N
537 self.nIncohInt = N
537 self.integ_counter = 0
538 self.integ_counter = 0
538 if timeInterval!=None:
539 if timeInterval!=None:
539 self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line
540 self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line
540
541
541 if ((timeInterval==None) and (N==None)):
542 if ((timeInterval==None) and (N==None)):
542 print 'N = None ; timeInterval = None'
543 print 'N = None ; timeInterval = None'
543 sys.exit(0)
544 sys.exit(0)
544 elif timeInterval == None:
545 elif timeInterval == None:
545 self.timeFlag = False
546 self.timeFlag = False
546 else:
547 else:
547 self.timeFlag = True
548 self.timeFlag = True
548
549
549
550
550 def exe(self,data,timeOfData):
551 def exe(self,data,timeOfData):
551 """
552 """
552 data
553 data
553
554
554 timeOfData [seconds]
555 timeOfData [seconds]
555 """
556 """
556
557
557 if self.timeFlag:
558 if self.timeFlag:
558 if self.timeOut == None:
559 if self.timeOut == None:
559 self.timeOut = timeOfData + self.timeIntervalInSeconds
560 self.timeOut = timeOfData + self.timeIntervalInSeconds
560
561
561 if timeOfData < self.timeOut:
562 if timeOfData < self.timeOut:
562 if self.buffer == None:
563 if self.buffer == None:
563 self.buffer = data
564 self.buffer = data
564 else:
565 else:
565 self.buffer = self.buffer + data
566 self.buffer = self.buffer + data
566 self.integ_counter += 1
567 self.integ_counter += 1
567 else:
568 else:
568 self.exitCondition = True
569 self.exitCondition = True
569
570
570 else:
571 else:
571 if self.integ_counter < self.nIncohInt:
572 if self.integ_counter < self.nIncohInt:
572 if self.buffer == None:
573 if self.buffer == None:
573 self.buffer = data
574 self.buffer = data
574 else:
575 else:
575 self.buffer = self.buffer + data
576 self.buffer = self.buffer + data
576
577
577 self.integ_counter += 1
578 self.integ_counter += 1
578
579
579 if self.integ_counter == self.nIncohInt:
580 if self.integ_counter == self.nIncohInt:
580 self.exitCondition = True
581 self.exitCondition = True
581
582
582 if self.exitCondition:
583 if self.exitCondition:
583 self.data = self.buffer
584 self.data = self.buffer
584 self.navg = self.integ_counter
585 self.navg = self.integ_counter
585 self.isReady = True
586 self.isReady = True
586 self.buffer = None
587 self.buffer = None
587 self.timeOut = None
588 self.timeOut = None
588 self.integ_counter = 0
589 self.integ_counter = 0
589 self.exitCondition = False
590 self.exitCondition = False
590
591
591 if self.timeFlag:
592 if self.timeFlag:
592 self.buffer = data
593 self.buffer = data
593 self.timeOut = timeOfData + self.timeIntervalInSeconds
594 self.timeOut = timeOfData + self.timeIntervalInSeconds
594 else:
595 else:
595 self.isReady = False
596 self.isReady = False
596 No newline at end of file
597
@@ -1,86 +1,101
1 '''
1 '''
2
2
3 $Author$
3 $Author$
4 $Id$
4 $Id$
5 '''
5 '''
6 import os, sys
6 import os, sys
7 import time, datetime
7 import time, datetime
8
8
9 path = os.path.split(os.getcwd())[0]
9 path = os.path.split(os.getcwd())[0]
10 sys.path.append(path)
10 sys.path.append(path)
11
11
12 from Data.JROData import Voltage
12 from Data.JROData import Voltage
13 from IO.VoltageIO import *
13 from IO.VoltageIO import *
14
14
15 from Processing.VoltageProcessor import *
15 from Processing.VoltageProcessor import *
16
16 from Processing.SpectraProcessor import *
17
17
18 class TestSChain():
18 class TestSChain():
19
19
20 def __init__(self):
20 def __init__(self):
21 self.setValues()
21 self.setValues()
22 self.createObjects()
22 self.createObjects()
23 self.testSChain()
23 self.testSChain()
24
24
25 def setValues(self):
25 def setValues(self):
26 self.path = "/home/roj-idl71/Data/RAWDATA/Meteors"
26 self.path = "/home/roj-idl71/Data/RAWDATA/Meteors"
27 self.path = "/remote/puma/2012_06/Meteors"
27
28
28 self.startDate = datetime.date(2005,1,1)
29 self.startDate = datetime.date(2012,1,1)
29 self.endDate = datetime.date(2012,7,30)
30 self.endDate = datetime.date(2012,12,30)
30
31
31 self.startTime = datetime.time(0,0,0)
32 self.startTime = datetime.time(0,0,0)
32 self.endTime = datetime.time(23,59,59)
33 self.endTime = datetime.time(23,59,59)
33
34
35 self.nFFTPoints = 64
36
34 self.wrpath = "/home/roj-idl71/tmp/results"
37 self.wrpath = "/home/roj-idl71/tmp/results"
35 self.profilesPerBlock = 40
38 self.profilesPerBlock = 40
36 self.blocksPerFile = 50
39 self.blocksPerFile = 50
37
40
38 def createObjects(self):
41 def createObjects(self):
39
42
40 self.readerObj = VoltageReader()
43 self.readerObj = VoltageReader()
41 self.voltProcObj = VoltageProcessor()
44 self.voltProcObj = VoltageProcessor()
42 self.specProcObj = SpectraProcessor()
45 self.specProcObj = SpectraProcessor()
43
46
44 self.voltObj1 = self.readerObj.setup(
47 self.voltObj1 = self.readerObj.setup(
45 path = self.path,
48 path = self.path,
46 startDate = self.startDate,
49 startDate = self.startDate,
47 endDate = self.endDate,
50 endDate = self.endDate,
48 startTime = self.startTime,
51 startTime = self.startTime,
49 endTime = self.endTime,
52 endTime = self.endTime,
50 expLabel = '',
53 expLabel = '',
51 online = 0)
54 online = 0)
52
55
53 self.voltObj2 = self.voltProcObj.setup(dataInObj = self.voltObj1)
56 self.voltObj2 = self.voltProcObj.setup(dataInObj = self.voltObj1)
57 self.specObj1 = self.specProcObj.setup(dataInObj = self.voltObj2, nFFTPoints = self.nFFTPoints)
54
58
55 def testSChain(self):
59 def testSChain(self):
56
60
57 ini = time.time()
61 ini = time.time()
58
62
59 while(True):
63 while(True):
60 self.readerObj.getData()
64 self.readerObj.getData()
61
65
62 self.voltProcObj.init()
66 self.voltProcObj.init()
63
67
64 self.voltProcObj.integrator(1000, overlapping=True)
68 self.voltProcObj.integrator(10, overlapping=False)
65 #
69 #
66 # self.voltProcObj.writeData(self.wrpath,self.profilesPerBlock,self.blocksPerFile)
70 # self.voltProcObj.writeData(self.wrpath,self.profilesPerBlock,self.blocksPerFile)
67
71
68
72
69 self.voltProcObj.plotScope(idfigure=1,
73 # self.voltProcObj.plotScope(idfigure=0,
70 wintitle='test plot library',
74 # wintitle='test plot library',
71 driver='plplot',
75 # driver='plplot',
72 save=False,
76 # save=False,
73 gpath=None,
77 # gpath=None,
74 type="power")
78 # type="power")
79
80 self.specProcObj.init()
81
82 self.specProcObj.plotSpc(idfigure=1,
83 wintitle='Spectra',
84 driver='plplot',
85 colormap='br_green',
86 colorbar=True,
87 showprofile=False,
88 save=False,
89 gpath=None)
75
90
76 if self.readerObj.flagNoMoreFiles:
91 if self.readerObj.flagNoMoreFiles:
77 break
92 break
78
93
79 if self.readerObj.flagIsNewBlock:
94 if self.readerObj.flagIsNewBlock:
80 # print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks, datetime.datetime.fromtimestamp(self.readerObj.basicHeaderObj.utc),)
95 # print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks, datetime.datetime.fromtimestamp(self.readerObj.basicHeaderObj.utc),)
81 print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks,
96 print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks,
82 datetime.datetime.utcfromtimestamp(self.readerObj.basicHeaderObj.utc + self.readerObj.basicHeaderObj.miliSecond/1000.0),)
97 datetime.datetime.fromtimestamp(self.readerObj.basicHeaderObj.utc + self.readerObj.basicHeaderObj.miliSecond/1000.0),)
83
98
84
99
85 if __name__ == '__main__':
100 if __name__ == '__main__':
86 TestSChain() No newline at end of file
101 TestSChain()
General Comments 0
You need to be logged in to leave comments. Login now