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