##// END OF EJS Templates
Se corrigieron errores en VoltageProcessor.py en el metodo de plotRTI. Se agrego el metodo de plotCrossSpc al modulo SpectraProcessor.py para graficos de Espectros, Coherencia y Fase, de la misma forma se han agregado clases al modulo schainPlotTypes.
Daniel Valdez -
r156:2d289a1e62b6
parent child
Show More
@@ -62,6 +62,7 class JROData:
62
62
63 ippSeconds = None
63 ippSeconds = None
64
64
65 timeInterval = None
65
66
66 def __init__(self):
67 def __init__(self):
67
68
@@ -58,9 +58,6 class Figure:
58
58
59 self.frameObjList = []
59 self.frameObjList = []
60
60
61 # self.showGraph1 = args[0]
62 # self.showGraph2 = args[1]
63
64 self.drvObj.driver.setFigure()
61 self.drvObj.driver.setFigure()
65 self.drvObj.driver.setColormap(colormap)
62 self.drvObj.driver.setColormap(colormap)
66
63
@@ -143,16 +140,12 class Figure:
143 self.createFrames()
140 self.createFrames()
144 self.__isConfig = True
141 self.__isConfig = True
145
142
146 if not(self.__isOutOfXRange(x)):
147 self.changeXRange(x)
148
143
149 if self.__isFigureOpen:
150 self.drvObj.driver.closePage()
151 self.__isFigureOpen = False
152
144
153 self.selectFigure()
145 self.selectFigure()
154 self.__newPage()
146 self.__newPage()
155
147
148
156 for channel in channelList:
149 for channel in channelList:
157 frameObj = self.frameObjList[channel]
150 frameObj = self.frameObjList[channel]
158 frameObj.init(xmin=self.xmin,
151 frameObj.init(xmin=self.xmin,
@@ -165,15 +158,12 class Figure:
165 for channel in channelList:
158 for channel in channelList:
166 dataCh = data1D[channel,:]
159 dataCh = data1D[channel,:]
167 frameObj = self.frameObjList[channel]
160 frameObj = self.frameObjList[channel]
168 # frameObj.clearData()
169 frameObj.plot(x, dataCh)
161 frameObj.plot(x, dataCh)
170
162
171 # frameObj.refresh()
172 self.__refresh()
163 self.__refresh()
173
164
174 if save:
175 # self.colorplotObj.setFigure(indexPlot)
176
165
166 if save:
177 path = gpath
167 path = gpath
178 now = datetime.datetime.now()
168 now = datetime.datetime.now()
179 file = "scope_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond)
169 file = "scope_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond)
@@ -198,7 +188,7 class Figure:
198 deltax=None,
188 deltax=None,
199 save=False,
189 save=False,
200 gpath='./',
190 gpath='./',
201 clearData=False,
191 cleardata=False,
202 *args):
192 *args):
203
193
204
194
@@ -225,6 +215,7 class Figure:
225 return 0
215 return 0
226
216
227 self.__closePage()
217 self.__closePage()
218 self.__isFigureOpen = False
228
219
229 self.selectFigure()
220 self.selectFigure()
230
221
@@ -256,7 +247,7 class Figure:
256
247
257
248
258 self.__refresh()
249 self.__refresh()
259 if clearData == True:
250 if cleardata == True:
260 self.__closePage()
251 self.__closePage()
261 self.__isFigureOpen = False
252 self.__isFigureOpen = False
262
253
@@ -3,9 +3,143 import datetime
3 import time
3 import time
4 from schainPlot import *
4 from schainPlot import *
5
5
6 class CrossSpc(Figure):
7 overplot = 0
8 xw = 900
9 yw = 650
10 showprofile = False
11 signalA = None
12 signalB = None
13 coherence = None
14 phase = None
15
16 def __init__(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile):
17 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
18
19 self.showprofile = showprofile
20 self.signalA = None
21 self.signalB = None
22 self.coherence = None
23 self.phase = None
24
25 def getSubplots(self):
26 nrows = self.nframes
27 ncolumns = 1
28 return nrows, ncolumns
29
30 def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
31
32 if xmin == None: xmin = numpy.min(x)
33 if xmax == None: xmax = numpy.max(x)
34 if ymin == None: ymin = numpy.min(y)
35 if ymax == None: ymax = numpy.max(y)
36 if minvalue == None: minvalue = 20.
37 if maxvalue == None: maxvalue = 90.
38
39 self.signalA = self.data[0]
40 self.signalB = self.data[1]
41 self.coherence = self.data[2]
42 self.phase = self.data[3]
43
44 self.xmin = xmin
45 self.xmax = xmax
46 self.minrange = ymin
47 self.maxrange = ymax
48 self.ymin = ymin
49 self.ymax = ymax
50 self.minvalue = minvalue
51 self.maxvalue = maxvalue
52
53 def changeXRange(self, *args):
54 pass
55
56 def createFrames(self):
57 self.frameObjList = []
58
59 for frame in range(self.nframes):
60 frameObj = CrossSpcFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile)
61 self.frameObjList.append(frameObj)
62
63
64 class CrossSpcFrame(Frame):
65 def __init__(self):
66 self.drvObj = drvObj
67 self.idframe = idframe
68 self.nplots = 4
69
70 if showprofile:
71 self.nplots += 4
72
73 self.colorbar = colorbar
74 self.showprofile = showprofile
75 self.createPlots()
76
77 def createPlots(self):
78 plotObjList = []
79 idplot = 0
80 counter_plot = 0
81 for i in range(self.nplots):
82 xi, yi, xw, yw = self.getScreenPos(idplot)
83 plotObj = SpcPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar)
84 plotObjList.append(plotObj)
85
86 if self.showprofile:
87 xi, yi, xw, yw = self.getScreenPos(idplot)
88 type = "pwbox"
89 title = ""
90 xlabel = "dB"
91 ylabel = ""
92 idplot += 1
93 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel)
94 plotObjList.append(plotObj)
95 idplot += 1
96
97 self.plotObjList = plotObjList
98
99 def getScreenPos(self,idplot):
100 pass
101
102 def getScreenPosMainPlot(self):
103 xi = 0.15
104
105 if self.showprofile:
106 xw = 0.55
107
108 else:
109 xw = 0.65
110
111 if self.colorbar:
112 xw = xw - 0.06
113
114 yi = 0.20; yw = 0.75
115
116 return xi, yi, xw, yw
117
118 def getScreenPosGraph1(self):
119 if self.colorbar:
120 xi = 0.65 + 0.08
121 else:
122 xi = 0.75 + 0.05
123
124 xw = xi + 0.2
125
126 yi = 0.2; yw = 0.75
127
128 return xi, yi, xw, yw
129
130 def plot(self,x, y, data):
131 plotObj = self.plotObjList[0]
132 plotObj.plot(x,y,data)
133
134 if self.showprofile:
135 plotObj = self.plotObjList[1]
136 avg_data = numpy.average(data, axis=0)
137 plotObj.plot(avg_data,y)
138
139
6 class SpcFigure(Figure):
140 class SpcFigure(Figure):
7 overplot = 0
141 overplot = 0
8 xw = 800
142 xw = 900
9 yw = 650
143 yw = 650
10 showprofile = False
144 showprofile = False
11
145
@@ -86,10 +220,10 class SpcFrame(Frame):
86 xi = 0.15
220 xi = 0.15
87
221
88 if self.showprofile:
222 if self.showprofile:
89 xw = 0.65
223 xw = 0.55
90
224
91 else:
225 else:
92 xw = 0.75
226 xw = 0.65
93
227
94 if self.colorbar:
228 if self.colorbar:
95 xw = xw - 0.06
229 xw = xw - 0.06
@@ -116,7 +250,8 class SpcFrame(Frame):
116
250
117 if self.showprofile:
251 if self.showprofile:
118 plotObj = self.plotObjList[1]
252 plotObj = self.plotObjList[1]
119 plotObj.plot(data,y)
253 avg_data = numpy.average(data, axis=0)
254 plotObj.plot(avg_data,y)
120
255
121 class SpcPlot(Plot):
256 class SpcPlot(Plot):
122
257
@@ -147,7 +282,7 class SpcPlot(Plot):
147 self.xopt = "bcnst"
282 self.xopt = "bcnst"
148 self.yopt = "bcnstv"
283 self.yopt = "bcnstv"
149
284
150 self.szchar = 0.8
285 self.szchar = 0.7
151 self.strforchannel = "Channel %d"%self.idframe
286 self.strforchannel = "Channel %d"%self.idframe
152 self.xlabel = "m/s"
287 self.xlabel = "m/s"
153 self.ylabel = "Range (Km)"
288 self.ylabel = "Range (Km)"
@@ -376,7 +511,7 class RTIPlot(Plot):
376 self.xpos = [self.xi,self.xw]
511 self.xpos = [self.xi,self.xw]
377 self.ypos = [self.yi,self.yw]
512 self.ypos = [self.yi,self.yw]
378 self.xaxisastime = True
513 self.xaxisastime = True
379 self.timefmt = "%H:%M"
514 self.timefmt = "%H:%M:%S"
380 self.xopt = "bcnstd"
515 self.xopt = "bcnstd"
381 self.yopt = "bcnstv"
516 self.yopt = "bcnstv"
382
517
@@ -492,7 +627,7 class Plot1D(Plot):
492 self.timefmt = None
627 self.timefmt = None
493 self.xopt = "bcnst"
628 self.xopt = "bcnst"
494 self.yopt = "bcnstv"
629 self.yopt = "bcnstv"
495 self.szchar = 1.0
630 self.szchar = 0.7
496 self.type = type
631 self.type = type
497 self.title = title
632 self.title = title
498 self.xlabel = xlabel
633 self.xlabel = xlabel
@@ -295,6 +295,10 class VoltageReader(JRODataReader):
295
295
296 self.dataOutObj.utctime = self.basicHeaderObj.utc + self.basicHeaderObj.miliSecond/1000. + self.profileIndex * self.ippSeconds
296 self.dataOutObj.utctime = self.basicHeaderObj.utc + self.basicHeaderObj.miliSecond/1000. + self.profileIndex * self.ippSeconds
297
297
298 self.dataOutObj.ippSeconds = self.ippSeconds
299
300 self.dataOutObj.timeInterval = self.ippSeconds
301
298 self.dataOutObj.nCohInt = self.processingHeaderObj.nCohInt
302 self.dataOutObj.nCohInt = self.processingHeaderObj.nCohInt
299
303
300 self.dataOutObj.flagShiftFFT = False
304 self.dataOutObj.flagShiftFFT = False
@@ -314,6 +318,10 class VoltageReader(JRODataReader):
314
318
315 self.dataOutObj.flagNoData = False
319 self.dataOutObj.flagNoData = False
316
320
321 # print self.profileIndex, self.dataOutObj.utctime
322 # if self.profileIndex == 800:
323 # a=1
324
317 return self.dataOutObj.data
325 return self.dataOutObj.data
318
326
319
327
@@ -53,7 +53,7 class SpectraProcessor:
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, pairsList=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"
@@ -70,13 +70,13 class SpectraProcessor:
70
70
71 nFFTPoints = dataInObj.nFFTPoints
71 nFFTPoints = dataInObj.nFFTPoints
72
72
73 if pairList == None:
73 if pairsList == None:
74 pairList = self.dataInObj.pairList
74 pairsList = dataInObj.pairsList
75
75
76 if pairList == None:
76 if pairsList == None:
77 nPairs = 0
77 nPairs = 0
78 else:
78 else:
79 nPairs = len(pairList)
79 nPairs = len(pairsList)
80
80
81 self.dataInObj = dataInObj
81 self.dataInObj = dataInObj
82
82
@@ -85,7 +85,7 class SpectraProcessor:
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.pairsList = pairsList
89 self.dataOutObj.nPairs = nPairs
89 self.dataOutObj.nPairs = nPairs
90
90
91 return self.dataOutObj
91 return self.dataOutObj
@@ -176,10 +176,10 class SpectraProcessor:
176
176
177 cspc = None
177 cspc = None
178 pairIndex = 0
178 pairIndex = 0
179 if self.dataOutObj.pairList != None:
179 if self.dataOutObj.pairsList != 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.dataOutObj.pairsList:
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
@@ -223,6 +223,47 class SpectraProcessor:
223 objIncohInt = IncoherentIntegration(N,timeInterval)
223 objIncohInt = IncoherentIntegration(N,timeInterval)
224 self.integratorObjList.append(objIncohInt)
224 self.integratorObjList.append(objIncohInt)
225
225
226 def addCrossSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile):
227 crossSpcObj = CrossSpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile)
228 self.plotObjList.append(crossSpcObj)
229
230 def plotCrossSpc(self, idfigure=None,
231 xmin=None,
232 xmax=None,
233 ymin=None,
234 ymax=None,
235 minvalue=None,
236 maxvalue=None,
237 wintitle='',
238 driver='plplot',
239 colormap='br_green',
240 colorbar=True,
241 showprofile=False,
242 save=False,
243 gpath=None,
244 pairsList = None):
245
246 if self.dataOutObj.flagNoData:
247 return 0
248
249 if pairsList == None:
250 pairsList = self.dataOutObj.pairsList
251
252 nframes = len(pairsList)
253
254 x = numpy.arange(self.dataOutObj.nFFTPoints)
255
256 y = self.dataOutObj.heightList
257
258
259
260
261 if len(self.plotObjList) <= self.plotObjIndex:
262 self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile)
263
264
265
266
226 def addSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile):
267 def addSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile):
227
268
228 spcObj = SpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile)
269 spcObj = SpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile)
@@ -276,7 +317,7 class SpectraProcessor:
276
317
277 plotObj = self.plotObjList[self.plotObjIndex]
318 plotObj = self.plotObjList[self.plotObjIndex]
278
319
279 plotObj.plotPcolor(data,
320 plotObj.plotPcolor(data=data,
280 x=x,
321 x=x,
281 y=y,
322 y=y,
282 channelList=channelList,
323 channelList=channelList,
@@ -289,9 +330,9 class SpectraProcessor:
289 figuretitle=figuretitle,
330 figuretitle=figuretitle,
290 xrangestep=None,
331 xrangestep=None,
291 deltax=None,
332 deltax=None,
292 save=False,
333 save=save,
293 gpath='./',
334 gpath=gpath,
294 clearData=True
335 cleardata=cleardata
295 )
336 )
296
337
297 self.plotObjIndex += 1
338 self.plotObjIndex += 1
@@ -67,7 +67,7 class VoltageProcessor:
67 maxvalue=None,
67 maxvalue=None,
68 wintitle='',
68 wintitle='',
69 driver='plplot',
69 driver='plplot',
70 colormap='br_green',
70 colormap='br_greeen',
71 colorbar=True,
71 colorbar=True,
72 showprofile=False,
72 showprofile=False,
73 xrangestep=None,
73 xrangestep=None,
@@ -103,21 +103,25 class VoltageProcessor:
103
103
104 cleardata = False
104 cleardata = False
105
105
106 plotObj.plotPcolor(data,
106 deltax = self.dataOutObj.timeInterval
107 currenttime,
107
108 range,
108 plotObj.plotPcolor(data=data,
109 channelList,
109 x=currenttime,
110 starttime,
110 y=range,
111 endtime,
111 channelList=channelList,
112 rangemin,
112 xmin=starttime,
113 rangemax,
113 xmax=endtime,
114 minvalue,
114 ymin=rangemin,
115 maxvalue,
115 ymax=rangemax,
116 figuretitle,
116 minvalue=minvalue,
117 xrangestep,
117 maxvalue=maxvalue,
118 save,
118 figuretitle=figuretitle,
119 gpath,
119 xrangestep=xrangestep,
120 cleardata)
120 deltax=deltax,
121 save=save,
122 gpath=gpath,
123 cleardata=cleardata)
124
121
125
122 self.plotObjIndex += 1
126 self.plotObjIndex += 1
123
127
@@ -168,16 +172,17 class VoltageProcessor:
168
172
169 plotObj = self.plotObjList[self.plotObjIndex]
173 plotObj = self.plotObjList[self.plotObjIndex]
170
174
171 plotObj.plot1DArray(data1D,
175 plotObj.plot1DArray(data1D=data1D,
172 self.dataOutObj.heightList,
176 x=self.dataOutObj.heightList,
173 self.dataOutObj.channelList,
177 channelList=self.dataOutObj.channelList,
174 xmin,
178 xmin=xmin,
175 xmax,
179 xmax=xmax,
176 minvalue,
180 minvalue=minvalue,
177 maxvalue,
181 maxvalue=maxvalue,
178 figureTitle,
182 figureTitle=figureTitle,
179 save,
183 save=save,
180 gpath)
184 gpath=gpath)
185
181
186
182 self.plotObjIndex += 1
187 self.plotObjIndex += 1
183
188
General Comments 0
You need to be logged in to leave comments. Login now