This diff has been collapsed as it changes many lines, (525 lines changed) Show them Hide them | |||||
@@ -23,6 +23,7 class SpectraPlot(Plot): | |||||
23 | buffering = False |
|
23 | buffering = False | |
24 |
|
24 | |||
25 | def setup(self): |
|
25 | def setup(self): | |
|
26 | ||||
26 | self.nplots = len(self.data.channels) |
|
27 | self.nplots = len(self.data.channels) | |
27 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
28 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) | |
28 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
29 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) | |
@@ -32,7 +33,7 class SpectraPlot(Plot): | |||||
32 | self.width = 4 * self.ncols |
|
33 | self.width = 4 * self.ncols | |
33 | else: |
|
34 | else: | |
34 | self.width = 3.5 * self.ncols |
|
35 | self.width = 3.5 * self.ncols | |
35 |
self.plots_adjust.update({'wspace': 0. |
|
36 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
36 | self.ylabel = 'Range [km]' |
|
37 | self.ylabel = 'Range [km]' | |
37 |
|
38 | |||
38 | def update(self, dataOut): |
|
39 | def update(self, dataOut): | |
@@ -44,18 +45,16 class SpectraPlot(Plot): | |||||
44 | data['rti'] = dataOut.getPower() |
|
45 | data['rti'] = dataOut.getPower() | |
45 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
46 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) | |
46 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
47 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |
47 |
|
48 | |||
48 | if self.CODE == 'spc_moments': |
|
49 | if self.CODE == 'spc_moments': | |
49 | data['moments'] = dataOut.moments |
|
50 | data['moments'] = dataOut.moments | |
50 | # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor) |
|
|||
51 | if self.CODE == 'gaussian_fit': |
|
51 | if self.CODE == 'gaussian_fit': | |
52 | # data['moments'] = dataOut.moments |
|
|||
53 | data['gaussfit'] = dataOut.DGauFitParams |
|
52 | data['gaussfit'] = dataOut.DGauFitParams | |
54 | # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor) |
|
|||
55 |
|
53 | |||
56 |
return data, meta |
|
54 | return data, meta | |
57 |
|
55 | |||
58 | def plot(self): |
|
56 | def plot(self): | |
|
57 | ||||
59 | if self.xaxis == "frequency": |
|
58 | if self.xaxis == "frequency": | |
60 | x = self.data.xrange[0] |
|
59 | x = self.data.xrange[0] | |
61 | self.xlabel = "Frequency (kHz)" |
|
60 | self.xlabel = "Frequency (kHz)" | |
@@ -80,10 +79,10 class SpectraPlot(Plot): | |||||
80 |
|
79 | |||
81 | for n, ax in enumerate(self.axes): |
|
80 | for n, ax in enumerate(self.axes): | |
82 | noise = data['noise'][n] |
|
81 | noise = data['noise'][n] | |
|
82 | ||||
83 | if self.CODE == 'spc_moments': |
|
83 | if self.CODE == 'spc_moments': | |
84 | mean = data['moments'][n, 1] |
|
84 | mean = data['moments'][n, 1] | |
85 |
if self.CODE == 'gaussian_fit': |
|
85 | if self.CODE == 'gaussian_fit': | |
86 | # mean = data['moments'][n, 1] |
|
|||
87 | gau0 = data['gaussfit'][n][2,:,0] |
|
86 | gau0 = data['gaussfit'][n][2,:,0] | |
88 | gau1 = data['gaussfit'][n][2,:,1] |
|
87 | gau1 = data['gaussfit'][n][2,:,1] | |
89 | if ax.firsttime: |
|
88 | if ax.firsttime: | |
@@ -105,7 +104,6 class SpectraPlot(Plot): | |||||
105 | if self.CODE == 'spc_moments': |
|
104 | if self.CODE == 'spc_moments': | |
106 | ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0] |
|
105 | ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0] | |
107 | if self.CODE == 'gaussian_fit': |
|
106 | 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] |
|
107 | 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] |
|
108 | ax.plt_gau1 = ax.plot(gau1, y, color='y', lw=1)[0] | |
111 | else: |
|
109 | else: | |
@@ -116,11 +114,115 class SpectraPlot(Plot): | |||||
116 | if self.CODE == 'spc_moments': |
|
114 | if self.CODE == 'spc_moments': | |
117 | ax.plt_mean.set_data(mean, y) |
|
115 | ax.plt_mean.set_data(mean, y) | |
118 | if self.CODE == 'gaussian_fit': |
|
116 | if self.CODE == 'gaussian_fit': | |
119 | # ax.plt_mean.set_data(mean, y) |
|
|||
120 | ax.plt_gau0.set_data(gau0, y) |
|
117 | ax.plt_gau0.set_data(gau0, y) | |
121 | ax.plt_gau1.set_data(gau1, y) |
|
118 | ax.plt_gau1.set_data(gau1, y) | |
122 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) |
|
119 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) | |
123 |
|
120 | |||
|
121 | class SpectraObliquePlot(Plot): | |||
|
122 | ''' | |||
|
123 | Plot for Spectra data | |||
|
124 | ''' | |||
|
125 | ||||
|
126 | CODE = 'spc_oblique' | |||
|
127 | colormap = 'jet' | |||
|
128 | plot_type = 'pcolor' | |||
|
129 | ||||
|
130 | def setup(self): | |||
|
131 | self.xaxis = "oblique" | |||
|
132 | self.nplots = len(self.data.channels) | |||
|
133 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) | |||
|
134 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) | |||
|
135 | self.height = 2.6 * self.nrows | |||
|
136 | self.cb_label = 'dB' | |||
|
137 | if self.showprofile: | |||
|
138 | self.width = 4 * self.ncols | |||
|
139 | else: | |||
|
140 | self.width = 3.5 * self.ncols | |||
|
141 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |||
|
142 | self.ylabel = 'Range [km]' | |||
|
143 | ||||
|
144 | def update(self, dataOut): | |||
|
145 | ||||
|
146 | data = {} | |||
|
147 | meta = {} | |||
|
148 | ||||
|
149 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) | |||
|
150 | data['spc'] = spc | |||
|
151 | data['rti'] = dataOut.getPower() | |||
|
152 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) | |||
|
153 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |||
|
154 | ||||
|
155 | data['shift1'] = dataOut.Dop_EEJ_T1[0] | |||
|
156 | data['shift2'] = dataOut.Dop_EEJ_T2[0] | |||
|
157 | data['max_val_2'] = dataOut.Oblique_params[0,-1,:] | |||
|
158 | data['shift1_error'] = dataOut.Err_Dop_EEJ_T1[0] | |||
|
159 | data['shift2_error'] = dataOut.Err_Dop_EEJ_T2[0] | |||
|
160 | ||||
|
161 | return data, meta | |||
|
162 | ||||
|
163 | def plot(self): | |||
|
164 | ||||
|
165 | if self.xaxis == "frequency": | |||
|
166 | x = self.data.xrange[0] | |||
|
167 | self.xlabel = "Frequency (kHz)" | |||
|
168 | elif self.xaxis == "time": | |||
|
169 | x = self.data.xrange[1] | |||
|
170 | self.xlabel = "Time (ms)" | |||
|
171 | else: | |||
|
172 | x = self.data.xrange[2] | |||
|
173 | self.xlabel = "Velocity (m/s)" | |||
|
174 | ||||
|
175 | self.titles = [] | |||
|
176 | ||||
|
177 | y = self.data.yrange | |||
|
178 | self.y = y | |||
|
179 | ||||
|
180 | data = self.data[-1] | |||
|
181 | z = data['spc'] | |||
|
182 | ||||
|
183 | for n, ax in enumerate(self.axes): | |||
|
184 | noise = self.data['noise'][n][-1] | |||
|
185 | shift1 = data['shift1'] | |||
|
186 | shift2 = data['shift2'] | |||
|
187 | max_val_2 = data['max_val_2'] | |||
|
188 | err1 = data['shift1_error'] | |||
|
189 | err2 = data['shift2_error'] | |||
|
190 | if ax.firsttime: | |||
|
191 | ||||
|
192 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |||
|
193 | self.xmin = self.xmin if self.xmin else -self.xmax | |||
|
194 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) | |||
|
195 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) | |||
|
196 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |||
|
197 | vmin=self.zmin, | |||
|
198 | vmax=self.zmax, | |||
|
199 | cmap=plt.get_cmap(self.colormap) | |||
|
200 | ) | |||
|
201 | ||||
|
202 | if self.showprofile: | |||
|
203 | ax.plt_profile = self.pf_axes[n].plot( | |||
|
204 | self.data['rti'][n][-1], y)[0] | |||
|
205 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, | |||
|
206 | color="k", linestyle="dashed", lw=1)[0] | |||
|
207 | ||||
|
208 | 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) | |||
|
209 | 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) | |||
|
210 | 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) | |||
|
211 | ||||
|
212 | else: | |||
|
213 | self.ploterr1.remove() | |||
|
214 | self.ploterr2.remove() | |||
|
215 | self.ploterr3.remove() | |||
|
216 | ax.plt.set_array(z[n].T.ravel()) | |||
|
217 | if self.showprofile: | |||
|
218 | ax.plt_profile.set_data(self.data['rti'][n][-1], y) | |||
|
219 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) | |||
|
220 | 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) | |||
|
221 | 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) | |||
|
222 | 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) | |||
|
223 | ||||
|
224 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) | |||
|
225 | ||||
124 |
|
226 | |||
125 | class CrossSpectraPlot(Plot): |
|
227 | class CrossSpectraPlot(Plot): | |
126 |
|
228 | |||
@@ -138,7 +240,7 class CrossSpectraPlot(Plot): | |||||
138 | self.nplots = len(self.data.pairs) * 2 |
|
240 | self.nplots = len(self.data.pairs) * 2 | |
139 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
241 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) | |
140 | self.width = 3.1 * self.ncols |
|
242 | self.width = 3.1 * self.ncols | |
141 |
self.height = |
|
243 | self.height = 5 * self.nrows | |
142 | self.ylabel = 'Range [km]' |
|
244 | self.ylabel = 'Range [km]' | |
143 | self.showprofile = False |
|
245 | self.showprofile = False | |
144 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
246 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |
@@ -164,8 +266,8 class CrossSpectraPlot(Plot): | |||||
164 |
|
266 | |||
165 | data['cspc'] = numpy.array(tmp) |
|
267 | data['cspc'] = numpy.array(tmp) | |
166 |
|
268 | |||
167 |
return data, meta |
|
269 | return data, meta | |
168 |
|
270 | |||
169 | def plot(self): |
|
271 | def plot(self): | |
170 |
|
272 | |||
171 | if self.xaxis == "frequency": |
|
273 | if self.xaxis == "frequency": | |
@@ -177,7 +279,7 class CrossSpectraPlot(Plot): | |||||
177 | else: |
|
279 | else: | |
178 | x = self.data.xrange[2] |
|
280 | x = self.data.xrange[2] | |
179 | self.xlabel = "Velocity (m/s)" |
|
281 | self.xlabel = "Velocity (m/s)" | |
180 |
|
282 | |||
181 | self.titles = [] |
|
283 | self.titles = [] | |
182 |
|
284 | |||
183 | y = self.data.yrange |
|
285 | y = self.data.yrange | |
@@ -201,19 +303,291 class CrossSpectraPlot(Plot): | |||||
201 | ax.plt.set_array(coh.T.ravel()) |
|
303 | ax.plt.set_array(coh.T.ravel()) | |
202 | self.titles.append( |
|
304 | self.titles.append( | |
203 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
305 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) | |
204 |
|
306 | |||
205 | ax = self.axes[2 * n + 1] |
|
307 | ax = self.axes[2 * n + 1] | |
206 | if ax.firsttime: |
|
308 | if ax.firsttime: | |
207 | ax.plt = ax.pcolormesh(x, y, phase.T, |
|
309 | ax.plt = ax.pcolormesh(x, y, phase.T, | |
208 | vmin=-180, |
|
310 | vmin=-180, | |
209 | vmax=180, |
|
311 | vmax=180, | |
210 |
cmap=plt.get_cmap(self.colormap_phase) |
|
312 | cmap=plt.get_cmap(self.colormap_phase) | |
211 | ) |
|
313 | ) | |
212 | else: |
|
314 | else: | |
213 | ax.plt.set_array(phase.T.ravel()) |
|
315 | ax.plt.set_array(phase.T.ravel()) | |
214 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) |
|
316 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) | |
215 |
|
317 | |||
216 |
|
318 | |||
|
319 | class CrossSpectra4Plot(Plot): | |||
|
320 | ||||
|
321 | CODE = 'cspc' | |||
|
322 | colormap = 'jet' | |||
|
323 | plot_type = 'pcolor' | |||
|
324 | zmin_coh = None | |||
|
325 | zmax_coh = None | |||
|
326 | zmin_phase = None | |||
|
327 | zmax_phase = None | |||
|
328 | ||||
|
329 | def setup(self): | |||
|
330 | ||||
|
331 | self.ncols = 4 | |||
|
332 | self.nrows = len(self.data.pairs) | |||
|
333 | self.nplots = self.nrows * 4 | |||
|
334 | self.width = 3.1 * self.ncols | |||
|
335 | self.height = 5 * self.nrows | |||
|
336 | self.ylabel = 'Range [km]' | |||
|
337 | self.showprofile = False | |||
|
338 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |||
|
339 | ||||
|
340 | def plot(self): | |||
|
341 | ||||
|
342 | if self.xaxis == "frequency": | |||
|
343 | x = self.data.xrange[0] | |||
|
344 | self.xlabel = "Frequency (kHz)" | |||
|
345 | elif self.xaxis == "time": | |||
|
346 | x = self.data.xrange[1] | |||
|
347 | self.xlabel = "Time (ms)" | |||
|
348 | else: | |||
|
349 | x = self.data.xrange[2] | |||
|
350 | self.xlabel = "Velocity (m/s)" | |||
|
351 | ||||
|
352 | self.titles = [] | |||
|
353 | ||||
|
354 | ||||
|
355 | y = self.data.heights | |||
|
356 | self.y = y | |||
|
357 | nspc = self.data['spc'] | |||
|
358 | spc = self.data['cspc'][0] | |||
|
359 | cspc = self.data['cspc'][1] | |||
|
360 | ||||
|
361 | for n in range(self.nrows): | |||
|
362 | noise = self.data['noise'][:,-1] | |||
|
363 | pair = self.data.pairs[n] | |||
|
364 | ||||
|
365 | ax = self.axes[4 * n] | |||
|
366 | if ax.firsttime: | |||
|
367 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |||
|
368 | self.xmin = self.xmin if self.xmin else -self.xmax | |||
|
369 | self.zmin = self.zmin if self.zmin else numpy.nanmin(nspc) | |||
|
370 | self.zmax = self.zmax if self.zmax else numpy.nanmax(nspc) | |||
|
371 | ax.plt = ax.pcolormesh(x , y , nspc[pair[0]].T, | |||
|
372 | vmin=self.zmin, | |||
|
373 | vmax=self.zmax, | |||
|
374 | cmap=plt.get_cmap(self.colormap) | |||
|
375 | ) | |||
|
376 | else: | |||
|
377 | ||||
|
378 | ax.plt.set_array(nspc[pair[0]].T.ravel()) | |||
|
379 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[0], noise[pair[0]])) | |||
|
380 | ||||
|
381 | ax = self.axes[4 * n + 1] | |||
|
382 | ||||
|
383 | if ax.firsttime: | |||
|
384 | ax.plt = ax.pcolormesh(x , y, numpy.flip(nspc[pair[1]],axis=0).T, | |||
|
385 | vmin=self.zmin, | |||
|
386 | vmax=self.zmax, | |||
|
387 | cmap=plt.get_cmap(self.colormap) | |||
|
388 | ) | |||
|
389 | else: | |||
|
390 | ||||
|
391 | ax.plt.set_array(numpy.flip(nspc[pair[1]],axis=0).T.ravel()) | |||
|
392 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[1], noise[pair[1]])) | |||
|
393 | ||||
|
394 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) | |||
|
395 | coh = numpy.abs(out) | |||
|
396 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi | |||
|
397 | ||||
|
398 | ax = self.axes[4 * n + 2] | |||
|
399 | if ax.firsttime: | |||
|
400 | ax.plt = ax.pcolormesh(x, y, numpy.flip(coh,axis=0).T, | |||
|
401 | vmin=0, | |||
|
402 | vmax=1, | |||
|
403 | cmap=plt.get_cmap(self.colormap_coh) | |||
|
404 | ) | |||
|
405 | else: | |||
|
406 | ax.plt.set_array(numpy.flip(coh,axis=0).T.ravel()) | |||
|
407 | self.titles.append( | |||
|
408 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) | |||
|
409 | ||||
|
410 | ax = self.axes[4 * n + 3] | |||
|
411 | if ax.firsttime: | |||
|
412 | ax.plt = ax.pcolormesh(x, y, numpy.flip(phase,axis=0).T, | |||
|
413 | vmin=-180, | |||
|
414 | vmax=180, | |||
|
415 | cmap=plt.get_cmap(self.colormap_phase) | |||
|
416 | ) | |||
|
417 | else: | |||
|
418 | ax.plt.set_array(numpy.flip(phase,axis=0).T.ravel()) | |||
|
419 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) | |||
|
420 | ||||
|
421 | ||||
|
422 | class CrossSpectra2Plot(Plot): | |||
|
423 | ||||
|
424 | CODE = 'cspc' | |||
|
425 | colormap = 'jet' | |||
|
426 | plot_type = 'pcolor' | |||
|
427 | zmin_coh = None | |||
|
428 | zmax_coh = None | |||
|
429 | zmin_phase = None | |||
|
430 | zmax_phase = None | |||
|
431 | ||||
|
432 | def setup(self): | |||
|
433 | ||||
|
434 | self.ncols = 1 | |||
|
435 | self.nrows = len(self.data.pairs) | |||
|
436 | self.nplots = self.nrows * 1 | |||
|
437 | self.width = 3.1 * self.ncols | |||
|
438 | self.height = 5 * self.nrows | |||
|
439 | self.ylabel = 'Range [km]' | |||
|
440 | self.showprofile = False | |||
|
441 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |||
|
442 | ||||
|
443 | def plot(self): | |||
|
444 | ||||
|
445 | if self.xaxis == "frequency": | |||
|
446 | x = self.data.xrange[0] | |||
|
447 | self.xlabel = "Frequency (kHz)" | |||
|
448 | elif self.xaxis == "time": | |||
|
449 | x = self.data.xrange[1] | |||
|
450 | self.xlabel = "Time (ms)" | |||
|
451 | else: | |||
|
452 | x = self.data.xrange[2] | |||
|
453 | self.xlabel = "Velocity (m/s)" | |||
|
454 | ||||
|
455 | self.titles = [] | |||
|
456 | ||||
|
457 | ||||
|
458 | y = self.data.heights | |||
|
459 | self.y = y | |||
|
460 | cspc = self.data['cspc'][1] | |||
|
461 | ||||
|
462 | for n in range(self.nrows): | |||
|
463 | noise = self.data['noise'][:,-1] | |||
|
464 | pair = self.data.pairs[n] | |||
|
465 | out = cspc[n] | |||
|
466 | cross = numpy.abs(out) | |||
|
467 | z = cross/self.data.nFactor | |||
|
468 | cross = 10*numpy.log10(z) | |||
|
469 | ||||
|
470 | ax = self.axes[1 * n] | |||
|
471 | if ax.firsttime: | |||
|
472 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |||
|
473 | self.xmin = self.xmin if self.xmin else -self.xmax | |||
|
474 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |||
|
475 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |||
|
476 | ax.plt = ax.pcolormesh(x, y, cross.T, | |||
|
477 | vmin=self.zmin, | |||
|
478 | vmax=self.zmax, | |||
|
479 | cmap=plt.get_cmap(self.colormap) | |||
|
480 | ) | |||
|
481 | else: | |||
|
482 | ax.plt.set_array(cross.T.ravel()) | |||
|
483 | self.titles.append( | |||
|
484 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) | |||
|
485 | ||||
|
486 | ||||
|
487 | class CrossSpectra3Plot(Plot): | |||
|
488 | ||||
|
489 | CODE = 'cspc' | |||
|
490 | colormap = 'jet' | |||
|
491 | plot_type = 'pcolor' | |||
|
492 | zmin_coh = None | |||
|
493 | zmax_coh = None | |||
|
494 | zmin_phase = None | |||
|
495 | zmax_phase = None | |||
|
496 | ||||
|
497 | def setup(self): | |||
|
498 | ||||
|
499 | self.ncols = 3 | |||
|
500 | self.nrows = len(self.data.pairs) | |||
|
501 | self.nplots = self.nrows * 3 | |||
|
502 | self.width = 3.1 * self.ncols | |||
|
503 | self.height = 5 * self.nrows | |||
|
504 | self.ylabel = 'Range [km]' | |||
|
505 | self.showprofile = False | |||
|
506 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |||
|
507 | ||||
|
508 | def plot(self): | |||
|
509 | ||||
|
510 | if self.xaxis == "frequency": | |||
|
511 | x = self.data.xrange[0] | |||
|
512 | self.xlabel = "Frequency (kHz)" | |||
|
513 | elif self.xaxis == "time": | |||
|
514 | x = self.data.xrange[1] | |||
|
515 | self.xlabel = "Time (ms)" | |||
|
516 | else: | |||
|
517 | x = self.data.xrange[2] | |||
|
518 | self.xlabel = "Velocity (m/s)" | |||
|
519 | ||||
|
520 | self.titles = [] | |||
|
521 | ||||
|
522 | ||||
|
523 | y = self.data.heights | |||
|
524 | self.y = y | |||
|
525 | ||||
|
526 | cspc = self.data['cspc'][1] | |||
|
527 | ||||
|
528 | for n in range(self.nrows): | |||
|
529 | noise = self.data['noise'][:,-1] | |||
|
530 | pair = self.data.pairs[n] | |||
|
531 | out = cspc[n] | |||
|
532 | ||||
|
533 | cross = numpy.abs(out) | |||
|
534 | z = cross/self.data.nFactor | |||
|
535 | cross = 10*numpy.log10(z) | |||
|
536 | ||||
|
537 | out_r= out.real/self.data.nFactor | |||
|
538 | ||||
|
539 | out_i= out.imag/self.data.nFactor | |||
|
540 | ||||
|
541 | ax = self.axes[3 * n] | |||
|
542 | if ax.firsttime: | |||
|
543 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |||
|
544 | self.xmin = self.xmin if self.xmin else -self.xmax | |||
|
545 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |||
|
546 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |||
|
547 | ax.plt = ax.pcolormesh(x, y, cross.T, | |||
|
548 | vmin=self.zmin, | |||
|
549 | vmax=self.zmax, | |||
|
550 | cmap=plt.get_cmap(self.colormap) | |||
|
551 | ) | |||
|
552 | else: | |||
|
553 | ax.plt.set_array(cross.T.ravel()) | |||
|
554 | self.titles.append( | |||
|
555 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) | |||
|
556 | ||||
|
557 | ax = self.axes[3 * n + 1] | |||
|
558 | if ax.firsttime: | |||
|
559 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |||
|
560 | self.xmin = self.xmin if self.xmin else -self.xmax | |||
|
561 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |||
|
562 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |||
|
563 | ax.plt = ax.pcolormesh(x, y, out_r.T, | |||
|
564 | vmin=-1.e6, | |||
|
565 | vmax=0, | |||
|
566 | cmap=plt.get_cmap(self.colormap) | |||
|
567 | ) | |||
|
568 | else: | |||
|
569 | ax.plt.set_array(out_r.T.ravel()) | |||
|
570 | self.titles.append( | |||
|
571 | 'Cross Spectra Real Ch{} * Ch{}'.format(pair[0], pair[1])) | |||
|
572 | ||||
|
573 | ax = self.axes[3 * n + 2] | |||
|
574 | ||||
|
575 | ||||
|
576 | if ax.firsttime: | |||
|
577 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |||
|
578 | self.xmin = self.xmin if self.xmin else -self.xmax | |||
|
579 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |||
|
580 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |||
|
581 | ax.plt = ax.pcolormesh(x, y, out_i.T, | |||
|
582 | vmin=-1.e6, | |||
|
583 | vmax=1.e6, | |||
|
584 | cmap=plt.get_cmap(self.colormap) | |||
|
585 | ) | |||
|
586 | else: | |||
|
587 | ax.plt.set_array(out_i.T.ravel()) | |||
|
588 | self.titles.append( | |||
|
589 | 'Cross Spectra Imag Ch{} * Ch{}'.format(pair[0], pair[1])) | |||
|
590 | ||||
217 | class RTIPlot(Plot): |
|
591 | class RTIPlot(Plot): | |
218 | ''' |
|
592 | ''' | |
219 | Plot for RTI data |
|
593 | Plot for RTI data | |
@@ -231,7 +605,7 class RTIPlot(Plot): | |||||
231 | self.ylabel = 'Range [km]' |
|
605 | self.ylabel = 'Range [km]' | |
232 | self.xlabel = 'Time' |
|
606 | self.xlabel = 'Time' | |
233 | self.cb_label = 'dB' |
|
607 | self.cb_label = 'dB' | |
234 |
self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0. |
|
608 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) | |
235 | self.titles = ['{} Channel {}'.format( |
|
609 | self.titles = ['{} Channel {}'.format( | |
236 | self.CODE.upper(), x) for x in range(self.nrows)] |
|
610 | self.CODE.upper(), x) for x in range(self.nrows)] | |
237 |
|
611 | |||
@@ -245,6 +619,7 class RTIPlot(Plot): | |||||
245 | return data, meta |
|
619 | return data, meta | |
246 |
|
620 | |||
247 | def plot(self): |
|
621 | def plot(self): | |
|
622 | ||||
248 | self.x = self.data.times |
|
623 | self.x = self.data.times | |
249 | self.y = self.data.yrange |
|
624 | self.y = self.data.yrange | |
250 | self.z = self.data[self.CODE] |
|
625 | self.z = self.data[self.CODE] | |
@@ -256,6 +631,7 class RTIPlot(Plot): | |||||
256 | x, y, z = self.fill_gaps(*self.decimate()) |
|
631 | x, y, z = self.fill_gaps(*self.decimate()) | |
257 |
|
632 | |||
258 | for n, ax in enumerate(self.axes): |
|
633 | for n, ax in enumerate(self.axes): | |
|
634 | ||||
259 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) |
|
635 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) | |
260 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) |
|
636 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) | |
261 | data = self.data[-1] |
|
637 | data = self.data[-1] | |
@@ -282,6 +658,87 class RTIPlot(Plot): | |||||
282 | ax.plot_noise.set_data(numpy.repeat( |
|
658 | ax.plot_noise.set_data(numpy.repeat( | |
283 | data['noise'][n], len(self.y)), self.y) |
|
659 | data['noise'][n], len(self.y)), self.y) | |
284 |
|
660 | |||
|
661 | class SpectrogramPlot(Plot): | |||
|
662 | ''' | |||
|
663 | Plot for Spectrogram data | |||
|
664 | ''' | |||
|
665 | ||||
|
666 | CODE = 'Spectrogram_Profile' | |||
|
667 | colormap = 'binary' | |||
|
668 | plot_type = 'pcolorbuffer' | |||
|
669 | ||||
|
670 | def setup(self): | |||
|
671 | self.xaxis = 'time' | |||
|
672 | self.ncols = 1 | |||
|
673 | self.nrows = len(self.data.channels) | |||
|
674 | self.nplots = len(self.data.channels) | |||
|
675 | self.xlabel = 'Time' | |||
|
676 | self.plots_adjust.update({'hspace':1.2, 'left': 0.1, 'bottom': 0.12, 'right':0.95}) | |||
|
677 | self.titles = [] | |||
|
678 | ||||
|
679 | self.titles = ['{} Channel {}'.format( | |||
|
680 | self.CODE.upper(), x) for x in range(self.nrows)] | |||
|
681 | ||||
|
682 | ||||
|
683 | def update(self, dataOut): | |||
|
684 | data = {} | |||
|
685 | meta = {} | |||
|
686 | ||||
|
687 | maxHei = 1620#+12000 | |||
|
688 | indb = numpy.where(dataOut.heightList <= maxHei) | |||
|
689 | hei = indb[0][-1] | |||
|
690 | ||||
|
691 | factor = dataOut.nIncohInt | |||
|
692 | z = dataOut.data_spc[:,:,hei] / factor | |||
|
693 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |||
|
694 | ||||
|
695 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |||
|
696 | data['Spectrogram_Profile'] = 10 * numpy.log10(z) | |||
|
697 | ||||
|
698 | data['hei'] = hei | |||
|
699 | data['DH'] = (dataOut.heightList[1] - dataOut.heightList[0])/dataOut.step | |||
|
700 | data['nProfiles'] = dataOut.nProfiles | |||
|
701 | ||||
|
702 | return data, meta | |||
|
703 | ||||
|
704 | def plot(self): | |||
|
705 | ||||
|
706 | self.x = self.data.times | |||
|
707 | self.z = self.data[self.CODE] | |||
|
708 | self.y = self.data.xrange[0] | |||
|
709 | ||||
|
710 | hei = self.data['hei'][-1] | |||
|
711 | DH = self.data['DH'][-1] | |||
|
712 | nProfiles = self.data['nProfiles'][-1] | |||
|
713 | ||||
|
714 | self.ylabel = "Frequency (kHz)" | |||
|
715 | ||||
|
716 | self.z = numpy.ma.masked_invalid(self.z) | |||
|
717 | ||||
|
718 | if self.decimation is None: | |||
|
719 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |||
|
720 | else: | |||
|
721 | x, y, z = self.fill_gaps(*self.decimate()) | |||
|
722 | ||||
|
723 | for n, ax in enumerate(self.axes): | |||
|
724 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) | |||
|
725 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) | |||
|
726 | data = self.data[-1] | |||
|
727 | if ax.firsttime: | |||
|
728 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |||
|
729 | vmin=self.zmin, | |||
|
730 | vmax=self.zmax, | |||
|
731 | cmap=plt.get_cmap(self.colormap) | |||
|
732 | ) | |||
|
733 | else: | |||
|
734 | ax.collections.remove(ax.collections[0]) | |||
|
735 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |||
|
736 | vmin=self.zmin, | |||
|
737 | vmax=self.zmax, | |||
|
738 | cmap=plt.get_cmap(self.colormap) | |||
|
739 | ) | |||
|
740 | ||||
|
741 | ||||
285 |
|
742 | |||
286 | class CoherencePlot(RTIPlot): |
|
743 | class CoherencePlot(RTIPlot): | |
287 | ''' |
|
744 | ''' | |
@@ -335,7 +792,7 class PhasePlot(CoherencePlot): | |||||
335 |
|
792 | |||
336 | class NoisePlot(Plot): |
|
793 | class NoisePlot(Plot): | |
337 | ''' |
|
794 | ''' | |
338 |
Plot for noise |
|
795 | Plot for noise | |
339 | ''' |
|
796 | ''' | |
340 |
|
797 | |||
341 | CODE = 'noise' |
|
798 | CODE = 'noise' | |
@@ -380,7 +837,6 class NoisePlot(Plot): | |||||
380 | y = Y[ch] |
|
837 | y = Y[ch] | |
381 | self.axes[0].lines[ch].set_data(x, y) |
|
838 | self.axes[0].lines[ch].set_data(x, y) | |
382 |
|
839 | |||
383 |
|
||||
384 | class PowerProfilePlot(Plot): |
|
840 | class PowerProfilePlot(Plot): | |
385 |
|
841 | |||
386 | CODE = 'pow_profile' |
|
842 | CODE = 'pow_profile' | |
@@ -412,10 +868,10 class PowerProfilePlot(Plot): | |||||
412 | self.y = y |
|
868 | self.y = y | |
413 |
|
869 | |||
414 | x = self.data[-1][self.CODE] |
|
870 | x = self.data[-1][self.CODE] | |
415 |
|
871 | |||
416 | if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9 |
|
872 | if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9 | |
417 | if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1 |
|
873 | if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1 | |
418 |
|
874 | |||
419 | if self.axes[0].firsttime: |
|
875 | if self.axes[0].firsttime: | |
420 | for ch in self.data.channels: |
|
876 | for ch in self.data.channels: | |
421 | self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch)) |
|
877 | self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch)) | |
@@ -446,7 +902,10 class SpectraCutPlot(Plot): | |||||
446 |
|
902 | |||
447 | data = {} |
|
903 | data = {} | |
448 | meta = {} |
|
904 | meta = {} | |
449 | spc = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor) |
|
905 | try: | |
|
906 | spc = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor) | |||
|
907 | except: | |||
|
908 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) | |||
450 | data['spc'] = spc |
|
909 | data['spc'] = spc | |
451 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
910 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |
452 | if self.CODE == 'cut_gaussian_fit': |
|
911 | if self.CODE == 'cut_gaussian_fit': | |
@@ -464,7 +923,7 class SpectraCutPlot(Plot): | |||||
464 | else: |
|
923 | else: | |
465 | x = self.data.xrange[2][:-1] |
|
924 | x = self.data.xrange[2][:-1] | |
466 | self.xlabel = "Velocity (m/s)" |
|
925 | self.xlabel = "Velocity (m/s)" | |
467 |
|
926 | |||
468 | if self.CODE == 'cut_gaussian_fit': |
|
927 | if self.CODE == 'cut_gaussian_fit': | |
469 | x = self.data.xrange[2][:-1] |
|
928 | x = self.data.xrange[2][:-1] | |
470 | self.xlabel = "Velocity (m/s)" |
|
929 | self.xlabel = "Velocity (m/s)" | |
@@ -481,22 +940,22 class SpectraCutPlot(Plot): | |||||
481 | index = numpy.arange(0, len(y), int((len(y))/9)) |
|
940 | index = numpy.arange(0, len(y), int((len(y))/9)) | |
482 |
|
941 | |||
483 | for n, ax in enumerate(self.axes): |
|
942 | for n, ax in enumerate(self.axes): | |
484 |
if self.CODE == 'cut_gaussian_fit': |
|
943 | if self.CODE == 'cut_gaussian_fit': | |
485 | gau0 = data['gauss_fit0'] |
|
944 | gau0 = data['gauss_fit0'] | |
486 | gau1 = data['gauss_fit1'] |
|
945 | gau1 = data['gauss_fit1'] | |
487 | if ax.firsttime: |
|
946 | if ax.firsttime: | |
488 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
947 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
489 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
948 | self.xmin = self.xmin if self.xmin else -self.xmax | |
490 | self.ymin = self.ymin if self.ymin else numpy.nanmin(z) |
|
949 | self.ymin = self.ymin if self.ymin else numpy.nanmin(z[:,:,index]) | |
491 | self.ymax = self.ymax if self.ymax else numpy.nanmax(z) |
|
950 | self.ymax = self.ymax if self.ymax else numpy.nanmax(z[:,:,index]) | |
492 | ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25) |
|
951 | ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25) | |
493 | if self.CODE == 'cut_gaussian_fit': |
|
952 | if self.CODE == 'cut_gaussian_fit': | |
494 | ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.') |
|
953 | ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.') | |
495 | for i, line in enumerate(ax.plt_gau0): |
|
954 | for i, line in enumerate(ax.plt_gau0): | |
496 |
line.set_color(ax.plt[i].get_color()) |
|
955 | line.set_color(ax.plt[i].get_color()) | |
497 | ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--') |
|
956 | ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--') | |
498 | for i, line in enumerate(ax.plt_gau1): |
|
957 | for i, line in enumerate(ax.plt_gau1): | |
499 |
line.set_color(ax.plt[i].get_color()) |
|
958 | line.set_color(ax.plt[i].get_color()) | |
500 | labels = ['Range = {:2.1f}km'.format(y[i]) for i in index] |
|
959 | labels = ['Range = {:2.1f}km'.format(y[i]) for i in index] | |
501 | self.figures[0].legend(ax.plt, labels, loc='center right') |
|
960 | self.figures[0].legend(ax.plt, labels, loc='center right') | |
502 | else: |
|
961 | else: | |
@@ -600,7 +1059,7 class BeaconPhase(Plot): | |||||
600 | server=None, folder=None, username=None, password=None, |
|
1059 | server=None, folder=None, username=None, password=None, | |
601 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1060 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
602 |
|
1061 | |||
603 |
if dataOut.flagNoData: |
|
1062 | if dataOut.flagNoData: | |
604 | return dataOut |
|
1063 | return dataOut | |
605 |
|
1064 | |||
606 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
1065 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | |
@@ -646,7 +1105,6 class BeaconPhase(Plot): | |||||
646 | update_figfile = False |
|
1105 | update_figfile = False | |
647 |
|
1106 | |||
648 | nplots = len(pairsIndexList) |
|
1107 | nplots = len(pairsIndexList) | |
649 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) |
|
|||
650 | phase_beacon = numpy.zeros(len(pairsIndexList)) |
|
1108 | phase_beacon = numpy.zeros(len(pairsIndexList)) | |
651 | for i in range(nplots): |
|
1109 | for i in range(nplots): | |
652 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
1110 | pair = dataOut.pairsList[pairsIndexList[i]] | |
@@ -696,11 +1154,6 class BeaconPhase(Plot): | |||||
696 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1154 | path = '%s%03d' %(self.PREFIX, self.id) | |
697 | beacon_file = os.path.join(path,'%s.txt'%self.name) |
|
1155 | beacon_file = os.path.join(path,'%s.txt'%self.name) | |
698 | self.filename_phase = os.path.join(figpath,beacon_file) |
|
1156 | self.filename_phase = os.path.join(figpath,beacon_file) | |
699 | #self.save_phase(self.filename_phase) |
|
|||
700 |
|
||||
701 |
|
||||
702 | #store data beacon phase |
|
|||
703 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) |
|
|||
704 |
|
1157 | |||
705 | self.setWinTitle(title) |
|
1158 | self.setWinTitle(title) | |
706 |
|
1159 |
General Comments 0
You need to be logged in to leave comments.
Login now