##// END OF EJS Templates
fixed vmin and vmax outside LogNorm due to deprecation
rflores -
r1735:fc643c085446
parent child
Show More
@@ -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 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 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 vmin=self.zmin,
254 vmax=self.zmax,
253 #vmin=self.zmin,
254 #vmax=self.zmax,
255 255 cmap=self.cmaps[n],
256 norm=colors.LogNorm()
256 norm=colors.LogNorm(vmin=self.zmin,vmax=self.zmax)
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 262 ax.plt.remove()
263 263 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
264 vmin=self.zmin,
265 vmax=self.zmax,
264 #vmin=self.zmin,
265 #vmax=self.zmax,
266 266 cmap=self.cmaps[n],
267 norm=colors.LogNorm()
267 norm=colors.LogNorm(vmin=self.zmin,vmax=self.zmax)
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 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