##// END OF EJS Templates
Se cambio el driver por defecto de las rutinas graficas a "xwin"
Miguel Valdez -
r44:0f5a49de205d
parent child
Show More
@@ -1,171 +1,171
1 1 '''
2 2 Created on Feb 7, 2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7
8 8 import os, sys
9 9 import numpy
10 10 import datetime
11 11 import plplot
12 12
13 13 path = os.path.split(os.getcwd())[0]
14 14 sys.path.append(path)
15 15
16 16 from Graphics.BaseGraph import *
17 17 from Model.Spectra import Spectra
18 18
19 19 class Spectrum():
20 20
21 21 def __init__(self, Spectra, index=0):
22 22
23 23 """
24 24
25 25 Inputs:
26 26
27 27 type: "power" ->> Potencia
28 28 "iq" ->> Real + Imaginario
29 29 """
30 30
31 31 self.__isPlotConfig = False
32 32
33 33 self.__isPlotIni = False
34 34
35 35 self.__xrange = None
36 36
37 37 self.__yrange = None
38 38
39 39 self.nGraphs = 0
40 40
41 41 self.indexPlot = index
42 42
43 43 self.graphObjList = []
44 44
45 45 self.m_Spectra = Spectra
46 46
47 47
48 48 def __addGraph(self, subpage, title="", xlabel="", ylabel="", showColorbar=False, showPowerProfile=True, XAxisAsTime=False):
49 49
50 50 graphObj = ColorPlot()
51 51 graphObj.setup(subpage,
52 52 title,
53 53 xlabel,
54 54 ylabel,
55 55 showColorbar=showColorbar,
56 56 showPowerProfile=showPowerProfile,
57 57 XAxisAsTime=XAxisAsTime)
58 58
59 59 self.graphObjList.append(graphObj)
60 60
61 61
62 62 def setup(self, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False):
63 63
64 64 nChan = int(self.m_Spectra.m_SystemHeader.numChannels)
65 65 channels = range(nChan)
66 66
67 67 myXlabel = "Radial Velocity (m/s)"
68 68 myYlabel = "Range (km)"
69 69
70 70 for i in channels:
71 71 if titleList != None:
72 72 myTitle = titleList[i]
73 73 myXlabel = xlabelList[i]
74 74 myYlabel = ylabelList[i]
75 75
76 76 if self.m_Spectra.noise != None:
77 77 noise = '%4.2fdB' %(self.m_Spectra.noise[i])
78 78 else:
79 79 noise = '--'
80 80
81 81 myTitle = "Channel: %d - Noise: %s" %(i, noise)
82 82
83 83 self.__addGraph(i+1,
84 84 title=myTitle,
85 85 xlabel=myXlabel,
86 86 ylabel=myYlabel,
87 87 showColorbar=showColorbar,
88 88 showPowerProfile=showPowerProfile,
89 89 XAxisAsTime=XAxisAsTime)
90 90
91 91 self.nGraphs = nChan
92 92 self.__isPlotConfig = True
93 93
94 94 def iniPlot(self):
95 95
96 96 nx = int(numpy.sqrt(self.nGraphs)+1)
97 97 #ny = int(self.nGraphs/nx)
98 98
99 99 plplot.plsstrm(self.indexPlot)
100 100 plplot.plsetopt("geometry", "%dx%d" %(300*nx, 240*nx))
101 plplot.plsdev("xcairo")
101 plplot.plsdev("xwin")
102 102 plplot.plscolbg(255,255,255)
103 103 plplot.plscol0(1,0,0,0)
104 104 plplot.plinit()
105 105 plplot.plspause(False)
106 106 plplot.pladv(0)
107 107 plplot.plssub(nx, nx)
108 108
109 109 self.__nx = nx
110 110 self.__ny = nx
111 111 self.__isPlotIni = True
112 112
113 113
114 114 def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False):
115 115
116 116 if not(self.__isPlotConfig):
117 117 self.setup(titleList,
118 118 xlabelList,
119 119 ylabelList,
120 120 showColorbar,
121 121 showPowerProfile,
122 122 XAxisAsTime)
123 123
124 124 if not(self.__isPlotIni):
125 125 self.iniPlot()
126 126
127 127 data = 10.*numpy.log10(self.m_Spectra.data_spc)
128 128
129 129 nX, nY, nChan = numpy.shape(data)
130 130
131 131 x = numpy.arange(nX)
132 132 y = self.m_Spectra.heights
133 133
134 134 thisDatetime = datetime.datetime.fromtimestamp(self.m_Spectra.m_BasicHeader.utc)
135 135 txtDate = "Self Spectra - Date: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
136 136
137 137 if xmin == None: xmin = x[0]
138 138 if xmax == None: xmax = x[-1]
139 139 if ymin == None: ymin = y[0]
140 140 if ymax == None: ymax = y[-1]
141 141 if zmin == None: zmin = numpy.nanmin(abs(data))
142 142 if zmax == None: zmax = numpy.nanmax(abs(data))
143 143
144 144 plplot.plbop()
145 145
146 146 plplot.plssub(self.__nx, self.__ny)
147 147 for i in range(self.nGraphs):
148 148 self.graphObjList[i].iniSubpage()
149 149 self.graphObjList[i].plotData(data[i,:,:],
150 150 x,
151 151 y,
152 152 xmin=xmin,
153 153 xmax=xmax,
154 154 ymin=ymin,
155 155 ymax=ymax,
156 156 zmin=zmin,
157 157 zmax=zmax)
158 158
159 159 plplot.plssub(1,0)
160 160 plplot.pladv(0)
161 161 plplot.plvpor(0., 1., 0., 1.)
162 162 plplot.plmtex("t",-1., 0.5, 0.5, txtDate)
163 163 plplot.plflush()
164 164 plplot.pleop()
165 165
166 166 def end(self):
167 167 plplot.plend()
168 168
169 169
170 170 if __name__ == '__main__':
171 171 pass No newline at end of file
@@ -1,179 +1,179
1 1 '''
2 2 Created on Feb 7, 2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7 import os, sys
8 8 import numpy
9 9 import plplot
10 10
11 11 path = os.path.split(os.getcwd())[0]
12 12 sys.path.append(path)
13 13
14 14 from Graphics.BaseGraph import *
15 15 from Model.Voltage import Voltage
16 16
17 17 class Osciloscope():
18 18
19 19 def __init__(self, Voltage, index=0):
20 20
21 21 """
22 22
23 23 Inputs:
24 24
25 25 type: "power" ->> Potencia
26 26 "iq" ->> Real + Imaginario
27 27 """
28 28
29 29 self.__isPlotConfig = False
30 30
31 31 self.__isPlotIni = False
32 32
33 33 self.__xrange = None
34 34
35 35 self.__yrange = None
36 36
37 37 self.m_Voltage = None
38 38
39 39 self.nGraphs = 0
40 40
41 41 self.indexPlot = index
42 42
43 43 self.graphObjList = []
44 44
45 45 self.m_Voltage = Voltage
46 46
47 47
48 48 def __addGraph(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False):
49 49
50 50 graphObj = LinearPlot()
51 51 graphObj.setup(subpage, title="", xlabel="", ylabel="", XAxisAsTime=False)
52 52 #graphObj.setScreenPos()
53 53
54 54 self.graphObjList.append(graphObj)
55 55
56 56 del graphObj
57 57
58 58 # def setXRange(self, xmin, xmax):
59 59 # self.__xrange = (xmin, xmax)
60 60 #
61 61 # def setYRange(self, ymin, ymax):
62 62 # self.__yrange = (ymin, ymax)
63 63
64 64
65 65 def setup(self, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False):
66 66
67 67 nChan = int(self.m_Voltage.m_SystemHeader.numChannels)
68 68
69 69 myTitle = ""
70 70 myXlabel = ""
71 71 myYlabel = ""
72 72
73 73 for i in range(nChan):
74 74 if titleList != None:
75 75 myTitle = titleList[i]
76 76 myXlabel = xlabelList[i]
77 77 myYlabel = ylabelList[i]
78 78
79 79 self.__addGraph(i+1, title=myTitle, xlabel=myXlabel, ylabel=myYlabel, XAxisAsTime=XAxisAsTime)
80 80
81 81 self.nGraphs = nChan
82 82 self.__isPlotConfig = True
83 83
84 84 def iniPlot(self):
85 85
86 86 plplot.plsstrm(self.indexPlot)
87 87 plplot.plsetopt("geometry", "%dx%d" %(700, 115*self.nGraphs))
88 plplot.plsdev("xcairo")
88 plplot.plsdev("xwin")
89 89 plplot.plscolbg(255,255,255)
90 90 plplot.plscol0(1,0,0,0)
91 91 plplot.plinit()
92 92 plplot.plspause(False)
93 93 plplot.plssub(1, self.nGraphs)
94 94
95 95 self.__isPlotIni = True
96 96
97 97 def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, idProfile=None, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False, type='iq'):
98 98
99 99 if idProfile != None and idProfile != self.m_Voltage.idProfile:
100 100 return
101 101
102 102 if not(self.__isPlotConfig):
103 103 self.setup(titleList, xlabelList, ylabelList, XAxisAsTime)
104 104
105 105 if not(self.__isPlotIni):
106 106 self.iniPlot()
107 107
108 108 data = self.m_Voltage.data
109 109
110 110 x = self.m_Voltage.heights
111 111
112 112 if xmin == None: xmin = x[0]
113 113 if xmax == None: xmax = x[-1]
114 114 if ymin == None: ymin = numpy.nanmin(abs(data))
115 115 if ymax == None: ymax = numpy.nanmax(abs(data))
116 116
117 117 plplot.plbop()
118 118 for i in range(self.nGraphs):
119 119 y = data[:,i]
120 120
121 121 self.graphObjList[i].iniSubpage()
122 122 self.graphObjList[i].plotComplexData(x, y, xmin, xmax, ymin, ymax, 8, type)
123 123
124 124 plplot.plflush()
125 125 plplot.pleop()
126 126
127 127 def end(self):
128 128 plplot.plend()
129 129
130 130 class VoltagePlot(object):
131 131 '''
132 132 classdocs
133 133 '''
134 134
135 135 __m_Voltage = None
136 136
137 137 def __init__(self, m_Voltage):
138 138 '''
139 139 Constructor
140 140 '''
141 141 self.__m_Voltage = m_Voltage
142 142
143 143 def setup(self):
144 144 pass
145 145
146 146 def addGraph(self, type, xrange=None, yrange=None, zrange=None):
147 147 pass
148 148
149 149 def plotData(self):
150 150 pass
151 151
152 152 if __name__ == '__main__':
153 153
154 154 import numpy
155 155
156 156 plplot.plsetopt("geometry", "%dx%d" %(450*2, 200*2))
157 157 plplot.plsdev("xcairo")
158 158 plplot.plscolbg(255,255,255)
159 159 plplot.plscol0(1,0,0,0)
160 160 plplot.plinit()
161 161 plplot.plssub(1, 2)
162 162
163 163 nx = 64
164 164 ny = 100
165 165
166 166 data = numpy.random.uniform(-50,50,(nx,ny))
167 167
168 168 baseObj = RTI()
169 169 baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False)
170 170 baseObj.plotData(data)
171 171
172 172 data = numpy.random.uniform(-50,50,(nx,ny))
173 173
174 174 base2Obj = RTI()
175 175 base2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True)
176 176 base2Obj.plotData(data)
177 177
178 178 plplot.plend()
179 179 exit(0) No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now