@@ -1,1302 +1,1302 | |||
|
1 | 1 | # Copyright (c) 2012-2021 Jicamarca Radio Observatory |
|
2 | 2 | # All rights reserved. |
|
3 | 3 | # |
|
4 | 4 | # Distributed under the terms of the BSD 3-clause license. |
|
5 | 5 | """Classes to plot Spectra data |
|
6 | 6 | |
|
7 | 7 | """ |
|
8 | 8 | |
|
9 | 9 | import os |
|
10 | 10 | import numpy |
|
11 | 11 | |
|
12 | 12 | from schainpy.model.graphics.jroplot_base import Plot, plt, log |
|
13 | 13 | |
|
14 | 14 | from matplotlib import __version__ as plt_version |
|
15 | 15 | |
|
16 | 16 | if plt_version >='3.3.4': |
|
17 | 17 | EXTRA_POINTS = 0 |
|
18 | 18 | else: |
|
19 | 19 | EXTRA_POINTS = 1 |
|
20 | 20 | |
|
21 | 21 | |
|
22 | 22 | class SpectraPlot(Plot): |
|
23 | 23 | ''' |
|
24 | 24 | Plot for Spectra data |
|
25 | 25 | ''' |
|
26 | 26 | |
|
27 | 27 | CODE = 'spc' |
|
28 | 28 | colormap = 'jet' |
|
29 | 29 | plot_type = 'pcolor' |
|
30 | 30 | buffering = False |
|
31 | 31 | |
|
32 | 32 | def setup(self): |
|
33 | 33 | |
|
34 | 34 | self.nplots = len(self.data.channels) |
|
35 | 35 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
36 | 36 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
37 | 37 | self.height = 2.6 * self.nrows |
|
38 | 38 | self.cb_label = 'dB' |
|
39 | 39 | if self.showprofile: |
|
40 | 40 | self.width = 4 * self.ncols |
|
41 | 41 | else: |
|
42 | 42 | self.width = 3.5 * self.ncols |
|
43 | 43 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
44 | 44 | self.ylabel = 'Range [km]' |
|
45 | 45 | |
|
46 | 46 | def update(self, dataOut): |
|
47 | 47 | |
|
48 | 48 | data = {} |
|
49 | 49 | meta = {} |
|
50 | 50 | spc = 10 * numpy.log10(dataOut.data_spc / dataOut.normFactor) |
|
51 | 51 | data['spc'] = spc |
|
52 | 52 | data['rti'] = dataOut.getPower() |
|
53 | 53 | if hasattr(dataOut, 'LagPlot'): #Double Pulse |
|
54 | 54 | max_hei_id = dataOut.nHeights - 2*dataOut.LagPlot |
|
55 | 55 | data['noise'] = 10*numpy.log10(dataOut.getNoise(ymin_index=53,ymax_index=max_hei_id)/dataOut.normFactor) |
|
56 | 56 | data['noise'][0] = 10*numpy.log10(dataOut.getNoise(ymin_index=53)[0]/dataOut.normFactor) |
|
57 | 57 | else: |
|
58 | 58 | data['noise'] = 10 * numpy.log10(dataOut.getNoise() / dataOut.normFactor) |
|
59 | 59 | extrapoints = spc.shape[1] % dataOut.nFFTPoints |
|
60 | 60 | extrapoints=1 |
|
61 | 61 | meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS) / 1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS)) |
|
62 | 62 | if self.CODE == 'spc_moments': |
|
63 | 63 | data['moments'] = dataOut.moments |
|
64 | 64 | if self.CODE == 'gaussian_fit': |
|
65 | 65 | data['gaussfit'] = dataOut.DGauFitParams |
|
66 | 66 | |
|
67 | 67 | return data, meta |
|
68 | 68 | |
|
69 | 69 | def plot(self): |
|
70 | 70 | |
|
71 | 71 | if self.xaxis == "frequency": |
|
72 | 72 | x = self.data.xrange[0] |
|
73 | 73 | self.xlabel = "Frequency (kHz)" |
|
74 | 74 | elif self.xaxis == "time": |
|
75 | 75 | x = self.data.xrange[1] |
|
76 | 76 | self.xlabel = "Time (ms)" |
|
77 | 77 | else: |
|
78 | 78 | x = self.data.xrange[2] |
|
79 | 79 | self.xlabel = "Velocity (m/s)" |
|
80 | 80 | |
|
81 | 81 | if (self.CODE == 'spc_moments') | (self.CODE == 'gaussian_fit'): |
|
82 | 82 | x = self.data.xrange[2] |
|
83 | 83 | self.xlabel = "Velocity (m/s)" |
|
84 | 84 | |
|
85 | 85 | self.titles = [] |
|
86 | 86 | |
|
87 | 87 | y = self.data.yrange |
|
88 | 88 | self.y = y |
|
89 | 89 | |
|
90 | 90 | data = self.data[-1] |
|
91 | 91 | z = data['spc'] |
|
92 | 92 | |
|
93 | 93 | for n, ax in enumerate(self.axes): |
|
94 | 94 | noise = data['noise'][n] |
|
95 | 95 | |
|
96 | 96 | if self.CODE == 'spc_moments': |
|
97 | 97 | mean = data['moments'][n, 1] |
|
98 | 98 | if self.CODE == 'gaussian_fit': |
|
99 | 99 | gau0 = data['gaussfit'][n][2,:,0] |
|
100 | 100 | gau1 = data['gaussfit'][n][2,:,1] |
|
101 | 101 | if ax.firsttime: |
|
102 | 102 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
103 | 103 | self.xmin = self.xmin if self.xmin else numpy.nanmin(x)#-self.xmax |
|
104 | 104 | #self.zmin = self.zmin if self.zmin else numpy.nanmin(z) |
|
105 | 105 | #self.zmax = self.zmax if self.zmax else numpy.nanmax(z) |
|
106 | 106 | if self.zlimits is not None: |
|
107 | 107 | self.zmin, self.zmax = self.zlimits[n] |
|
108 | 108 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
109 | 109 | vmin=self.zmin, |
|
110 | 110 | vmax=self.zmax, |
|
111 | 111 | cmap=plt.get_cmap(self.colormap) |
|
112 | 112 | ) |
|
113 | 113 | |
|
114 | 114 | if self.showprofile: |
|
115 | 115 | ax.plt_profile = self.pf_axes[n].plot( |
|
116 | 116 | data['rti'][n], y)[0] |
|
117 | 117 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, |
|
118 | 118 | color="k", linestyle="dashed", lw=1)[0] |
|
119 | 119 | if self.CODE == 'spc_moments': |
|
120 | 120 | ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0] |
|
121 | 121 | if self.CODE == 'gaussian_fit': |
|
122 | 122 | ax.plt_gau0 = ax.plot(gau0, y, color='r', lw=1)[0] |
|
123 | 123 | ax.plt_gau1 = ax.plot(gau1, y, color='y', lw=1)[0] |
|
124 | 124 | else: |
|
125 | 125 | if self.zlimits is not None: |
|
126 | 126 | self.zmin, self.zmax = self.zlimits[n] |
|
127 | 127 | ax.plt.set_array(z[n].T.ravel()) |
|
128 | 128 | if self.showprofile: |
|
129 | 129 | ax.plt_profile.set_data(data['rti'][n], y) |
|
130 | 130 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) |
|
131 | 131 | if self.CODE == 'spc_moments': |
|
132 | 132 | ax.plt_mean.set_data(mean, y) |
|
133 | 133 | if self.CODE == 'gaussian_fit': |
|
134 | 134 | ax.plt_gau0.set_data(gau0, y) |
|
135 | 135 | ax.plt_gau1.set_data(gau1, y) |
|
136 | 136 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) |
|
137 | 137 | |
|
138 | 138 | class SpectraObliquePlot(Plot): |
|
139 | 139 | ''' |
|
140 | 140 | Plot for Spectra data |
|
141 | 141 | |
|
142 | 142 | Written by R. Flores |
|
143 | 143 | ''' |
|
144 | 144 | |
|
145 | 145 | CODE = 'spc_oblique' |
|
146 | 146 | colormap = 'jet' |
|
147 | 147 | plot_type = 'pcolor' |
|
148 | 148 | |
|
149 | 149 | def setup(self): |
|
150 | 150 | self.xaxis = "oblique" |
|
151 | 151 | self.nplots = len(self.data.channels) |
|
152 | 152 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
153 | 153 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
154 | 154 | self.height = 2.6 * self.nrows |
|
155 | 155 | self.cb_label = 'dB' |
|
156 | 156 | if self.showprofile: |
|
157 | 157 | self.width = 4 * self.ncols |
|
158 | 158 | else: |
|
159 | 159 | self.width = 3.5 * self.ncols |
|
160 | 160 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
161 | 161 | self.ylabel = 'Range [km]' |
|
162 | 162 | |
|
163 | 163 | def update(self, dataOut): |
|
164 | 164 | |
|
165 | 165 | data = {} |
|
166 | 166 | meta = {} |
|
167 | 167 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) |
|
168 | 168 | data['spc'] = spc |
|
169 | 169 | data['rti'] = dataOut.getPower() |
|
170 | 170 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
171 | 171 | meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS)/1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS)) |
|
172 | 172 | |
|
173 | 173 | data['shift1'] = dataOut.Dop_EEJ_T1[0] |
|
174 | 174 | data['shift2'] = dataOut.Dop_EEJ_T2[0] |
|
175 | 175 | data['max_val_2'] = dataOut.Oblique_params[0,-1,:] |
|
176 | 176 | data['shift1_error'] = dataOut.Err_Dop_EEJ_T1[0] |
|
177 | 177 | data['shift2_error'] = dataOut.Err_Dop_EEJ_T2[0] |
|
178 | 178 | |
|
179 | 179 | return data, meta |
|
180 | 180 | |
|
181 | 181 | def plot(self): |
|
182 | 182 | |
|
183 | 183 | if self.xaxis == "frequency": |
|
184 | 184 | x = self.data.xrange[0] |
|
185 | 185 | self.xlabel = "Frequency (kHz)" |
|
186 | 186 | elif self.xaxis == "time": |
|
187 | 187 | x = self.data.xrange[1] |
|
188 | 188 | self.xlabel = "Time (ms)" |
|
189 | 189 | else: |
|
190 | 190 | x = self.data.xrange[2] |
|
191 | 191 | self.xlabel = "Velocity (m/s)" |
|
192 | 192 | |
|
193 | 193 | self.titles = [] |
|
194 | 194 | |
|
195 | 195 | y = self.data.yrange |
|
196 | 196 | self.y = y |
|
197 | 197 | data = self.data[-1] |
|
198 | 198 | z = data['spc'] |
|
199 | 199 | |
|
200 | 200 | for n, ax in enumerate(self.axes): |
|
201 | 201 | noise = self.data['noise'][n][-1] |
|
202 | 202 | shift1 = data['shift1'] |
|
203 | 203 | shift2 = data['shift2'] |
|
204 | 204 | max_val_2 = data['max_val_2'] |
|
205 | 205 | err1 = data['shift1_error'] |
|
206 | 206 | err2 = data['shift2_error'] |
|
207 | 207 | if ax.firsttime: |
|
208 | 208 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
209 | 209 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
210 | 210 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) |
|
211 | 211 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) |
|
212 | 212 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
213 | 213 | vmin=self.zmin, |
|
214 | 214 | vmax=self.zmax, |
|
215 | 215 | cmap=plt.get_cmap(self.colormap) |
|
216 | 216 | ) |
|
217 | 217 | |
|
218 | 218 | if self.showprofile: |
|
219 | 219 | ax.plt_profile = self.pf_axes[n].plot( |
|
220 | 220 | self.data['rti'][n][-1], y)[0] |
|
221 | 221 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, |
|
222 | 222 | color="k", linestyle="dashed", lw=1)[0] |
|
223 | 223 | |
|
224 | 224 | self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^', elinewidth=2.2, marker='o', linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) |
|
225 | 225 | self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) |
|
226 | 226 | self.ploterr3 = ax.errorbar(max_val_2, y, xerr=0, fmt='g^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) |
|
227 | 227 | else: |
|
228 | 228 | self.ploterr1.remove() |
|
229 | 229 | self.ploterr2.remove() |
|
230 | 230 | self.ploterr3.remove() |
|
231 | 231 | ax.plt.set_array(z[n].T.ravel()) |
|
232 | 232 | if self.showprofile: |
|
233 | 233 | ax.plt_profile.set_data(self.data['rti'][n][-1], y) |
|
234 | 234 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) |
|
235 | 235 | self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^', elinewidth=2.2, marker='o', linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) |
|
236 | 236 | self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) |
|
237 | 237 | self.ploterr3 = ax.errorbar(max_val_2, y, xerr=0, fmt='g^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) |
|
238 | 238 | |
|
239 | 239 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) |
|
240 | 240 | |
|
241 | 241 | |
|
242 | 242 | class CrossSpectraPlot(Plot): |
|
243 | 243 | |
|
244 | 244 | CODE = 'cspc' |
|
245 | 245 | colormap = 'jet' |
|
246 | 246 | plot_type = 'pcolor' |
|
247 | 247 | zmin_coh = None |
|
248 | 248 | zmax_coh = None |
|
249 | 249 | zmin_phase = None |
|
250 | 250 | zmax_phase = None |
|
251 | 251 | |
|
252 | 252 | def setup(self): |
|
253 | 253 | |
|
254 | 254 | self.ncols = 4 |
|
255 | 255 | self.nplots = len(self.data.pairs) * 2 |
|
256 | 256 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
257 | 257 | self.width = 3.1 * self.ncols |
|
258 | 258 | self.height = 5 * self.nrows |
|
259 | 259 | self.ylabel = 'Range [km]' |
|
260 | 260 | self.showprofile = False |
|
261 | 261 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
262 | 262 | |
|
263 | 263 | def update(self, dataOut): |
|
264 | 264 | |
|
265 | 265 | data = {} |
|
266 | 266 | meta = {} |
|
267 | 267 | |
|
268 | 268 | spc = dataOut.data_spc |
|
269 | 269 | cspc = dataOut.data_cspc |
|
270 | 270 | extrapoints = spc.shape[1] % dataOut.nFFTPoints |
|
271 | 271 | meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS) / 1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS)) |
|
272 | 272 | meta['pairs'] = dataOut.pairsList |
|
273 | 273 | |
|
274 | 274 | tmp = [] |
|
275 | 275 | |
|
276 | 276 | for n, pair in enumerate(meta['pairs']): |
|
277 | 277 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
278 | 278 | coh = numpy.abs(out) |
|
279 | 279 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
280 | 280 | tmp.append(coh) |
|
281 | 281 | tmp.append(phase) |
|
282 | 282 | |
|
283 | 283 | data['cspc'] = numpy.array(tmp) |
|
284 | 284 | |
|
285 | 285 | return data, meta |
|
286 | 286 | |
|
287 | 287 | def plot(self): |
|
288 | 288 | |
|
289 | 289 | if self.xaxis == "frequency": |
|
290 | 290 | x = self.data.xrange[0] |
|
291 | 291 | self.xlabel = "Frequency (kHz)" |
|
292 | 292 | elif self.xaxis == "time": |
|
293 | 293 | x = self.data.xrange[1] |
|
294 | 294 | self.xlabel = "Time (ms)" |
|
295 | 295 | else: |
|
296 | 296 | x = self.data.xrange[2] |
|
297 | 297 | self.xlabel = "Velocity (m/s)" |
|
298 | 298 | |
|
299 | 299 | self.titles = [] |
|
300 | 300 | |
|
301 | 301 | y = self.data.yrange |
|
302 | 302 | self.y = y |
|
303 | 303 | |
|
304 | 304 | data = self.data[-1] |
|
305 | 305 | cspc = data['cspc'] |
|
306 | 306 | |
|
307 | 307 | for n in range(len(self.data.pairs)): |
|
308 | 308 | pair = self.data.pairs[n] |
|
309 | 309 | coh = cspc[n * 2] |
|
310 | 310 | phase = cspc[n * 2 + 1] |
|
311 | 311 | ax = self.axes[2 * n] |
|
312 | 312 | if ax.firsttime: |
|
313 | 313 | ax.plt = ax.pcolormesh(x, y, coh.T, |
|
314 | 314 | vmin=0, |
|
315 | 315 | vmax=1, |
|
316 | 316 | cmap=plt.get_cmap(self.colormap_coh) |
|
317 | 317 | ) |
|
318 | 318 | else: |
|
319 | 319 | ax.plt.set_array(coh.T.ravel()) |
|
320 | 320 | self.titles.append( |
|
321 | 321 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
322 | 322 | |
|
323 | 323 | ax = self.axes[2 * n + 1] |
|
324 | 324 | if ax.firsttime: |
|
325 | 325 | ax.plt = ax.pcolormesh(x, y, phase.T, |
|
326 | 326 | vmin=-180, |
|
327 | 327 | vmax=180, |
|
328 | 328 | cmap=plt.get_cmap(self.colormap_phase) |
|
329 | 329 | ) |
|
330 | 330 | else: |
|
331 | 331 | ax.plt.set_array(phase.T.ravel()) |
|
332 | 332 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) |
|
333 | 333 | |
|
334 | 334 | |
|
335 | 335 | class CrossSpectra4Plot(Plot): |
|
336 | 336 | |
|
337 | 337 | CODE = 'cspc' |
|
338 | 338 | colormap = 'jet' |
|
339 | 339 | plot_type = 'pcolor' |
|
340 | 340 | zmin_coh = None |
|
341 | 341 | zmax_coh = None |
|
342 | 342 | zmin_phase = None |
|
343 | 343 | zmax_phase = None |
|
344 | 344 | |
|
345 | 345 | def setup(self): |
|
346 | 346 | |
|
347 | 347 | self.ncols = 4 |
|
348 | 348 | self.nrows = len(self.data.pairs) |
|
349 | 349 | self.nplots = self.nrows * 4 |
|
350 | 350 | self.width = 3.1 * self.ncols |
|
351 | 351 | self.height = 5 * self.nrows |
|
352 | 352 | self.ylabel = 'Range [km]' |
|
353 | 353 | self.showprofile = False |
|
354 | 354 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
355 | 355 | |
|
356 | 356 | def plot(self): |
|
357 | 357 | |
|
358 | 358 | if self.xaxis == "frequency": |
|
359 | 359 | x = self.data.xrange[0] |
|
360 | 360 | self.xlabel = "Frequency (kHz)" |
|
361 | 361 | elif self.xaxis == "time": |
|
362 | 362 | x = self.data.xrange[1] |
|
363 | 363 | self.xlabel = "Time (ms)" |
|
364 | 364 | else: |
|
365 | 365 | x = self.data.xrange[2] |
|
366 | 366 | self.xlabel = "Velocity (m/s)" |
|
367 | 367 | |
|
368 | 368 | self.titles = [] |
|
369 | 369 | |
|
370 | 370 | |
|
371 | 371 | y = self.data.heights |
|
372 | 372 | self.y = y |
|
373 | 373 | nspc = self.data['spc'] |
|
374 | 374 | #print(numpy.shape(self.data['spc'])) |
|
375 | 375 | spc = self.data['cspc'][0] |
|
376 | 376 | #print(numpy.shape(nspc)) |
|
377 | 377 | #exit() |
|
378 | 378 | #nspc[1,:,:] = numpy.flip(nspc[1,:,:],axis=0) |
|
379 | 379 | #print(numpy.shape(spc)) |
|
380 | 380 | #exit() |
|
381 | 381 | cspc = self.data['cspc'][1] |
|
382 | 382 | |
|
383 | 383 | #xflip=numpy.flip(x) |
|
384 | 384 | #print(numpy.shape(cspc)) |
|
385 | 385 | #exit() |
|
386 | 386 | |
|
387 | 387 | for n in range(self.nrows): |
|
388 | 388 | noise = self.data['noise'][:,-1] |
|
389 | 389 | pair = self.data.pairs[n] |
|
390 | 390 | #print(pair) |
|
391 | 391 | #exit() |
|
392 | 392 | ax = self.axes[4 * n] |
|
393 | 393 | if ax.firsttime: |
|
394 | 394 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
395 | 395 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
396 | 396 | self.zmin = self.zmin if self.zmin else numpy.nanmin(nspc) |
|
397 | 397 | self.zmax = self.zmax if self.zmax else numpy.nanmax(nspc) |
|
398 | 398 | ax.plt = ax.pcolormesh(x , y , nspc[pair[0]].T, |
|
399 | 399 | vmin=self.zmin, |
|
400 | 400 | vmax=self.zmax, |
|
401 | 401 | cmap=plt.get_cmap(self.colormap) |
|
402 | 402 | ) |
|
403 | 403 | else: |
|
404 | 404 | #print(numpy.shape(nspc[pair[0]].T)) |
|
405 | 405 | #exit() |
|
406 | 406 | ax.plt.set_array(nspc[pair[0]].T.ravel()) |
|
407 | 407 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[0], noise[pair[0]])) |
|
408 | 408 | |
|
409 | 409 | ax = self.axes[4 * n + 1] |
|
410 | 410 | |
|
411 | 411 | if ax.firsttime: |
|
412 | 412 | ax.plt = ax.pcolormesh(x , y, numpy.flip(nspc[pair[1]],axis=0).T, |
|
413 | 413 | vmin=self.zmin, |
|
414 | 414 | vmax=self.zmax, |
|
415 | 415 | cmap=plt.get_cmap(self.colormap) |
|
416 | 416 | ) |
|
417 | 417 | else: |
|
418 | 418 | |
|
419 | 419 | ax.plt.set_array(numpy.flip(nspc[pair[1]],axis=0).T.ravel()) |
|
420 | 420 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[1], noise[pair[1]])) |
|
421 | 421 | |
|
422 | 422 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
423 | 423 | coh = numpy.abs(out) |
|
424 | 424 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
425 | 425 | |
|
426 | 426 | ax = self.axes[4 * n + 2] |
|
427 | 427 | if ax.firsttime: |
|
428 | 428 | ax.plt = ax.pcolormesh(x, y, numpy.flip(coh,axis=0).T, |
|
429 | 429 | vmin=0, |
|
430 | 430 | vmax=1, |
|
431 | 431 | cmap=plt.get_cmap(self.colormap_coh) |
|
432 | 432 | ) |
|
433 | 433 | else: |
|
434 | 434 | ax.plt.set_array(numpy.flip(coh,axis=0).T.ravel()) |
|
435 | 435 | self.titles.append( |
|
436 | 436 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
437 | 437 | |
|
438 | 438 | ax = self.axes[4 * n + 3] |
|
439 | 439 | if ax.firsttime: |
|
440 | 440 | ax.plt = ax.pcolormesh(x, y, numpy.flip(phase,axis=0).T, |
|
441 | 441 | vmin=-180, |
|
442 | 442 | vmax=180, |
|
443 | 443 | cmap=plt.get_cmap(self.colormap_phase) |
|
444 | 444 | ) |
|
445 | 445 | else: |
|
446 | 446 | ax.plt.set_array(numpy.flip(phase,axis=0).T.ravel()) |
|
447 | 447 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) |
|
448 | 448 | |
|
449 | 449 | |
|
450 | 450 | class CrossSpectra2Plot(Plot): |
|
451 | 451 | |
|
452 | 452 | CODE = 'cspc' |
|
453 | 453 | colormap = 'jet' |
|
454 | 454 | plot_type = 'pcolor' |
|
455 | 455 | zmin_coh = None |
|
456 | 456 | zmax_coh = None |
|
457 | 457 | zmin_phase = None |
|
458 | 458 | zmax_phase = None |
|
459 | 459 | |
|
460 | 460 | def setup(self): |
|
461 | 461 | |
|
462 | 462 | self.ncols = 1 |
|
463 | 463 | self.nrows = len(self.data.pairs) |
|
464 | 464 | self.nplots = self.nrows * 1 |
|
465 | 465 | self.width = 3.1 * self.ncols |
|
466 | 466 | self.height = 5 * self.nrows |
|
467 | 467 | self.ylabel = 'Range [km]' |
|
468 | 468 | self.showprofile = False |
|
469 | 469 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
470 | 470 | |
|
471 | 471 | def plot(self): |
|
472 | 472 | |
|
473 | 473 | if self.xaxis == "frequency": |
|
474 | 474 | x = self.data.xrange[0] |
|
475 | 475 | self.xlabel = "Frequency (kHz)" |
|
476 | 476 | elif self.xaxis == "time": |
|
477 | 477 | x = self.data.xrange[1] |
|
478 | 478 | self.xlabel = "Time (ms)" |
|
479 | 479 | else: |
|
480 | 480 | x = self.data.xrange[2] |
|
481 | 481 | self.xlabel = "Velocity (m/s)" |
|
482 | 482 | |
|
483 | 483 | self.titles = [] |
|
484 | 484 | |
|
485 | 485 | |
|
486 | 486 | y = self.data.heights |
|
487 | 487 | self.y = y |
|
488 | 488 | #nspc = self.data['spc'] |
|
489 | 489 | #print(numpy.shape(self.data['spc'])) |
|
490 | 490 | #spc = self.data['cspc'][0] |
|
491 | 491 | #print(numpy.shape(spc)) |
|
492 | 492 | #exit() |
|
493 | 493 | cspc = self.data['cspc'][1] |
|
494 | 494 | #print(numpy.shape(cspc)) |
|
495 | 495 | #exit() |
|
496 | 496 | |
|
497 | 497 | for n in range(self.nrows): |
|
498 | 498 | noise = self.data['noise'][:,-1] |
|
499 | 499 | pair = self.data.pairs[n] |
|
500 | 500 | #print(pair) #exit() |
|
501 | 501 | |
|
502 | 502 | |
|
503 | 503 | |
|
504 | 504 | out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
505 | 505 | |
|
506 | 506 | #print(out[:,53]) |
|
507 | 507 | #exit() |
|
508 | 508 | cross = numpy.abs(out) |
|
509 | 509 | z = cross/self.data.nFactor |
|
510 | 510 | #print("here") |
|
511 | 511 | #print(dataOut.data_spc[0,0,0]) |
|
512 | 512 | #exit() |
|
513 | 513 | |
|
514 | 514 | cross = 10*numpy.log10(z) |
|
515 | 515 | #print(numpy.shape(cross)) |
|
516 | 516 | #print(cross[0,:]) |
|
517 | 517 | #print(self.data.nFactor) |
|
518 | 518 | #exit() |
|
519 | 519 | #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
520 | 520 | |
|
521 | 521 | ax = self.axes[1 * n] |
|
522 | 522 | if ax.firsttime: |
|
523 | 523 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
524 | 524 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
525 | 525 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
526 | 526 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
527 | 527 | ax.plt = ax.pcolormesh(x, y, cross.T, |
|
528 | 528 | vmin=self.zmin, |
|
529 | 529 | vmax=self.zmax, |
|
530 | 530 | cmap=plt.get_cmap(self.colormap) |
|
531 | 531 | ) |
|
532 | 532 | else: |
|
533 | 533 | ax.plt.set_array(cross.T.ravel()) |
|
534 | 534 | self.titles.append( |
|
535 | 535 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
536 | 536 | |
|
537 | 537 | |
|
538 | 538 | class CrossSpectra3Plot(Plot): |
|
539 | 539 | |
|
540 | 540 | CODE = 'cspc' |
|
541 | 541 | colormap = 'jet' |
|
542 | 542 | plot_type = 'pcolor' |
|
543 | 543 | zmin_coh = None |
|
544 | 544 | zmax_coh = None |
|
545 | 545 | zmin_phase = None |
|
546 | 546 | zmax_phase = None |
|
547 | 547 | |
|
548 | 548 | def setup(self): |
|
549 | 549 | |
|
550 | 550 | self.ncols = 3 |
|
551 | 551 | self.nrows = len(self.data.pairs) |
|
552 | 552 | self.nplots = self.nrows * 3 |
|
553 | 553 | self.width = 3.1 * self.ncols |
|
554 | 554 | self.height = 5 * self.nrows |
|
555 | 555 | self.ylabel = 'Range [km]' |
|
556 | 556 | self.showprofile = False |
|
557 | 557 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
558 | 558 | |
|
559 | 559 | def plot(self): |
|
560 | 560 | |
|
561 | 561 | if self.xaxis == "frequency": |
|
562 | 562 | x = self.data.xrange[0] |
|
563 | 563 | self.xlabel = "Frequency (kHz)" |
|
564 | 564 | elif self.xaxis == "time": |
|
565 | 565 | x = self.data.xrange[1] |
|
566 | 566 | self.xlabel = "Time (ms)" |
|
567 | 567 | else: |
|
568 | 568 | x = self.data.xrange[2] |
|
569 | 569 | self.xlabel = "Velocity (m/s)" |
|
570 | 570 | |
|
571 | 571 | self.titles = [] |
|
572 | 572 | |
|
573 | 573 | |
|
574 | 574 | y = self.data.heights |
|
575 | 575 | self.y = y |
|
576 | 576 | #nspc = self.data['spc'] |
|
577 | 577 | #print(numpy.shape(self.data['spc'])) |
|
578 | 578 | #spc = self.data['cspc'][0] |
|
579 | 579 | #print(numpy.shape(spc)) |
|
580 | 580 | #exit() |
|
581 | 581 | cspc = self.data['cspc'][1] |
|
582 | 582 | #print(numpy.shape(cspc)) |
|
583 | 583 | #exit() |
|
584 | 584 | |
|
585 | 585 | for n in range(self.nrows): |
|
586 | 586 | noise = self.data['noise'][:,-1] |
|
587 | 587 | pair = self.data.pairs[n] |
|
588 | 588 | #print(pair) #exit() |
|
589 | 589 | |
|
590 | 590 | |
|
591 | 591 | |
|
592 | 592 | out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
593 | 593 | |
|
594 | 594 | #print(out[:,53]) |
|
595 | 595 | #exit() |
|
596 | 596 | cross = numpy.abs(out) |
|
597 | 597 | z = cross/self.data.nFactor |
|
598 | 598 | cross = 10*numpy.log10(z) |
|
599 | 599 | |
|
600 | 600 | out_r= out.real/self.data.nFactor |
|
601 | 601 | #out_r = 10*numpy.log10(out_r) |
|
602 | 602 | |
|
603 | 603 | out_i= out.imag/self.data.nFactor |
|
604 | 604 | #out_i = 10*numpy.log10(out_i) |
|
605 | 605 | #print(numpy.shape(cross)) |
|
606 | 606 | #print(cross[0,:]) |
|
607 | 607 | #print(self.data.nFactor) |
|
608 | 608 | #exit() |
|
609 | 609 | #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
610 | 610 | |
|
611 | 611 | ax = self.axes[3 * n] |
|
612 | 612 | if ax.firsttime: |
|
613 | 613 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
614 | 614 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
615 | 615 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
616 | 616 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
617 | 617 | ax.plt = ax.pcolormesh(x, y, cross.T, |
|
618 | 618 | vmin=self.zmin, |
|
619 | 619 | vmax=self.zmax, |
|
620 | 620 | cmap=plt.get_cmap(self.colormap) |
|
621 | 621 | ) |
|
622 | 622 | else: |
|
623 | 623 | ax.plt.set_array(cross.T.ravel()) |
|
624 | 624 | self.titles.append( |
|
625 | 625 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
626 | 626 | |
|
627 | 627 | ax = self.axes[3 * n + 1] |
|
628 | 628 | if ax.firsttime: |
|
629 | 629 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
630 | 630 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
631 | 631 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
632 | 632 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
633 | 633 | ax.plt = ax.pcolormesh(x, y, out_r.T, |
|
634 | 634 | vmin=-1.e6, |
|
635 | 635 | vmax=0, |
|
636 | 636 | cmap=plt.get_cmap(self.colormap) |
|
637 | 637 | ) |
|
638 | 638 | else: |
|
639 | 639 | ax.plt.set_array(out_r.T.ravel()) |
|
640 | 640 | self.titles.append( |
|
641 | 641 | 'Cross Spectra Real Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
642 | 642 | |
|
643 | 643 | ax = self.axes[3 * n + 2] |
|
644 | 644 | |
|
645 | 645 | |
|
646 | 646 | if ax.firsttime: |
|
647 | 647 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
648 | 648 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
649 | 649 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
650 | 650 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
651 | 651 | ax.plt = ax.pcolormesh(x, y, out_i.T, |
|
652 | 652 | vmin=-1.e6, |
|
653 | 653 | vmax=1.e6, |
|
654 | 654 | cmap=plt.get_cmap(self.colormap) |
|
655 | 655 | ) |
|
656 | 656 | else: |
|
657 | 657 | ax.plt.set_array(out_i.T.ravel()) |
|
658 | 658 | self.titles.append( |
|
659 | 659 | 'Cross Spectra Imag Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
660 | 660 | |
|
661 | 661 | class RTIPlot(Plot): |
|
662 | 662 | ''' |
|
663 | 663 | Plot for RTI data |
|
664 | 664 | ''' |
|
665 | 665 | |
|
666 | 666 | CODE = 'rti' |
|
667 | 667 | colormap = 'jet' |
|
668 | 668 | plot_type = 'pcolorbuffer' |
|
669 | 669 | |
|
670 | 670 | def setup(self): |
|
671 | 671 | self.xaxis = 'time' |
|
672 | 672 | self.ncols = 1 |
|
673 | 673 | self.nrows = len(self.data.channels) |
|
674 | 674 | self.nplots = len(self.data.channels) |
|
675 | 675 | self.ylabel = 'Range [km]' |
|
676 | 676 | self.xlabel = 'Time' |
|
677 | 677 | self.cb_label = 'dB' |
|
678 | 678 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) |
|
679 | 679 | self.titles = ['{} Channel {}'.format( |
|
680 | 680 | self.CODE.upper(), x) for x in range(self.nrows)] |
|
681 | 681 | |
|
682 | 682 | def update(self, dataOut): |
|
683 | 683 | |
|
684 | 684 | data = {} |
|
685 | 685 | meta = {} |
|
686 | 686 | data['rti'] = dataOut.getPower() |
|
687 | 687 | data['noise'] = 10 * numpy.log10(dataOut.getNoise() / dataOut.normFactor) |
|
688 | 688 | |
|
689 | 689 | return data, meta |
|
690 | 690 | |
|
691 | 691 | def plot(self): |
|
692 | 692 | self.x = self.data.times |
|
693 | 693 | self.y = self.data.yrange |
|
694 | 694 | self.z = self.data[self.CODE] |
|
695 | 695 | |
|
696 | 696 | self.z = numpy.ma.masked_invalid(self.z) |
|
697 | 697 | |
|
698 | 698 | if self.decimation is None: |
|
699 | 699 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
700 | 700 | else: |
|
701 | 701 | x, y, z = self.fill_gaps(*self.decimate()) |
|
702 | 702 | |
|
703 | 703 | for n, ax in enumerate(self.axes): |
|
704 | 704 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) |
|
705 | 705 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) |
|
706 | 706 | if ax.firsttime: |
|
707 | 707 | if self.zlimits is not None: |
|
708 | 708 | self.zmin, self.zmax = self.zlimits[n] |
|
709 | 709 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
710 | 710 | vmin=self.zmin, |
|
711 | 711 | vmax=self.zmax, |
|
712 | 712 | cmap=plt.get_cmap(self.colormap) |
|
713 | 713 | ) |
|
714 | 714 | if self.showprofile: |
|
715 | 715 | ax.plot_profile = self.pf_axes[n].plot( |
|
716 | 716 | self.data['rti'][n][-1], self.y)[0] |
|
717 | 717 | ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y, |
|
718 | 718 | color="k", linestyle="dashed", lw=1)[0] |
|
719 | 719 | else: |
|
720 | 720 | if self.zlimits is not None: |
|
721 | 721 | self.zmin, self.zmax = self.zlimits[n] |
|
722 | 722 | ax.plt.remove() |
|
723 | 723 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
724 | 724 | vmin=self.zmin, |
|
725 | 725 | vmax=self.zmax, |
|
726 | 726 | cmap=plt.get_cmap(self.colormap) |
|
727 | 727 | ) |
|
728 | 728 | if self.showprofile: |
|
729 | 729 | ax.plot_profile.set_data(self.data['rti'][n][-1], self.y) |
|
730 | 730 | ax.plot_noise.set_data(numpy.repeat( |
|
731 | 731 | self.data['noise'][n][-1], len(self.y)), self.y) |
|
732 | 732 | |
|
733 | 733 | |
|
734 | 734 | class SpectrogramPlot(Plot): |
|
735 | 735 | ''' |
|
736 | 736 | Plot for Spectrogram data |
|
737 | 737 | ''' |
|
738 | 738 | |
|
739 | 739 | CODE = 'Spectrogram_Profile' |
|
740 | 740 | colormap = 'binary' |
|
741 | 741 | plot_type = 'pcolorbuffer' |
|
742 | 742 | |
|
743 | 743 | def setup(self): |
|
744 | 744 | self.xaxis = 'time' |
|
745 | 745 | self.ncols = 1 |
|
746 | 746 | self.nrows = len(self.data.channels) |
|
747 | 747 | self.nplots = len(self.data.channels) |
|
748 | 748 | self.xlabel = 'Time' |
|
749 | 749 | #self.cb_label = 'dB' |
|
750 | 750 | self.plots_adjust.update({'hspace':1.2, 'left': 0.1, 'bottom': 0.12, 'right':0.95}) |
|
751 | 751 | self.titles = [] |
|
752 | 752 | |
|
753 | 753 | #self.titles = ['{} Channel {} \n H = {} km ({} - {})'.format( |
|
754 | 754 | #self.CODE.upper(), x, self.data.heightList[self.data.hei], self.data.heightList[self.data.hei],self.data.heightList[self.data.hei]+(self.data.DH*self.data.nProfiles)) for x in range(self.nrows)] |
|
755 | 755 | |
|
756 | 756 | self.titles = ['{} Channel {}'.format( |
|
757 | 757 | self.CODE.upper(), x) for x in range(self.nrows)] |
|
758 | 758 | |
|
759 | 759 | |
|
760 | 760 | def update(self, dataOut): |
|
761 | 761 | data = {} |
|
762 | 762 | meta = {} |
|
763 | 763 | |
|
764 | 764 | maxHei = 1620#+12000 |
|
765 | 765 | maxHei = 1180 |
|
766 | 766 | indb = numpy.where(dataOut.heightList <= maxHei) |
|
767 | 767 | hei = indb[0][-1] |
|
768 | 768 | #print(dataOut.heightList) |
|
769 | 769 | |
|
770 | 770 | factor = dataOut.nIncohInt |
|
771 | 771 | z = dataOut.data_spc[:,:,hei] / factor |
|
772 | 772 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
773 | 773 | #buffer = 10 * numpy.log10(z) |
|
774 | 774 | |
|
775 | 775 | meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS)/1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS)) |
|
776 | 776 | |
|
777 | 777 | |
|
778 | 778 | #self.hei = hei |
|
779 | 779 | #self.heightList = dataOut.heightList |
|
780 | 780 | #self.DH = (dataOut.heightList[1] - dataOut.heightList[0])/dataOut.step |
|
781 | 781 | #self.nProfiles = dataOut.nProfiles |
|
782 | 782 | |
|
783 | 783 | data['Spectrogram_Profile'] = 10 * numpy.log10(z) |
|
784 | 784 | |
|
785 | 785 | data['hei'] = hei |
|
786 | 786 | data['DH'] = (dataOut.heightList[1] - dataOut.heightList[0])/dataOut.step |
|
787 | 787 | data['nProfiles'] = dataOut.nProfiles |
|
788 | 788 | #meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] |
|
789 | 789 | ''' |
|
790 | 790 | import matplotlib.pyplot as plt |
|
791 | 791 | plt.plot(10 * numpy.log10(z[0,:])) |
|
792 | 792 | plt.show() |
|
793 | 793 | |
|
794 | 794 | from time import sleep |
|
795 | 795 | sleep(10) |
|
796 | 796 | ''' |
|
797 | 797 | return data, meta |
|
798 | 798 | |
|
799 | 799 | def plot(self): |
|
800 | 800 | |
|
801 | 801 | self.x = self.data.times |
|
802 | 802 | self.z = self.data[self.CODE] |
|
803 | 803 | self.y = self.data.xrange[0] |
|
804 | 804 | |
|
805 | 805 | hei = self.data['hei'][-1] |
|
806 | 806 | DH = self.data['DH'][-1] |
|
807 | 807 | nProfiles = self.data['nProfiles'][-1] |
|
808 | 808 | |
|
809 | 809 | self.ylabel = "Frequency (kHz)" |
|
810 | 810 | |
|
811 | 811 | self.z = numpy.ma.masked_invalid(self.z) |
|
812 | 812 | |
|
813 | 813 | if self.decimation is None: |
|
814 | 814 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
815 | 815 | else: |
|
816 | 816 | x, y, z = self.fill_gaps(*self.decimate()) |
|
817 | 817 | |
|
818 | 818 | for n, ax in enumerate(self.axes): |
|
819 | 819 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) |
|
820 | 820 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) |
|
821 | 821 | data = self.data[-1] |
|
822 | 822 | if ax.firsttime: |
|
823 | 823 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
824 | 824 | vmin=self.zmin, |
|
825 | 825 | vmax=self.zmax, |
|
826 | 826 | cmap=plt.get_cmap(self.colormap) |
|
827 | 827 | ) |
|
828 | 828 | else: |
|
829 |
ax. |
|
|
829 | ax.plt.remove() | |
|
830 | 830 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
831 | 831 | vmin=self.zmin, |
|
832 | 832 | vmax=self.zmax, |
|
833 | 833 | cmap=plt.get_cmap(self.colormap) |
|
834 | 834 | ) |
|
835 | 835 | |
|
836 | 836 | #self.titles.append('Spectrogram') |
|
837 | 837 | |
|
838 | 838 | #self.titles.append('{} Channel {} \n H = {} km ({} - {})'.format( |
|
839 | 839 | #self.CODE.upper(), x, y[hei], y[hei],y[hei]+(DH*nProfiles))) |
|
840 | 840 | |
|
841 | 841 | class CoherencePlot(RTIPlot): |
|
842 | 842 | ''' |
|
843 | 843 | Plot for Coherence data |
|
844 | 844 | ''' |
|
845 | 845 | |
|
846 | 846 | CODE = 'coh' |
|
847 | 847 | |
|
848 | 848 | def setup(self): |
|
849 | 849 | self.xaxis = 'time' |
|
850 | 850 | self.ncols = 1 |
|
851 | 851 | self.nrows = len(self.data.pairs) |
|
852 | 852 | self.nplots = len(self.data.pairs) |
|
853 | 853 | self.ylabel = 'Range [km]' |
|
854 | 854 | self.xlabel = 'Time' |
|
855 | 855 | self.plots_adjust.update({'hspace':0.6, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) |
|
856 | 856 | if self.CODE == 'coh': |
|
857 | 857 | self.cb_label = '' |
|
858 | 858 | self.titles = [ |
|
859 | 859 | 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] |
|
860 | 860 | else: |
|
861 | 861 | self.cb_label = 'Degrees' |
|
862 | 862 | self.titles = [ |
|
863 | 863 | 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] |
|
864 | 864 | |
|
865 | 865 | def update(self, dataOut): |
|
866 | 866 | |
|
867 | 867 | data = {} |
|
868 | 868 | meta = {} |
|
869 | 869 | data['coh'] = dataOut.getCoherence() |
|
870 | 870 | meta['pairs'] = dataOut.pairsList |
|
871 | 871 | |
|
872 | 872 | return data, meta |
|
873 | 873 | |
|
874 | 874 | class PhasePlot(CoherencePlot): |
|
875 | 875 | ''' |
|
876 | 876 | Plot for Phase map data |
|
877 | 877 | ''' |
|
878 | 878 | |
|
879 | 879 | CODE = 'phase' |
|
880 | 880 | colormap = 'seismic' |
|
881 | 881 | |
|
882 | 882 | def update(self, dataOut): |
|
883 | 883 | |
|
884 | 884 | data = {} |
|
885 | 885 | meta = {} |
|
886 | 886 | data['phase'] = dataOut.getCoherence(phase=True) |
|
887 | 887 | meta['pairs'] = dataOut.pairsList |
|
888 | 888 | |
|
889 | 889 | return data, meta |
|
890 | 890 | |
|
891 | 891 | class NoisePlot(Plot): |
|
892 | 892 | ''' |
|
893 | 893 | Plot for noise |
|
894 | 894 | ''' |
|
895 | 895 | |
|
896 | 896 | CODE = 'noise' |
|
897 | 897 | plot_type = 'scatterbuffer' |
|
898 | 898 | |
|
899 | 899 | def setup(self): |
|
900 | 900 | self.xaxis = 'time' |
|
901 | 901 | self.ncols = 1 |
|
902 | 902 | self.nrows = 1 |
|
903 | 903 | self.nplots = 1 |
|
904 | 904 | self.ylabel = 'Intensity [dB]' |
|
905 | 905 | self.xlabel = 'Time' |
|
906 | 906 | self.titles = ['Noise'] |
|
907 | 907 | self.colorbar = False |
|
908 | 908 | self.plots_adjust.update({'right': 0.85 }) |
|
909 | 909 | |
|
910 | 910 | def update(self, dataOut): |
|
911 | 911 | |
|
912 | 912 | data = {} |
|
913 | 913 | meta = {} |
|
914 | 914 | data['noise'] = 10 * numpy.log10(dataOut.getNoise() / dataOut.normFactor).reshape(dataOut.nChannels, 1) |
|
915 | 915 | meta['yrange'] = numpy.array([]) |
|
916 | 916 | |
|
917 | 917 | return data, meta |
|
918 | 918 | |
|
919 | 919 | def plot(self): |
|
920 | 920 | |
|
921 | 921 | x = self.data.times |
|
922 | 922 | xmin = self.data.min_time |
|
923 | 923 | xmax = xmin + self.xrange * 60 * 60 |
|
924 | 924 | Y = self.data['noise'] |
|
925 | 925 | |
|
926 | 926 | if self.axes[0].firsttime: |
|
927 | 927 | self.ymin = numpy.nanmin(Y) - 5 |
|
928 | 928 | self.ymax = numpy.nanmax(Y) + 5 |
|
929 | 929 | for ch in self.data.channels: |
|
930 | 930 | y = Y[ch] |
|
931 | 931 | self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch)) |
|
932 | 932 | plt.legend(bbox_to_anchor=(1.18, 1.0)) |
|
933 | 933 | else: |
|
934 | 934 | for ch in self.data.channels: |
|
935 | 935 | y = Y[ch] |
|
936 | 936 | self.axes[0].lines[ch].set_data(x, y) |
|
937 | 937 | |
|
938 | 938 | self.ymin = numpy.nanmin(Y) - 5 |
|
939 | 939 | self.ymax = numpy.nanmax(Y) + 10 |
|
940 | 940 | |
|
941 | 941 | |
|
942 | 942 | class PowerProfilePlot(Plot): |
|
943 | 943 | |
|
944 | 944 | CODE = 'pow_profile' |
|
945 | 945 | plot_type = 'scatter' |
|
946 | 946 | |
|
947 | 947 | def setup(self): |
|
948 | 948 | |
|
949 | 949 | self.ncols = 1 |
|
950 | 950 | self.nrows = 1 |
|
951 | 951 | self.nplots = 1 |
|
952 | 952 | self.height = 4 |
|
953 | 953 | self.width = 3 |
|
954 | 954 | self.ylabel = 'Range [km]' |
|
955 | 955 | self.xlabel = 'Intensity [dB]' |
|
956 | 956 | self.titles = ['Power Profile'] |
|
957 | 957 | self.colorbar = False |
|
958 | 958 | |
|
959 | 959 | def update(self, dataOut): |
|
960 | 960 | |
|
961 | 961 | data = {} |
|
962 | 962 | meta = {} |
|
963 | 963 | data[self.CODE] = dataOut.getPower() |
|
964 | 964 | |
|
965 | 965 | return data, meta |
|
966 | 966 | |
|
967 | 967 | def plot(self): |
|
968 | 968 | |
|
969 | 969 | y = self.data.yrange |
|
970 | 970 | self.y = y |
|
971 | 971 | |
|
972 | 972 | x = self.data[-1][self.CODE] |
|
973 | 973 | |
|
974 | 974 | if self.xmin is None: self.xmin = numpy.nanmin(x) * 0.9 |
|
975 | 975 | if self.xmax is None: self.xmax = numpy.nanmax(x) * 1.1 |
|
976 | 976 | |
|
977 | 977 | if self.axes[0].firsttime: |
|
978 | 978 | for ch in self.data.channels: |
|
979 | 979 | self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch)) |
|
980 | 980 | plt.legend() |
|
981 | 981 | else: |
|
982 | 982 | for ch in self.data.channels: |
|
983 | 983 | self.axes[0].lines[ch].set_data(x[ch], y) |
|
984 | 984 | |
|
985 | 985 | |
|
986 | 986 | class SpectraCutPlot(Plot): |
|
987 | 987 | |
|
988 | 988 | CODE = 'spc_cut' |
|
989 | 989 | plot_type = 'scatter' |
|
990 | 990 | buffering = False |
|
991 | 991 | |
|
992 | 992 | def setup(self): |
|
993 | 993 | |
|
994 | 994 | self.nplots = len(self.data.channels) |
|
995 | 995 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
996 | 996 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
997 | 997 | self.width = 3.4 * self.ncols + 1.5 |
|
998 | 998 | self.height = 3 * self.nrows |
|
999 | 999 | self.ylabel = 'Power [dB]' |
|
1000 | 1000 | self.colorbar = False |
|
1001 | 1001 | self.plots_adjust.update({'left':0.1, 'hspace':0.3, 'right': 0.75, 'bottom':0.08}) |
|
1002 | 1002 | |
|
1003 | 1003 | def update(self, dataOut): |
|
1004 | 1004 | |
|
1005 | 1005 | data = {} |
|
1006 | 1006 | meta = {} |
|
1007 | 1007 | spc = 10 * numpy.log10(dataOut.data_pre[0] / dataOut.normFactor) |
|
1008 | 1008 | data['spc'] = spc |
|
1009 | 1009 | meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS) / 1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS)) |
|
1010 | 1010 | if self.CODE == 'cut_gaussian_fit': |
|
1011 | 1011 | data['gauss_fit0'] = 10 * numpy.log10(dataOut.GaussFit0 / dataOut.normFactor) |
|
1012 | 1012 | data['gauss_fit1'] = 10 * numpy.log10(dataOut.GaussFit1 / dataOut.normFactor) |
|
1013 | 1013 | return data, meta |
|
1014 | 1014 | |
|
1015 | 1015 | def plot(self): |
|
1016 | 1016 | if self.xaxis == "frequency": |
|
1017 | 1017 | x = self.data.xrange[0][1:] |
|
1018 | 1018 | self.xlabel = "Frequency (kHz)" |
|
1019 | 1019 | elif self.xaxis == "time": |
|
1020 | 1020 | x = self.data.xrange[1] |
|
1021 | 1021 | self.xlabel = "Time (ms)" |
|
1022 | 1022 | else: |
|
1023 | 1023 | x = self.data.xrange[2][:-1] |
|
1024 | 1024 | self.xlabel = "Velocity (m/s)" |
|
1025 | 1025 | |
|
1026 | 1026 | if self.CODE == 'cut_gaussian_fit': |
|
1027 | 1027 | x = self.data.xrange[2][:-1] |
|
1028 | 1028 | self.xlabel = "Velocity (m/s)" |
|
1029 | 1029 | |
|
1030 | 1030 | self.titles = [] |
|
1031 | 1031 | |
|
1032 | 1032 | y = self.data.yrange |
|
1033 | 1033 | data = self.data[-1] |
|
1034 | 1034 | z = data['spc'] |
|
1035 | 1035 | |
|
1036 | 1036 | if self.height_index: |
|
1037 | 1037 | index = numpy.array(self.height_index) |
|
1038 | 1038 | else: |
|
1039 | 1039 | index = numpy.arange(0, len(y), int((len(y)) / 9)) |
|
1040 | 1040 | |
|
1041 | 1041 | for n, ax in enumerate(self.axes): |
|
1042 | 1042 | if self.CODE == 'cut_gaussian_fit': |
|
1043 | 1043 | gau0 = data['gauss_fit0'] |
|
1044 | 1044 | gau1 = data['gauss_fit1'] |
|
1045 | 1045 | if ax.firsttime: |
|
1046 | 1046 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
1047 | 1047 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
1048 | 1048 | self.ymin = self.ymin if self.ymin else numpy.nanmin(z[:,:,index]) |
|
1049 | 1049 | self.ymax = self.ymax if self.ymax else numpy.nanmax(z[:,:,index]) |
|
1050 | 1050 | |
|
1051 | 1051 | ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25) |
|
1052 | 1052 | if self.CODE == 'cut_gaussian_fit': |
|
1053 | 1053 | ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.') |
|
1054 | 1054 | for i, line in enumerate(ax.plt_gau0): |
|
1055 | 1055 | line.set_color(ax.plt[i].get_color()) |
|
1056 | 1056 | ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--') |
|
1057 | 1057 | for i, line in enumerate(ax.plt_gau1): |
|
1058 | 1058 | line.set_color(ax.plt[i].get_color()) |
|
1059 | 1059 | labels = ['Range = {:2.1f}km'.format(y[i]) for i in index] |
|
1060 | 1060 | self.figures[0].legend(ax.plt, labels, loc='center right') |
|
1061 | 1061 | else: |
|
1062 | 1062 | for i, line in enumerate(ax.plt): |
|
1063 | 1063 | line.set_data(x, z[n, :, index[i]].T) |
|
1064 | 1064 | for i, line in enumerate(ax.plt_gau0): |
|
1065 | 1065 | line.set_data(x, gau0[n, :, index[i]].T) |
|
1066 | 1066 | line.set_color(ax.plt[i].get_color()) |
|
1067 | 1067 | for i, line in enumerate(ax.plt_gau1): |
|
1068 | 1068 | line.set_data(x, gau1[n, :, index[i]].T) |
|
1069 | 1069 | line.set_color(ax.plt[i].get_color()) |
|
1070 | 1070 | self.titles.append('CH {}'.format(n)) |
|
1071 | 1071 | |
|
1072 | 1072 | |
|
1073 | 1073 | class BeaconPhase(Plot): |
|
1074 | 1074 | |
|
1075 | 1075 | __isConfig = None |
|
1076 | 1076 | __nsubplots = None |
|
1077 | 1077 | |
|
1078 | 1078 | PREFIX = 'beacon_phase' |
|
1079 | 1079 | |
|
1080 | 1080 | def __init__(self): |
|
1081 | 1081 | Plot.__init__(self) |
|
1082 | 1082 | self.timerange = 24 * 60 * 60 |
|
1083 | 1083 | self.isConfig = False |
|
1084 | 1084 | self.__nsubplots = 1 |
|
1085 | 1085 | self.counter_imagwr = 0 |
|
1086 | 1086 | self.WIDTH = 800 |
|
1087 | 1087 | self.HEIGHT = 400 |
|
1088 | 1088 | self.WIDTHPROF = 120 |
|
1089 | 1089 | self.HEIGHTPROF = 0 |
|
1090 | 1090 | self.xdata = None |
|
1091 | 1091 | self.ydata = None |
|
1092 | 1092 | |
|
1093 | 1093 | self.PLOT_CODE = BEACON_CODE |
|
1094 | 1094 | |
|
1095 | 1095 | self.FTP_WEI = None |
|
1096 | 1096 | self.EXP_CODE = None |
|
1097 | 1097 | self.SUB_EXP_CODE = None |
|
1098 | 1098 | self.PLOT_POS = None |
|
1099 | 1099 | |
|
1100 | 1100 | self.filename_phase = None |
|
1101 | 1101 | |
|
1102 | 1102 | self.figfile = None |
|
1103 | 1103 | |
|
1104 | 1104 | self.xmin = None |
|
1105 | 1105 | self.xmax = None |
|
1106 | 1106 | |
|
1107 | 1107 | def getSubplots(self): |
|
1108 | 1108 | |
|
1109 | 1109 | ncol = 1 |
|
1110 | 1110 | nrow = 1 |
|
1111 | 1111 | |
|
1112 | 1112 | return nrow, ncol |
|
1113 | 1113 | |
|
1114 | 1114 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1115 | 1115 | |
|
1116 | 1116 | self.__showprofile = showprofile |
|
1117 | 1117 | self.nplots = nplots |
|
1118 | 1118 | |
|
1119 | 1119 | ncolspan = 7 |
|
1120 | 1120 | colspan = 6 |
|
1121 | 1121 | self.__nsubplots = 2 |
|
1122 | 1122 | |
|
1123 | 1123 | self.createFigure(id=id, |
|
1124 | 1124 | wintitle=wintitle, |
|
1125 | 1125 | widthplot=self.WIDTH + self.WIDTHPROF, |
|
1126 | 1126 | heightplot=self.HEIGHT + self.HEIGHTPROF, |
|
1127 | 1127 | show=show) |
|
1128 | 1128 | |
|
1129 | 1129 | nrow, ncol = self.getSubplots() |
|
1130 | 1130 | |
|
1131 | 1131 | self.addAxes(nrow, ncol * ncolspan, 0, 0, colspan, 1) |
|
1132 | 1132 | |
|
1133 | 1133 | def save_phase(self, filename_phase): |
|
1134 | 1134 | f = open(filename_phase, 'w+') |
|
1135 | 1135 | f.write('\n\n') |
|
1136 | 1136 | f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n') |
|
1137 | 1137 | f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n') |
|
1138 | 1138 | f.close() |
|
1139 | 1139 | |
|
1140 | 1140 | def save_data(self, filename_phase, data, data_datetime): |
|
1141 | 1141 | f = open(filename_phase, 'a') |
|
1142 | 1142 | timetuple_data = data_datetime.timetuple() |
|
1143 | 1143 | day = str(timetuple_data.tm_mday) |
|
1144 | 1144 | month = str(timetuple_data.tm_mon) |
|
1145 | 1145 | year = str(timetuple_data.tm_year) |
|
1146 | 1146 | hour = str(timetuple_data.tm_hour) |
|
1147 | 1147 | minute = str(timetuple_data.tm_min) |
|
1148 | 1148 | second = str(timetuple_data.tm_sec) |
|
1149 | 1149 | f.write(day + ' ' + month + ' ' + year + ' ' + hour + ' ' + minute + ' ' + second + ' ' + str(data[0]) + ' ' + str(data[1]) + ' ' + str(data[2]) + ' ' + str(data[3]) + '\n') |
|
1150 | 1150 | f.close() |
|
1151 | 1151 | |
|
1152 | 1152 | def plot(self): |
|
1153 | 1153 | log.warning('TODO: Not yet implemented...') |
|
1154 | 1154 | |
|
1155 | 1155 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
1156 | 1156 | xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None, |
|
1157 | 1157 | timerange=None, |
|
1158 | 1158 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1159 | 1159 | server=None, folder=None, username=None, password=None, |
|
1160 | 1160 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1161 | 1161 | |
|
1162 | 1162 | if dataOut.flagNoData: |
|
1163 | 1163 | return dataOut |
|
1164 | 1164 | |
|
1165 | 1165 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
1166 | 1166 | return |
|
1167 | 1167 | |
|
1168 | 1168 | if pairsList == None: |
|
1169 | 1169 | pairsIndexList = dataOut.pairsIndexList[:10] |
|
1170 | 1170 | else: |
|
1171 | 1171 | pairsIndexList = [] |
|
1172 | 1172 | for pair in pairsList: |
|
1173 | 1173 | if pair not in dataOut.pairsList: |
|
1174 | 1174 | raise ValueError("Pair %s is not in dataOut.pairsList" % (pair)) |
|
1175 | 1175 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
1176 | 1176 | |
|
1177 | 1177 | if pairsIndexList == []: |
|
1178 | 1178 | return |
|
1179 | 1179 | |
|
1180 | 1180 | # if len(pairsIndexList) > 4: |
|
1181 | 1181 | # pairsIndexList = pairsIndexList[0:4] |
|
1182 | 1182 | |
|
1183 | 1183 | hmin_index = None |
|
1184 | 1184 | hmax_index = None |
|
1185 | 1185 | |
|
1186 | 1186 | if hmin != None and hmax != None: |
|
1187 | 1187 | indexes = numpy.arange(dataOut.nHeights) |
|
1188 | 1188 | hmin_list = indexes[dataOut.heightList >= hmin] |
|
1189 | 1189 | hmax_list = indexes[dataOut.heightList <= hmax] |
|
1190 | 1190 | |
|
1191 | 1191 | if hmin_list.any(): |
|
1192 | 1192 | hmin_index = hmin_list[0] |
|
1193 | 1193 | |
|
1194 | 1194 | if hmax_list.any(): |
|
1195 | 1195 | hmax_index = hmax_list[-1] + 1 |
|
1196 | 1196 | |
|
1197 | 1197 | x = dataOut.getTimeRange() |
|
1198 | 1198 | |
|
1199 | 1199 | thisDatetime = dataOut.datatime |
|
1200 | 1200 | |
|
1201 | 1201 | title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1202 | 1202 | xlabel = "Local Time" |
|
1203 | 1203 | ylabel = "Phase (degrees)" |
|
1204 | 1204 | |
|
1205 | 1205 | update_figfile = False |
|
1206 | 1206 | |
|
1207 | 1207 | nplots = len(pairsIndexList) |
|
1208 | 1208 | # phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) |
|
1209 | 1209 | phase_beacon = numpy.zeros(len(pairsIndexList)) |
|
1210 | 1210 | for i in range(nplots): |
|
1211 | 1211 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
1212 | 1212 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0) |
|
1213 | 1213 | powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0) |
|
1214 | 1214 | powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0) |
|
1215 | 1215 | avgcoherenceComplex = ccf / numpy.sqrt(powa * powb) |
|
1216 | 1216 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real) * 180 / numpy.pi |
|
1217 | 1217 | |
|
1218 | 1218 | if dataOut.beacon_heiIndexList: |
|
1219 | 1219 | phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList]) |
|
1220 | 1220 | else: |
|
1221 | 1221 | phase_beacon[i] = numpy.average(phase) |
|
1222 | 1222 | |
|
1223 | 1223 | if not self.isConfig: |
|
1224 | 1224 | |
|
1225 | 1225 | nplots = len(pairsIndexList) |
|
1226 | 1226 | |
|
1227 | 1227 | self.setup(id=id, |
|
1228 | 1228 | nplots=nplots, |
|
1229 | 1229 | wintitle=wintitle, |
|
1230 | 1230 | showprofile=showprofile, |
|
1231 | 1231 | show=show) |
|
1232 | 1232 | |
|
1233 | 1233 | if timerange != None: |
|
1234 | 1234 | self.timerange = timerange |
|
1235 | 1235 | |
|
1236 | 1236 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1237 | 1237 | |
|
1238 | 1238 | if ymin == None: ymin = 0 |
|
1239 | 1239 | if ymax == None: ymax = 360 |
|
1240 | 1240 | |
|
1241 | 1241 | self.FTP_WEI = ftp_wei |
|
1242 | 1242 | self.EXP_CODE = exp_code |
|
1243 | 1243 | self.SUB_EXP_CODE = sub_exp_code |
|
1244 | 1244 | self.PLOT_POS = plot_pos |
|
1245 | 1245 | |
|
1246 | 1246 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1247 | 1247 | self.isConfig = True |
|
1248 | 1248 | self.figfile = figfile |
|
1249 | 1249 | self.xdata = numpy.array([]) |
|
1250 | 1250 | self.ydata = numpy.array([]) |
|
1251 | 1251 | |
|
1252 | 1252 | update_figfile = True |
|
1253 | 1253 | |
|
1254 | 1254 | # open file beacon phase |
|
1255 | 1255 | path = '%s%03d' % (self.PREFIX, self.id) |
|
1256 | 1256 | beacon_file = os.path.join(path, '%s.txt' % self.name) |
|
1257 | 1257 | self.filename_phase = os.path.join(figpath, beacon_file) |
|
1258 | 1258 | # self.save_phase(self.filename_phase) |
|
1259 | 1259 | |
|
1260 | 1260 | |
|
1261 | 1261 | # store data beacon phase |
|
1262 | 1262 | # self.save_data(self.filename_phase, phase_beacon, thisDatetime) |
|
1263 | 1263 | |
|
1264 | 1264 | self.setWinTitle(title) |
|
1265 | 1265 | |
|
1266 | 1266 | |
|
1267 | 1267 | title = "Phase Plot %s" % (thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1268 | 1268 | |
|
1269 | 1269 | legendlabels = ["Pair (%d,%d)" % (pair[0], pair[1]) for pair in dataOut.pairsList] |
|
1270 | 1270 | |
|
1271 | 1271 | axes = self.axesList[0] |
|
1272 | 1272 | |
|
1273 | 1273 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1274 | 1274 | |
|
1275 | 1275 | if len(self.ydata) == 0: |
|
1276 | 1276 | self.ydata = phase_beacon.reshape(-1, 1) |
|
1277 | 1277 | else: |
|
1278 | 1278 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1, 1))) |
|
1279 | 1279 | |
|
1280 | 1280 | |
|
1281 | 1281 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1282 | 1282 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, |
|
1283 | 1283 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1284 | 1284 | XAxisAsTime=True, grid='both' |
|
1285 | 1285 | ) |
|
1286 | 1286 | |
|
1287 | 1287 | self.draw() |
|
1288 | 1288 | |
|
1289 | 1289 | if dataOut.ltctime >= self.xmax: |
|
1290 | 1290 | self.counter_imagwr = wr_period |
|
1291 | 1291 | self.isConfig = False |
|
1292 | 1292 | update_figfile = True |
|
1293 | 1293 | |
|
1294 | 1294 | self.save(figpath=figpath, |
|
1295 | 1295 | figfile=figfile, |
|
1296 | 1296 | save=save, |
|
1297 | 1297 | ftp=ftp, |
|
1298 | 1298 | wr_period=wr_period, |
|
1299 | 1299 | thisDatetime=thisDatetime, |
|
1300 | 1300 | update_figfile=update_figfile) |
|
1301 | 1301 | |
|
1302 | 1302 | return dataOut |
@@ -1,1425 +1,1425 | |||
|
1 | 1 | |
|
2 | 2 | import os |
|
3 | 3 | import time |
|
4 | 4 | import math |
|
5 | 5 | import datetime |
|
6 | 6 | import numpy |
|
7 | 7 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator #YONG |
|
8 | 8 | |
|
9 | 9 | from .jroplot_spectra import RTIPlot, NoisePlot |
|
10 | 10 | |
|
11 | 11 | from schainpy.utils import log |
|
12 | 12 | from .plotting_codes import * |
|
13 | 13 | |
|
14 | 14 | from schainpy.model.graphics.jroplot_base import Plot, plt |
|
15 | 15 | |
|
16 | 16 | import matplotlib.pyplot as plt |
|
17 | 17 | import matplotlib.colors as colors |
|
18 | 18 | from matplotlib.ticker import MultipleLocator, LogLocator, NullFormatter |
|
19 | 19 | |
|
20 | 20 | |
|
21 | 21 | class RTIDPPlot(RTIPlot): |
|
22 | 22 | ''' |
|
23 | 23 | Written by R. Flores |
|
24 | 24 | ''' |
|
25 | 25 | '''Plot for RTI Double Pulse Experiment Using Cross Products Analysis |
|
26 | 26 | ''' |
|
27 | 27 | |
|
28 | 28 | CODE = 'RTIDP' |
|
29 | 29 | colormap = 'jro' |
|
30 | 30 | plot_name = 'RTI' |
|
31 | 31 | |
|
32 | 32 | def setup(self): |
|
33 | 33 | self.xaxis = 'time' |
|
34 | 34 | self.ncols = 1 |
|
35 | 35 | self.nrows = 3 |
|
36 | 36 | self.nplots = self.nrows |
|
37 | 37 | #self.height=10 |
|
38 | 38 | if self.showSNR: |
|
39 | 39 | self.nrows += 1 |
|
40 | 40 | self.nplots += 1 |
|
41 | 41 | |
|
42 | 42 | self.ylabel = 'Height [km]' |
|
43 | 43 | self.xlabel = 'Time (LT)' |
|
44 | 44 | |
|
45 | 45 | self.cb_label = 'Intensity (dB)' |
|
46 | 46 | |
|
47 | 47 | self.titles = ['{} Channel {}'.format( |
|
48 | 48 | self.plot_name.upper(), '0x1'),'{} Channel {}'.format( |
|
49 | 49 | self.plot_name.upper(), '0'),'{} Channel {}'.format( |
|
50 | 50 | self.plot_name.upper(), '1')] |
|
51 | 51 | |
|
52 | 52 | def update(self, dataOut): |
|
53 | 53 | |
|
54 | 54 | data = {} |
|
55 | 55 | meta = {} |
|
56 | 56 | data[self.CODE] = dataOut.data_for_RTI_DP |
|
57 | 57 |
data['NRANGE'] = dataOut.NDP |
|
58 | 58 | |
|
59 | 59 | return data, meta |
|
60 | 60 | |
|
61 | 61 | def plot(self): |
|
62 | 62 | |
|
63 | 63 | self.x = self.data.times |
|
64 | 64 | self.y = self.data.yrange[0: self.data['NRANGE']] |
|
65 | 65 | self.z = self.data[self.CODE] |
|
66 | 66 | self.z = numpy.ma.masked_invalid(self.z) |
|
67 | 67 | |
|
68 | 68 | if self.decimation is None: |
|
69 | 69 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
70 | 70 | else: |
|
71 | 71 | x, y, z = self.fill_gaps(*self.decimate()) |
|
72 | 72 | |
|
73 | 73 | for n, ax in enumerate(self.axes): |
|
74 | 74 | |
|
75 | 75 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
76 | 76 | self.z[1][0,12:40]) |
|
77 | 77 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
78 | 78 | self.z[1][0,12:40]) |
|
79 | 79 | |
|
80 | 80 | if ax.firsttime: |
|
81 | 81 | |
|
82 | 82 | if self.zlimits is not None: |
|
83 | 83 | self.zmin, self.zmax = self.zlimits[n] |
|
84 | 84 | |
|
85 | 85 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
86 | 86 | vmin=self.zmin, |
|
87 | 87 | vmax=self.zmax, |
|
88 | 88 | cmap=self.cmaps[n] |
|
89 | 89 | ) |
|
90 | 90 | else: |
|
91 | 91 | if self.zlimits is not None: |
|
92 | 92 | self.zmin, self.zmax = self.zlimits[n] |
|
93 |
ax. |
|
|
93 | ax.plt.remove() | |
|
94 | 94 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
95 | 95 | vmin=self.zmin, |
|
96 | 96 | vmax=self.zmax, |
|
97 | 97 | cmap=self.cmaps[n] |
|
98 | 98 | ) |
|
99 | 99 | |
|
100 | 100 | |
|
101 | 101 | class RTILPPlot(RTIPlot): |
|
102 | 102 | |
|
103 | 103 | ''' |
|
104 | 104 | Written by R. Flores |
|
105 | 105 | ''' |
|
106 | 106 | ''' |
|
107 | 107 | Plot for RTI Long Pulse Using Cross Products Analysis |
|
108 | 108 | ''' |
|
109 | 109 | |
|
110 | 110 | CODE = 'RTILP' |
|
111 | 111 | colormap = 'jro' |
|
112 | 112 | plot_name = 'RTI LP' |
|
113 | 113 | |
|
114 | 114 | def setup(self): |
|
115 | 115 | self.xaxis = 'time' |
|
116 | 116 | self.ncols = 1 |
|
117 | 117 | self.nrows = 2 |
|
118 | 118 | self.nplots = self.nrows |
|
119 | 119 | if self.showSNR: |
|
120 | 120 | self.nrows += 1 |
|
121 | 121 | self.nplots += 1 |
|
122 | 122 | |
|
123 | 123 | self.ylabel = 'Height [km]' |
|
124 | 124 | self.xlabel = 'Time (LT)' |
|
125 | 125 | |
|
126 | 126 | self.cb_label = 'Intensity (dB)' |
|
127 | 127 | |
|
128 | 128 | self.titles = ['{} Channel {}'.format( |
|
129 | 129 | self.plot_name.upper(), '0'),'{} Channel {}'.format( |
|
130 | 130 | self.plot_name.upper(), '1'),'{} Channel {}'.format( |
|
131 | 131 | self.plot_name.upper(), '2'),'{} Channel {}'.format( |
|
132 | 132 | self.plot_name.upper(), '3')] |
|
133 | 133 | |
|
134 | 134 | |
|
135 | 135 | def update(self, dataOut): |
|
136 | 136 | |
|
137 | 137 | data = {} |
|
138 | 138 | meta = {} |
|
139 | 139 | data['rti'] = dataOut.data_for_RTI_LP |
|
140 | 140 | data['NRANGE'] = dataOut.NRANGE |
|
141 | 141 | |
|
142 | 142 | return data, meta |
|
143 | 143 | def plot(self): |
|
144 | 144 | |
|
145 | 145 | NRANGE = self.data['NRANGE'][-1] |
|
146 | 146 | self.x = self.data.times |
|
147 | 147 | self.y = self.data.yrange[0:NRANGE] |
|
148 | 148 | |
|
149 | 149 | self.z = self.data['rti'] |
|
150 | 150 | |
|
151 | 151 | self.z = numpy.ma.masked_invalid(self.z) |
|
152 | 152 | |
|
153 | 153 | if self.decimation is None: |
|
154 | 154 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
155 | 155 | else: |
|
156 | 156 | x, y, z = self.fill_gaps(*self.decimate()) |
|
157 | 157 | |
|
158 | 158 | for n, ax in enumerate(self.axes): |
|
159 | 159 | |
|
160 | 160 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
161 | 161 | self.z[1][0,12:40]) |
|
162 | 162 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
163 | 163 | self.z[1][0,12:40]) |
|
164 | 164 | |
|
165 | 165 | if ax.firsttime: |
|
166 | 166 | |
|
167 | 167 | if self.zlimits is not None: |
|
168 | 168 | self.zmin, self.zmax = self.zlimits[n] |
|
169 | 169 | |
|
170 | 170 | |
|
171 | 171 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
172 | 172 | vmin=self.zmin, |
|
173 | 173 | vmax=self.zmax, |
|
174 | 174 | cmap=self.cmaps[n] |
|
175 | 175 | ) |
|
176 | 176 | #plt.tight_layout() |
|
177 | 177 | else: |
|
178 | 178 | if self.zlimits is not None: |
|
179 | 179 | self.zmin, self.zmax = self.zlimits[n] |
|
180 |
ax. |
|
|
180 | ax.plt.remove() | |
|
181 | 181 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
182 | 182 | vmin=self.zmin, |
|
183 | 183 | vmax=self.zmax, |
|
184 | 184 | cmap=self.cmaps[n] |
|
185 | 185 | ) |
|
186 | 186 | #plt.tight_layout() |
|
187 | 187 | |
|
188 | 188 | |
|
189 | 189 | class DenRTIPlot(RTIPlot): |
|
190 | 190 | ''' |
|
191 | 191 | Written by R. Flores |
|
192 | 192 | ''' |
|
193 | 193 | ''' |
|
194 | 194 | RTI Plot for Electron Densities |
|
195 | 195 | ''' |
|
196 | 196 | |
|
197 | 197 | CODE = 'denrti' |
|
198 | 198 | colormap = 'jet' |
|
199 | 199 | |
|
200 | 200 | def setup(self): |
|
201 | 201 | self.xaxis = 'time' |
|
202 | 202 | self.ncols = 1 |
|
203 | 203 | self.nrows = self.data.shape(self.CODE)[0] |
|
204 | 204 | self.nplots = self.nrows |
|
205 | 205 | |
|
206 | 206 | self.ylabel = 'Range [km]' |
|
207 | 207 | self.xlabel = 'Time (LT)' |
|
208 | 208 | |
|
209 | 209 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
210 | 210 | |
|
211 | 211 | if self.CODE == 'denrti': |
|
212 | 212 | self.cb_label = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' |
|
213 | 213 | |
|
214 | 214 | self.titles = ['Electron Density RTI'] |
|
215 | 215 | |
|
216 | 216 | def update(self, dataOut): |
|
217 | 217 | |
|
218 | 218 | data = {} |
|
219 | 219 | meta = {} |
|
220 | 220 | |
|
221 | 221 | data['denrti'] = dataOut.DensityFinal*1.e-6 #To Plot in cm^-3 |
|
222 | 222 | |
|
223 | 223 | return data, meta |
|
224 | 224 | |
|
225 | 225 | def plot(self): |
|
226 | 226 | |
|
227 | 227 | self.x = self.data.times |
|
228 | 228 | self.y = self.data.yrange |
|
229 | 229 | |
|
230 | 230 | self.z = self.data[self.CODE] |
|
231 | 231 | |
|
232 | 232 | self.z = numpy.ma.masked_invalid(self.z) |
|
233 | 233 | |
|
234 | 234 | if self.decimation is None: |
|
235 | 235 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
236 | 236 | else: |
|
237 | 237 | x, y, z = self.fill_gaps(*self.decimate()) |
|
238 | 238 | |
|
239 | 239 | for n, ax in enumerate(self.axes): |
|
240 | 240 | |
|
241 | 241 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
242 | 242 | self.z[n]) |
|
243 | 243 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
244 | 244 | self.z[n]) |
|
245 | 245 | |
|
246 | 246 | if ax.firsttime: |
|
247 | 247 | |
|
248 | 248 | if self.zlimits is not None: |
|
249 | 249 | self.zmin, self.zmax = self.zlimits[n] |
|
250 | 250 | if numpy.log10(self.zmin)<0: |
|
251 | 251 | self.zmin=1 |
|
252 | 252 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
253 | 253 | vmin=self.zmin, |
|
254 | 254 | vmax=self.zmax, |
|
255 | 255 | cmap=self.cmaps[n], |
|
256 | 256 | norm=colors.LogNorm() |
|
257 | 257 | ) |
|
258 | 258 | |
|
259 | 259 | else: |
|
260 | 260 | if self.zlimits is not None: |
|
261 | 261 | self.zmin, self.zmax = self.zlimits[n] |
|
262 |
ax. |
|
|
262 | ax.plt.remove() | |
|
263 | 263 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
264 | 264 | vmin=self.zmin, |
|
265 | 265 | vmax=self.zmax, |
|
266 | 266 | cmap=self.cmaps[n], |
|
267 | 267 | norm=colors.LogNorm() |
|
268 | 268 | ) |
|
269 | 269 | |
|
270 | 270 | |
|
271 | 271 | class ETempRTIPlot(RTIPlot): |
|
272 | 272 | ''' |
|
273 | 273 | Written by R. Flores |
|
274 | 274 | ''' |
|
275 | 275 | ''' |
|
276 | 276 | Plot for Electron Temperature |
|
277 | 277 | ''' |
|
278 | 278 | |
|
279 | 279 | CODE = 'ETemp' |
|
280 | 280 | colormap = 'jet' |
|
281 | 281 | |
|
282 | 282 | def setup(self): |
|
283 | 283 | self.xaxis = 'time' |
|
284 | 284 | self.ncols = 1 |
|
285 | 285 | self.nrows = self.data.shape(self.CODE)[0] |
|
286 | 286 | self.nplots = self.nrows |
|
287 | 287 | |
|
288 | 288 | self.ylabel = 'Range [km]' |
|
289 | 289 | self.xlabel = 'Time (LT)' |
|
290 | 290 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
291 | 291 | if self.CODE == 'ETemp': |
|
292 | 292 | self.cb_label = 'Electron Temperature (K)' |
|
293 | 293 | self.titles = ['Electron Temperature RTI'] |
|
294 | 294 | if self.CODE == 'ITemp': |
|
295 | 295 | self.cb_label = 'Ion Temperature (K)' |
|
296 | 296 | self.titles = ['Ion Temperature RTI'] |
|
297 | 297 | if self.CODE == 'HeFracLP': |
|
298 | 298 | self.cb_label ='He+ Fraction' |
|
299 | 299 | self.titles = ['He+ Fraction RTI'] |
|
300 | 300 | self.zmax=0.16 |
|
301 | 301 | if self.CODE == 'HFracLP': |
|
302 | 302 | self.cb_label ='H+ Fraction' |
|
303 | 303 | self.titles = ['H+ Fraction RTI'] |
|
304 | 304 | |
|
305 | 305 | def update(self, dataOut): |
|
306 | 306 | |
|
307 | 307 | data = {} |
|
308 | 308 | meta = {} |
|
309 | 309 | |
|
310 | 310 | data['ETemp'] = dataOut.ElecTempFinal |
|
311 | 311 | |
|
312 | 312 | return data, meta |
|
313 | 313 | |
|
314 | 314 | def plot(self): |
|
315 | 315 | |
|
316 | 316 | self.x = self.data.times |
|
317 | 317 | self.y = self.data.yrange |
|
318 | 318 | self.z = self.data[self.CODE] |
|
319 | 319 | |
|
320 | 320 | self.z = numpy.ma.masked_invalid(self.z) |
|
321 | 321 | |
|
322 | 322 | if self.decimation is None: |
|
323 | 323 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
324 | 324 | else: |
|
325 | 325 | x, y, z = self.fill_gaps(*self.decimate()) |
|
326 | 326 | |
|
327 | 327 | for n, ax in enumerate(self.axes): |
|
328 | 328 | |
|
329 | 329 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
330 | 330 | self.z[n]) |
|
331 | 331 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
332 | 332 | self.z[n]) |
|
333 | 333 | |
|
334 | 334 | if ax.firsttime: |
|
335 | 335 | |
|
336 | 336 | if self.zlimits is not None: |
|
337 | 337 | self.zmin, self.zmax = self.zlimits[n] |
|
338 | 338 | |
|
339 | 339 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
340 | 340 | vmin=self.zmin, |
|
341 | 341 | vmax=self.zmax, |
|
342 | 342 | cmap=self.cmaps[n] |
|
343 | 343 | ) |
|
344 | 344 | #plt.tight_layout() |
|
345 | 345 | |
|
346 | 346 | else: |
|
347 | 347 | if self.zlimits is not None: |
|
348 | 348 | self.zmin, self.zmax = self.zlimits[n] |
|
349 |
ax. |
|
|
349 | ax.plt.remove() | |
|
350 | 350 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
351 | 351 | vmin=self.zmin, |
|
352 | 352 | vmax=self.zmax, |
|
353 | 353 | cmap=self.cmaps[n] |
|
354 | 354 | ) |
|
355 | 355 | |
|
356 | 356 | |
|
357 | 357 | class ITempRTIPlot(ETempRTIPlot): |
|
358 | 358 | ''' |
|
359 | 359 | Written by R. Flores |
|
360 | 360 | ''' |
|
361 | 361 | ''' |
|
362 | 362 | Plot for Ion Temperature |
|
363 | 363 | ''' |
|
364 | 364 | |
|
365 | 365 | CODE = 'ITemp' |
|
366 | 366 | colormap = 'jet' |
|
367 | 367 | plot_name = 'Ion Temperature' |
|
368 | 368 | |
|
369 | 369 | def update(self, dataOut): |
|
370 | 370 | |
|
371 | 371 | data = {} |
|
372 | 372 | meta = {} |
|
373 | 373 | |
|
374 | 374 | data['ITemp'] = dataOut.IonTempFinal |
|
375 | 375 | |
|
376 | 376 | return data, meta |
|
377 | 377 | |
|
378 | 378 | |
|
379 | 379 | class HFracRTIPlot(ETempRTIPlot): |
|
380 | 380 | ''' |
|
381 | 381 | Written by R. Flores |
|
382 | 382 | ''' |
|
383 | 383 | ''' |
|
384 | 384 | Plot for H+ LP |
|
385 | 385 | ''' |
|
386 | 386 | |
|
387 | 387 | CODE = 'HFracLP' |
|
388 | 388 | colormap = 'jet' |
|
389 | 389 | plot_name = 'H+ Frac' |
|
390 | 390 | |
|
391 | 391 | def update(self, dataOut): |
|
392 | 392 | |
|
393 | 393 | data = {} |
|
394 | 394 | meta = {} |
|
395 | 395 | data['HFracLP'] = dataOut.PhyFinal |
|
396 | 396 | |
|
397 | 397 | return data, meta |
|
398 | 398 | |
|
399 | 399 | |
|
400 | 400 | class HeFracRTIPlot(ETempRTIPlot): |
|
401 | 401 | ''' |
|
402 | 402 | Written by R. Flores |
|
403 | 403 | ''' |
|
404 | 404 | ''' |
|
405 | 405 | Plot for He+ LP |
|
406 | 406 | ''' |
|
407 | 407 | |
|
408 | 408 | CODE = 'HeFracLP' |
|
409 | 409 | colormap = 'jet' |
|
410 | 410 | plot_name = 'He+ Frac' |
|
411 | 411 | |
|
412 | 412 | def update(self, dataOut): |
|
413 | 413 | |
|
414 | 414 | data = {} |
|
415 | 415 | meta = {} |
|
416 | 416 | data['HeFracLP'] = dataOut.PheFinal |
|
417 | 417 | |
|
418 | 418 | return data, meta |
|
419 | 419 | |
|
420 | 420 | |
|
421 | 421 | class TempsDPPlot(Plot): |
|
422 | 422 | ''' |
|
423 | 423 | Written by R. Flores |
|
424 | 424 | ''' |
|
425 | 425 | ''' |
|
426 | 426 | Plot for Electron - Ion Temperatures |
|
427 | 427 | ''' |
|
428 | 428 | |
|
429 | 429 | CODE = 'tempsDP' |
|
430 | 430 | #plot_name = 'Temperatures' |
|
431 | 431 | plot_type = 'scatterbuffer' |
|
432 | 432 | |
|
433 | 433 | def setup(self): |
|
434 | 434 | |
|
435 | 435 | self.ncols = 1 |
|
436 | 436 | self.nrows = 1 |
|
437 | 437 | self.nplots = 1 |
|
438 | 438 | self.ylabel = 'Range [km]' |
|
439 | 439 | self.xlabel = 'Temperature (K)' |
|
440 | 440 | self.titles = ['Electron/Ion Temperatures'] |
|
441 | 441 | self.width = 3.5 |
|
442 | 442 | self.height = 5.5 |
|
443 | 443 | self.colorbar = False |
|
444 | 444 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
445 | 445 | |
|
446 | 446 | def update(self, dataOut): |
|
447 | 447 | data = {} |
|
448 | 448 | meta = {} |
|
449 | 449 | |
|
450 | 450 | data['Te'] = dataOut.te2 |
|
451 | 451 | data['Ti'] = dataOut.ti2 |
|
452 | 452 | data['Te_error'] = dataOut.ete2 |
|
453 | 453 | data['Ti_error'] = dataOut.eti2 |
|
454 | 454 | |
|
455 | 455 | meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] |
|
456 | 456 | |
|
457 | 457 | return data, meta |
|
458 | 458 | |
|
459 | 459 | def plot(self): |
|
460 | 460 | |
|
461 | 461 | y = self.data.yrange |
|
462 | 462 | |
|
463 | 463 | self.xmin = -100 |
|
464 | 464 | self.xmax = 5000 |
|
465 | 465 | |
|
466 | 466 | ax = self.axes[0] |
|
467 | 467 | |
|
468 | 468 | data = self.data[-1] |
|
469 | 469 | |
|
470 | 470 | Te = data['Te'] |
|
471 | 471 | Ti = data['Ti'] |
|
472 | 472 | errTe = data['Te_error'] |
|
473 | 473 | errTi = data['Ti_error'] |
|
474 | 474 | |
|
475 | 475 | if ax.firsttime: |
|
476 | 476 | ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
477 | 477 | ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
478 | 478 | plt.legend(loc='lower right') |
|
479 | 479 | self.ystep_given = 50 |
|
480 | 480 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
481 | 481 | ax.grid(which='minor') |
|
482 | 482 | |
|
483 | 483 | else: |
|
484 | 484 | self.clear_figures() |
|
485 | 485 | ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
486 | 486 | ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
487 | 487 | plt.legend(loc='lower right') |
|
488 | 488 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
489 | 489 | |
|
490 | 490 | |
|
491 | 491 | class TempsHPPlot(Plot): |
|
492 | 492 | ''' |
|
493 | 493 | Written by R. Flores |
|
494 | 494 | ''' |
|
495 | 495 | ''' |
|
496 | 496 | Plot for Temperatures Hybrid Experiment |
|
497 | 497 | ''' |
|
498 | 498 | |
|
499 | 499 | CODE = 'temps_LP' |
|
500 | 500 | #plot_name = 'Temperatures' |
|
501 | 501 | plot_type = 'scatterbuffer' |
|
502 | 502 | |
|
503 | 503 | |
|
504 | 504 | def setup(self): |
|
505 | 505 | |
|
506 | 506 | self.ncols = 1 |
|
507 | 507 | self.nrows = 1 |
|
508 | 508 | self.nplots = 1 |
|
509 | 509 | self.ylabel = 'Range [km]' |
|
510 | 510 | self.xlabel = 'Temperature (K)' |
|
511 | 511 | self.titles = ['Electron/Ion Temperatures'] |
|
512 | 512 | self.width = 3.5 |
|
513 | 513 | self.height = 6.5 |
|
514 | 514 | self.colorbar = False |
|
515 | 515 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
516 | 516 | |
|
517 | 517 | def update(self, dataOut): |
|
518 | 518 | data = {} |
|
519 | 519 | meta = {} |
|
520 | 520 | |
|
521 | 521 | |
|
522 | 522 | data['Te'] = numpy.concatenate((dataOut.te2[:dataOut.cut],dataOut.te[dataOut.cut:])) |
|
523 | 523 | data['Ti'] = numpy.concatenate((dataOut.ti2[:dataOut.cut],dataOut.ti[dataOut.cut:])) |
|
524 | 524 | data['Te_error'] = numpy.concatenate((dataOut.ete2[:dataOut.cut],dataOut.ete[dataOut.cut:])) |
|
525 | 525 | data['Ti_error'] = numpy.concatenate((dataOut.eti2[:dataOut.cut],dataOut.eti[dataOut.cut:])) |
|
526 | 526 | |
|
527 | 527 | meta['yrange'] = dataOut.heightList[0:dataOut.NACF] |
|
528 | 528 | |
|
529 | 529 | return data, meta |
|
530 | 530 | |
|
531 | 531 | def plot(self): |
|
532 | 532 | |
|
533 | 533 | |
|
534 | 534 | self.y = self.data.yrange |
|
535 | 535 | self.xmin = -100 |
|
536 | 536 | self.xmax = 4500 |
|
537 | 537 | ax = self.axes[0] |
|
538 | 538 | |
|
539 | 539 | data = self.data[-1] |
|
540 | 540 | |
|
541 | 541 | Te = data['Te'] |
|
542 | 542 | Ti = data['Ti'] |
|
543 | 543 | errTe = data['Te_error'] |
|
544 | 544 | errTi = data['Ti_error'] |
|
545 | 545 | |
|
546 | 546 | if ax.firsttime: |
|
547 | 547 | |
|
548 | 548 | ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
549 | 549 | ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
550 | 550 | plt.legend(loc='lower right') |
|
551 | 551 | self.ystep_given = 200 |
|
552 | 552 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
553 | 553 | ax.grid(which='minor') |
|
554 | 554 | |
|
555 | 555 | else: |
|
556 | 556 | self.clear_figures() |
|
557 | 557 | ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
558 | 558 | ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
559 | 559 | plt.legend(loc='lower right') |
|
560 | 560 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
561 | 561 | ax.grid(which='minor') |
|
562 | 562 | |
|
563 | 563 | |
|
564 | 564 | class FracsHPPlot(Plot): |
|
565 | 565 | ''' |
|
566 | 566 | Written by R. Flores |
|
567 | 567 | ''' |
|
568 | 568 | ''' |
|
569 | 569 | Plot for Composition LP |
|
570 | 570 | ''' |
|
571 | 571 | |
|
572 | 572 | CODE = 'fracs_LP' |
|
573 | 573 | plot_type = 'scatterbuffer' |
|
574 | 574 | |
|
575 | 575 | |
|
576 | 576 | def setup(self): |
|
577 | 577 | |
|
578 | 578 | self.ncols = 1 |
|
579 | 579 | self.nrows = 1 |
|
580 | 580 | self.nplots = 1 |
|
581 | 581 | self.ylabel = 'Range [km]' |
|
582 | 582 | self.xlabel = 'Frac' |
|
583 | 583 | self.titles = ['Composition'] |
|
584 | 584 | self.width = 3.5 |
|
585 | 585 | self.height = 6.5 |
|
586 | 586 | self.colorbar = False |
|
587 | 587 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
588 | 588 | |
|
589 | 589 | def update(self, dataOut): |
|
590 | 590 | data = {} |
|
591 | 591 | meta = {} |
|
592 | 592 | |
|
593 | 593 | #aux_nan=numpy.zeros(dataOut.cut,'float32') |
|
594 | 594 | #aux_nan[:]=numpy.nan |
|
595 | 595 | #data['ph'] = numpy.concatenate((aux_nan,dataOut.ph[dataOut.cut:])) |
|
596 | 596 | #data['eph'] = numpy.concatenate((aux_nan,dataOut.eph[dataOut.cut:])) |
|
597 | 597 | |
|
598 | 598 | data['ph'] = dataOut.ph[dataOut.cut:] |
|
599 | 599 | data['eph'] = dataOut.eph[dataOut.cut:] |
|
600 | 600 | data['phe'] = dataOut.phe[dataOut.cut:] |
|
601 | 601 | data['ephe'] = dataOut.ephe[dataOut.cut:] |
|
602 | 602 | |
|
603 | 603 | data['cut'] = dataOut.cut |
|
604 | 604 | |
|
605 | 605 | meta['yrange'] = dataOut.heightList[0:dataOut.NACF] |
|
606 | 606 | |
|
607 | 607 | |
|
608 | 608 | return data, meta |
|
609 | 609 | |
|
610 | 610 | def plot(self): |
|
611 | 611 | |
|
612 | 612 | data = self.data[-1] |
|
613 | 613 | |
|
614 | 614 | ph = data['ph'] |
|
615 | 615 | eph = data['eph'] |
|
616 | 616 | phe = data['phe'] |
|
617 | 617 | ephe = data['ephe'] |
|
618 | 618 | cut = data['cut'] |
|
619 | 619 | self.y = self.data.yrange |
|
620 | 620 | |
|
621 | 621 | self.xmin = 0 |
|
622 | 622 | self.xmax = 1 |
|
623 | 623 | ax = self.axes[0] |
|
624 | 624 | |
|
625 | 625 | if ax.firsttime: |
|
626 | 626 | |
|
627 | 627 | ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') |
|
628 | 628 | ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') |
|
629 | 629 | plt.legend(loc='lower right') |
|
630 | 630 | self.xstep_given = 0.2 |
|
631 | 631 | self.ystep_given = 200 |
|
632 | 632 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
633 | 633 | ax.grid(which='minor') |
|
634 | 634 | |
|
635 | 635 | else: |
|
636 | 636 | self.clear_figures() |
|
637 | 637 | ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') |
|
638 | 638 | ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') |
|
639 | 639 | plt.legend(loc='lower right') |
|
640 | 640 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
641 | 641 | ax.grid(which='minor') |
|
642 | 642 | |
|
643 | 643 | class EDensityPlot(Plot): |
|
644 | 644 | ''' |
|
645 | 645 | Written by R. Flores |
|
646 | 646 | ''' |
|
647 | 647 | ''' |
|
648 | 648 | Plot for electron density |
|
649 | 649 | ''' |
|
650 | 650 | |
|
651 | 651 | CODE = 'den' |
|
652 | 652 | #plot_name = 'Electron Density' |
|
653 | 653 | plot_type = 'scatterbuffer' |
|
654 | 654 | |
|
655 | 655 | def setup(self): |
|
656 | 656 | |
|
657 | 657 | self.ncols = 1 |
|
658 | 658 | self.nrows = 1 |
|
659 | 659 | self.nplots = 1 |
|
660 | 660 | self.ylabel = 'Range [km]' |
|
661 | 661 | self.xlabel = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' |
|
662 | 662 | self.titles = ['Electron Density'] |
|
663 | 663 | self.width = 3.5 |
|
664 | 664 | self.height = 5.5 |
|
665 | 665 | self.colorbar = False |
|
666 | 666 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
667 | 667 | |
|
668 | 668 | def update(self, dataOut): |
|
669 | 669 | data = {} |
|
670 | 670 | meta = {} |
|
671 | 671 | |
|
672 | 672 | data['den_power'] = dataOut.ph2[:dataOut.NSHTS] |
|
673 | 673 | data['den_Faraday'] = dataOut.dphi[:dataOut.NSHTS] |
|
674 | 674 | data['den_error'] = dataOut.sdp2[:dataOut.NSHTS] |
|
675 | 675 | #data['err_Faraday'] = dataOut.sdn1[:dataOut.NSHTS] |
|
676 | 676 | #print(numpy.shape(data['den_power'])) |
|
677 | 677 | #print(numpy.shape(data['den_Faraday'])) |
|
678 | 678 | #print(numpy.shape(data['den_error'])) |
|
679 | 679 | |
|
680 | 680 | data['NSHTS'] = dataOut.NSHTS |
|
681 | 681 | |
|
682 | 682 | meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] |
|
683 | 683 | |
|
684 | 684 | return data, meta |
|
685 | 685 | |
|
686 | 686 | def plot(self): |
|
687 | 687 | |
|
688 | 688 | y = self.data.yrange |
|
689 | 689 | |
|
690 | 690 | #self.xmin = 1e3 |
|
691 | 691 | #self.xmax = 1e7 |
|
692 | 692 | |
|
693 | 693 | ax = self.axes[0] |
|
694 | 694 | |
|
695 | 695 | data = self.data[-1] |
|
696 | 696 | |
|
697 | 697 | DenPow = data['den_power'] |
|
698 | 698 | DenFar = data['den_Faraday'] |
|
699 | 699 | errDenPow = data['den_error'] |
|
700 | 700 | #errFaraday = data['err_Faraday'] |
|
701 | 701 | |
|
702 | 702 | NSHTS = data['NSHTS'] |
|
703 | 703 | |
|
704 | 704 | if self.CODE == 'denLP': |
|
705 | 705 | DenPowLP = data['den_LP'] |
|
706 | 706 | errDenPowLP = data['den_LP_error'] |
|
707 | 707 | cut = data['cut'] |
|
708 | 708 | |
|
709 | 709 | if ax.firsttime: |
|
710 | 710 | self.autoxticks=False |
|
711 | 711 | #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) |
|
712 | 712 | ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2,linestyle='-') |
|
713 | 713 | #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) |
|
714 | 714 | ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-') |
|
715 | 715 | |
|
716 | 716 | if self.CODE=='denLP': |
|
717 | 717 | ax.errorbar(DenPowLP[cut:], y[cut:], xerr=errDenPowLP[cut:], fmt='r^-',elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) |
|
718 | 718 | |
|
719 | 719 | plt.legend(loc='upper left',fontsize=8.5) |
|
720 | 720 | #plt.legend(loc='lower left',fontsize=8.5) |
|
721 | 721 | ax.set_xscale("log", nonposx='clip') |
|
722 | 722 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) |
|
723 | 723 | self.ystep_given=100 |
|
724 | 724 | if self.CODE=='denLP': |
|
725 | 725 | self.ystep_given=200 |
|
726 | 726 | ax.set_yticks(grid_y_ticks,minor=True) |
|
727 | 727 | locmaj = LogLocator(base=10,numticks=12) |
|
728 | 728 | ax.xaxis.set_major_locator(locmaj) |
|
729 | 729 | locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12) |
|
730 | 730 | ax.xaxis.set_minor_locator(locmin) |
|
731 | 731 | ax.xaxis.set_minor_formatter(NullFormatter()) |
|
732 | 732 | ax.grid(which='minor') |
|
733 | 733 | |
|
734 | 734 | else: |
|
735 | 735 | dataBefore = self.data[-2] |
|
736 | 736 | DenPowBefore = dataBefore['den_power'] |
|
737 | 737 | self.clear_figures() |
|
738 | 738 | #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) |
|
739 | 739 | ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2,linestyle='-') |
|
740 | 740 | #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) |
|
741 | 741 | ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-') |
|
742 | 742 | ax.errorbar(DenPowBefore, y[:NSHTS], elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed") |
|
743 | 743 | |
|
744 | 744 | if self.CODE=='denLP': |
|
745 | 745 | ax.errorbar(DenPowLP[cut:], y[cut:], fmt='r^-', xerr=errDenPowLP[cut:],elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) |
|
746 | 746 | |
|
747 | 747 | ax.set_xscale("log", nonposx='clip') |
|
748 | 748 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) |
|
749 | 749 | ax.set_yticks(grid_y_ticks,minor=True) |
|
750 | 750 | locmaj = LogLocator(base=10,numticks=12) |
|
751 | 751 | ax.xaxis.set_major_locator(locmaj) |
|
752 | 752 | locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12) |
|
753 | 753 | ax.xaxis.set_minor_locator(locmin) |
|
754 | 754 | ax.xaxis.set_minor_formatter(NullFormatter()) |
|
755 | 755 | ax.grid(which='minor') |
|
756 | 756 | plt.legend(loc='upper left',fontsize=8.5) |
|
757 | 757 | #plt.legend(loc='lower left',fontsize=8.5) |
|
758 | 758 | |
|
759 | 759 | class RelativeDenPlot(Plot): |
|
760 | 760 | ''' |
|
761 | 761 | Written by R. Flores |
|
762 | 762 | ''' |
|
763 | 763 | ''' |
|
764 | 764 | Plot for electron density |
|
765 | 765 | ''' |
|
766 | 766 | |
|
767 | 767 | CODE = 'den' |
|
768 | 768 | #plot_name = 'Electron Density' |
|
769 | 769 | plot_type = 'scatterbuffer' |
|
770 | 770 | |
|
771 | 771 | def setup(self): |
|
772 | 772 | |
|
773 | 773 | self.ncols = 1 |
|
774 | 774 | self.nrows = 1 |
|
775 | 775 | self.nplots = 1 |
|
776 | 776 | self.ylabel = 'Range [km]' |
|
777 | 777 | self.xlabel = r'$\mathrm{N_e}$ Relative Electron Density ($\mathrm{1/cm^3}$)' |
|
778 | 778 | self.titles = ['Electron Density'] |
|
779 | 779 | self.width = 3.5 |
|
780 | 780 | self.height = 5.5 |
|
781 | 781 | self.colorbar = False |
|
782 | 782 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
783 | 783 | |
|
784 | 784 | def update(self, dataOut): |
|
785 | 785 | data = {} |
|
786 | 786 | meta = {} |
|
787 | 787 | |
|
788 | 788 | data['den_power'] = dataOut.ph2 |
|
789 | 789 | data['den_error'] = dataOut.sdp2 |
|
790 | 790 | |
|
791 | 791 | meta['yrange'] = dataOut.heightList |
|
792 | 792 | |
|
793 | 793 | return data, meta |
|
794 | 794 | |
|
795 | 795 | def plot(self): |
|
796 | 796 | |
|
797 | 797 | y = self.data.yrange |
|
798 | 798 | |
|
799 | 799 | ax = self.axes[0] |
|
800 | 800 | |
|
801 | 801 | data = self.data[-1] |
|
802 | 802 | |
|
803 | 803 | DenPow = data['den_power'] |
|
804 | 804 | errDenPow = data['den_error'] |
|
805 | 805 | |
|
806 | 806 | if ax.firsttime: |
|
807 | 807 | self.autoxticks=False |
|
808 | 808 | ax.errorbar(DenPow, y, fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-') |
|
809 | 809 | |
|
810 | 810 | plt.legend(loc='upper left',fontsize=8.5) |
|
811 | 811 | #plt.legend(loc='lower left',fontsize=8.5) |
|
812 | 812 | ax.set_xscale("log", nonposx='clip') |
|
813 | 813 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) |
|
814 | 814 | self.ystep_given=100 |
|
815 | 815 | ax.set_yticks(grid_y_ticks,minor=True) |
|
816 | 816 | locmaj = LogLocator(base=10,numticks=12) |
|
817 | 817 | ax.xaxis.set_major_locator(locmaj) |
|
818 | 818 | locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12) |
|
819 | 819 | ax.xaxis.set_minor_locator(locmin) |
|
820 | 820 | ax.xaxis.set_minor_formatter(NullFormatter()) |
|
821 | 821 | ax.grid(which='minor') |
|
822 | 822 | |
|
823 | 823 | else: |
|
824 | 824 | dataBefore = self.data[-2] |
|
825 | 825 | DenPowBefore = dataBefore['den_power'] |
|
826 | 826 | self.clear_figures() |
|
827 | 827 | ax.errorbar(DenPow, y, fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-') |
|
828 | 828 | ax.errorbar(DenPowBefore, y, elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed") |
|
829 | 829 | |
|
830 | 830 | ax.set_xscale("log", nonposx='clip') |
|
831 | 831 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) |
|
832 | 832 | ax.set_yticks(grid_y_ticks,minor=True) |
|
833 | 833 | locmaj = LogLocator(base=10,numticks=12) |
|
834 | 834 | ax.xaxis.set_major_locator(locmaj) |
|
835 | 835 | locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12) |
|
836 | 836 | ax.xaxis.set_minor_locator(locmin) |
|
837 | 837 | ax.xaxis.set_minor_formatter(NullFormatter()) |
|
838 | 838 | ax.grid(which='minor') |
|
839 | 839 | plt.legend(loc='upper left',fontsize=8.5) |
|
840 | 840 | #plt.legend(loc='lower left',fontsize=8.5) |
|
841 | 841 | |
|
842 | 842 | class FaradayAnglePlot(Plot): |
|
843 | 843 | ''' |
|
844 | 844 | Written by R. Flores |
|
845 | 845 | ''' |
|
846 | 846 | ''' |
|
847 | 847 | Plot for electron density |
|
848 | 848 | ''' |
|
849 | 849 | |
|
850 | 850 | CODE = 'angle' |
|
851 | 851 | plot_name = 'Faraday Angle' |
|
852 | 852 | plot_type = 'scatterbuffer' |
|
853 | 853 | |
|
854 | 854 | def setup(self): |
|
855 | 855 | |
|
856 | 856 | self.ncols = 1 |
|
857 | 857 | self.nrows = 1 |
|
858 | 858 | self.nplots = 1 |
|
859 | 859 | self.ylabel = 'Range [km]' |
|
860 | 860 | self.xlabel = 'Faraday Angle (ΒΊ)' |
|
861 | 861 | self.titles = ['Electron Density'] |
|
862 | 862 | self.width = 3.5 |
|
863 | 863 | self.height = 5.5 |
|
864 | 864 | self.colorbar = False |
|
865 | 865 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
866 | 866 | |
|
867 | 867 | def update(self, dataOut): |
|
868 | 868 | data = {} |
|
869 | 869 | meta = {} |
|
870 | 870 | |
|
871 | 871 | data['angle'] = numpy.degrees(dataOut.phi) |
|
872 | 872 | #''' |
|
873 | 873 | #print(dataOut.phi_uwrp) |
|
874 | 874 | #print(data['angle']) |
|
875 | 875 | #exit(1) |
|
876 | 876 | #''' |
|
877 | 877 | data['dphi'] = dataOut.dphi_uc*10 |
|
878 | 878 | #print(dataOut.dphi) |
|
879 | 879 | |
|
880 | 880 | #data['NSHTS'] = dataOut.NSHTS |
|
881 | 881 | |
|
882 | 882 | #meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] |
|
883 | 883 | |
|
884 | 884 | return data, meta |
|
885 | 885 | |
|
886 | 886 | def plot(self): |
|
887 | 887 | |
|
888 | 888 | data = self.data[-1] |
|
889 | 889 | self.x = data[self.CODE] |
|
890 | 890 | dphi = data['dphi'] |
|
891 | 891 | self.y = self.data.yrange |
|
892 | 892 | self.xmin = -360#-180 |
|
893 | 893 | self.xmax = 360#180 |
|
894 | 894 | ax = self.axes[0] |
|
895 | 895 | |
|
896 | 896 | if ax.firsttime: |
|
897 | 897 | self.autoxticks=False |
|
898 | 898 | #if self.CODE=='den': |
|
899 | 899 | ax.plot(self.x, self.y,marker='o',color='g',linewidth=1.0,markersize=2) |
|
900 | 900 | ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2) |
|
901 | 901 | |
|
902 | 902 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) |
|
903 | 903 | self.ystep_given=100 |
|
904 | 904 | if self.CODE=='denLP': |
|
905 | 905 | self.ystep_given=200 |
|
906 | 906 | ax.set_yticks(grid_y_ticks,minor=True) |
|
907 | 907 | ax.grid(which='minor') |
|
908 | 908 | #plt.tight_layout() |
|
909 | 909 | else: |
|
910 | 910 | |
|
911 | 911 | self.clear_figures() |
|
912 | 912 | #if self.CODE=='den': |
|
913 | 913 | #print(numpy.shape(self.x)) |
|
914 | 914 | ax.plot(self.x, self.y, marker='o',color='g',linewidth=1.0, markersize=2) |
|
915 | 915 | ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2) |
|
916 | 916 | |
|
917 | 917 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) |
|
918 | 918 | ax.set_yticks(grid_y_ticks,minor=True) |
|
919 | 919 | ax.grid(which='minor') |
|
920 | 920 | |
|
921 | 921 | class EDensityHPPlot(EDensityPlot): |
|
922 | 922 | ''' |
|
923 | 923 | Written by R. Flores |
|
924 | 924 | ''' |
|
925 | 925 | ''' |
|
926 | 926 | Plot for Electron Density Hybrid Experiment |
|
927 | 927 | ''' |
|
928 | 928 | |
|
929 | 929 | CODE = 'denLP' |
|
930 | 930 | plot_name = 'Electron Density' |
|
931 | 931 | plot_type = 'scatterbuffer' |
|
932 | 932 | |
|
933 | 933 | def update(self, dataOut): |
|
934 | 934 | data = {} |
|
935 | 935 | meta = {} |
|
936 | 936 | |
|
937 | 937 | data['den_power'] = dataOut.ph2[:dataOut.NSHTS] |
|
938 | 938 | data['den_Faraday']=dataOut.dphi[:dataOut.NSHTS] |
|
939 | 939 | data['den_error']=dataOut.sdp2[:dataOut.NSHTS] |
|
940 | 940 | data['den_LP']=dataOut.ne[:dataOut.NACF] |
|
941 | 941 | data['den_LP_error']=dataOut.ene[:dataOut.NACF]*dataOut.ne[:dataOut.NACF]*0.434 |
|
942 | 942 | #self.ene=10**dataOut.ene[:dataOut.NACF] |
|
943 | 943 | data['NSHTS']=dataOut.NSHTS |
|
944 | 944 | data['cut']=dataOut.cut |
|
945 | 945 | |
|
946 | 946 | return data, meta |
|
947 | 947 | |
|
948 | 948 | |
|
949 | 949 | class ACFsPlot(Plot): |
|
950 | 950 | ''' |
|
951 | 951 | Written by R. Flores |
|
952 | 952 | ''' |
|
953 | 953 | ''' |
|
954 | 954 | Plot for ACFs Double Pulse Experiment |
|
955 | 955 | ''' |
|
956 | 956 | |
|
957 | 957 | CODE = 'acfs' |
|
958 | 958 | #plot_name = 'ACF' |
|
959 | 959 | plot_type = 'scatterbuffer' |
|
960 | 960 | |
|
961 | 961 | |
|
962 | 962 | def setup(self): |
|
963 | 963 | self.ncols = 1 |
|
964 | 964 | self.nrows = 1 |
|
965 | 965 | self.nplots = 1 |
|
966 | 966 | self.ylabel = 'Range [km]' |
|
967 | 967 | self.xlabel = 'Lag (ms)' |
|
968 | 968 | self.titles = ['ACFs'] |
|
969 | 969 | self.width = 3.5 |
|
970 | 970 | self.height = 5.5 |
|
971 | 971 | self.colorbar = False |
|
972 | 972 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
973 | 973 | |
|
974 | 974 | def update(self, dataOut): |
|
975 | 975 | data = {} |
|
976 | 976 | meta = {} |
|
977 | 977 | |
|
978 | 978 | data['ACFs'] = dataOut.acfs_to_plot |
|
979 | 979 | data['ACFs_error'] = dataOut.acfs_error_to_plot |
|
980 | 980 | data['lags'] = dataOut.lags_to_plot |
|
981 | 981 | data['Lag_contaminated_1'] = dataOut.x_igcej_to_plot |
|
982 | 982 | data['Lag_contaminated_2'] = dataOut.x_ibad_to_plot |
|
983 | 983 | data['Height_contaminated_1'] = dataOut.y_igcej_to_plot |
|
984 | 984 | data['Height_contaminated_2'] = dataOut.y_ibad_to_plot |
|
985 | 985 | |
|
986 | 986 | meta['yrange'] = numpy.array([]) |
|
987 | 987 | #meta['NSHTS'] = dataOut.NSHTS |
|
988 | 988 | #meta['DPL'] = dataOut.DPL |
|
989 | 989 | data['NSHTS'] = dataOut.NSHTS #This is metadata |
|
990 | 990 | data['DPL'] = dataOut.DPL #This is metadata |
|
991 | 991 | |
|
992 | 992 | return data, meta |
|
993 | 993 | |
|
994 | 994 | def plot(self): |
|
995 | 995 | |
|
996 | 996 | data = self.data[-1] |
|
997 | 997 | #NSHTS = self.meta['NSHTS'] |
|
998 | 998 | #DPL = self.meta['DPL'] |
|
999 | 999 | NSHTS = data['NSHTS'] #This is metadata |
|
1000 | 1000 | DPL = data['DPL'] #This is metadata |
|
1001 | 1001 | |
|
1002 | 1002 | lags = data['lags'] |
|
1003 | 1003 | ACFs = data['ACFs'] |
|
1004 | 1004 | errACFs = data['ACFs_error'] |
|
1005 | 1005 | BadLag1 = data['Lag_contaminated_1'] |
|
1006 | 1006 | BadLag2 = data['Lag_contaminated_2'] |
|
1007 | 1007 | BadHei1 = data['Height_contaminated_1'] |
|
1008 | 1008 | BadHei2 = data['Height_contaminated_2'] |
|
1009 | 1009 | |
|
1010 | 1010 | self.xmin = 0.0 |
|
1011 | 1011 | self.xmax = 2.0 |
|
1012 | 1012 | self.y = ACFs |
|
1013 | 1013 | |
|
1014 | 1014 | ax = self.axes[0] |
|
1015 | 1015 | |
|
1016 | 1016 | if ax.firsttime: |
|
1017 | 1017 | |
|
1018 | 1018 | for i in range(NSHTS): |
|
1019 | 1019 | x_aux = numpy.isfinite(lags[i,:]) |
|
1020 | 1020 | y_aux = numpy.isfinite(ACFs[i,:]) |
|
1021 | 1021 | yerr_aux = numpy.isfinite(errACFs[i,:]) |
|
1022 | 1022 | x_igcej_aux = numpy.isfinite(BadLag1[i,:]) |
|
1023 | 1023 | y_igcej_aux = numpy.isfinite(BadHei1[i,:]) |
|
1024 | 1024 | x_ibad_aux = numpy.isfinite(BadLag2[i,:]) |
|
1025 | 1025 | y_ibad_aux = numpy.isfinite(BadHei2[i,:]) |
|
1026 | 1026 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: |
|
1027 | 1027 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',marker='o',linewidth=1.0,markersize=2) |
|
1028 | 1028 | ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2) |
|
1029 | 1029 | ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2) |
|
1030 | 1030 | |
|
1031 | 1031 | self.xstep_given = (self.xmax-self.xmin)/(DPL-1) |
|
1032 | 1032 | self.ystep_given = 50 |
|
1033 | 1033 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
1034 | 1034 | ax.grid(which='minor') |
|
1035 | 1035 | |
|
1036 | 1036 | else: |
|
1037 | 1037 | self.clear_figures() |
|
1038 | 1038 | for i in range(NSHTS): |
|
1039 | 1039 | x_aux = numpy.isfinite(lags[i,:]) |
|
1040 | 1040 | y_aux = numpy.isfinite(ACFs[i,:]) |
|
1041 | 1041 | yerr_aux = numpy.isfinite(errACFs[i,:]) |
|
1042 | 1042 | x_igcej_aux = numpy.isfinite(BadLag1[i,:]) |
|
1043 | 1043 | y_igcej_aux = numpy.isfinite(BadHei1[i,:]) |
|
1044 | 1044 | x_ibad_aux = numpy.isfinite(BadLag2[i,:]) |
|
1045 | 1045 | y_ibad_aux = numpy.isfinite(BadHei2[i,:]) |
|
1046 | 1046 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: |
|
1047 | 1047 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],linewidth=1.0,markersize=2,color='b',marker='o') |
|
1048 | 1048 | ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2) |
|
1049 | 1049 | ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2) |
|
1050 | 1050 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
1051 | 1051 | |
|
1052 | 1052 | class ACFsLPPlot(Plot): |
|
1053 | 1053 | ''' |
|
1054 | 1054 | Written by R. Flores |
|
1055 | 1055 | ''' |
|
1056 | 1056 | ''' |
|
1057 | 1057 | Plot for ACFs Double Pulse Experiment |
|
1058 | 1058 | ''' |
|
1059 | 1059 | |
|
1060 | 1060 | CODE = 'acfs_LP' |
|
1061 | 1061 | #plot_name = 'ACF' |
|
1062 | 1062 | plot_type = 'scatterbuffer' |
|
1063 | 1063 | |
|
1064 | 1064 | |
|
1065 | 1065 | def setup(self): |
|
1066 | 1066 | self.ncols = 1 |
|
1067 | 1067 | self.nrows = 1 |
|
1068 | 1068 | self.nplots = 1 |
|
1069 | 1069 | self.ylabel = 'Range [km]' |
|
1070 | 1070 | self.xlabel = 'Lag (ms)' |
|
1071 | 1071 | self.titles = ['ACFs'] |
|
1072 | 1072 | self.width = 3.5 |
|
1073 | 1073 | self.height = 5.5 |
|
1074 | 1074 | self.colorbar = False |
|
1075 | 1075 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
1076 | 1076 | |
|
1077 | 1077 | def update(self, dataOut): |
|
1078 | 1078 | data = {} |
|
1079 | 1079 | meta = {} |
|
1080 | 1080 | |
|
1081 | 1081 | aux=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') |
|
1082 | 1082 | errors=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') |
|
1083 | 1083 | lags_LP_to_plot=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') |
|
1084 | 1084 | |
|
1085 | 1085 | for i in range(dataOut.NACF): |
|
1086 | 1086 | for j in range(dataOut.IBITS): |
|
1087 | 1087 | if numpy.abs(dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0])<1.0: |
|
1088 | 1088 | aux[i,j]=dataOut.output_LP_integrated.real[j,i,0]/dataOut.output_LP_integrated.real[0,i,0] |
|
1089 | 1089 | aux[i,j]=max(min(aux[i,j],1.0),-1.0)*dataOut.DH+dataOut.heightList[i] |
|
1090 | 1090 | lags_LP_to_plot[i,j]=dataOut.lags_LP[j] |
|
1091 | 1091 | errors[i,j]=dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0]*dataOut.DH |
|
1092 | 1092 | else: |
|
1093 | 1093 | aux[i,j]=numpy.nan |
|
1094 | 1094 | lags_LP_to_plot[i,j]=numpy.nan |
|
1095 | 1095 | errors[i,j]=numpy.nan |
|
1096 | 1096 | |
|
1097 | 1097 | data['ACFs'] = aux |
|
1098 | 1098 | data['ACFs_error'] = errors |
|
1099 | 1099 | data['lags'] = lags_LP_to_plot |
|
1100 | 1100 | |
|
1101 | 1101 | meta['yrange'] = numpy.array([]) |
|
1102 | 1102 | #meta['NACF'] = dataOut.NACF |
|
1103 | 1103 | #meta['NLAG'] = dataOut.NLAG |
|
1104 | 1104 | data['NACF'] = dataOut.NACF #This is metadata |
|
1105 | 1105 | data['NLAG'] = dataOut.NLAG #This is metadata |
|
1106 | 1106 | |
|
1107 | 1107 | return data, meta |
|
1108 | 1108 | |
|
1109 | 1109 | def plot(self): |
|
1110 | 1110 | |
|
1111 | 1111 | data = self.data[-1] |
|
1112 | 1112 | #NACF = self.meta['NACF'] |
|
1113 | 1113 | #NLAG = self.meta['NLAG'] |
|
1114 | 1114 | NACF = data['NACF'] #This is metadata |
|
1115 | 1115 | NLAG = data['NLAG'] #This is metadata |
|
1116 | 1116 | |
|
1117 | 1117 | lags = data['lags'] |
|
1118 | 1118 | ACFs = data['ACFs'] |
|
1119 | 1119 | errACFs = data['ACFs_error'] |
|
1120 | 1120 | |
|
1121 | 1121 | self.xmin = 0.0 |
|
1122 | 1122 | self.xmax = 1.5 |
|
1123 | 1123 | |
|
1124 | 1124 | self.y = ACFs |
|
1125 | 1125 | |
|
1126 | 1126 | ax = self.axes[0] |
|
1127 | 1127 | |
|
1128 | 1128 | if ax.firsttime: |
|
1129 | 1129 | |
|
1130 | 1130 | for i in range(NACF): |
|
1131 | 1131 | x_aux = numpy.isfinite(lags[i,:]) |
|
1132 | 1132 | y_aux = numpy.isfinite(ACFs[i,:]) |
|
1133 | 1133 | yerr_aux = numpy.isfinite(errACFs[i,:]) |
|
1134 | 1134 | |
|
1135 | 1135 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: |
|
1136 | 1136 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') |
|
1137 | 1137 | |
|
1138 | 1138 | #self.xstep_given = (self.xmax-self.xmin)/(self.data.NLAG-1) |
|
1139 | 1139 | self.xstep_given=0.3 |
|
1140 | 1140 | self.ystep_given = 200 |
|
1141 | 1141 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
1142 | 1142 | ax.grid(which='minor') |
|
1143 | 1143 | |
|
1144 | 1144 | else: |
|
1145 | 1145 | self.clear_figures() |
|
1146 | 1146 | |
|
1147 | 1147 | for i in range(NACF): |
|
1148 | 1148 | x_aux = numpy.isfinite(lags[i,:]) |
|
1149 | 1149 | y_aux = numpy.isfinite(ACFs[i,:]) |
|
1150 | 1150 | yerr_aux = numpy.isfinite(errACFs[i,:]) |
|
1151 | 1151 | |
|
1152 | 1152 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: |
|
1153 | 1153 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') |
|
1154 | 1154 | |
|
1155 | 1155 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
1156 | 1156 | |
|
1157 | 1157 | |
|
1158 | 1158 | class CrossProductsPlot(Plot): |
|
1159 | 1159 | ''' |
|
1160 | 1160 | Written by R. Flores |
|
1161 | 1161 | ''' |
|
1162 | 1162 | ''' |
|
1163 | 1163 | Plot for cross products |
|
1164 | 1164 | ''' |
|
1165 | 1165 | |
|
1166 | 1166 | CODE = 'crossprod' |
|
1167 | 1167 | plot_name = 'Cross Products' |
|
1168 | 1168 | plot_type = 'scatterbuffer' |
|
1169 | 1169 | |
|
1170 | 1170 | def setup(self): |
|
1171 | 1171 | |
|
1172 | 1172 | self.ncols = 3 |
|
1173 | 1173 | self.nrows = 1 |
|
1174 | 1174 | self.nplots = 3 |
|
1175 | 1175 | self.ylabel = 'Range [km]' |
|
1176 | 1176 | self.width = 3.5*self.nplots |
|
1177 | 1177 | self.height = 5.5 |
|
1178 | 1178 | self.colorbar = False |
|
1179 | 1179 | self.titles = [] |
|
1180 | 1180 | |
|
1181 | 1181 | def update(self, dataOut): |
|
1182 | 1182 | |
|
1183 | 1183 | data = {} |
|
1184 | 1184 | meta = {} |
|
1185 | 1185 | |
|
1186 | 1186 | data['crossprod'] = dataOut.crossprods |
|
1187 | 1187 | data['NDP'] = dataOut.NDP |
|
1188 | 1188 | |
|
1189 | 1189 | return data, meta |
|
1190 | 1190 | |
|
1191 | 1191 | def plot(self): |
|
1192 | 1192 | |
|
1193 | 1193 | self.x = self.data['crossprod'][:,-1,:,:,:,:] |
|
1194 | 1194 | self.y = self.data.heights[0:self.data['NDP']] |
|
1195 | 1195 | |
|
1196 | 1196 | for n, ax in enumerate(self.axes): |
|
1197 | 1197 | |
|
1198 | 1198 | self.xmin=numpy.min(numpy.concatenate((self.x[n][0,20:30,0,0],self.x[n][1,20:30,0,0],self.x[n][2,20:30,0,0],self.x[n][3,20:30,0,0]))) |
|
1199 | 1199 | self.xmax=numpy.max(numpy.concatenate((self.x[n][0,20:30,0,0],self.x[n][1,20:30,0,0],self.x[n][2,20:30,0,0],self.x[n][3,20:30,0,0]))) |
|
1200 | 1200 | |
|
1201 | 1201 | if ax.firsttime: |
|
1202 | 1202 | |
|
1203 | 1203 | self.autoxticks=False |
|
1204 | 1204 | if n==0: |
|
1205 | 1205 | label1='kax' |
|
1206 | 1206 | label2='kay' |
|
1207 | 1207 | label3='kbx' |
|
1208 | 1208 | label4='kby' |
|
1209 | 1209 | self.xlimits=[(self.xmin,self.xmax)] |
|
1210 | 1210 | elif n==1: |
|
1211 | 1211 | label1='kax2' |
|
1212 | 1212 | label2='kay2' |
|
1213 | 1213 | label3='kbx2' |
|
1214 | 1214 | label4='kby2' |
|
1215 | 1215 | self.xlimits.append((self.xmin,self.xmax)) |
|
1216 | 1216 | elif n==2: |
|
1217 | 1217 | label1='kaxay' |
|
1218 | 1218 | label2='kbxby' |
|
1219 | 1219 | label3='kaxbx' |
|
1220 | 1220 | label4='kaxby' |
|
1221 | 1221 | self.xlimits.append((self.xmin,self.xmax)) |
|
1222 | 1222 | |
|
1223 | 1223 | ax.plotline1 = ax.plot(self.x[n][0,:,0,0], self.y, color='r',linewidth=2.0, label=label1) |
|
1224 | 1224 | ax.plotline2 = ax.plot(self.x[n][1,:,0,0], self.y, color='k',linewidth=2.0, label=label2) |
|
1225 | 1225 | ax.plotline3 = ax.plot(self.x[n][2,:,0,0], self.y, color='b',linewidth=2.0, label=label3) |
|
1226 | 1226 | ax.plotline4 = ax.plot(self.x[n][3,:,0,0], self.y, color='m',linewidth=2.0, label=label4) |
|
1227 | 1227 | ax.legend(loc='upper right') |
|
1228 | 1228 | ax.set_xlim(self.xmin, self.xmax) |
|
1229 | 1229 | self.titles.append('{}'.format(self.plot_name.upper())) |
|
1230 | 1230 | |
|
1231 | 1231 | else: |
|
1232 | 1232 | |
|
1233 | 1233 | if n==0: |
|
1234 | 1234 | self.xlimits=[(self.xmin,self.xmax)] |
|
1235 | 1235 | else: |
|
1236 | 1236 | self.xlimits.append((self.xmin,self.xmax)) |
|
1237 | 1237 | |
|
1238 | 1238 | ax.set_xlim(self.xmin, self.xmax) |
|
1239 | 1239 | |
|
1240 | 1240 | ax.plotline1[0].set_data(self.x[n][0,:,0,0],self.y) |
|
1241 | 1241 | ax.plotline2[0].set_data(self.x[n][1,:,0,0],self.y) |
|
1242 | 1242 | ax.plotline3[0].set_data(self.x[n][2,:,0,0],self.y) |
|
1243 | 1243 | ax.plotline4[0].set_data(self.x[n][3,:,0,0],self.y) |
|
1244 | 1244 | self.titles.append('{}'.format(self.plot_name.upper())) |
|
1245 | 1245 | |
|
1246 | 1246 | |
|
1247 | 1247 | class CrossProductsLPPlot(Plot): |
|
1248 | 1248 | ''' |
|
1249 | 1249 | Written by R. Flores |
|
1250 | 1250 | ''' |
|
1251 | 1251 | ''' |
|
1252 | 1252 | Plot for cross products LP |
|
1253 | 1253 | ''' |
|
1254 | 1254 | |
|
1255 | 1255 | CODE = 'crossprodslp' |
|
1256 | 1256 | plot_name = 'Cross Products LP' |
|
1257 | 1257 | plot_type = 'scatterbuffer' |
|
1258 | 1258 | |
|
1259 | 1259 | |
|
1260 | 1260 | def setup(self): |
|
1261 | 1261 | |
|
1262 | 1262 | self.ncols = 2 |
|
1263 | 1263 | self.nrows = 1 |
|
1264 | 1264 | self.nplots = 2 |
|
1265 | 1265 | self.ylabel = 'Range [km]' |
|
1266 | 1266 | self.xlabel = 'dB' |
|
1267 | 1267 | self.width = 3.5*self.nplots |
|
1268 | 1268 | self.height = 5.5 |
|
1269 | 1269 | self.colorbar = False |
|
1270 | 1270 | self.titles = [] |
|
1271 | 1271 | self.plots_adjust.update({'wspace': .8 ,'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
1272 | 1272 | |
|
1273 | 1273 | def update(self, dataOut): |
|
1274 | 1274 | data = {} |
|
1275 | 1275 | meta = {} |
|
1276 | 1276 | |
|
1277 | 1277 | data['crossprodslp'] = 10*numpy.log10(numpy.abs(dataOut.output_LP)) |
|
1278 | 1278 | |
|
1279 | 1279 | data['NRANGE'] = dataOut.NRANGE #This is metadata |
|
1280 | 1280 | data['NLAG'] = dataOut.NLAG #This is metadata |
|
1281 | 1281 | |
|
1282 | 1282 | return data, meta |
|
1283 | 1283 | |
|
1284 | 1284 | def plot(self): |
|
1285 | 1285 | |
|
1286 | 1286 | NRANGE = self.data['NRANGE'][-1] |
|
1287 | 1287 | NLAG = self.data['NLAG'][-1] |
|
1288 | 1288 | |
|
1289 | 1289 | x = self.data[self.CODE][:,-1,:,:] |
|
1290 | 1290 | self.y = self.data.yrange[0:NRANGE] |
|
1291 | 1291 | |
|
1292 | 1292 | label_array=numpy.array(['lag '+ str(x) for x in range(NLAG)]) |
|
1293 | 1293 | color_array=['r','k','g','b','c','m','y','orange','steelblue','purple','peru','darksalmon','grey','limegreen','olive','midnightblue'] |
|
1294 | 1294 | |
|
1295 | 1295 | |
|
1296 | 1296 | for n, ax in enumerate(self.axes): |
|
1297 | 1297 | |
|
1298 | 1298 | self.xmin=28#30 |
|
1299 | 1299 | self.xmax=70#70 |
|
1300 | 1300 | #self.xmin=numpy.min(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) |
|
1301 | 1301 | #self.xmax=numpy.max(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) |
|
1302 | 1302 | |
|
1303 | 1303 | if ax.firsttime: |
|
1304 | 1304 | |
|
1305 | 1305 | self.autoxticks=False |
|
1306 | 1306 | if n == 0: |
|
1307 | 1307 | self.plotline_array=numpy.zeros((2,NLAG),dtype=object) |
|
1308 | 1308 | |
|
1309 | 1309 | for i in range(NLAG): |
|
1310 | 1310 | self.plotline_array[n,i], = ax.plot(x[i,:,n], self.y, color=color_array[i],linewidth=1.0, label=label_array[i]) |
|
1311 | 1311 | |
|
1312 | 1312 | ax.legend(loc='upper right') |
|
1313 | 1313 | ax.set_xlim(self.xmin, self.xmax) |
|
1314 | 1314 | if n==0: |
|
1315 | 1315 | self.titles.append('{} CH0'.format(self.plot_name.upper())) |
|
1316 | 1316 | if n==1: |
|
1317 | 1317 | self.titles.append('{} CH1'.format(self.plot_name.upper())) |
|
1318 | 1318 | else: |
|
1319 | 1319 | for i in range(NLAG): |
|
1320 | 1320 | self.plotline_array[n,i].set_data(x[i,:,n],self.y) |
|
1321 | 1321 | |
|
1322 | 1322 | if n==0: |
|
1323 | 1323 | self.titles.append('{} CH0'.format(self.plot_name.upper())) |
|
1324 | 1324 | if n==1: |
|
1325 | 1325 | self.titles.append('{} CH1'.format(self.plot_name.upper())) |
|
1326 | 1326 | |
|
1327 | 1327 | |
|
1328 | 1328 | class NoiseDPPlot(NoisePlot): |
|
1329 | 1329 | ''' |
|
1330 | 1330 | Written by R. Flores |
|
1331 | 1331 | ''' |
|
1332 | 1332 | ''' |
|
1333 | 1333 | Plot for noise Double Pulse |
|
1334 | 1334 | ''' |
|
1335 | 1335 | |
|
1336 | 1336 | CODE = 'noise' |
|
1337 | 1337 | #plot_name = 'Noise' |
|
1338 | 1338 | #plot_type = 'scatterbuffer' |
|
1339 | 1339 | |
|
1340 | 1340 | def update(self, dataOut): |
|
1341 | 1341 | |
|
1342 | 1342 | data = {} |
|
1343 | 1343 | meta = {} |
|
1344 | 1344 | data['noise'] = 10*numpy.log10(dataOut.noise_final) |
|
1345 | 1345 | |
|
1346 | 1346 | return data, meta |
|
1347 | 1347 | |
|
1348 | 1348 | |
|
1349 | 1349 | class XmitWaveformPlot(Plot): |
|
1350 | 1350 | ''' |
|
1351 | 1351 | Written by R. Flores |
|
1352 | 1352 | ''' |
|
1353 | 1353 | ''' |
|
1354 | 1354 | Plot for xmit waveform |
|
1355 | 1355 | ''' |
|
1356 | 1356 | |
|
1357 | 1357 | CODE = 'xmit' |
|
1358 | 1358 | plot_name = 'Xmit Waveform' |
|
1359 | 1359 | plot_type = 'scatterbuffer' |
|
1360 | 1360 | |
|
1361 | 1361 | |
|
1362 | 1362 | def setup(self): |
|
1363 | 1363 | |
|
1364 | 1364 | self.ncols = 1 |
|
1365 | 1365 | self.nrows = 1 |
|
1366 | 1366 | self.nplots = 1 |
|
1367 | 1367 | self.ylabel = '' |
|
1368 | 1368 | self.xlabel = 'Number of Lag' |
|
1369 | 1369 | self.width = 5.5 |
|
1370 | 1370 | self.height = 3.5 |
|
1371 | 1371 | self.colorbar = False |
|
1372 | 1372 | self.plots_adjust.update({'right': 0.85 }) |
|
1373 | 1373 | self.titles = [self.plot_name] |
|
1374 | 1374 | #self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
1375 | 1375 | |
|
1376 | 1376 | #if not self.titles: |
|
1377 | 1377 | #self.titles = self.data.parameters \ |
|
1378 | 1378 | #if self.data.parameters else ['{}'.format(self.plot_name.upper())] |
|
1379 | 1379 | |
|
1380 | 1380 | def update(self, dataOut): |
|
1381 | 1381 | |
|
1382 | 1382 | data = {} |
|
1383 | 1383 | meta = {} |
|
1384 | 1384 | |
|
1385 | 1385 | y_1=numpy.arctan2(dataOut.output_LP[:,0,2].imag,dataOut.output_LP[:,0,2].real)* 180 / (numpy.pi*10) |
|
1386 | 1386 | y_2=numpy.abs(dataOut.output_LP[:,0,2]) |
|
1387 | 1387 | norm=numpy.max(y_2) |
|
1388 | 1388 | norm=max(norm,0.1) |
|
1389 | 1389 | y_2=y_2/norm |
|
1390 | 1390 | |
|
1391 | 1391 | meta['yrange'] = numpy.array([]) |
|
1392 | 1392 | |
|
1393 | 1393 | data['xmit'] = numpy.vstack((y_1,y_2)) |
|
1394 | 1394 | data['NLAG'] = dataOut.NLAG |
|
1395 | 1395 | |
|
1396 | 1396 | return data, meta |
|
1397 | 1397 | |
|
1398 | 1398 | def plot(self): |
|
1399 | 1399 | |
|
1400 | 1400 | data = self.data[-1] |
|
1401 | 1401 | NLAG = data['NLAG'] |
|
1402 | 1402 | x = numpy.arange(0,NLAG,1,'float32') |
|
1403 | 1403 | y = data['xmit'] |
|
1404 | 1404 | |
|
1405 | 1405 | self.xmin = 0 |
|
1406 | 1406 | self.xmax = NLAG-1 |
|
1407 | 1407 | self.ymin = -1.0 |
|
1408 | 1408 | self.ymax = 1.0 |
|
1409 | 1409 | ax = self.axes[0] |
|
1410 | 1410 | |
|
1411 | 1411 | if ax.firsttime: |
|
1412 | 1412 | ax.plotline0=ax.plot(x,y[0,:],color='blue') |
|
1413 | 1413 | ax.plotline1=ax.plot(x,y[1,:],color='red') |
|
1414 | 1414 | secax=ax.secondary_xaxis(location=0.5) |
|
1415 | 1415 | secax.xaxis.tick_bottom() |
|
1416 | 1416 | secax.tick_params( labelleft=False, labeltop=False, |
|
1417 | 1417 | labelright=False, labelbottom=False) |
|
1418 | 1418 | |
|
1419 | 1419 | self.xstep_given = 3 |
|
1420 | 1420 | self.ystep_given = .25 |
|
1421 | 1421 | secax.set_xticks(numpy.linspace(self.xmin, self.xmax, 6)) #only works on matplotlib.version>3.2 |
|
1422 | 1422 | |
|
1423 | 1423 | else: |
|
1424 | 1424 | ax.plotline0[0].set_data(x,y[0,:]) |
|
1425 | 1425 | ax.plotline1[0].set_data(x,y[1,:]) |
General Comments 0
You need to be logged in to leave comments.
Login now