##// END OF EJS Templates
Para graficos se ha habilitado escritura de graficos en disco. Para el caso de RTI el intervalo[xmin,xmax] de ploteo en el eje X esta dado en segundos
Daniel Valdez -
r158:610e58680afb
parent child
Show More
@@ -9,7 +9,7 class Figure:
9 9 __isDriverOpen = False
10 10 __isFigureOpen = False
11 11 __isConfig = False
12
12 __counter = 0
13 13 drvObj = None
14 14 driver = None
15 15 idfigure = None
@@ -43,6 +43,7 class Figure:
43 43 self.__isDriverOpen = False
44 44 self.__isFigureOpen = False
45 45 self.__isConfig = False
46 self.__counter = 0
46 47
47 48 self.drvObj = Driver(driver, idfigure, xw, yw, wintitle, overplot, colormap, colorbar)
48 49 self.driver = driver
@@ -107,7 +108,7 class Figure:
107 108
108 109 self.drvObj.driver.save(filename)
109 110
110 def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvalue=None, figuretitle=None, save=False, gpath='./'):
111 def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvalue=None, figuretitle=None, save=False, gpath='./', ratio=1):
111 112
112 113 nx, ny = data1D.shape
113 114
@@ -146,7 +147,7 class Figure:
146 147 self.__newPage()
147 148
148 149
149 for channel in channelList:
150 for channel in range(len(channelList)):
150 151 frameObj = self.frameObjList[channel]
151 152 frameObj.init(xmin=self.xmin,
152 153 xmax=self.xmax,
@@ -155,20 +156,25 class Figure:
155 156 minvalue=self.minvalue,
156 157 maxvalue=self.maxvalue)
157 158
158 for channel in channelList:
159 for channel in range(len(channelList)):
159 160 dataCh = data1D[channel,:]
160 161 frameObj = self.frameObjList[channel]
161 162 frameObj.plot(x, dataCh)
162 163
163 164 self.__refresh()
164 165
165
166 166 if save:
167 path = gpath
168 now = datetime.datetime.now()
169 file = "scope_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond)
170 filename = os.path.join(path,file)
171 self.save(filename)
167 if self.__counter == 0:
168 path = gpath
169 now = datetime.datetime.now()
170 file = "plot_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond)
171 filename = os.path.join(path,file)
172 self.save(filename)
173 self.__counter += 1
174
175 if self.__counter == ratio:
176 self.__counter = 0
177
172 178
173 179 self.__closePage()
174 180
@@ -188,6 +194,7 class Figure:
188 194 deltax=None,
189 195 save=False,
190 196 gpath='./',
197 ratio=1,
191 198 cleardata=False,
192 199 *args):
193 200
@@ -223,7 +230,7 class Figure:
223 230 self.__newPage()
224 231 self.__isFigureOpen = True
225 232
226 for channel in channelList:
233 for channel in range(len(channelList)):
227 234 if len(args) != 0: value = args[0][channel]
228 235 else: value = args
229 236
@@ -240,13 +247,27 class Figure:
240 247 value)
241 248
242 249
243 for channel in channelList:
250 for channel in range(len(channelList)):
244 251 dataCh = data[channel,:]
245 252 frameObj = self.frameObjList[channel]
246 253 frameObj.plot(x, y, dataCh)
247 254
248 255
249 256 self.__refresh()
257
258 if save:
259 if self.__counter == 0:
260 path = gpath
261 now = datetime.datetime.now()
262 file = "pcolor_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond)
263 filename = os.path.join(path,file)
264 self.save(filename)
265 self.__counter += 1
266
267 if self.__counter == ratio:
268 self.__counter = 0
269
270
250 271 if cleardata == True:
251 272 self.__closePage()
252 273 self.__isFigureOpen = False
@@ -62,6 +62,11 class CrossSpc(Figure):
62 62
63 63
64 64 class CrossSpcFrame(Frame):
65 xi = None
66 xw = None
67 yi = None
68 yw = None
69 alpha = None
65 70 def __init__(self):
66 71 self.drvObj = drvObj
67 72 self.idframe = idframe
@@ -72,6 +77,12 class CrossSpcFrame(Frame):
72 77
73 78 self.colorbar = colorbar
74 79 self.showprofile = showprofile
80 self.xi = 0.
81 self.xw = 0.
82 self.yi = 0.
83 self.yw = 0.
84 self.alpha = 1.
85
75 86 self.createPlots()
76 87
77 88 def createPlots(self):
@@ -84,7 +95,7 class CrossSpcFrame(Frame):
84 95 plotObjList.append(plotObj)
85 96
86 97 if self.showprofile:
87 xi, yi, xw, yw = self.getScreenPos(idplot)
98 xi, yi, xw, yw = self.getScreenPosGraph1(idplot)
88 99 type = "pwbox"
89 100 title = ""
90 101 xlabel = "dB"
@@ -96,20 +107,36 class CrossSpcFrame(Frame):
96 107
97 108 self.plotObjList = plotObjList
98 109
99 def getScreenPos(self,idplot):
100 pass
110 # def getScreenPos(self,idplot):
111 # pass
101 112
102 def getScreenPosMainPlot(self):
103 xi = 0.15
113 def getScreenPos(self, diplot):
114
115 xi = self.xi
116 xw = self.xw
104 117
105 118 if self.showprofile:
106 xw = 0.55
119 width = 0.55
120 xw += width
121
122
123
124
125 self.xi = 0.15 + idplot*self.alpha
126
127 if self.showprofile:
128 width = 0.55
129 self.xw += width
107 130
108 131 else:
109 xw = 0.65
132 width = 0.65
133 self.xw += width
110 134
111 135 if self.colorbar:
112 xw = xw - 0.06
136 self.xw = self.xw - 0.06
137
138
139 self.alpha = self.xw
113 140
114 141 yi = 0.20; yw = 0.75
115 142
@@ -117,9 +144,18 class CrossSpcFrame(Frame):
117 144
118 145 def getScreenPosGraph1(self):
119 146 if self.colorbar:
120 xi = 0.65 + 0.08
147 xi = self.xw + 0.08
121 148 else:
122 xi = 0.75 + 0.05
149 xi = self.xw + 0.05
150
151 xw = xi + 0.2
152
153 self.alpha = xw
154
155 if self.colorbar:
156 self.xi = 0.65 + 0.08
157 else:
158 self.xi = 0.75 + 0.05
123 159
124 160 xw = xi + 0.2
125 161
@@ -211,7 +247,8 class SpcFrame(Frame):
211 247 title = ""
212 248 xlabel = "dB"
213 249 ylabel = ""
214 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel)
250 szchar = 0.70
251 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel, szchar)
215 252 plotObjList.append(plotObj)
216 253
217 254 self.plotObjList = plotObjList
@@ -319,7 +356,7 class RTIFigure(Figure):
319 356 minvalue = None
320 357 maxvalue = None
321 358 xrangestepinsecs = None
322
359 timefmt=None
323 360
324 361 def __init__(self, idfigure, nframes, wintitle, driver, colormap="br_green", colorbar= True, showprofile=False):
325 362 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
@@ -339,29 +376,24 class RTIFigure(Figure):
339 376 cdatetime = datetime.datetime.utcfromtimestamp(x)
340 377
341 378 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.starttime.hour,self.starttime.minute,self.starttime.second)
342 if ((xrangestep == 0) or (xrangestep == None)):
343 maxdatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.endtime.hour,self.endtime.minute,self.endtime.second)
344 self.xrangestepinsecs = time.mktime(maxdatetime.timetuple()) - time.mktime(mindatetime.timetuple())
345 npoints = 1000.
346 if xrangestep == 1:
347 maxdatetime = mindatetime + datetime.timedelta(hours=1)
348 self.xrangestepinsecs = 60*60.
349 npoints = 500.
350 if xrangestep == 2:
351 maxdatetime = mindatetime + datetime.timedelta(minutes=1)
352 self.xrangestepinsecs = 60.
353 npoints = 250.
354 if xrangestep == 3:
355 maxdatetime = mindatetime + datetime.timedelta(seconds=1)
356 self.xrangestepinsecs = 1.
357 npoints = 125.
379
380 maxdatetime = mindatetime + datetime.timedelta(seconds=xrangestep)
381 self.xrangestepinsecs = xrangestep
358 382
359 383 xmin = time.mktime(mindatetime.timetuple())
360 384 xmax = time.mktime(maxdatetime.timetuple())
361 385
362 deltax1 = (xmax-xmin) / npoints
363 # deltax = timeInterval
386 if self.xrangestepinsecs<=60.:
387 self.timefmt="%H:%M:%S"
388
389 if self.xrangestepinsecs>0. and self.xrangestepinsecs<=1200.:
390 self.timefmt="%H:%M:%S"
391
392 if self.xrangestepinsecs>1200. and self.xrangestepinsecs<=86400.:
393 self.timefmt="%H:%M"
364 394
395 if self.xrangestepinsecs>86400.:
396 self.timefmt="%y:%m:%d:%H"
365 397
366 398 if ymin == None: ymin = numpy.min(y)
367 399 if ymax == None: ymax = numpy.max(y)
@@ -385,14 +417,8 class RTIFigure(Figure):
385 417 cdatetime = datetime.datetime.utcfromtimestamp(x)
386 418
387 419 if ((cdatetime.time()>=self.starttime) and (cdatetime.time()<self.endtime)):
388 if self.xrangestep == 1:
389 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,self.starttime.minute,self.starttime.second)
390
391 if self.xrangestep == 2:
392 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,self.starttime.second)
393
394 if self.xrangestep == 3:
395 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,cdatetime.second)
420
421 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,cdatetime.second)
396 422
397 423 self.xmin = time.mktime(mindatetime.timetuple()) - time.timezone
398 424 self.xmax = self.xmin + self.xrangestepinsecs
@@ -409,11 +435,11 class RTIFigure(Figure):
409 435 self.frameObjList = []
410 436
411 437 for frame in range(self.nframes):
412 frameObj = RTIFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile)
438 frameObj = RTIFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile, self.timefmt)
413 439 self.frameObjList.append(frameObj)
414 440
415 441 class RTIFrame(Frame):
416 def __init__(self,drvObj,idframe,colorbar,showprofile):
442 def __init__(self,drvObj,idframe,colorbar,showprofile, timefmt):
417 443 self.drvObj = drvObj
418 444 self.idframe = idframe
419 445 self.nplots = 1
@@ -423,6 +449,7 class RTIFrame(Frame):
423 449
424 450 self.colorbar = colorbar
425 451 self.showprofile = showprofile
452 self.timefmt = timefmt
426 453 self.createPlots()
427 454
428 455 def createPlots(self):
@@ -431,7 +458,7 class RTIFrame(Frame):
431 458 idplot = 0
432 459 xi, yi, xw, yw = self.getScreenPos(idplot)
433 460
434 plotObj = RTIPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar)
461 plotObj = RTIPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar, self.timefmt)
435 462 plotObjList.append(plotObj)
436 463
437 464 if self.showprofile:
@@ -441,7 +468,8 class RTIFrame(Frame):
441 468 title = ""
442 469 xlabel = "dB"
443 470 ylabel = ""
444 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel)
471 szchar = 0.75
472 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel, szchar)
445 473 plotObjList.append(plotObj)
446 474
447 475 self.plotObjList = plotObjList
@@ -490,7 +518,7 class RTIPlot(Plot):
490 518 xg = None
491 519 yg = None
492 520
493 def __init__(self,drvObj, idframe, idplot, xi, yi, xw, yw, colorbar):
521 def __init__(self,drvObj, idframe, idplot, xi, yi, xw, yw, colorbar, timefmt):
494 522 self.drvObj = drvObj
495 523 self.idframe = idframe
496 524 self.idplot = idplot
@@ -511,7 +539,7 class RTIPlot(Plot):
511 539 self.xpos = [self.xi,self.xw]
512 540 self.ypos = [self.yi,self.yw]
513 541 self.xaxisastime = True
514 self.timefmt = "%H:%M:%S"
542 self.timefmt = timefmt
515 543 self.xopt = "bcnstd"
516 544 self.yopt = "bcnstv"
517 545
@@ -577,14 +605,15 class ScopeFigure(Figure):
577 605
578 606
579 607 class ScopeFrame(Frame):
580 # plotObjList = []
581 608 xlabel = ""
582 609 ylabel = ""
583 610 title = ""
611 szchar = 1.1
612
584 613 def __init__(self,drvObj,idframe):
585 614 self.drvObj = drvObj
586 615 self.idframe = idframe
587 self.nplots = 1 #nplots/frame
616 self.nplots = 1
588 617 self.createPlots()
589 618 # Frame.__init__(self, drvObj, idframe)
590 619
@@ -601,10 +630,11 class ScopeFrame(Frame):
601 630 title = "Channel %d"%self.idframe
602 631 xlabel = "range (Km)"
603 632 ylabel = "intensity"
604 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel)
633 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel, self.szchar)
605 634 plotObjList.append(plotObj)
635
606 636 self.plotObjList = plotObjList
607 # self.plotObjList.append(plotObj)
637
608 638
609 639 def plot(self, x, y, z=None):
610 640 for plotObj in self.plotObjList:
@@ -613,7 +643,7 class ScopeFrame(Frame):
613 643
614 644 class Plot1D(Plot):
615 645 # type, title, xlabel, ylabel
616 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel):
646 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel, szchar):
617 647 self.drvObj = drvObj
618 648 self.idframe = idframe
619 649 self.idplot = idplot
@@ -627,7 +657,7 class Plot1D(Plot):
627 657 self.timefmt = None
628 658 self.xopt = "bcnst"
629 659 self.yopt = "bcnstv"
630 self.szchar = 0.7
660 self.szchar = szchar
631 661 self.type = type
632 662 self.title = title
633 663 self.xlabel = xlabel
@@ -283,7 +283,8 class SpectraProcessor:
283 283 showprofile=False,
284 284 save=False,
285 285 gpath=None,
286 channelList = None):
286 ratio=1,
287 channelList=None):
287 288
288 289 if self.dataOutObj.flagNoData:
289 290 return 0
@@ -72,27 +72,28 class VoltageProcessor:
72 72 showprofile=False,
73 73 xrangestep=None,
74 74 save=False,
75 gpath=None):
75 gpath=None,
76 ratio=1,
77 channelList=None):
76 78
77 79 if self.dataOutObj.flagNoData:
78 80 return 0
79 81
80 nframes = len(self.dataOutObj.channelList)
82 if channelList == None:
83 channelList = self.dataOutObj.channelList
84
85 nframes = len(channelList)
81 86
82 87 if len(self.plotObjList) <= self.plotObjIndex:
83 88 self.addRti(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile)
84
85 data = self.dataOutObj.data * numpy.conjugate(self.dataOutObj.data)
89
90 data = self.dataOutObj.data[channelList,:] * numpy.conjugate(self.dataOutObj.data[channelList,:])
86 91 data = 10*numpy.log10(data.real)
87 92
88 # currenttime = self.dataOutObj.utctime
89 # if timezone == "lt":
90 93 currenttime = self.dataOutObj.utctime - time.timezone
91 94
92 95 range = self.dataOutObj.heightList
93 96
94 channelList = self.dataOutObj.channelList
95
96 97 thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime)
97 98 dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S"))
98 99 date = "%s"%(thisdatetime.strftime("%d-%b-%Y"))
@@ -120,7 +121,9 class VoltageProcessor:
120 121 deltax=deltax,
121 122 save=save,
122 123 gpath=gpath,
123 cleardata=cleardata)
124 ratio=ratio,
125 cleardata=cleardata
126 )
124 127
125 128
126 129 self.plotObjIndex += 1
@@ -142,9 +145,7 class VoltageProcessor:
142 145 driver='plplot',
143 146 save=False,
144 147 gpath=None,
145 titleList=None,
146 xlabelList=None,
147 ylabelList=None,
148 ratio=1,
148 149 type="power"):
149 150
150 151 if self.dataOutObj.flagNoData:
@@ -181,7 +182,8 class VoltageProcessor:
181 182 maxvalue=maxvalue,
182 183 figuretitle=figuretitle,
183 184 save=save,
184 gpath=gpath)
185 gpath=gpath,
186 ratio=ratio)
185 187
186 188
187 189 self.plotObjIndex += 1
@@ -223,6 +225,7 class VoltageProcessor:
223 225 self.dataOutObj.flagNoData = True
224 226
225 227 if myCohIntObj.isReady:
228 self.dataOutObj.timeInterval = myCohIntObj.nCohInt * self.dataOutObj.timeInterval
226 229 self.dataOutObj.flagNoData = False
227 230
228 231 def selectChannels(self, channelList):
General Comments 0
You need to be logged in to leave comments. Login now