##// END OF EJS Templates
jroplot_voltage.py: New feature added. Support for plotting voltages when getByBlock is set.
Miguel Valdez -
r742:888768c1e762
parent child
Show More
@@ -1,180 +1,212
1 1 '''
2 2 Created on Jul 9, 2014
3 3
4 4 @author: roj-idl71
5 5 '''
6 6 import os
7 7 import datetime
8 8 import numpy
9 9
10 10 from figure import Figure
11 11
12 12 class Scope(Figure):
13 13
14 14 isConfig = None
15 15
16 16 def __init__(self):
17 17
18 18 self.isConfig = False
19 19 self.WIDTH = 300
20 20 self.HEIGHT = 200
21 21 self.counter_imagwr = 0
22 22
23 23 def getSubplots(self):
24 24
25 25 nrow = self.nplots
26 26 ncol = 3
27 27 return nrow, ncol
28 28
29 29 def setup(self, id, nplots, wintitle, show):
30 30
31 31 self.nplots = nplots
32 32
33 33 self.createFigure(id=id,
34 34 wintitle=wintitle,
35 35 show=show)
36 36
37 37 nrow,ncol = self.getSubplots()
38 38 colspan = 3
39 39 rowspan = 1
40 40
41 41 for i in range(nplots):
42 42 self.addAxes(nrow, ncol, i, 0, colspan, rowspan)
43 43
44 44 def plot_iq(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax):
45 45 yreal = y[channelIndexList,:].real
46 46 yimag = y[channelIndexList,:].imag
47 47
48 48 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
49 49 xlabel = "Range (Km)"
50 50 ylabel = "Intensity - IQ"
51 51
52 52 if not self.isConfig:
53 53 nplots = len(channelIndexList)
54 54
55 55 self.setup(id=id,
56 56 nplots=nplots,
57 57 wintitle='',
58 58 show=show)
59 59
60 60 if xmin == None: xmin = numpy.nanmin(x)
61 61 if xmax == None: xmax = numpy.nanmax(x)
62 62 if ymin == None: ymin = min(numpy.nanmin(yreal),numpy.nanmin(yimag))
63 63 if ymax == None: ymax = max(numpy.nanmax(yreal),numpy.nanmax(yimag))
64 64
65 65 self.isConfig = True
66 66
67 67 self.setWinTitle(title)
68 68
69 69 for i in range(len(self.axesList)):
70 70 title = "Channel %d" %(i)
71 71 axes = self.axesList[i]
72 72
73 73 axes.pline(x, yreal[i,:],
74 74 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
75 75 xlabel=xlabel, ylabel=ylabel, title=title)
76 76
77 77 axes.addpline(x, yimag[i,:], idline=1, color="red", linestyle="solid", lw=2)
78 78
79 79 def plot_power(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax):
80 80 y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:])
81 81 yreal = y.real
82 82
83 83 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
84 84 xlabel = "Range (Km)"
85 85 ylabel = "Intensity"
86 86
87 87 if not self.isConfig:
88 88 nplots = len(channelIndexList)
89 89
90 90 self.setup(id=id,
91 91 nplots=nplots,
92 92 wintitle='',
93 93 show=show)
94 94
95 95 if xmin == None: xmin = numpy.nanmin(x)
96 96 if xmax == None: xmax = numpy.nanmax(x)
97 97 if ymin == None: ymin = numpy.nanmin(yreal)
98 98 if ymax == None: ymax = numpy.nanmax(yreal)
99 99
100 100 self.isConfig = True
101 101
102 102 self.setWinTitle(title)
103 103
104 104 for i in range(len(self.axesList)):
105 105 title = "Channel %d" %(i)
106 106 axes = self.axesList[i]
107 107 ychannel = yreal[i,:]
108 108 axes.pline(x, ychannel,
109 109 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
110 110 xlabel=xlabel, ylabel=ylabel, title=title)
111 111
112 112
113 113 def run(self, dataOut, id, wintitle="", channelList=None,
114 114 xmin=None, xmax=None, ymin=None, ymax=None, save=False,
115 115 figpath='./', figfile=None, show=True, wr_period=1,
116 116 ftp=False, server=None, folder=None, username=None, password=None, type='power'):
117 117
118 118 """
119 119
120 120 Input:
121 121 dataOut :
122 122 id :
123 123 wintitle :
124 124 channelList :
125 125 xmin : None,
126 126 xmax : None,
127 127 ymin : None,
128 128 ymax : None,
129 129 """
130 130
131 131 if channelList == None:
132 132 channelIndexList = dataOut.channelIndexList
133 133 else:
134 134 channelIndexList = []
135 135 for channel in channelList:
136 136 if channel not in dataOut.channelList:
137 137 raise ValueError, "Channel %d is not in dataOut.channelList"
138 138 channelIndexList.append(dataOut.channelList.index(channel))
139 139
140 x = dataOut.heightList
141 y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
142 y = y.real
143
144 140 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
145 141
142 if dataOut.flagDataAsBlock:
143
144 for i in range(dataOut.nProfiles):
145
146 wintitle1 = wintitle + " [Profile = %d] " %i
147
148 if type == "power":
149 self.plot_power(dataOut.heightList,
150 dataOut.data[:,i,:],
151 id,
152 channelIndexList,
153 thisDatetime,
154 wintitle1,
155 show,
156 xmin,
157 xmax,
158 ymin,
159 ymax)
160
161 if type == "iq":
162 self.plot_iq(dataOut.heightList,
163 dataOut.data[:,i,:],
164 id,
165 channelIndexList,
166 thisDatetime,
167 wintitle1,
168 show,
169 xmin,
170 xmax,
171 ymin,
172 ymax)
173
174 self.draw()
175
176 else:
177 wintitle += " [Profile = %d] " %dataOut.profileIndex
178
146 179 if type == "power":
147 180 self.plot_power(dataOut.heightList,
148 181 dataOut.data,
149 182 id,
150 183 channelIndexList,
151 184 thisDatetime,
152 185 wintitle,
153 186 show,
154 187 xmin,
155 188 xmax,
156 189 ymin,
157 190 ymax)
158 191
159 192 if type == "iq":
160 193 self.plot_iq(dataOut.heightList,
161 194 dataOut.data,
162 195 id,
163 196 channelIndexList,
164 197 thisDatetime,
165 198 wintitle,
166 199 show,
167 200 xmin,
168 201 xmax,
169 202 ymin,
170 203 ymax)
171 204
172
173 205 self.draw()
174 206
175 207 self.save(figpath=figpath,
176 208 figfile=figfile,
177 209 save=save,
178 210 ftp=ftp,
179 211 wr_period=wr_period,
180 212 thisDatetime=thisDatetime)
General Comments 0
You need to be logged in to leave comments. Login now