##// END OF EJS Templates
graficos de ploteo pulsepair
avaldez -
r1305:a85d72605709
parent child
Show More
@@ -1,233 +1,276
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):
131
132 x = x[channelIndexList,:]
133 yreal = y
134 self.y = yreal
135 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
136 self.xlabel = "width "
137 self.ylabel = "Range (Km)"
138 self.xmin = numpy.min(x)
139 self.xmax = numpy.max(x)
140 self.titles[0] =title
141 for i,ax in enumerate(self.axes):
142 title = "Channel %d" %(i)
143 xchannel = x[i,:]
144 if ax.firsttime:
145 ax.plt_r = ax.plot(xchannel, yreal)[0]
146 else:
147 #pass
148 ax.plt_r.set_data(xchannel, yreal)
149
130 def plot(self):
150 def plot(self):
131 if self.channels:
151 if self.channels:
132 channels = self.channels
152 channels = self.channels
133 else:
153 else:
134 channels = self.data.channels
154 channels = self.data.channels
135
155
136 thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1])
156 thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1])
137 if self.CODE == "pp_power":
157 if self.CODE == "pp_power":
138 scope = self.data['pp_power']
158 scope = self.data['pp_power']
139 elif self.CODE == "pp_velocity":
159 elif self.CODE == "pp_velocity":
140 scope = self.data["pp_velocity"]
160 scope = self.data["pp_velocity"]
161 elif self.CODE == "pp_specwidth":
162 scope = self.data["pp_specwidth"]
141 else:
163 else:
142 scope =self.data["scope"]
164 scope =self.data["scope"]
143
165
144 if self.data.flagDataAsBlock:
166 if self.data.flagDataAsBlock:
145
167
146 for i in range(self.data.nProfiles):
168 for i in range(self.data.nProfiles):
147
169
148 wintitle1 = " [Profile = %d] " %i
170 wintitle1 = " [Profile = %d] " %i
149 if self.CODE =="scope":
171 if self.CODE =="scope":
150 if self.type == "power":
172 if self.type == "power":
151 self.plot_power(self.data.heights,
173 self.plot_power(self.data.heights,
152 scope[:,i,:],
174 scope[:,i,:],
153 channels,
175 channels,
154 thisDatetime,
176 thisDatetime,
155 wintitle1
177 wintitle1
156 )
178 )
157
179
158 if self.type == "iq":
180 if self.type == "iq":
159 self.plot_iq(self.data.heights,
181 self.plot_iq(self.data.heights,
160 scope[:,i,:],
182 scope[:,i,:],
161 channels,
183 channels,
162 thisDatetime,
184 thisDatetime,
163 wintitle1
185 wintitle1
164 )
186 )
165 if self.CODE=="pp_power":
187 if self.CODE=="pp_power":
166 self.plot_weatherpower(self.data.heights,
188 self.plot_weatherpower(self.data.heights,
167 scope[:,i,:],
189 scope[:,i,:],
168 channels,
190 channels,
169 thisDatetime,
191 thisDatetime,
170 wintitle
192 wintitle
171 )
193 )
172 if self.CODE=="pp_velocity":
194 if self.CODE=="pp_velocity":
173 self.plot_weathervelocity(scope[:,i,:],
195 self.plot_weathervelocity(scope[:,i,:],
174 self.data.heights,
196 self.data.heights,
175 channels,
197 channels,
176 thisDatetime,
198 thisDatetime,
177 wintitle
199 wintitle
178 )
200 )
201 if self.CODE=="pp_spcwidth":
202 self.plot_weatherspecwidth(scope[:,i,:],
203 self.data.heights,
204 channels,
205 thisDatetime,
206 wintitle
207 )
179 else:
208 else:
180 wintitle = " [Profile = %d] " %self.data.profileIndex
209 wintitle = " [Profile = %d] " %self.data.profileIndex
181 if self.CODE== "scope":
210 if self.CODE== "scope":
182 if self.type == "power":
211 if self.type == "power":
183 self.plot_power(self.data.heights,
212 self.plot_power(self.data.heights,
184 scope,
213 scope,
185 channels,
214 channels,
186 thisDatetime,
215 thisDatetime,
187 wintitle
216 wintitle
188 )
217 )
189
218
190 if self.type == "iq":
219 if self.type == "iq":
191 self.plot_iq(self.data.heights,
220 self.plot_iq(self.data.heights,
192 scope,
221 scope,
193 channels,
222 channels,
194 thisDatetime,
223 thisDatetime,
195 wintitle
224 wintitle
196 )
225 )
197 if self.CODE=="pp_power":
226 if self.CODE=="pp_power":
198 self.plot_weatherpower(self.data.heights,
227 self.plot_weatherpower(self.data.heights,
199 scope,
228 scope,
200 channels,
229 channels,
201 thisDatetime,
230 thisDatetime,
202 wintitle
231 wintitle
203 )
232 )
204 if self.CODE=="pp_velocity":
233 if self.CODE=="pp_velocity":
205 self.plot_weathervelocity(scope,
234 self.plot_weathervelocity(scope,
206 self.data.heights,
235 self.data.heights,
207 channels,
236 channels,
208 thisDatetime,
237 thisDatetime,
209 wintitle
238 wintitle
210 )
239 )
240 if self.CODE=="pp_specwidth":
241 self.plot_weatherspecwidth(scope,
242 self.data.heights,
243 channels,
244 thisDatetime,
245 wintitle
246 )
211
247
212
248
213
249
214 class PulsepairPowerPlot(ScopePlot):
250 class PulsepairPowerPlot(ScopePlot):
215 '''
251 '''
216 Plot for
252 Plot for
217 '''
253 '''
218
254
219 CODE = 'pp_power'
255 CODE = 'pp_power'
220 plot_name = 'PulsepairPower'
256 plot_name = 'PulsepairPower'
221 plot_type = 'scatter'
257 plot_type = 'scatter'
222 buffering = False
258 buffering = False
223
259
224
225
226 class PulsepairVelocityPlot(ScopePlot):
260 class PulsepairVelocityPlot(ScopePlot):
227 '''
261 '''
228 Plot for
262 Plot for
229 '''
263 '''
230 CODE = 'pp_velocity'
264 CODE = 'pp_velocity'
231 plot_name = 'PulsepairVelocity'
265 plot_name = 'PulsepairVelocity'
232 plot_type = 'scatter'
266 plot_type = 'scatter'
233 buffering = False
267 buffering = False
268
269 class PulsepairSpecwidthPlot(ScopePlot):
270 '''
271 Plot for
272 '''
273 CODE = 'pp_specwidth'
274 plot_name = 'PulsepairSpecwidth'
275 plot_type = 'scatter'
276 buffering = False
General Comments 0
You need to be logged in to leave comments. Login now