@@ -25,33 +25,28 class Figure: | |||||
25 | figuretitle = "" |
|
25 | figuretitle = "" | |
26 | xrangestep = None |
|
26 | xrangestep = None | |
27 |
|
27 | |||
28 |
def __init__(self,idfigure, nframes, wintitle, xw=600, yw=800, overplot=0, driver='plplot', colorbar= True |
|
28 | def __init__(self,idfigure, nframes, wintitle, xw=600, yw=800, overplot=0, driver='plplot', colormap=None, colorbar= True, *args): | |
|
29 | ||||
|
30 | self.drvObj = Driver(driver, idfigure, xw, yw, wintitle, overplot, colormap, colorbar) | |||
|
31 | self.driver = driver | |||
29 | self.idfigure = idfigure |
|
32 | self.idfigure = idfigure | |
30 | self.nframes = nframes |
|
|||
31 | self.wintitle = wintitle |
|
|||
32 | self.xw = xw |
|
33 | self.xw = xw | |
33 | self.yw = yw |
|
34 | self.yw = yw | |
|
35 | self.nframes = nframes | |||
|
36 | self.wintitle = wintitle | |||
|
37 | self.colormap = colormap | |||
34 | self.overplot = overplot |
|
38 | self.overplot = overplot | |
35 | self.colorbar = colorbar |
|
39 | self.colorbar = colorbar | |
36 |
self. |
|
40 | # self.showGraph1 = args[0] | |
37 | #esta seccion deberia ser dinamica de acuerdo a len(args) |
|
41 | # self.showGraph2 = args[1] | |
38 | self.showGraph1 = args[0] |
|
|||
39 | self.showGraph2 = args[1] |
|
|||
40 |
|
||||
41 | self.drvObj = Driver(driver, idfigure, xw, yw, wintitle, overplot, colorbar, colormap) |
|
|||
42 |
|
42 | |||
43 | self.drvObj.driver.setFigure() |
|
43 | self.drvObj.driver.setFigure() | |
44 | self.drvObj.driver.setColormap(colormap) |
|
44 | self.drvObj.driver.setColormap(colormap) | |
45 |
|
45 | |||
|
46 | ||||
46 |
|
47 | |||
47 | def __openDriver(self): |
|
48 | def __openDriver(self): | |
48 | self.drvObj.driver.openDriver() |
|
49 | self.drvObj.driver.openDriver() | |
49 |
|
||||
50 | # def __openFigure(self): |
|
|||
51 | # nrows, ncolumns = self.getSubplots() |
|
|||
52 | # self.drvObj.driver.openFigure() |
|
|||
53 | # self.drvObj.driver.setTitleFig(title) |
|
|||
54 | # self.drvObj.driver.setSubPlots(nrows, ncolumns) |
|
|||
55 |
|
50 | |||
56 | def __initFigure(self): |
|
51 | def __initFigure(self): | |
57 | nrows, ncolumns = self.getSubplots() |
|
52 | nrows, ncolumns = self.getSubplots() | |
@@ -60,10 +55,12 class Figure: | |||||
60 | self.drvObj.driver.setSubPlots(nrows, ncolumns) |
|
55 | self.drvObj.driver.setSubPlots(nrows, ncolumns) | |
61 |
|
56 | |||
62 | def __isOutOfXRange(self,x): |
|
57 | def __isOutOfXRange(self,x): | |
63 |
|
58 | try: | ||
64 | if ((x>=self.xmin) and (x<self.xmax)): |
|
59 | if ((x>=self.xmin) and (x<self.xmax)): | |
|
60 | return 0 | |||
|
61 | except: | |||
65 | return 0 |
|
62 | return 0 | |
66 |
|
63 | |||
67 | return 1 |
|
64 | return 1 | |
68 |
|
65 | |||
69 | def changeXRange(self,x): |
|
66 | def changeXRange(self,x): | |
@@ -110,7 +107,7 class Figure: | |||||
110 | self.__isConfig = True |
|
107 | self.__isConfig = True | |
111 |
|
108 | |||
112 | if not(self.__isOutOfXRange(x)): |
|
109 | if not(self.__isOutOfXRange(x)): | |
113 |
self. |
|
110 | self.changeXRange(x) | |
114 |
|
111 | |||
115 | if self.__isFigureOpen: |
|
112 | if self.__isFigureOpen: | |
116 | self.driverObj.closePage() |
|
113 | self.driverObj.closePage() | |
@@ -163,7 +160,9 class Figure: | |||||
163 | figuretitle=None, |
|
160 | figuretitle=None, | |
164 | xrangestep=None, |
|
161 | xrangestep=None, | |
165 | save=False, |
|
162 | save=False, | |
166 |
gpath='./' |
|
163 | gpath='./', | |
|
164 | clearData=False, | |||
|
165 | *args): | |||
167 |
|
166 | |||
168 |
|
167 | |||
169 | if figuretitle == None: |
|
168 | if figuretitle == None: | |
@@ -190,10 +189,6 class Figure: | |||||
190 | return 0 |
|
189 | return 0 | |
191 |
|
190 | |||
192 | self.__isFigureOpen = False |
|
191 | self.__isFigureOpen = False | |
193 |
|
||||
194 | # if self.__isFigureOpen: |
|
|||
195 | # self.driverObj.closePage() |
|
|||
196 | # self.__isFigureOpen = False |
|
|||
197 |
|
192 | |||
198 | if not(self.__isFigureOpen): |
|
193 | if not(self.__isFigureOpen): | |
199 |
|
194 | |||
@@ -202,24 +197,30 class Figure: | |||||
202 | self.__isFigureOpen = True |
|
197 | self.__isFigureOpen = True | |
203 |
|
198 | |||
204 | for channel in channelList: |
|
199 | for channel in channelList: | |
|
200 | if len(args) != 0: value = args[0][channel] | |||
|
201 | else: value = args | |||
|
202 | ||||
205 | frameObj = self.frameObjList[channel] |
|
203 | frameObj = self.frameObjList[channel] | |
206 |
frameObj.init( |
|
204 | frameObj.init(self.xmin, | |
207 |
|
|
205 | self.xmax, | |
208 |
|
|
206 | self.ymin, | |
209 |
|
|
207 | self.ymax, | |
210 |
|
|
208 | self.minvalue, | |
211 |
|
|
209 | self.maxvalue, | |
212 |
|
|
210 | self.deltax, | |
213 |
|
|
211 | self.deltay, | |
|
212 | self.colorbar, | |||
|
213 | value) | |||
214 |
|
214 | |||
215 | for channel in channelList: |
|
215 | for channel in channelList: | |
216 | dataCh = data[channel,:] |
|
216 | dataCh = data[channel,:] | |
217 | frameObj = self.frameObjList[channel] |
|
217 | frameObj = self.frameObjList[channel] | |
218 | # frameObj.clearData() |
|
|||
219 | frameObj.plot(x, y, dataCh) |
|
218 | frameObj.plot(x, y, dataCh) | |
220 |
|
219 | |||
221 | # frameObj.refresh() |
|
220 | ||
222 | self.__refresh() |
|
221 | self.__refresh() | |
|
222 | if clearData == True: | |||
|
223 | self.__isFigureOpen = False | |||
223 |
|
224 | |||
224 |
|
225 | |||
225 |
|
226 | |||
@@ -253,10 +254,12 class Frame: | |||||
253 | return xi, yi, xw, yw |
|
254 | return xi, yi, xw, yw | |
254 |
|
255 | |||
255 |
|
256 | |||
256 | def init(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax=None, deltay=None): |
|
257 | def init(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax=None, deltay=None, colorbar=False, *args): | |
257 |
|
258 | |||
258 | for plotObj in self.plotObjList: |
|
259 | for plotObj in self.plotObjList: | |
259 |
plotObj. |
|
260 | plotObj.setBox(xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax, deltay, colorbar, *args) | |
|
261 | plotObj.plotBox() | |||
|
262 | ||||
260 |
|
263 | |||
261 |
|
264 | |||
262 | class Plot: |
|
265 | class Plot: | |
@@ -272,6 +275,9 class Plot: | |||||
272 | szchar = None |
|
275 | szchar = None | |
273 | idframe = None |
|
276 | idframe = None | |
274 | idplot = None |
|
277 | idplot = None | |
|
278 | colorbar = None | |||
|
279 | cbxpos = None | |||
|
280 | cbypos = None | |||
275 |
|
281 | |||
276 | def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw): |
|
282 | def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw): | |
277 | self.drvObj = drvObj |
|
283 | self.drvObj = drvObj | |
@@ -282,13 +288,8 class Plot: | |||||
282 | self.xw = xw |
|
288 | self.xw = xw | |
283 | self.yw = yw |
|
289 | self.yw = yw | |
284 |
|
290 | |||
285 | def plotBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue): |
|
291 | ||
286 | self.xmin = xmin |
|
292 | def plotBox(self): | |
287 | self.xmax = xmax |
|
|||
288 | self.ymin = ymin |
|
|||
289 | self.ymax = ymax |
|
|||
290 | self.minvalue = minvalue |
|
|||
291 | self.maxvalue = maxvalue |
|
|||
292 |
|
293 | |||
293 | self.drvObj.driver.plotBox(self.idframe, |
|
294 | self.drvObj.driver.plotBox(self.idframe, | |
294 | self.xpos, |
|
295 | self.xpos, | |
@@ -306,6 +307,9 class Plot: | |||||
306 | self.timefmt) |
|
307 | self.timefmt) | |
307 |
|
308 | |||
308 | self.drvObj.driver.setPlotLabels(self.xlabel, self.ylabel, self.title) |
|
309 | self.drvObj.driver.setPlotLabels(self.xlabel, self.ylabel, self.title) | |
|
310 | ||||
|
311 | if self.colorbar: | |||
|
312 | self.drvObj.driver.plotColorbar(self.minvalue, self.maxvalue, self.cbxpos,self.cbypos) | |||
309 |
|
313 | |||
310 | def plotPcolor(self, x, y, z, deltax, deltay, getGrid): |
|
314 | def plotPcolor(self, x, y, z, deltax, deltay, getGrid): | |
311 |
|
315 |
@@ -152,6 +152,9 class PlplotDriver: | |||||
152 | if getGrid: |
|
152 | if getGrid: | |
153 | self.__xg, self.__yg = self.__getGrid(x, y, deltax, deltay) |
|
153 | self.__xg, self.__yg = self.__getGrid(x, y, deltax, deltay) | |
154 |
|
154 | |||
|
155 | if deltax == None: deltax = x[-1] - x[0] | |||
|
156 | # if deltay == None: deltay = y[-1] - y[-2] | |||
|
157 | ||||
155 | xmin = x[0] |
|
158 | xmin = x[0] | |
156 | xmax = xmin + deltax |
|
159 | xmax = xmin + deltax | |
157 |
|
160 |
@@ -2,7 +2,171 import numpy | |||||
2 | import datetime |
|
2 | import datetime | |
3 | import time |
|
3 | import time | |
4 | from schainPlot import * |
|
4 | from schainPlot import * | |
5 | #from schainPlotLib import Driver |
|
5 | ||
|
6 | class SpcFigure(Figure): | |||
|
7 | overplot = 0 | |||
|
8 | xw = 800 | |||
|
9 | yw = 650 | |||
|
10 | showprofile = False | |||
|
11 | ||||
|
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) | |||
|
14 | ||||
|
15 | self.showprofile = showprofile | |||
|
16 | ||||
|
17 | def getSubplots(self): | |||
|
18 | ncolumns = int(numpy.sqrt(self.nframes)+0.9) | |||
|
19 | nrows = int(self.nframes*1./ncolumns + 0.9) | |||
|
20 | ||||
|
21 | return nrows, ncolumns | |||
|
22 | ||||
|
23 | def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args): | |||
|
24 | ||||
|
25 | if xmin == None: xmin = numpy.min(x) | |||
|
26 | if xmax == None: xmax = numpy.max(x) | |||
|
27 | if ymin == None: ymin = numpy.min(y) | |||
|
28 | if ymax == None: ymax = numpy.max(y) | |||
|
29 | if minvalue == None: minvalue = 20. | |||
|
30 | if maxvalue == None: maxvalue = 90. | |||
|
31 | ||||
|
32 | self.xmin = xmin | |||
|
33 | self.xmax = xmax | |||
|
34 | self.minrange = ymin | |||
|
35 | self.maxrange = ymax | |||
|
36 | self.ymin = ymin | |||
|
37 | self.ymax = ymax | |||
|
38 | self.minvalue = minvalue | |||
|
39 | self.maxvalue = maxvalue | |||
|
40 | ||||
|
41 | ||||
|
42 | def changeXRange(self, *args): | |||
|
43 | pass | |||
|
44 | ||||
|
45 | def createFrames(self): | |||
|
46 | for frame in range(self.nframes): | |||
|
47 | frameObj = SpcFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile) | |||
|
48 | self.frameObjList.append(frameObj) | |||
|
49 | ||||
|
50 | class SpcFrame(Frame): | |||
|
51 | def __init__(self,drvObj,idframe,colorbar,showprofile): | |||
|
52 | self.drvObj = drvObj | |||
|
53 | self.idframe = idframe | |||
|
54 | self.nplots = 1 | |||
|
55 | ||||
|
56 | if showprofile: | |||
|
57 | self.nplots += 1 | |||
|
58 | ||||
|
59 | self.colorbar = colorbar | |||
|
60 | self.showprofile = showprofile | |||
|
61 | self.createPlots() | |||
|
62 | ||||
|
63 | def createPlots(self): | |||
|
64 | plotObjList = [] | |||
|
65 | idplot = 0 | |||
|
66 | xi, yi, xw, yw = self.getScreenPos(idplot) | |||
|
67 | plotObj = SpcPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar) | |||
|
68 | plotObjList.append(plotObj) | |||
|
69 | ||||
|
70 | if self.showprofile: | |||
|
71 | idplot = 1 | |||
|
72 | xi, yi, xw, yw = self.getScreenPos(idplot) | |||
|
73 | type = "pwbox" | |||
|
74 | title = "" | |||
|
75 | xlabel = "dB" | |||
|
76 | ylabel = "" | |||
|
77 | plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel) | |||
|
78 | plotObjList.append(plotObj) | |||
|
79 | ||||
|
80 | self.plotObjList = plotObjList | |||
|
81 | ||||
|
82 | def getScreenPosMainPlot(self): | |||
|
83 | xi = 0.15 | |||
|
84 | ||||
|
85 | if self.showprofile: | |||
|
86 | xw = 0.65 | |||
|
87 | ||||
|
88 | else: | |||
|
89 | xw = 0.75 | |||
|
90 | ||||
|
91 | if self.colorbar: | |||
|
92 | xw = xw - 0.06 | |||
|
93 | ||||
|
94 | yi = 0.20; yw = 0.75 | |||
|
95 | ||||
|
96 | return xi, yi, xw, yw | |||
|
97 | ||||
|
98 | def getScreenPosGraph1(self): | |||
|
99 | if self.colorbar: | |||
|
100 | xi = 0.65 + 0.08 | |||
|
101 | else: | |||
|
102 | xi = 0.75 + 0.05 | |||
|
103 | ||||
|
104 | xw = xi + 0.2 | |||
|
105 | ||||
|
106 | yi = 0.2; yw = 0.75 | |||
|
107 | ||||
|
108 | return xi, yi, xw, yw | |||
|
109 | ||||
|
110 | def plot(self,x, y, data): | |||
|
111 | plotObj = self.plotObjList[0] | |||
|
112 | plotObj.plot(x,y,data) | |||
|
113 | ||||
|
114 | if self.showprofile: | |||
|
115 | plotObj = self.plotObjList[1] | |||
|
116 | plotObj.plot(data,y) | |||
|
117 | ||||
|
118 | class SpcPlot(Plot): | |||
|
119 | ||||
|
120 | getGrid = True | |||
|
121 | ||||
|
122 | def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, colorbar): | |||
|
123 | self.drvObj = drvObj | |||
|
124 | self.idframe = idframe | |||
|
125 | self.idplot = idplot | |||
|
126 | self.xi = xi | |||
|
127 | self.yi = yi | |||
|
128 | self.xw = xw | |||
|
129 | self.yw = yw | |||
|
130 | self.colorbar = colorbar | |||
|
131 | ||||
|
132 | if self.colorbar: | |||
|
133 | cbxi = xw + 0.03 | |||
|
134 | cbxw = cbxi + 0.03 | |||
|
135 | cbyi = yi | |||
|
136 | cbyw = yw | |||
|
137 | self.cbxpos = [cbxi,cbxw] | |||
|
138 | self.cbypos = [cbyi,cbyw] | |||
|
139 | ||||
|
140 | self.xpos = [self.xi,self.xw] | |||
|
141 | self.ypos = [self.yi,self.yw] | |||
|
142 | self.xaxisastime = False | |||
|
143 | self.timefmt = None | |||
|
144 | self.xopt = "bcnst" | |||
|
145 | self.yopt = "bcnstv" | |||
|
146 | ||||
|
147 | self.szchar = 0.8 | |||
|
148 | self.strforchannel = "Channel %d"%self.idframe | |||
|
149 | self.xlabel = "m/s" | |||
|
150 | self.ylabel = "Range (Km)" | |||
|
151 | ||||
|
152 | def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args): | |||
|
153 | self.xmin = xmin | |||
|
154 | self.xmax = xmax | |||
|
155 | self.ymin = ymin | |||
|
156 | self.ymax = ymax | |||
|
157 | self.minvalue = minvalue | |||
|
158 | self.maxvalue = maxvalue | |||
|
159 | self.colorbar = args[2] | |||
|
160 | self.title = "%s - %s"%(self.strforchannel,args[3]) | |||
|
161 | ||||
|
162 | ||||
|
163 | ||||
|
164 | def plot(self, x, y, data): | |||
|
165 | z = data | |||
|
166 | deltax = None | |||
|
167 | deltay = None | |||
|
168 | self.plotPcolor(x, y, z, deltax, deltay, self.getGrid) | |||
|
169 | self.getGrid = False | |||
6 |
|
170 | |||
7 |
|
171 | |||
8 | class RTIFigure(Figure): |
|
172 | class RTIFigure(Figure): | |
@@ -19,18 +183,11 class RTIFigure(Figure): | |||||
19 | xrangestepinsecs = None |
|
183 | xrangestepinsecs = None | |
20 |
|
184 | |||
21 |
|
185 | |||
22 | def __init__(self, idfigure, nframes, wintitle, driver, colormap="br_green", colorbar= True, showprofile=False): |
|
186 | def __init__(self, idfigure, nframes, wintitle, driver, colormap="br_green", colorbar= True, showprofile=False): | |
23 | self.idfigure = idfigure |
|
187 | Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar) | |
24 | self.nframes = nframes |
|
188 | ||
25 | self.wintitle = wintitle |
|
|||
26 | self.colormap = colormap |
|
|||
27 | self.colorbar = colorbar |
|
|||
28 | self.showprofile = showprofile |
|
189 | self.showprofile = showprofile | |
29 | self.driver = driver |
|
190 | ||
30 | self.drvObj = Driver(self.driver, self.idfigure, self.xw, self.yw, self.wintitle, self.overplot, self.colormap, self.colorbar) |
|
|||
31 | self.drvObj.driver.setFigure() |
|
|||
32 | self.drvObj.driver.setColormap(colormap) |
|
|||
33 |
|
||||
34 | def getSubplots(self): |
|
191 | def getSubplots(self): | |
35 | nrows = self.nframes |
|
192 | nrows = self.nframes | |
36 | ncolumns = 1 |
|
193 | ncolumns = 1 | |
@@ -41,7 +198,7 class RTIFigure(Figure): | |||||
41 | self.starttime = xmin |
|
198 | self.starttime = xmin | |
42 | self.endtime = xmax |
|
199 | self.endtime = xmax | |
43 |
|
200 | |||
44 |
cdatetime = datetime.datetime.utcfromtimestamp(x) |
|
201 | cdatetime = datetime.datetime.utcfromtimestamp(x) | |
45 |
|
202 | |||
46 | mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.starttime.hour,self.starttime.minute,self.starttime.second) |
|
203 | mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.starttime.hour,self.starttime.minute,self.starttime.second) | |
47 | if ((xrangestep == 0) or (xrangestep == None)): |
|
204 | if ((xrangestep == 0) or (xrangestep == None)): | |
@@ -83,11 +240,10 class RTIFigure(Figure): | |||||
83 | self.maxvalue = maxvalue |
|
240 | self.maxvalue = maxvalue | |
84 | self.xrangestep = xrangestep |
|
241 | self.xrangestep = xrangestep | |
85 | self.deltax = deltax |
|
242 | self.deltax = deltax | |
86 |
|
243 | |||
87 |
|
||||
88 | def changeXRange(self,x): |
|
244 | def changeXRange(self,x): | |
89 |
|
245 | |||
90 |
cdatetime = datetime.datetime.utcfromtimestamp(x) |
|
246 | cdatetime = datetime.datetime.utcfromtimestamp(x) | |
91 |
|
247 | |||
92 | if ((cdatetime.time()>=self.starttime) and (cdatetime.time()<self.endtime)): |
|
248 | if ((cdatetime.time()>=self.starttime) and (cdatetime.time()<self.endtime)): | |
93 | if self.xrangestep == 1: |
|
249 | if self.xrangestep == 1: | |
@@ -99,19 +255,15 class RTIFigure(Figure): | |||||
99 | if self.xrangestep == 3: |
|
255 | if self.xrangestep == 3: | |
100 | mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,cdatetime.second) |
|
256 | mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,cdatetime.second) | |
101 |
|
257 | |||
102 | # mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.starttime.hour,self.starttime.minute,self.starttime.second) |
|
|||
103 | self.xmin = time.mktime(mindatetime.timetuple()) - time.timezone |
|
258 | self.xmin = time.mktime(mindatetime.timetuple()) - time.timezone | |
104 | self.xmax = self.xmin + self.xrangestepinsecs |
|
259 | self.xmax = self.xmin + self.xrangestepinsecs | |
105 |
|
260 | |||
106 |
self.figuretitle = "%s |
|
261 | self.figuretitle = "%s %s : %s"%(self.figuretitle, | |
107 | datetime.datetime.utcfromtimestamp(self.xmin).strftime("%d-%b-%Y %H:%M:%S"), |
|
262 | datetime.datetime.utcfromtimestamp(self.xmin).strftime("%d-%b-%Y %H:%M:%S"), | |
108 | datetime.datetime.utcfromtimestamp(self.xmax).strftime("%d-%b-%Y %H:%M:%S")) |
|
263 | datetime.datetime.utcfromtimestamp(self.xmax).strftime("%d-%b-%Y %H:%M:%S")) | |
109 |
|
||||
110 |
|
||||
111 | return 1 |
|
264 | return 1 | |
112 |
|
265 | |||
113 | return 0 |
|
266 | return 0 | |
114 |
|
||||
115 |
|
267 | |||
116 | def createFrames(self): |
|
268 | def createFrames(self): | |
117 | for frame in range(self.nframes): |
|
269 | for frame in range(self.nframes): | |
@@ -136,23 +288,26 class RTIFrame(Frame): | |||||
136 |
|
288 | |||
137 | idplot = 0 |
|
289 | idplot = 0 | |
138 | xi, yi, xw, yw = self.getScreenPos(idplot) |
|
290 | xi, yi, xw, yw = self.getScreenPos(idplot) | |
|
291 | ||||
139 | plotObj = RTIPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar) |
|
292 | plotObj = RTIPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar) | |
140 | plotObjList.append(plotObj) |
|
293 | plotObjList.append(plotObj) | |
141 |
|
294 | |||
142 | if self.showprofile: |
|
295 | if self.showprofile: | |
143 | idplot = 1 |
|
296 | idplot = 1 | |
144 | xi, yi, xw, yw = self.getScreenPos(idplot) |
|
297 | xi, yi, xw, yw = self.getScreenPos(idplot) | |
145 | plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw) |
|
298 | type = "pwbox" | |
|
299 | title = "" | |||
|
300 | xlabel = "dB" | |||
|
301 | ylabel = "" | |||
|
302 | plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel) | |||
146 | plotObjList.append(plotObj) |
|
303 | plotObjList.append(plotObj) | |
147 |
|
304 | |||
148 | self.plotObjList = plotObjList |
|
305 | self.plotObjList = plotObjList | |
149 |
|
306 | |||
150 | def getScreenPosMainPlot(self):#cada Frame determina las coordenadas de los plots |
|
307 | def getScreenPosMainPlot(self): | |
151 | xi = 0.07 |
|
308 | xi = 0.07 | |
152 |
|
||||
153 | if self.showprofile: |
|
309 | if self.showprofile: | |
154 | xw = 0.65 |
|
310 | xw = 0.65 | |
155 |
|
||||
156 | else: |
|
311 | else: | |
157 | xw = 0.9 |
|
312 | xw = 0.9 | |
158 |
|
313 | |||
@@ -165,7 +320,7 class RTIFrame(Frame): | |||||
165 |
|
320 | |||
166 | def getScreenPosGraph1(self): |
|
321 | def getScreenPosGraph1(self): | |
167 | if self.colorbar: |
|
322 | if self.colorbar: | |
168 |
xi = 0.65 + 0.0 |
|
323 | xi = 0.65 + 0.08 | |
169 | else: |
|
324 | else: | |
170 | xi = 0.9 + 0.05 |
|
325 | xi = 0.9 + 0.05 | |
171 |
|
326 | |||
@@ -176,9 +331,6 class RTIFrame(Frame): | |||||
176 | return xi, yi, xw, yw |
|
331 | return xi, yi, xw, yw | |
177 |
|
332 | |||
178 | def plot(self, currenttime, range, data): |
|
333 | def plot(self, currenttime, range, data): | |
179 | # for plotObj in self.plotObjList: |
|
|||
180 | # plotObj.plot(currenttime, range, data) |
|
|||
181 |
|
||||
182 | plotObj = self.plotObjList[0] |
|
334 | plotObj = self.plotObjList[0] | |
183 | plotObj.plot(currenttime,range,data) |
|
335 | plotObj.plot(currenttime,range,data) | |
184 |
|
336 | |||
@@ -227,7 +379,7 class RTIPlot(Plot): | |||||
227 | self.ylabel = "Range (Km)" |
|
379 | self.ylabel = "Range (Km)" | |
228 |
|
380 | |||
229 |
|
381 | |||
230 |
def |
|
382 | def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax=None, deltay=None, colorbar=True, *args): | |
231 | self.xmin = xmin |
|
383 | self.xmin = xmin | |
232 | self.xmax = xmax |
|
384 | self.xmax = xmax | |
233 | self.ymin = ymin |
|
385 | self.ymin = ymin | |
@@ -236,28 +388,7 class RTIPlot(Plot): | |||||
236 | self.maxvalue = maxvalue |
|
388 | self.maxvalue = maxvalue | |
237 | self.deltax = deltax |
|
389 | self.deltax = deltax | |
238 | self.deltay = deltay |
|
390 | self.deltay = deltay | |
239 |
|
391 | self.colorbar = colorbar | ||
240 | self.drvObj.driver.plotBox(self.idframe, |
|
|||
241 | self.xpos, |
|
|||
242 | self.ypos, |
|
|||
243 | self.xmin, |
|
|||
244 | self.xmax, |
|
|||
245 | self.ymin, |
|
|||
246 | self.ymax, |
|
|||
247 | self.minvalue, |
|
|||
248 | self.maxvalue, |
|
|||
249 | self.xopt, |
|
|||
250 | self.yopt, |
|
|||
251 | self.szchar, |
|
|||
252 | self.xaxisastime, |
|
|||
253 | self.timefmt) |
|
|||
254 |
|
||||
255 | self.drvObj.driver.setPlotLabels(self.xlabel, self.ylabel, self.title) |
|
|||
256 |
|
||||
257 | if self.colorbar: |
|
|||
258 | self.drvObj.driver.plotColorbar(minvalue, maxvalue, self.cbxpos,self.cbypos) |
|
|||
259 |
|
||||
260 |
|
||||
261 |
|
392 | |||
262 | def plot(self, currenttime, range, data): |
|
393 | def plot(self, currenttime, range, data): | |
263 |
|
394 | |||
@@ -330,7 +461,11 class ScopeFrame(Frame): | |||||
330 | plotObjList = [] |
|
461 | plotObjList = [] | |
331 | for idplot in range(self.nplots): |
|
462 | for idplot in range(self.nplots): | |
332 | xi, yi, xw, yw = self.getScreenPos(idplot) |
|
463 | xi, yi, xw, yw = self.getScreenPos(idplot) | |
333 | plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw) |
|
464 | type = "scopebox" | |
|
465 | title = "Channel %d"%self.idframe | |||
|
466 | xlabel = "range (Km)" | |||
|
467 | ylabel = "intensity" | |||
|
468 | plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel) | |||
334 | plotObjList.append(plotObj) |
|
469 | plotObjList.append(plotObj) | |
335 | self.plotObjList = plotObjList |
|
470 | self.plotObjList = plotObjList | |
336 | # self.plotObjList.append(plotObj) |
|
471 | # self.plotObjList.append(plotObj) | |
@@ -341,8 +476,8 class ScopeFrame(Frame): | |||||
341 |
|
476 | |||
342 |
|
477 | |||
343 | class Plot1D(Plot): |
|
478 | class Plot1D(Plot): | |
344 |
|
479 | # type, title, xlabel, ylabel | ||
345 | def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw): |
|
480 | def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel): | |
346 | self.drvObj = drvObj |
|
481 | self.drvObj = drvObj | |
347 | self.idframe = idframe |
|
482 | self.idframe = idframe | |
348 | self.idplot = idplot |
|
483 | self.idplot = idplot | |
@@ -357,10 +492,31 class Plot1D(Plot): | |||||
357 | self.xopt = "bcnst" |
|
492 | self.xopt = "bcnst" | |
358 | self.yopt = "bcnstv" |
|
493 | self.yopt = "bcnstv" | |
359 | self.szchar = 1.0 |
|
494 | self.szchar = 1.0 | |
360 | self.title = "Channel %d"%self.idframe |
|
495 | self.type = type | |
361 |
self. |
|
496 | self.title = title | |
362 |
self. |
|
497 | self.xlabel = xlabel | |
|
498 | self.ylabel = ylabel | |||
|
499 | ||||
363 |
|
500 | |||
|
501 | ||||
|
502 | def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args): | |||
|
503 | if self.type == "pwbox": | |||
|
504 | self.xmin = minvalue | |||
|
505 | self.xmax = maxvalue | |||
|
506 | self.ymin = ymin | |||
|
507 | self.ymax = ymax | |||
|
508 | self.minvalue = minvalue | |||
|
509 | self.maxvalue = maxvalue | |||
|
510 | ||||
|
511 | else: | |||
|
512 | self.xmin = xmin | |||
|
513 | self.xmax = xmax | |||
|
514 | self.ymin = ymin | |||
|
515 | self.ymax = ymax | |||
|
516 | self.minvalue = minvalue | |||
|
517 | self.maxvalue = maxvalue | |||
|
518 | ||||
|
519 | self.colorbar = False | |||
364 |
|
520 | |||
365 | def plot(self,x,y): |
|
521 | def plot(self,x,y): | |
366 | if y.dtype == "complex128": |
|
522 | if y.dtype == "complex128": |
@@ -7,13 +7,13 $Id$ | |||||
7 | import os, sys |
|
7 | import os, sys | |
8 | import numpy |
|
8 | import numpy | |
9 | import time |
|
9 | import time | |
10 |
|
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 |
|
14 | from Data.JROData import Spectra | |
15 | from IO.SpectraIO import SpectraWriter |
|
15 | from IO.SpectraIO import SpectraWriter | |
16 |
|
|
16 | from Graphics.schainPlotTypes import SpcFigure | |
17 | #from JRONoise import Noise |
|
17 | #from JRONoise import Noise | |
18 |
|
18 | |||
19 | class SpectraProcessor: |
|
19 | class SpectraProcessor: | |
@@ -36,36 +36,6 class SpectraProcessor: | |||||
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 |
|
||||
40 | # integratorObjList = [] |
|
|||
41 | # |
|
|||
42 | # decoderObjList = [] |
|
|||
43 | # |
|
|||
44 | # writerObjList = [] |
|
|||
45 | # |
|
|||
46 | # plotterObjList = [] |
|
|||
47 | # |
|
|||
48 | # integratorObjIndex = None |
|
|||
49 | # |
|
|||
50 | # decoderObjIndex = None |
|
|||
51 | # |
|
|||
52 | # writerObjIndex = None |
|
|||
53 | # |
|
|||
54 | # plotterObjIndex = None |
|
|||
55 | # |
|
|||
56 | # buffer = None |
|
|||
57 | # |
|
|||
58 | # profIndex = 0 |
|
|||
59 | # |
|
|||
60 | # nFFTPoints = None |
|
|||
61 | # |
|
|||
62 | # nChannels = None |
|
|||
63 | # |
|
|||
64 | # nHeights = None |
|
|||
65 | # |
|
|||
66 | # nPairs = None |
|
|||
67 | # |
|
|||
68 | # pairList = None |
|
|||
69 |
|
39 | |||
70 |
|
40 | |||
71 | def __init__(self): |
|
41 | def __init__(self): | |
@@ -75,8 +45,10 class SpectraProcessor: | |||||
75 |
|
45 | |||
76 | self.integratorObjIndex = None |
|
46 | self.integratorObjIndex = None | |
77 | self.writerObjIndex = None |
|
47 | self.writerObjIndex = None | |
|
48 | self.plotObjIndex = None | |||
78 | self.integratorObjList = [] |
|
49 | self.integratorObjList = [] | |
79 | self.writerObjList = [] |
|
50 | self.writerObjList = [] | |
|
51 | self.plotObjList = [] | |||
80 | self.noiseObj = None |
|
52 | self.noiseObj = None | |
81 | self.buffer = None |
|
53 | self.buffer = None | |
82 | self.profIndex = 0 |
|
54 | self.profIndex = 0 | |
@@ -99,71 +71,13 class SpectraProcessor: | |||||
99 |
|
71 | |||
100 | self.dataOutObj = dataOutObj |
|
72 | self.dataOutObj = dataOutObj | |
101 |
|
73 | |||
102 | # self.noiseObj = Noise() #aun no se incluye el objeto Noise() |
|
|||
103 |
|
||||
104 | ########################################## |
|
|||
105 | # self.nFFTPoints = nFFTPoints |
|
|||
106 | # self.nChannels = self.dataInObj.nChannels |
|
|||
107 | # self.nHeights = self.dataInObj.nHeights |
|
|||
108 | # self.pairList = pairList |
|
|||
109 | # if pairList != None: |
|
|||
110 | # self.nPairs = len(pairList) |
|
|||
111 | # else: |
|
|||
112 | # self.nPairs = 0 |
|
|||
113 | # |
|
|||
114 | # self.dataOutObj.heightList = self.dataInObj.heightList |
|
|||
115 | # self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList |
|
|||
116 | # self.dataOutObj.m_BasicHeader = self.dataInObj.m_BasicHeader.copy() |
|
|||
117 | # self.dataOutObj.m_ProcessingHeader = self.dataInObj.m_ProcessingHeader.copy() |
|
|||
118 | # self.dataOutObj.m_RadarControllerHeader = self.dataInObj.m_RadarControllerHeader.copy() |
|
|||
119 | # self.dataOutObj.m_SystemHeader = self.dataInObj.m_SystemHeader.copy() |
|
|||
120 | # |
|
|||
121 | # self.dataOutObj.dataType = self.dataInObj.dataType |
|
|||
122 | # self.dataOutObj.nPairs = self.nPairs |
|
|||
123 | # self.dataOutObj.nChannels = self.nChannels |
|
|||
124 | # self.dataOutObj.nProfiles = self.nFFTPoints |
|
|||
125 | # self.dataOutObj.nHeights = self.nHeights |
|
|||
126 | # self.dataOutObj.nFFTPoints = self.nFFTPoints |
|
|||
127 | # #self.dataOutObj.data = None |
|
|||
128 | # |
|
|||
129 | # self.dataOutObj.m_SystemHeader.numChannels = self.nChannels |
|
|||
130 | # self.dataOutObj.m_SystemHeader.nProfiles = self.nFFTPoints |
|
|||
131 | # |
|
|||
132 | # self.dataOutObj.m_ProcessingHeader.totalSpectra = self.nChannels + self.nPairs |
|
|||
133 | # self.dataOutObj.m_ProcessingHeader.profilesPerBlock = self.nFFTPoints |
|
|||
134 | # self.dataOutObj.m_ProcessingHeader.numHeights = self.nHeights |
|
|||
135 | # self.dataOutObj.m_ProcessingHeader.shif_fft = True |
|
|||
136 | # |
|
|||
137 | # spectraComb = numpy.zeros( (self.nChannels+self.nPairs)*2,numpy.dtype('u1')) |
|
|||
138 | # k = 0 |
|
|||
139 | # for i in range( 0,self.nChannels*2,2 ): |
|
|||
140 | # spectraComb[i] = k |
|
|||
141 | # spectraComb[i+1] = k |
|
|||
142 | # k += 1 |
|
|||
143 | # |
|
|||
144 | # k *= 2 |
|
|||
145 | # |
|
|||
146 | # if self.pairList != None: |
|
|||
147 | # |
|
|||
148 | # for pair in self.pairList: |
|
|||
149 | # spectraComb[k] = pair[0] |
|
|||
150 | # spectraComb[k+1] = pair[1] |
|
|||
151 | # k += 2 |
|
|||
152 | # |
|
|||
153 | # self.dataOutObj.m_ProcessingHeader.spectraComb = spectraComb |
|
|||
154 |
|
||||
155 | return self.dataOutObj |
|
74 | return self.dataOutObj | |
156 |
|
75 | |||
157 | def init(self): |
|
76 | def init(self): | |
158 | # |
|
|||
159 | # self.nHeights = self.dataInObj.nHeights |
|
|||
160 | # self.dataOutObj.nHeights = self.nHeights |
|
|||
161 | # self.dataOutObj.heightList = self.dataInObj.heightList |
|
|||
162 | # |
|
|||
163 |
|
77 | |||
164 | self.integratorObjIndex = 0 |
|
78 | self.integratorObjIndex = 0 | |
165 | self.writerObjIndex = 0 |
|
79 | self.writerObjIndex = 0 | |
166 |
|
80 | self.plotObjIndex = 0 | ||
167 | if self.dataInObj.type == "Voltage": |
|
81 | if self.dataInObj.type == "Voltage": | |
168 |
|
82 | |||
169 | if self.buffer == None: |
|
83 | if self.buffer == None: | |
@@ -266,6 +180,76 class SpectraProcessor: | |||||
266 | objIncohInt = IncoherentIntegration(N,timeInterval) |
|
180 | objIncohInt = IncoherentIntegration(N,timeInterval) | |
267 | self.integratorObjList.append(objIncohInt) |
|
181 | self.integratorObjList.append(objIncohInt) | |
268 |
|
182 | |||
|
183 | def addSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): | |||
|
184 | spcObj = SpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |||
|
185 | self.plotObjList.append(spcObj) | |||
|
186 | ||||
|
187 | def plotSpc(self, idfigure=None, | |||
|
188 | xmin=None, | |||
|
189 | xmax=None, | |||
|
190 | ymin=None, | |||
|
191 | ymax=None, | |||
|
192 | minvalue=None, | |||
|
193 | maxvalue=None, | |||
|
194 | wintitle='', | |||
|
195 | driver='plplot', | |||
|
196 | colormap='br_greeen', | |||
|
197 | colorbar=True, | |||
|
198 | showprofile=False, | |||
|
199 | save=False, | |||
|
200 | gpath=None): | |||
|
201 | ||||
|
202 | if self.dataOutObj.flagNoData: | |||
|
203 | return 0 | |||
|
204 | ||||
|
205 | nframes = len(self.dataOutObj.channelList) | |||
|
206 | ||||
|
207 | if len(self.plotObjList) <= self.plotObjIndex: | |||
|
208 | self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |||
|
209 | ||||
|
210 | x = numpy.arange(self.dataOutObj.nFFTPoints) | |||
|
211 | ||||
|
212 | y = self.dataOutObj.heightList | |||
|
213 | ||||
|
214 | channelList = self.dataOutObj.channelList | |||
|
215 | ||||
|
216 | data = 10.*numpy.log10(self.dataOutObj.data_spc[channelList,:,:]) | |||
|
217 | # noisedB = 10.*numpy.log10(noise) | |||
|
218 | noisedB = numpy.arange(len(channelList)+1) | |||
|
219 | noisedB = noisedB *1.2 | |||
|
220 | titleList = [] | |||
|
221 | for i in range(len(noisedB)): | |||
|
222 | title = "%.2f"%noisedB[i] | |||
|
223 | titleList.append(title) | |||
|
224 | ||||
|
225 | thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.dataUtcTime) | |||
|
226 | dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S")) | |||
|
227 | figuretitle = "Spc Radar Data: %s"%dateTime | |||
|
228 | ||||
|
229 | cleardata = True | |||
|
230 | ||||
|
231 | plotObj = self.plotObjList[self.plotObjIndex] | |||
|
232 | ||||
|
233 | plotObj.plotPcolor(data, | |||
|
234 | x, | |||
|
235 | y, | |||
|
236 | channelList, | |||
|
237 | xmin, | |||
|
238 | xmax, | |||
|
239 | ymin, | |||
|
240 | ymax, | |||
|
241 | minvalue, | |||
|
242 | maxvalue, | |||
|
243 | figuretitle, | |||
|
244 | None, | |||
|
245 | save, | |||
|
246 | gpath, | |||
|
247 | cleardata, | |||
|
248 | titleList) | |||
|
249 | ||||
|
250 | self.plotObjIndex += 1 | |||
|
251 | ||||
|
252 | ||||
269 | def writeData(self, wrpath, blocksPerFile): |
|
253 | def writeData(self, wrpath, blocksPerFile): | |
270 | if self.dataOutObj.flagNoData: |
|
254 | if self.dataOutObj.flagNoData: | |
271 | return 0 |
|
255 | return 0 | |
@@ -292,7 +276,6 class SpectraProcessor: | |||||
292 | self.dataOutObj.data_spc = myIncohIntObj.data |
|
276 | self.dataOutObj.data_spc = myIncohIntObj.data | |
293 | self.dataOutObj.nAvg = myIncohIntObj.navg |
|
277 | self.dataOutObj.nAvg = myIncohIntObj.navg | |
294 | self.dataOutObj.m_ProcessingHeader.incoherentInt = self.dataInObj.m_ProcessingHeader.incoherentInt*myIncohIntObj.navg |
|
278 | self.dataOutObj.m_ProcessingHeader.incoherentInt = self.dataInObj.m_ProcessingHeader.incoherentInt*myIncohIntObj.navg | |
295 | #print "myIncohIntObj.navg: ",myIncohIntObj.navg |
|
|||
296 | self.dataOutObj.flagNoData = False |
|
279 | self.dataOutObj.flagNoData = False | |
297 |
|
280 | |||
298 | """Calcular el ruido""" |
|
281 | """Calcular el ruido""" |
@@ -54,8 +54,8 class VoltageProcessor: | |||||
54 | # No necesita copiar en cada init() los atributos de dataInObj |
|
54 | # No necesita copiar en cada init() los atributos de dataInObj | |
55 | # la copia deberia hacerse por cada nuevo bloque de datos |
|
55 | # la copia deberia hacerse por cada nuevo bloque de datos | |
56 |
|
56 | |||
57 |
def addRti(self, idfigure, nframes, wintitle, driver, color |
|
57 | def addRti(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): | |
58 |
rtiObj = RTIFigure(idfigure, nframes, wintitle, driver, color |
|
58 | rtiObj = RTIFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
59 | self.plotObjList.append(rtiObj) |
|
59 | self.plotObjList.append(rtiObj) | |
60 |
|
60 | |||
61 | def plotRti(self, idfigure=None, |
|
61 | def plotRti(self, idfigure=None, | |
@@ -89,8 +89,6 class VoltageProcessor: | |||||
89 | # if timezone == "lt": |
|
89 | # if timezone == "lt": | |
90 | currenttime = self.dataOutObj.dataUtcTime - time.timezone |
|
90 | currenttime = self.dataOutObj.dataUtcTime - time.timezone | |
91 |
|
91 | |||
92 |
|
||||
93 |
|
||||
94 | range = self.dataOutObj.heightList |
|
92 | range = self.dataOutObj.heightList | |
95 |
|
93 | |||
96 | channelList = self.dataOutObj.channelList |
|
94 | channelList = self.dataOutObj.channelList | |
@@ -103,6 +101,8 class VoltageProcessor: | |||||
103 |
|
101 | |||
104 | plotObj = self.plotObjList[self.plotObjIndex] |
|
102 | plotObj = self.plotObjList[self.plotObjIndex] | |
105 |
|
103 | |||
|
104 | cleardata = False | |||
|
105 | ||||
106 | plotObj.plotPcolor(data, |
|
106 | plotObj.plotPcolor(data, | |
107 | currenttime, |
|
107 | currenttime, | |
108 | range, |
|
108 | range, | |
@@ -116,7 +116,8 class VoltageProcessor: | |||||
116 | figuretitle, |
|
116 | figuretitle, | |
117 | xrangestep, |
|
117 | xrangestep, | |
118 | save, |
|
118 | save, | |
119 |
gpath |
|
119 | gpath, | |
|
120 | cleardata) | |||
120 |
|
121 | |||
121 | self.plotObjIndex += 1 |
|
122 | self.plotObjIndex += 1 | |
122 |
|
123 |
General Comments 0
You need to be logged in to leave comments.
Login now