From fcb6f29e1f3731d1b0d57c38d40a2c6830c6daac 2012-08-28 21:05:51 From: Daniel Valdez Date: 2012-08-28 21:05:51 Subject: [PATCH] Correcciones y se agrega metodo para guardar plots en disco, aun no funciona satisfactoriamente --- diff --git a/schainpy/Graphics/BaseGraph.py b/schainpy/Graphics/BaseGraph.py index 6e1cafe..b259cb9 100644 --- a/schainpy/Graphics/BaseGraph.py +++ b/schainpy/Graphics/BaseGraph.py @@ -5,7 +5,7 @@ Created on Feb 7, 2012 @version $Id$ """ - +import os import numpy import sys import time @@ -191,6 +191,19 @@ def cmap1_init(colormap="gray"): def setColormap(colormap="jet"): cmap1_init(colormap) +def savePlplot(indexPlot,filename,ncol,nrow,width,height): + curr_strm = plplot.plgstrm() + save_strm = plplot.plmkstrm() + plplot.plsetopt("geometry", "%dx%d"%(width*ncol,height*nrow)) + plplot.plsdev("pngcairo") + plplot.plsfnam(filename) + plplot.plcpstrm(curr_strm,0) + plplot.plreplot() + plplot.plend1() + plplot.plsstrm(indexPlot) + print '' + + def initPlplot(indexPlot,ncol,nrow,winTitle,width,height): plplot.plsstrm(indexPlot) plplot.plparseopts([winTitle],plplot.PL_PARSE_FULL) @@ -547,7 +560,7 @@ class SpectraPlot: showColorbar = None showPowerProfile = None XAxisAsTime = None - widht = None + width = None height = None __spcxpos = None __spcypos = None @@ -722,6 +735,15 @@ class SpectraPlot: powObj.basicXYPlot(power,y) powObj.setXYData(power,y) + def savePlot(self,indexPlot,path): + + now = datetime.datetime.now().timetuple() + file = "spc_img%02d_%03d_%02d%02d%02d"%(indexPlot,now[7],now[3],now[4],now[5]) + filename = os.path.join(path,file+".png") + savePlplot(indexPlot,filename,self.ncol,self.nrow,self.width,self.height) + + + def refresh(self): plFlush() diff --git a/schainpy/Graphics/SpectraPlot.py b/schainpy/Graphics/SpectraPlot.py index 204164e..fe9f0d9 100644 --- a/schainpy/Graphics/SpectraPlot.py +++ b/schainpy/Graphics/SpectraPlot.py @@ -57,7 +57,8 @@ class Spectrum: colormap = "br_green", showColorbar = True, showPowerProfile = True, - XAxisAsTime = False): + XAxisAsTime = False, + save = False): databuffer = 10.*numpy.log10(self.spectraObj.data_spc) noise = 10.*numpy.log10(self.spectraObj.noise) @@ -115,5 +116,11 @@ class Spectrum: self.colorplotObj.refresh() + + if save: + self.colorplotObj.setFigure(indexPlot) + path4plot = "/Users/jro/Pictures" + self.colorplotObj.savePlot(indexPlot,path4plot) + diff --git a/schainpy/Processing/SpectraProcessor.py b/schainpy/Processing/SpectraProcessor.py index 5f25337..a58b246 100644 --- a/schainpy/Processing/SpectraProcessor.py +++ b/schainpy/Processing/SpectraProcessor.py @@ -284,6 +284,7 @@ class SpectraProcessor: showColorbar=False, showPowerProfile=False, XAxisAsTime=False, + save=False, index=None): if self.dataOutObj.flagNoData: @@ -305,7 +306,8 @@ class SpectraProcessor: colormap, showColorbar, showPowerProfile, - XAxisAsTime) + XAxisAsTime, + save) self.plotterObjIndex += 1 diff --git a/schainpy/TestSVoltageChain.py b/schainpy/TestSVoltageChain.py index 796261f..1c041bb 100644 --- a/schainpy/TestSVoltageChain.py +++ b/schainpy/TestSVoltageChain.py @@ -79,7 +79,7 @@ class TestSChain(): self.specProcObj.integrator(N=4) # self.specProcObj.plotSpec(winTitle='Spectra Test', showColorbar=True,showPowerProfile=True,index=3) - self.specProcObj.plotData(winTitle='Spectra Test', showColorbar=True,showPowerProfile=True,index=3) + self.specProcObj.plotData(winTitle='Spectra Test', showColorbar=True,showPowerProfile=True,save=False,index=3) if self.readerObj.flagNoMoreFiles: break