##// END OF EJS Templates
plot extra point depending on matplotlib version
rflores -
r1732:8e0a97a787ce
parent child
Show More
@@ -11,6 +11,13 import numpy
11
11
12 from schainpy.model.graphics.jroplot_base import Plot, plt, log
12 from schainpy.model.graphics.jroplot_base import Plot, plt, log
13
13
14 from matplotlib import __version__ as plt_version
15
16 if plt_version >='3.3.4':
17 EXTRA_POINTS = 0
18 else:
19 EXTRA_POINTS = 1
20
14
21
15 class SpectraPlot(Plot):
22 class SpectraPlot(Plot):
16 '''
23 '''
@@ -49,16 +56,16 class SpectraPlot(Plot):
49 data['noise'][0] = 10*numpy.log10(dataOut.getNoise(ymin_index=53)[0]/dataOut.normFactor)
56 data['noise'][0] = 10*numpy.log10(dataOut.getNoise(ymin_index=53)[0]/dataOut.normFactor)
50 else:
57 else:
51 data['noise'] = 10 * numpy.log10(dataOut.getNoise() / dataOut.normFactor)
58 data['noise'] = 10 * numpy.log10(dataOut.getNoise() / dataOut.normFactor)
52 extrapoints = spc.shape[1] % dataOut.nFFTPoints
59 extrapoints = spc.shape[1] % dataOut.nFFTPoints
53 extrapoints=1
60 extrapoints=1
54 meta['xrange'] = (dataOut.getFreqRange(extrapoints) / 1000., dataOut.getAcfRange(extrapoints), dataOut.getVelRange(extrapoints))
61 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS) / 1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
55 if self.CODE == 'spc_moments':
62 if self.CODE == 'spc_moments':
56 data['moments'] = dataOut.moments
63 data['moments'] = dataOut.moments
57 if self.CODE == 'gaussian_fit':
64 if self.CODE == 'gaussian_fit':
58 data['gaussfit'] = dataOut.DGauFitParams
65 data['gaussfit'] = dataOut.DGauFitParams
59
66
60 return data, meta
67 return data, meta
61
68
62 def plot(self):
69 def plot(self):
63
70
64 if self.xaxis == "frequency":
71 if self.xaxis == "frequency":
@@ -76,7 +83,7 class SpectraPlot(Plot):
76 self.xlabel = "Velocity (m/s)"
83 self.xlabel = "Velocity (m/s)"
77
84
78 self.titles = []
85 self.titles = []
79
86
80 y = self.data.yrange
87 y = self.data.yrange
81 self.y = y
88 self.y = y
82
89
@@ -88,7 +95,7 class SpectraPlot(Plot):
88
95
89 if self.CODE == 'spc_moments':
96 if self.CODE == 'spc_moments':
90 mean = data['moments'][n, 1]
97 mean = data['moments'][n, 1]
91 if self.CODE == 'gaussian_fit':
98 if self.CODE == 'gaussian_fit':
92 gau0 = data['gaussfit'][n][2,:,0]
99 gau0 = data['gaussfit'][n][2,:,0]
93 gau1 = data['gaussfit'][n][2,:,1]
100 gau1 = data['gaussfit'][n][2,:,1]
94 if ax.firsttime:
101 if ax.firsttime:
@@ -154,22 +161,22 class SpectraObliquePlot(Plot):
154 self.ylabel = 'Range [km]'
161 self.ylabel = 'Range [km]'
155
162
156 def update(self, dataOut):
163 def update(self, dataOut):
157
164
158 data = {}
165 data = {}
159 meta = {}
166 meta = {}
160 spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor)
167 spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor)
161 data['spc'] = spc
168 data['spc'] = spc
162 data['rti'] = dataOut.getPower()
169 data['rti'] = dataOut.getPower()
163 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
170 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
164 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
171 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS)/1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
165
172
166 data['shift1'] = dataOut.Dop_EEJ_T1[0]
173 data['shift1'] = dataOut.Dop_EEJ_T1[0]
167 data['shift2'] = dataOut.Dop_EEJ_T2[0]
174 data['shift2'] = dataOut.Dop_EEJ_T2[0]
168 data['max_val_2'] = dataOut.Oblique_params[0,-1,:]
175 data['max_val_2'] = dataOut.Oblique_params[0,-1,:]
169 data['shift1_error'] = dataOut.Err_Dop_EEJ_T1[0]
176 data['shift1_error'] = dataOut.Err_Dop_EEJ_T1[0]
170 data['shift2_error'] = dataOut.Err_Dop_EEJ_T2[0]
177 data['shift2_error'] = dataOut.Err_Dop_EEJ_T2[0]
171
178
172 return data, meta
179 return data, meta
173
180
174 def plot(self):
181 def plot(self):
175
182
@@ -213,7 +220,7 class SpectraObliquePlot(Plot):
213 self.data['rti'][n][-1], y)[0]
220 self.data['rti'][n][-1], y)[0]
214 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
221 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
215 color="k", linestyle="dashed", lw=1)[0]
222 color="k", linestyle="dashed", lw=1)[0]
216
223
217 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)
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)
218 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)
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)
219 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)
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)
@@ -228,7 +235,7 class SpectraObliquePlot(Plot):
228 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)
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)
229 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)
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)
230 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)
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)
231
238
232 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
239 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
233
240
234
241
@@ -261,7 +268,7 class CrossSpectraPlot(Plot):
261 spc = dataOut.data_spc
268 spc = dataOut.data_spc
262 cspc = dataOut.data_cspc
269 cspc = dataOut.data_cspc
263 extrapoints = spc.shape[1] % dataOut.nFFTPoints
270 extrapoints = spc.shape[1] % dataOut.nFFTPoints
264 meta['xrange'] = (dataOut.getFreqRange(extrapoints) / 1000., dataOut.getAcfRange(extrapoints), dataOut.getVelRange(extrapoints))
271 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS) / 1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
265 meta['pairs'] = dataOut.pairsList
272 meta['pairs'] = dataOut.pairsList
266
273
267 tmp = []
274 tmp = []
@@ -275,8 +282,8 class CrossSpectraPlot(Plot):
275
282
276 data['cspc'] = numpy.array(tmp)
283 data['cspc'] = numpy.array(tmp)
277
284
278 return data, meta
285 return data, meta
279
286
280 def plot(self):
287 def plot(self):
281
288
282 if self.xaxis == "frequency":
289 if self.xaxis == "frequency":
@@ -312,7 +319,7 class CrossSpectraPlot(Plot):
312 ax.plt.set_array(coh.T.ravel())
319 ax.plt.set_array(coh.T.ravel())
313 self.titles.append(
320 self.titles.append(
314 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
321 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
315
322
316 ax = self.axes[2 * n + 1]
323 ax = self.axes[2 * n + 1]
317 if ax.firsttime:
324 if ax.firsttime:
318 ax.plt = ax.pcolormesh(x, y, phase.T,
325 ax.plt = ax.pcolormesh(x, y, phase.T,
@@ -765,7 +772,7 class SpectrogramPlot(Plot):
765 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
772 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
766 #buffer = 10 * numpy.log10(z)
773 #buffer = 10 * numpy.log10(z)
767
774
768 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
775 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS)/1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
769
776
770
777
771 #self.hei = hei
778 #self.hei = hei
@@ -963,10 +970,10 class PowerProfilePlot(Plot):
963 self.y = y
970 self.y = y
964
971
965 x = self.data[-1][self.CODE]
972 x = self.data[-1][self.CODE]
966
973
967 if self.xmin is None: self.xmin = numpy.nanmin(x) * 0.9
974 if self.xmin is None: self.xmin = numpy.nanmin(x) * 0.9
968 if self.xmax is None: self.xmax = numpy.nanmax(x) * 1.1
975 if self.xmax is None: self.xmax = numpy.nanmax(x) * 1.1
969
976
970 if self.axes[0].firsttime:
977 if self.axes[0].firsttime:
971 for ch in self.data.channels:
978 for ch in self.data.channels:
972 self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch))
979 self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch))
@@ -999,7 +1006,7 class SpectraCutPlot(Plot):
999 meta = {}
1006 meta = {}
1000 spc = 10 * numpy.log10(dataOut.data_pre[0] / dataOut.normFactor)
1007 spc = 10 * numpy.log10(dataOut.data_pre[0] / dataOut.normFactor)
1001 data['spc'] = spc
1008 data['spc'] = spc
1002 meta['xrange'] = (dataOut.getFreqRange(1) / 1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
1009 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS) / 1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
1003 if self.CODE == 'cut_gaussian_fit':
1010 if self.CODE == 'cut_gaussian_fit':
1004 data['gauss_fit0'] = 10 * numpy.log10(dataOut.GaussFit0 / dataOut.normFactor)
1011 data['gauss_fit0'] = 10 * numpy.log10(dataOut.GaussFit0 / dataOut.normFactor)
1005 data['gauss_fit1'] = 10 * numpy.log10(dataOut.GaussFit1 / dataOut.normFactor)
1012 data['gauss_fit1'] = 10 * numpy.log10(dataOut.GaussFit1 / dataOut.normFactor)
@@ -1015,7 +1022,7 class SpectraCutPlot(Plot):
1015 else:
1022 else:
1016 x = self.data.xrange[2][:-1]
1023 x = self.data.xrange[2][:-1]
1017 self.xlabel = "Velocity (m/s)"
1024 self.xlabel = "Velocity (m/s)"
1018
1025
1019 if self.CODE == 'cut_gaussian_fit':
1026 if self.CODE == 'cut_gaussian_fit':
1020 x = self.data.xrange[2][:-1]
1027 x = self.data.xrange[2][:-1]
1021 self.xlabel = "Velocity (m/s)"
1028 self.xlabel = "Velocity (m/s)"
@@ -1032,7 +1039,7 class SpectraCutPlot(Plot):
1032 index = numpy.arange(0, len(y), int((len(y)) / 9))
1039 index = numpy.arange(0, len(y), int((len(y)) / 9))
1033
1040
1034 for n, ax in enumerate(self.axes):
1041 for n, ax in enumerate(self.axes):
1035 if self.CODE == 'cut_gaussian_fit':
1042 if self.CODE == 'cut_gaussian_fit':
1036 gau0 = data['gauss_fit0']
1043 gau0 = data['gauss_fit0']
1037 gau1 = data['gauss_fit1']
1044 gau1 = data['gauss_fit1']
1038 if ax.firsttime:
1045 if ax.firsttime:
@@ -1040,15 +1047,15 class SpectraCutPlot(Plot):
1040 self.xmin = self.xmin if self.xmin else -self.xmax
1047 self.xmin = self.xmin if self.xmin else -self.xmax
1041 self.ymin = self.ymin if self.ymin else numpy.nanmin(z[:,:,index])
1048 self.ymin = self.ymin if self.ymin else numpy.nanmin(z[:,:,index])
1042 self.ymax = self.ymax if self.ymax else numpy.nanmax(z[:,:,index])
1049 self.ymax = self.ymax if self.ymax else numpy.nanmax(z[:,:,index])
1043
1050
1044 ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25)
1051 ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25)
1045 if self.CODE == 'cut_gaussian_fit':
1052 if self.CODE == 'cut_gaussian_fit':
1046 ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.')
1053 ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.')
1047 for i, line in enumerate(ax.plt_gau0):
1054 for i, line in enumerate(ax.plt_gau0):
1048 line.set_color(ax.plt[i].get_color())
1055 line.set_color(ax.plt[i].get_color())
1049 ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--')
1056 ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--')
1050 for i, line in enumerate(ax.plt_gau1):
1057 for i, line in enumerate(ax.plt_gau1):
1051 line.set_color(ax.plt[i].get_color())
1058 line.set_color(ax.plt[i].get_color())
1052 labels = ['Range = {:2.1f}km'.format(y[i]) for i in index]
1059 labels = ['Range = {:2.1f}km'.format(y[i]) for i in index]
1053 self.figures[0].legend(ax.plt, labels, loc='center right')
1060 self.figures[0].legend(ax.plt, labels, loc='center right')
1054 else:
1061 else:
General Comments 0
You need to be logged in to leave comments. Login now