##// END OF EJS Templates
UPDATE del jroplot_voltage.py
avaldez -
r1312:f4fa6c62c9fb
parent child
Show More
@@ -1,276 +1,302
1 '''
1 '''
2 Created on Jul 9, 2014
2 Created on Jul 9, 2014
3
3
4 @author: roj-idl71
4 @author: roj-idl71
5 '''
5 '''
6 import os
6 import os
7 import datetime
7 import datetime
8 import numpy
8 import numpy
9
9
10 from schainpy.model.graphics.jroplot_base import Plot, plt
10 from schainpy.model.graphics.jroplot_base import Plot, plt
11
11
12
12
13 class ScopePlot(Plot):
13 class ScopePlot(Plot):
14
14
15 '''
15 '''
16 Plot for Scope
16 Plot for Scope
17 '''
17 '''
18
18
19 CODE = 'scope'
19 CODE = 'scope'
20 plot_name = 'Scope'
20 plot_name = 'Scope'
21 plot_type = 'scatter'
21 plot_type = 'scatter'
22
22
23 def setup(self):
23 def setup(self):
24
24
25 self.xaxis = 'Range (Km)'
25 self.xaxis = 'Range (Km)'
26 self.ncols = 1
26 self.ncols = 1
27 self.nrows = 1
27 self.nrows = 1
28 self.nplots = 1
28 self.nplots = 1
29 self.ylabel = 'Intensity [dB]'
29 self.ylabel = 'Intensity [dB]'
30 self.titles = ['Scope']
30 self.titles = ['Scope']
31 self.colorbar = False
31 self.colorbar = False
32 self.width = 6
32 self.width = 6
33 self.height = 4
33 self.height = 4
34
34
35 def plot_iq(self, x, y, channelIndexList, thisDatetime, wintitle):
35 def plot_iq(self, x, y, channelIndexList, thisDatetime, wintitle):
36
36
37 yreal = y[channelIndexList,:].real
37 yreal = y[channelIndexList,:].real
38 yimag = y[channelIndexList,:].imag
38 yimag = y[channelIndexList,:].imag
39 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y"))
39 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y"))
40 self.xlabel = "Range (Km)"
40 self.xlabel = "Range (Km)"
41 self.ylabel = "Intensity - IQ"
41 self.ylabel = "Intensity - IQ"
42
42
43 self.y = yreal
43 self.y = yreal
44 self.x = x
44 self.x = x
45 self.xmin = min(x)
45 self.xmin = min(x)
46 self.xmax = max(x)
46 self.xmax = max(x)
47
47
48
48
49 self.titles[0] = title
49 self.titles[0] = title
50
50
51 for i,ax in enumerate(self.axes):
51 for i,ax in enumerate(self.axes):
52 title = "Channel %d" %(i)
52 title = "Channel %d" %(i)
53 if ax.firsttime:
53 if ax.firsttime:
54 ax.plt_r = ax.plot(x, yreal[i,:], color='b')[0]
54 ax.plt_r = ax.plot(x, yreal[i,:], color='b')[0]
55 ax.plt_i = ax.plot(x, yimag[i,:], color='r')[0]
55 ax.plt_i = ax.plot(x, yimag[i,:], color='r')[0]
56 else:
56 else:
57 ax.plt_r.set_data(x, yreal[i,:])
57 ax.plt_r.set_data(x, yreal[i,:])
58 ax.plt_i.set_data(x, yimag[i,:])
58 ax.plt_i.set_data(x, yimag[i,:])
59
59
60 def plot_power(self, x, y, channelIndexList, thisDatetime, wintitle):
60 def plot_power(self, x, y, channelIndexList, thisDatetime, wintitle):
61 y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:])
61 y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:])
62 yreal = y.real
62 yreal = y.real
63 yreal = 10*numpy.log10(yreal)
63 yreal = 10*numpy.log10(yreal)
64 self.y = yreal
64 self.y = yreal
65 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y"))
65 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y"))
66 self.xlabel = "Range (Km)"
66 self.xlabel = "Range (Km)"
67 self.ylabel = "Intensity"
67 self.ylabel = "Intensity"
68 self.xmin = min(x)
68 self.xmin = min(x)
69 self.xmax = max(x)
69 self.xmax = max(x)
70
70
71
71
72 self.titles[0] = title
72 self.titles[0] = title
73
73
74 for i,ax in enumerate(self.axes):
74 for i,ax in enumerate(self.axes):
75 title = "Channel %d" %(i)
75 title = "Channel %d" %(i)
76
76
77 ychannel = yreal[i,:]
77 ychannel = yreal[i,:]
78
78
79 if ax.firsttime:
79 if ax.firsttime:
80 ax.plt_r = ax.plot(x, ychannel)[0]
80 ax.plt_r = ax.plot(x, ychannel)[0]
81 else:
81 else:
82 #pass
82 #pass
83 ax.plt_r.set_data(x, ychannel)
83 ax.plt_r.set_data(x, ychannel)
84
84
85 def plot_weatherpower(self, x, y, channelIndexList, thisDatetime, wintitle):
85 def plot_weatherpower(self, x, y, channelIndexList, thisDatetime, wintitle):
86
86
87
87
88 y = y[channelIndexList,:]
88 y = y[channelIndexList,:]
89 yreal = y.real
89 yreal = y.real
90 yreal = 10*numpy.log10(yreal)
90 yreal = 10*numpy.log10(yreal)
91 self.y = yreal
91 self.y = yreal
92 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
92 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
93 self.xlabel = "Range (Km)"
93 self.xlabel = "Range (Km)"
94 self.ylabel = "Intensity"
94 self.ylabel = "Intensity"
95 self.xmin = min(x)
95 self.xmin = min(x)
96 self.xmax = max(x)
96 self.xmax = max(x)
97
97
98 self.titles[0] =title
98 self.titles[0] =title
99 for i,ax in enumerate(self.axes):
99 for i,ax in enumerate(self.axes):
100 title = "Channel %d" %(i)
100 title = "Channel %d" %(i)
101
101
102 ychannel = yreal[i,:]
102 ychannel = yreal[i,:]
103
103
104 if ax.firsttime:
104 if ax.firsttime:
105 ax.plt_r = ax.plot(x, ychannel)[0]
105 ax.plt_r = ax.plot(x, ychannel)[0]
106 else:
106 else:
107 #pass
107 #pass
108 ax.plt_r.set_data(x, ychannel)
108 ax.plt_r.set_data(x, ychannel)
109
109
110 def plot_weathervelocity(self, x, y, channelIndexList, thisDatetime, wintitle):
110 def plot_weathervelocity(self, x, y, channelIndexList, thisDatetime, wintitle):
111
111
112 x = x[channelIndexList,:]
112 x = x[channelIndexList,:]
113 yreal = y
113 yreal = y
114 self.y = yreal
114 self.y = yreal
115 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
115 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
116 self.xlabel = "Velocity (m/s)"
116 self.xlabel = "Velocity (m/s)"
117 self.ylabel = "Range (Km)"
117 self.ylabel = "Range (Km)"
118 self.xmin = numpy.min(x)
118 self.xmin = numpy.min(x)
119 self.xmax = numpy.max(x)
119 self.xmax = numpy.max(x)
120 self.titles[0] =title
120 self.titles[0] =title
121 for i,ax in enumerate(self.axes):
121 for i,ax in enumerate(self.axes):
122 title = "Channel %d" %(i)
122 title = "Channel %d" %(i)
123 xchannel = x[i,:]
123 xchannel = x[i,:]
124 if ax.firsttime:
124 if ax.firsttime:
125 ax.plt_r = ax.plot(xchannel, yreal)[0]
125 ax.plt_r = ax.plot(xchannel, yreal)[0]
126 else:
126 else:
127 #pass
127 #pass
128 ax.plt_r.set_data(xchannel, yreal)
128 ax.plt_r.set_data(xchannel, yreal)
129
129
130 def plot_weatherspecwidth(self, x, y, channelIndexList, thisDatetime, wintitle):
130 def plot_weatherspecwidth(self, x, y, channelIndexList, thisDatetime, wintitle):
131
131
132 x = x[channelIndexList,:]
132 x = x[channelIndexList,:]
133 yreal = y
133 yreal = y
134 self.y = yreal
134 self.y = yreal
135 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
135 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
136 self.xlabel = "width "
136 self.xlabel = "width "
137 self.ylabel = "Range (Km)"
137 self.ylabel = "Range (Km)"
138 self.xmin = numpy.min(x)
138 self.xmin = numpy.min(x)
139 self.xmax = numpy.max(x)
139 self.xmax = numpy.max(x)
140 self.titles[0] =title
140 self.titles[0] =title
141 for i,ax in enumerate(self.axes):
141 for i,ax in enumerate(self.axes):
142 title = "Channel %d" %(i)
142 title = "Channel %d" %(i)
143 xchannel = x[i,:]
143 xchannel = x[i,:]
144 if ax.firsttime:
144 if ax.firsttime:
145 ax.plt_r = ax.plot(xchannel, yreal)[0]
145 ax.plt_r = ax.plot(xchannel, yreal)[0]
146 else:
146 else:
147 #pass
147 #pass
148 ax.plt_r.set_data(xchannel, yreal)
148 ax.plt_r.set_data(xchannel, yreal)
149
149
150 def plot(self):
150 def plot(self):
151 if self.channels:
151 if self.channels:
152 channels = self.channels
152 channels = self.channels
153 else:
153 else:
154 channels = self.data.channels
154 channels = self.data.channels
155
155
156 thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1])
156 thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1])
157 if self.CODE == "pp_power":
157 if self.CODE == "pp_power":
158 scope = self.data['pp_power']
158 scope = self.data['pp_power']
159 elif self.CODE == "pp_signal":
160 scope = self.data["pp_signal"]
159 elif self.CODE == "pp_velocity":
161 elif self.CODE == "pp_velocity":
160 scope = self.data["pp_velocity"]
162 scope = self.data["pp_velocity"]
161 elif self.CODE == "pp_specwidth":
163 elif self.CODE == "pp_specwidth":
162 scope = self.data["pp_specwidth"]
164 scope = self.data["pp_specwidth"]
163 else:
165 else:
164 scope =self.data["scope"]
166 scope =self.data["scope"]
165
167
166 if self.data.flagDataAsBlock:
168 if self.data.flagDataAsBlock:
167
169
168 for i in range(self.data.nProfiles):
170 for i in range(self.data.nProfiles):
169
171
170 wintitle1 = " [Profile = %d] " %i
172 wintitle1 = " [Profile = %d] " %i
171 if self.CODE =="scope":
173 if self.CODE =="scope":
172 if self.type == "power":
174 if self.type == "power":
173 self.plot_power(self.data.heights,
175 self.plot_power(self.data.heights,
174 scope[:,i,:],
176 scope[:,i,:],
175 channels,
177 channels,
176 thisDatetime,
178 thisDatetime,
177 wintitle1
179 wintitle1
178 )
180 )
179
181
180 if self.type == "iq":
182 if self.type == "iq":
181 self.plot_iq(self.data.heights,
183 self.plot_iq(self.data.heights,
182 scope[:,i,:],
184 scope[:,i,:],
183 channels,
185 channels,
184 thisDatetime,
186 thisDatetime,
185 wintitle1
187 wintitle1
186 )
188 )
187 if self.CODE=="pp_power":
189 if self.CODE=="pp_power":
188 self.plot_weatherpower(self.data.heights,
190 self.plot_weatherpower(self.data.heights,
189 scope[:,i,:],
191 scope[:,i,:],
190 channels,
192 channels,
191 thisDatetime,
193 thisDatetime,
192 wintitle
194 wintitle
193 )
195 )
196 if self.CODE=="pp_signal":
197 self.plot_weatherpower(self.data.heights,
198 scope[:,i,:],
199 channels,
200 thisDatetime,
201 wintitle
202 )
194 if self.CODE=="pp_velocity":
203 if self.CODE=="pp_velocity":
195 self.plot_weathervelocity(scope[:,i,:],
204 self.plot_weathervelocity(scope[:,i,:],
196 self.data.heights,
205 self.data.heights,
197 channels,
206 channels,
198 thisDatetime,
207 thisDatetime,
199 wintitle
208 wintitle
200 )
209 )
201 if self.CODE=="pp_spcwidth":
210 if self.CODE=="pp_spcwidth":
202 self.plot_weatherspecwidth(scope[:,i,:],
211 self.plot_weatherspecwidth(scope[:,i,:],
203 self.data.heights,
212 self.data.heights,
204 channels,
213 channels,
205 thisDatetime,
214 thisDatetime,
206 wintitle
215 wintitle
207 )
216 )
208 else:
217 else:
209 wintitle = " [Profile = %d] " %self.data.profileIndex
218 wintitle = " [Profile = %d] " %self.data.profileIndex
210 if self.CODE== "scope":
219 if self.CODE== "scope":
211 if self.type == "power":
220 if self.type == "power":
212 self.plot_power(self.data.heights,
221 self.plot_power(self.data.heights,
213 scope,
222 scope,
214 channels,
223 channels,
215 thisDatetime,
224 thisDatetime,
216 wintitle
225 wintitle
217 )
226 )
218
227
219 if self.type == "iq":
228 if self.type == "iq":
220 self.plot_iq(self.data.heights,
229 self.plot_iq(self.data.heights,
221 scope,
230 scope,
222 channels,
231 channels,
223 thisDatetime,
232 thisDatetime,
224 wintitle
233 wintitle
225 )
234 )
226 if self.CODE=="pp_power":
235 if self.CODE=="pp_power":
227 self.plot_weatherpower(self.data.heights,
236 self.plot_weatherpower(self.data.heights,
228 scope,
237 scope,
229 channels,
238 channels,
230 thisDatetime,
239 thisDatetime,
231 wintitle
240 wintitle
232 )
241 )
242 if self.CODE=="pp_signal":
243 self.plot_weatherpower(self.data.heights,
244 scope,
245 channels,
246 thisDatetime,
247 wintitle
248 )
233 if self.CODE=="pp_velocity":
249 if self.CODE=="pp_velocity":
234 self.plot_weathervelocity(scope,
250 self.plot_weathervelocity(scope,
235 self.data.heights,
251 self.data.heights,
236 channels,
252 channels,
237 thisDatetime,
253 thisDatetime,
238 wintitle
254 wintitle
239 )
255 )
240 if self.CODE=="pp_specwidth":
256 if self.CODE=="pp_specwidth":
241 self.plot_weatherspecwidth(scope,
257 self.plot_weatherspecwidth(scope,
242 self.data.heights,
258 self.data.heights,
243 channels,
259 channels,
244 thisDatetime,
260 thisDatetime,
245 wintitle
261 wintitle
246 )
262 )
247
263
248
264
249
265
250 class PulsepairPowerPlot(ScopePlot):
266 class PulsepairPowerPlot(ScopePlot):
251 '''
267 '''
252 Plot for
268 Plot for P= S+N
253 '''
269 '''
254
270
255 CODE = 'pp_power'
271 CODE = 'pp_power'
256 plot_name = 'PulsepairPower'
272 plot_name = 'PulsepairPower'
257 plot_type = 'scatter'
273 plot_type = 'scatter'
258 buffering = False
274 buffering = False
259
275
260 class PulsepairVelocityPlot(ScopePlot):
276 class PulsepairVelocityPlot(ScopePlot):
261 '''
277 '''
262 Plot for
278 Plot for VELOCITY
263 '''
279 '''
264 CODE = 'pp_velocity'
280 CODE = 'pp_velocity'
265 plot_name = 'PulsepairVelocity'
281 plot_name = 'PulsepairVelocity'
266 plot_type = 'scatter'
282 plot_type = 'scatter'
267 buffering = False
283 buffering = False
268
284
269 class PulsepairSpecwidthPlot(ScopePlot):
285 class PulsepairSpecwidthPlot(ScopePlot):
270 '''
286 '''
271 Plot for
287 Plot for WIDTH
272 '''
288 '''
273 CODE = 'pp_specwidth'
289 CODE = 'pp_specwidth'
274 plot_name = 'PulsepairSpecwidth'
290 plot_name = 'PulsepairSpecwidth'
275 plot_type = 'scatter'
291 plot_type = 'scatter'
276 buffering = False
292 buffering = False
293
294 class PulsepairSignalPlot(ScopePlot):
295 '''
296 Plot for S
297 '''
298
299 CODE = 'pp_signal'
300 plot_name = 'PulsepairSignal'
301 plot_type = 'scatter'
302 buffering = False
General Comments 0
You need to be logged in to leave comments. Login now