@@ -1,233 +1,276 | |||
|
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 schainpy.model.graphics.jroplot_base import Plot, plt |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | class ScopePlot(Plot): |
|
14 | 14 | |
|
15 | 15 | ''' |
|
16 | 16 | Plot for Scope |
|
17 | 17 | ''' |
|
18 | 18 | |
|
19 | 19 | CODE = 'scope' |
|
20 | 20 | plot_name = 'Scope' |
|
21 | 21 | plot_type = 'scatter' |
|
22 | 22 | |
|
23 | 23 | def setup(self): |
|
24 | 24 | |
|
25 | 25 | self.xaxis = 'Range (Km)' |
|
26 | 26 | self.ncols = 1 |
|
27 | 27 | self.nrows = 1 |
|
28 | 28 | self.nplots = 1 |
|
29 | 29 | self.ylabel = 'Intensity [dB]' |
|
30 | 30 | self.titles = ['Scope'] |
|
31 | 31 | self.colorbar = False |
|
32 | 32 | self.width = 6 |
|
33 | 33 | self.height = 4 |
|
34 | 34 | |
|
35 | 35 | def plot_iq(self, x, y, channelIndexList, thisDatetime, wintitle): |
|
36 | 36 | |
|
37 | 37 | yreal = y[channelIndexList,:].real |
|
38 | 38 | yimag = y[channelIndexList,:].imag |
|
39 | 39 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
40 | 40 | self.xlabel = "Range (Km)" |
|
41 | 41 | self.ylabel = "Intensity - IQ" |
|
42 | 42 | |
|
43 | 43 | self.y = yreal |
|
44 | 44 | self.x = x |
|
45 | 45 | self.xmin = min(x) |
|
46 | 46 | self.xmax = max(x) |
|
47 | 47 | |
|
48 | 48 | |
|
49 | 49 | self.titles[0] = title |
|
50 | 50 | |
|
51 | 51 | for i,ax in enumerate(self.axes): |
|
52 | 52 | title = "Channel %d" %(i) |
|
53 | 53 | if ax.firsttime: |
|
54 | 54 | ax.plt_r = ax.plot(x, yreal[i,:], color='b')[0] |
|
55 | 55 | ax.plt_i = ax.plot(x, yimag[i,:], color='r')[0] |
|
56 | 56 | else: |
|
57 | 57 | ax.plt_r.set_data(x, yreal[i,:]) |
|
58 | 58 | ax.plt_i.set_data(x, yimag[i,:]) |
|
59 | 59 | |
|
60 | 60 | def plot_power(self, x, y, channelIndexList, thisDatetime, wintitle): |
|
61 | 61 | y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:]) |
|
62 | 62 | yreal = y.real |
|
63 | 63 | yreal = 10*numpy.log10(yreal) |
|
64 | 64 | self.y = yreal |
|
65 | 65 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
66 | 66 | self.xlabel = "Range (Km)" |
|
67 | 67 | self.ylabel = "Intensity" |
|
68 | 68 | self.xmin = min(x) |
|
69 | 69 | self.xmax = max(x) |
|
70 | 70 | |
|
71 | 71 | |
|
72 | 72 | self.titles[0] = title |
|
73 | 73 | |
|
74 | 74 | for i,ax in enumerate(self.axes): |
|
75 | 75 | title = "Channel %d" %(i) |
|
76 | 76 | |
|
77 | 77 | ychannel = yreal[i,:] |
|
78 | 78 | |
|
79 | 79 | if ax.firsttime: |
|
80 | 80 | ax.plt_r = ax.plot(x, ychannel)[0] |
|
81 | 81 | else: |
|
82 | 82 | #pass |
|
83 | 83 | ax.plt_r.set_data(x, ychannel) |
|
84 | 84 | |
|
85 | 85 | def plot_weatherpower(self, x, y, channelIndexList, thisDatetime, wintitle): |
|
86 | 86 | |
|
87 | 87 | |
|
88 | 88 | y = y[channelIndexList,:] |
|
89 | 89 | yreal = y.real |
|
90 | 90 | yreal = 10*numpy.log10(yreal) |
|
91 | 91 | self.y = yreal |
|
92 | 92 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
93 | 93 | self.xlabel = "Range (Km)" |
|
94 | 94 | self.ylabel = "Intensity" |
|
95 | 95 | self.xmin = min(x) |
|
96 | 96 | self.xmax = max(x) |
|
97 | 97 | |
|
98 | 98 | self.titles[0] =title |
|
99 | 99 | for i,ax in enumerate(self.axes): |
|
100 | 100 | title = "Channel %d" %(i) |
|
101 | 101 | |
|
102 | 102 | ychannel = yreal[i,:] |
|
103 | 103 | |
|
104 | 104 | if ax.firsttime: |
|
105 | 105 | ax.plt_r = ax.plot(x, ychannel)[0] |
|
106 | 106 | else: |
|
107 | 107 | #pass |
|
108 | 108 | ax.plt_r.set_data(x, ychannel) |
|
109 | 109 | |
|
110 | 110 | def plot_weathervelocity(self, x, y, channelIndexList, thisDatetime, wintitle): |
|
111 | 111 | |
|
112 | 112 | x = x[channelIndexList,:] |
|
113 | 113 | yreal = y |
|
114 | 114 | self.y = yreal |
|
115 | 115 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
116 | 116 | self.xlabel = "Velocity (m/s)" |
|
117 | 117 | self.ylabel = "Range (Km)" |
|
118 | 118 | self.xmin = numpy.min(x) |
|
119 | 119 | self.xmax = numpy.max(x) |
|
120 | 120 | self.titles[0] =title |
|
121 | 121 | for i,ax in enumerate(self.axes): |
|
122 | 122 | title = "Channel %d" %(i) |
|
123 | 123 | xchannel = x[i,:] |
|
124 | 124 | if ax.firsttime: |
|
125 | 125 | ax.plt_r = ax.plot(xchannel, yreal)[0] |
|
126 | 126 | else: |
|
127 | 127 | #pass |
|
128 | 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 | 150 | def plot(self): |
|
131 | 151 | if self.channels: |
|
132 | 152 | channels = self.channels |
|
133 | 153 | else: |
|
134 | 154 | channels = self.data.channels |
|
135 | 155 | |
|
136 | 156 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) |
|
137 | 157 | if self.CODE == "pp_power": |
|
138 | 158 | scope = self.data['pp_power'] |
|
139 | 159 | elif self.CODE == "pp_velocity": |
|
140 | 160 | scope = self.data["pp_velocity"] |
|
161 | elif self.CODE == "pp_specwidth": | |
|
162 | scope = self.data["pp_specwidth"] | |
|
141 | 163 | else: |
|
142 | 164 | scope =self.data["scope"] |
|
143 | 165 | |
|
144 | 166 | if self.data.flagDataAsBlock: |
|
145 | 167 | |
|
146 | 168 | for i in range(self.data.nProfiles): |
|
147 | 169 | |
|
148 | 170 | wintitle1 = " [Profile = %d] " %i |
|
149 | 171 | if self.CODE =="scope": |
|
150 | 172 | if self.type == "power": |
|
151 | 173 | self.plot_power(self.data.heights, |
|
152 | 174 | scope[:,i,:], |
|
153 | 175 | channels, |
|
154 | 176 | thisDatetime, |
|
155 | 177 | wintitle1 |
|
156 | 178 | ) |
|
157 | 179 | |
|
158 | 180 | if self.type == "iq": |
|
159 | 181 | self.plot_iq(self.data.heights, |
|
160 | 182 | scope[:,i,:], |
|
161 | 183 | channels, |
|
162 | 184 | thisDatetime, |
|
163 | 185 | wintitle1 |
|
164 | 186 | ) |
|
165 | 187 | if self.CODE=="pp_power": |
|
166 | 188 | self.plot_weatherpower(self.data.heights, |
|
167 | 189 | scope[:,i,:], |
|
168 | 190 | channels, |
|
169 | 191 | thisDatetime, |
|
170 | 192 | wintitle |
|
171 | 193 | ) |
|
172 | 194 | if self.CODE=="pp_velocity": |
|
173 | 195 | self.plot_weathervelocity(scope[:,i,:], |
|
174 | 196 | self.data.heights, |
|
175 | 197 | channels, |
|
176 | 198 | thisDatetime, |
|
177 | 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 | 208 | else: |
|
180 | 209 | wintitle = " [Profile = %d] " %self.data.profileIndex |
|
181 | 210 | if self.CODE== "scope": |
|
182 | 211 | if self.type == "power": |
|
183 | 212 | self.plot_power(self.data.heights, |
|
184 | 213 | scope, |
|
185 | 214 | channels, |
|
186 | 215 | thisDatetime, |
|
187 | 216 | wintitle |
|
188 | 217 | ) |
|
189 | 218 | |
|
190 | 219 | if self.type == "iq": |
|
191 | 220 | self.plot_iq(self.data.heights, |
|
192 | 221 | scope, |
|
193 | 222 | channels, |
|
194 | 223 | thisDatetime, |
|
195 | 224 | wintitle |
|
196 | 225 | ) |
|
197 | 226 | if self.CODE=="pp_power": |
|
198 | 227 | self.plot_weatherpower(self.data.heights, |
|
199 | 228 | scope, |
|
200 | 229 | channels, |
|
201 | 230 | thisDatetime, |
|
202 | 231 | wintitle |
|
203 | 232 | ) |
|
204 | 233 | if self.CODE=="pp_velocity": |
|
205 | 234 | self.plot_weathervelocity(scope, |
|
206 | 235 | self.data.heights, |
|
207 | 236 | channels, |
|
208 | 237 | thisDatetime, |
|
209 | 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 | 250 | class PulsepairPowerPlot(ScopePlot): |
|
215 | 251 | ''' |
|
216 | 252 | Plot for |
|
217 | 253 | ''' |
|
218 | 254 | |
|
219 | 255 | CODE = 'pp_power' |
|
220 | 256 | plot_name = 'PulsepairPower' |
|
221 | 257 | plot_type = 'scatter' |
|
222 | 258 | buffering = False |
|
223 | 259 | |
|
224 | ||
|
225 | ||
|
226 | 260 | class PulsepairVelocityPlot(ScopePlot): |
|
227 | 261 | ''' |
|
228 | 262 | Plot for |
|
229 | 263 | ''' |
|
230 | 264 | CODE = 'pp_velocity' |
|
231 | 265 | plot_name = 'PulsepairVelocity' |
|
232 | 266 | plot_type = 'scatter' |
|
233 | 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