##// END OF EJS Templates
Se inclute SpectralMoments y DoubleGaussianPlot de tipo SpectraPlot
Danny Scipión -
r1358:fd32f6159d97
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -3,7 +3,7 import datetime
3 import numpy
3 import numpy
4
4
5 from schainpy.model.graphics.jroplot_base import Plot, plt
5 from schainpy.model.graphics.jroplot_base import Plot, plt
6 from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot
6 from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot, SpectraCutPlot
7 from schainpy.utils import log
7 from schainpy.utils import log
8
8
9 EARTH_RADIUS = 6.3710e3
9 EARTH_RADIUS = 6.3710e3
@@ -35,9 +35,22 class SpectralMomentsPlot(SpectraPlot):
35 Plot for Spectral Moments
35 Plot for Spectral Moments
36 '''
36 '''
37 CODE = 'spc_moments'
37 CODE = 'spc_moments'
38 colormap = 'jet'
38 # colormap = 'jet'
39 plot_type = 'pcolor'
39 # plot_type = 'pcolor'
40
41 class DobleGaussianPlot(SpectraPlot):
42 '''
43 Plot for Double Gaussian Plot
44 '''
45 CODE = 'gaussian_fit'
46 # colormap = 'jet'
47 # plot_type = 'pcolor'
40
48
49 class DoubleGaussianSpectraCutPlot(SpectraCutPlot):
50 '''
51 Plot SpectraCut with Double Gaussian Fit
52 '''
53 CODE = 'cut_gaussian_fit'
41
54
42 class SnrPlot(RTIPlot):
55 class SnrPlot(RTIPlot):
43 '''
56 '''
@@ -82,7 +95,7 class PowerPlot(RTIPlot):
82 def update(self, dataOut):
95 def update(self, dataOut):
83
96
84 data = {
97 data = {
85 'pow': 10*numpy.log10(dataOut.data_pow)
98 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor)
86 }
99 }
87
100
88 return data, {}
101 return data, {}
@@ -170,7 +183,7 class GenericRTIPlot(Plot):
170 if not self.xlabel:
183 if not self.xlabel:
171 self.xlabel = 'Time'
184 self.xlabel = 'Time'
172
185
173 self.ylabel = 'Height [km]'
186 self.ylabel = 'Range [km]'
174 if not self.titles:
187 if not self.titles:
175 self.titles = self.data.parameters \
188 self.titles = self.data.parameters \
176 if self.data.parameters else ['Param {}'.format(x) for x in range(self.nrows)]
189 if self.data.parameters else ['Param {}'.format(x) for x in range(self.nrows)]
@@ -1,4 +1,4
1 # Copyright (c) 2012-2020 Jicamarca Radio Observatory
1 # Copyright (c) 2012-2021 Jicamarca Radio Observatory
2 # All rights reserved.
2 # All rights reserved.
3 #
3 #
4 # Distributed under the terms of the BSD 3-clause license.
4 # Distributed under the terms of the BSD 3-clause license.
@@ -44,9 +44,15 class SpectraPlot(Plot):
44 data['rti'] = dataOut.getPower()
44 data['rti'] = dataOut.getPower()
45 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
45 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
46 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
46 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
47
47 if self.CODE == 'spc_moments':
48 if self.CODE == 'spc_moments':
48 data['moments'] = dataOut.moments
49 data['moments'] = dataOut.moments
49
50 # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor)
51 if self.CODE == 'gaussian_fit':
52 # data['moments'] = dataOut.moments
53 data['gaussfit'] = dataOut.DGauFitParams
54 # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor)
55
50 return data, meta
56 return data, meta
51
57
52 def plot(self):
58 def plot(self):
@@ -60,7 +66,7 class SpectraPlot(Plot):
60 x = self.data.xrange[2]
66 x = self.data.xrange[2]
61 self.xlabel = "Velocity (m/s)"
67 self.xlabel = "Velocity (m/s)"
62
68
63 if self.CODE == 'spc_moments':
69 if (self.CODE == 'spc_moments') | (self.CODE == 'gaussian_fit'):
64 x = self.data.xrange[2]
70 x = self.data.xrange[2]
65 self.xlabel = "Velocity (m/s)"
71 self.xlabel = "Velocity (m/s)"
66
72
@@ -75,7 +81,11 class SpectraPlot(Plot):
75 for n, ax in enumerate(self.axes):
81 for n, ax in enumerate(self.axes):
76 noise = data['noise'][n]
82 noise = data['noise'][n]
77 if self.CODE == 'spc_moments':
83 if self.CODE == 'spc_moments':
78 mean = data['moments'][n, 2]
84 mean = data['moments'][n, 1]
85 if self.CODE == 'gaussian_fit':
86 # mean = data['moments'][n, 1]
87 gau0 = data['gaussfit'][n][2,:,0]
88 gau1 = data['gaussfit'][n][2,:,1]
79 if ax.firsttime:
89 if ax.firsttime:
80 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
90 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
81 self.xmin = self.xmin if self.xmin else -self.xmax
91 self.xmin = self.xmin if self.xmin else -self.xmax
@@ -93,7 +103,11 class SpectraPlot(Plot):
93 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
103 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
94 color="k", linestyle="dashed", lw=1)[0]
104 color="k", linestyle="dashed", lw=1)[0]
95 if self.CODE == 'spc_moments':
105 if self.CODE == 'spc_moments':
96 ax.plt_mean = ax.plot(mean, y, color='k')[0]
106 ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0]
107 if self.CODE == 'gaussian_fit':
108 # ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0]
109 ax.plt_gau0 = ax.plot(gau0, y, color='r', lw=1)[0]
110 ax.plt_gau1 = ax.plot(gau1, y, color='y', lw=1)[0]
97 else:
111 else:
98 ax.plt.set_array(z[n].T.ravel())
112 ax.plt.set_array(z[n].T.ravel())
99 if self.showprofile:
113 if self.showprofile:
@@ -101,6 +115,10 class SpectraPlot(Plot):
101 ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y)
115 ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y)
102 if self.CODE == 'spc_moments':
116 if self.CODE == 'spc_moments':
103 ax.plt_mean.set_data(mean, y)
117 ax.plt_mean.set_data(mean, y)
118 if self.CODE == 'gaussian_fit':
119 # ax.plt_mean.set_data(mean, y)
120 ax.plt_gau0.set_data(gau0, y)
121 ax.plt_gau1.set_data(gau1, y)
104 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
122 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
105
123
106
124
@@ -428,10 +446,12 class SpectraCutPlot(Plot):
428
446
429 data = {}
447 data = {}
430 meta = {}
448 meta = {}
431 spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor)
449 spc = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor)
432 data['spc'] = spc
450 data['spc'] = spc
433 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
451 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
434
452 if self.CODE == 'cut_gaussian_fit':
453 data['gauss_fit0'] = 10*numpy.log10(dataOut.GaussFit0/dataOut.normFactor)
454 data['gauss_fit1'] = 10*numpy.log10(dataOut.GaussFit1/dataOut.normFactor)
435 return data, meta
455 return data, meta
436
456
437 def plot(self):
457 def plot(self):
@@ -442,13 +462,18 class SpectraCutPlot(Plot):
442 x = self.data.xrange[1]
462 x = self.data.xrange[1]
443 self.xlabel = "Time (ms)"
463 self.xlabel = "Time (ms)"
444 else:
464 else:
445 x = self.data.xrange[2]
465 x = self.data.xrange[2][:-1]
466 self.xlabel = "Velocity (m/s)"
467
468 if self.CODE == 'cut_gaussian_fit':
469 x = self.data.xrange[2][:-1]
446 self.xlabel = "Velocity (m/s)"
470 self.xlabel = "Velocity (m/s)"
447
471
448 self.titles = []
472 self.titles = []
449
473
450 y = self.data.yrange
474 y = self.data.yrange
451 z = self.data[-1]['spc']
475 data = self.data[-1]
476 z = data['spc']
452
477
453 if self.height_index:
478 if self.height_index:
454 index = numpy.array(self.height_index)
479 index = numpy.array(self.height_index)
@@ -456,17 +481,33 class SpectraCutPlot(Plot):
456 index = numpy.arange(0, len(y), int((len(y))/9))
481 index = numpy.arange(0, len(y), int((len(y))/9))
457
482
458 for n, ax in enumerate(self.axes):
483 for n, ax in enumerate(self.axes):
484 if self.CODE == 'cut_gaussian_fit':
485 gau0 = data['gauss_fit0']
486 gau1 = data['gauss_fit1']
459 if ax.firsttime:
487 if ax.firsttime:
460 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
488 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
461 self.xmin = self.xmin if self.xmin else -self.xmax
489 self.xmin = self.xmin if self.xmin else -self.xmax
462 self.ymin = self.ymin if self.ymin else numpy.nanmin(z)
490 self.ymin = self.ymin if self.ymin else numpy.nanmin(z)
463 self.ymax = self.ymax if self.ymax else numpy.nanmax(z)
491 self.ymax = self.ymax if self.ymax else numpy.nanmax(z)
464 ax.plt = ax.plot(x, z[n, :, index].T)
492 ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25)
493 if self.CODE == 'cut_gaussian_fit':
494 ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.')
495 for i, line in enumerate(ax.plt_gau0):
496 line.set_color(ax.plt[i].get_color())
497 ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--')
498 for i, line in enumerate(ax.plt_gau1):
499 line.set_color(ax.plt[i].get_color())
465 labels = ['Range = {:2.1f}km'.format(y[i]) for i in index]
500 labels = ['Range = {:2.1f}km'.format(y[i]) for i in index]
466 self.figures[0].legend(ax.plt, labels, loc='center right')
501 self.figures[0].legend(ax.plt, labels, loc='center right')
467 else:
502 else:
468 for i, line in enumerate(ax.plt):
503 for i, line in enumerate(ax.plt):
469 line.set_data(x, z[n, :, i])
504 line.set_data(x, z[n, :, index[i]].T)
505 for i, line in enumerate(ax.plt_gau0):
506 line.set_data(x, gau0[n, :, index[i]].T)
507 line.set_color(ax.plt[i].get_color())
508 for i, line in enumerate(ax.plt_gau1):
509 line.set_data(x, gau1[n, :, index[i]].T)
510 line.set_color(ax.plt[i].get_color())
470 self.titles.append('CH {}'.format(n))
511 self.titles.append('CH {}'.format(n))
471
512
472
513
General Comments 0
You need to be logged in to leave comments. Login now