@@ -1,1196 +1,1208 | |||||
|
1 | # MASTER | |||
1 | # Copyright (c) 2012-2021 Jicamarca Radio Observatory |
|
2 | # Copyright (c) 2012-2021 Jicamarca Radio Observatory | |
2 | # All rights reserved. |
|
3 | # All rights reserved. | |
3 | # |
|
4 | # | |
4 | # Distributed under the terms of the BSD 3-clause license. |
|
5 | # Distributed under the terms of the BSD 3-clause license. | |
5 | """Classes to plot Spectra data |
|
6 | """Classes to plot Spectra data | |
6 |
|
7 | |||
7 | """ |
|
8 | """ | |
8 |
|
9 | |||
9 | import os |
|
10 | import os | |
10 | import numpy |
|
11 | import numpy | |
11 |
|
12 | |||
12 | from schainpy.model.graphics.jroplot_base import Plot, plt, log |
|
13 | from schainpy.model.graphics.jroplot_base import Plot, plt, log | |
13 |
|
14 | |||
14 |
|
15 | |||
15 | class SpectraPlot(Plot): |
|
16 | class SpectraPlot(Plot): | |
16 | ''' |
|
17 | ''' | |
17 | Plot for Spectra data |
|
18 | Plot for Spectra data | |
18 | ''' |
|
19 | ''' | |
19 |
|
20 | |||
20 | CODE = 'spc' |
|
21 | CODE = 'spc' | |
21 | colormap = 'jet' |
|
22 | colormap = 'jet' | |
22 | plot_type = 'pcolor' |
|
23 | plot_type = 'pcolor' | |
23 | buffering = False |
|
24 | buffering = False | |
24 |
|
25 | |||
25 | def setup(self): |
|
26 | def setup(self): | |
26 |
|
27 | |||
27 | self.nplots = len(self.data.channels) |
|
28 | self.nplots = len(self.data.channels) | |
28 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
29 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) | |
29 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
30 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) | |
30 | self.height = 2.6 * self.nrows |
|
31 | self.height = 2.6 * self.nrows | |
31 | self.cb_label = 'dB' |
|
32 | self.cb_label = 'dB' | |
32 | if self.showprofile: |
|
33 | if self.showprofile: | |
33 | self.width = 4 * self.ncols |
|
34 | self.width = 4 * self.ncols | |
34 | else: |
|
35 | else: | |
35 | self.width = 3.5 * self.ncols |
|
36 | self.width = 3.5 * self.ncols | |
36 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
37 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
37 | self.ylabel = 'Range [km]' |
|
38 | self.ylabel = 'Range [km]' | |
38 |
|
39 | |||
39 | def update(self, dataOut): |
|
40 | def update(self, dataOut): | |
40 |
|
41 | |||
41 | data = {} |
|
42 | data = {} | |
42 | meta = {} |
|
43 | meta = {} | |
43 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) |
|
44 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) | |
44 | data['spc'] = spc |
|
45 | data['spc'] = spc | |
45 | data['rti'] = dataOut.getPower() |
|
46 | data['rti'] = dataOut.getPower() | |
|
47 | if hasattr(dataOut, 'LagPlot'): #Double Pulse | |||
|
48 | max_hei_id = dataOut.nHeights - 2*dataOut.LagPlot | |||
|
49 | data['noise'] = 10*numpy.log10(dataOut.getNoise(ymin_index=53,ymax_index=max_hei_id)/dataOut.normFactor) | |||
|
50 | data['noise'][0] = 10*numpy.log10(dataOut.getNoise(ymin_index=53)[0]/dataOut.normFactor) | |||
|
51 | else: | |||
46 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
52 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) | |
47 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
53 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |
48 |
|
54 | |||
49 | if self.CODE == 'spc_moments': |
|
55 | if self.CODE == 'spc_moments': | |
50 | data['moments'] = dataOut.moments |
|
56 | data['moments'] = dataOut.moments | |
51 | if self.CODE == 'gaussian_fit': |
|
57 | if self.CODE == 'gaussian_fit': | |
52 | data['gaussfit'] = dataOut.DGauFitParams |
|
58 | data['gaussfit'] = dataOut.DGauFitParams | |
53 |
|
59 | |||
54 | return data, meta |
|
60 | return data, meta | |
55 |
|
61 | |||
56 | def plot(self): |
|
62 | def plot(self): | |
57 |
|
63 | |||
58 | if self.xaxis == "frequency": |
|
64 | if self.xaxis == "frequency": | |
59 | x = self.data.xrange[0] |
|
65 | x = self.data.xrange[0] | |
60 | self.xlabel = "Frequency (kHz)" |
|
66 | self.xlabel = "Frequency (kHz)" | |
61 | elif self.xaxis == "time": |
|
67 | elif self.xaxis == "time": | |
62 | x = self.data.xrange[1] |
|
68 | x = self.data.xrange[1] | |
63 | self.xlabel = "Time (ms)" |
|
69 | self.xlabel = "Time (ms)" | |
64 | else: |
|
70 | else: | |
65 | x = self.data.xrange[2] |
|
71 | x = self.data.xrange[2] | |
66 | self.xlabel = "Velocity (m/s)" |
|
72 | self.xlabel = "Velocity (m/s)" | |
67 |
|
73 | |||
68 | if (self.CODE == 'spc_moments') | (self.CODE == 'gaussian_fit'): |
|
74 | if (self.CODE == 'spc_moments') | (self.CODE == 'gaussian_fit'): | |
|
75 | print("data",self.data.shape) | |||
69 | x = self.data.xrange[2] |
|
76 | x = self.data.xrange[2] | |
70 | self.xlabel = "Velocity (m/s)" |
|
77 | self.xlabel = "Velocity (m/s)" | |
71 |
|
78 | |||
72 | self.titles = [] |
|
79 | self.titles = [] | |
73 |
|
80 | |||
74 | y = self.data.yrange |
|
81 | y = self.data.yrange | |
75 | self.y = y |
|
82 | self.y = y | |
76 |
|
83 | |||
77 | data = self.data[-1] |
|
84 | data = self.data[-1] | |
78 | z = data['spc'] |
|
85 | z = data['spc'] | |
79 |
|
86 | |||
|
87 | self.CODE2 = 'spc_oblique' | |||
|
88 | ||||
80 | for n, ax in enumerate(self.axes): |
|
89 | for n, ax in enumerate(self.axes): | |
81 | noise = data['noise'][n] |
|
90 | noise = data['noise'][n] | |
82 |
|
||||
83 | if self.CODE == 'spc_moments': |
|
91 | if self.CODE == 'spc_moments': | |
84 | mean = data['moments'][n, 1] |
|
92 | mean = data['moments'][n, 1] | |
85 | if self.CODE == 'gaussian_fit': |
|
93 | if self.CODE == 'gaussian_fit': | |
86 | gau0 = data['gaussfit'][n][2,:,0] |
|
94 | gau0 = data['gaussfit'][n][2,:,0] | |
87 | gau1 = data['gaussfit'][n][2,:,1] |
|
95 | gau1 = data['gaussfit'][n][2,:,1] | |
88 | if ax.firsttime: |
|
96 | if ax.firsttime: | |
89 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
97 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
90 |
self.xmin = self.xmin if self.xmin else |
|
98 | self.xmin = self.xmin if self.xmin else numpy.nanmin(x)#-self.xmax | |
91 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) |
|
99 | #self.zmin = self.zmin if self.zmin else numpy.nanmin(z) | |
92 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) |
|
100 | #self.zmax = self.zmax if self.zmax else numpy.nanmax(z) | |
|
101 | if self.zlimits is not None: | |||
|
102 | self.zmin, self.zmax = self.zlimits[n] | |||
|
103 | # CORREGIR CON matplotlib==3.3.4 | |||
93 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
104 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
94 | vmin=self.zmin, |
|
105 | vmin=self.zmin, | |
95 | vmax=self.zmax, |
|
106 | vmax=self.zmax, | |
96 | cmap=plt.get_cmap(self.colormap) |
|
107 | cmap=plt.get_cmap(self.colormap), | |
97 | ) |
|
108 | ) | |
98 |
|
109 | |||
99 | if self.showprofile: |
|
110 | if self.showprofile: | |
100 | ax.plt_profile = self.pf_axes[n].plot( |
|
111 | ax.plt_profile = self.pf_axes[n].plot( | |
101 | data['rti'][n], y)[0] |
|
112 | data['rti'][n], y)[0] | |
102 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, |
|
113 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, | |
103 | color="k", linestyle="dashed", lw=1)[0] |
|
114 | color="k", linestyle="dashed", lw=1)[0] | |
104 | if self.CODE == 'spc_moments': |
|
115 | if self.CODE == 'spc_moments': | |
105 | ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0] |
|
116 | ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0] | |
106 | if self.CODE == 'gaussian_fit': |
|
117 | if self.CODE == 'gaussian_fit': | |
107 | ax.plt_gau0 = ax.plot(gau0, y, color='r', lw=1)[0] |
|
118 | ax.plt_gau0 = ax.plot(gau0, y, color='r', lw=1)[0] | |
108 | ax.plt_gau1 = ax.plot(gau1, y, color='y', lw=1)[0] |
|
119 | ax.plt_gau1 = ax.plot(gau1, y, color='y', lw=1)[0] | |
109 | else: |
|
120 | else: | |
|
121 | if self.zlimits is not None: | |||
|
122 | self.zmin, self.zmax = self.zlimits[n] | |||
110 | ax.plt.set_array(z[n].T.ravel()) |
|
123 | ax.plt.set_array(z[n].T.ravel()) | |
111 | if self.showprofile: |
|
124 | if self.showprofile: | |
112 | ax.plt_profile.set_data(data['rti'][n], y) |
|
125 | ax.plt_profile.set_data(data['rti'][n], y) | |
113 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) |
|
126 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) | |
114 | if self.CODE == 'spc_moments': |
|
127 | if self.CODE == 'spc_moments': | |
115 | ax.plt_mean.set_data(mean, y) |
|
128 | ax.plt_mean.set_data(mean, y) | |
116 | if self.CODE == 'gaussian_fit': |
|
129 | if self.CODE == 'gaussian_fit': | |
117 | ax.plt_gau0.set_data(gau0, y) |
|
130 | ax.plt_gau0.set_data(gau0, y) | |
118 | ax.plt_gau1.set_data(gau1, y) |
|
131 | ax.plt_gau1.set_data(gau1, y) | |
119 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) |
|
132 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) | |
120 |
|
133 | |||
121 | class SpectraObliquePlot(Plot): |
|
134 | class SpectraObliquePlot(Plot): | |
122 | ''' |
|
135 | ''' | |
123 | Plot for Spectra data |
|
136 | Plot for Spectra data | |
124 | ''' |
|
137 | ''' | |
125 |
|
138 | |||
126 | CODE = 'spc_oblique' |
|
139 | CODE = 'spc_oblique' | |
127 | colormap = 'jet' |
|
140 | colormap = 'jet' | |
128 | plot_type = 'pcolor' |
|
141 | plot_type = 'pcolor' | |
129 |
|
142 | |||
130 | def setup(self): |
|
143 | def setup(self): | |
131 | self.xaxis = "oblique" |
|
144 | self.xaxis = "oblique" | |
132 | self.nplots = len(self.data.channels) |
|
145 | self.nplots = len(self.data.channels) | |
133 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
146 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) | |
134 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
147 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) | |
135 | self.height = 2.6 * self.nrows |
|
148 | self.height = 2.6 * self.nrows | |
136 | self.cb_label = 'dB' |
|
149 | self.cb_label = 'dB' | |
137 | if self.showprofile: |
|
150 | if self.showprofile: | |
138 | self.width = 4 * self.ncols |
|
151 | self.width = 4 * self.ncols | |
139 | else: |
|
152 | else: | |
140 | self.width = 3.5 * self.ncols |
|
153 | 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}) |
|
154 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
142 | self.ylabel = 'Range [km]' |
|
155 | self.ylabel = 'Range [km]' | |
143 |
|
156 | |||
144 | def update(self, dataOut): |
|
157 | def update(self, dataOut): | |
145 |
|
158 | |||
146 | data = {} |
|
159 | data = {} | |
147 | meta = {} |
|
160 | meta = {} | |
148 |
|
161 | |||
149 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) |
|
162 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) | |
150 | data['spc'] = spc |
|
163 | data['spc'] = spc | |
151 | data['rti'] = dataOut.getPower() |
|
164 | data['rti'] = dataOut.getPower() | |
152 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
165 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) | |
153 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
166 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |
154 |
|
167 | |||
155 | data['shift1'] = dataOut.Dop_EEJ_T1[0] |
|
168 | data['shift1'] = dataOut.Dop_EEJ_T1[0] | |
156 | data['shift2'] = dataOut.Dop_EEJ_T2[0] |
|
169 | data['shift2'] = dataOut.Dop_EEJ_T2[0] | |
157 | data['max_val_2'] = dataOut.Oblique_params[0,-1,:] |
|
170 | data['max_val_2'] = dataOut.Oblique_params[0,-1,:] | |
158 | data['shift1_error'] = dataOut.Err_Dop_EEJ_T1[0] |
|
171 | data['shift1_error'] = dataOut.Err_Dop_EEJ_T1[0] | |
159 | data['shift2_error'] = dataOut.Err_Dop_EEJ_T2[0] |
|
172 | data['shift2_error'] = dataOut.Err_Dop_EEJ_T2[0] | |
160 |
|
173 | |||
161 | return data, meta |
|
174 | return data, meta | |
162 |
|
175 | |||
163 | def plot(self): |
|
176 | def plot(self): | |
164 |
|
177 | |||
165 | if self.xaxis == "frequency": |
|
178 | if self.xaxis == "frequency": | |
166 | x = self.data.xrange[0] |
|
179 | x = self.data.xrange[0] | |
167 | self.xlabel = "Frequency (kHz)" |
|
180 | self.xlabel = "Frequency (kHz)" | |
168 | elif self.xaxis == "time": |
|
181 | elif self.xaxis == "time": | |
169 | x = self.data.xrange[1] |
|
182 | x = self.data.xrange[1] | |
170 | self.xlabel = "Time (ms)" |
|
183 | self.xlabel = "Time (ms)" | |
171 | else: |
|
184 | else: | |
172 | x = self.data.xrange[2] |
|
185 | x = self.data.xrange[2] | |
173 | self.xlabel = "Velocity (m/s)" |
|
186 | self.xlabel = "Velocity (m/s)" | |
174 |
|
187 | |||
175 | self.titles = [] |
|
188 | self.titles = [] | |
176 |
|
189 | |||
177 | y = self.data.yrange |
|
190 | y = self.data.yrange | |
178 | self.y = y |
|
191 | self.y = y | |
179 |
|
192 | |||
180 | data = self.data[-1] |
|
193 | data = self.data[-1] | |
181 | z = data['spc'] |
|
194 | z = data['spc'] | |
182 |
|
195 | |||
183 | for n, ax in enumerate(self.axes): |
|
196 | for n, ax in enumerate(self.axes): | |
184 | noise = self.data['noise'][n][-1] |
|
197 | noise = self.data['noise'][n][-1] | |
185 | shift1 = data['shift1'] |
|
198 | shift1 = data['shift1'] | |
186 | shift2 = data['shift2'] |
|
199 | shift2 = data['shift2'] | |
187 | max_val_2 = data['max_val_2'] |
|
200 | max_val_2 = data['max_val_2'] | |
188 | err1 = data['shift1_error'] |
|
201 | err1 = data['shift1_error'] | |
189 | err2 = data['shift2_error'] |
|
202 | err2 = data['shift2_error'] | |
190 | if ax.firsttime: |
|
203 | if ax.firsttime: | |
191 |
|
204 | |||
192 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
205 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
193 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
206 | self.xmin = self.xmin if self.xmin else -self.xmax | |
194 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) |
|
207 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) | |
195 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) |
|
208 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) | |
196 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
209 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
197 | vmin=self.zmin, |
|
210 | vmin=self.zmin, | |
198 | vmax=self.zmax, |
|
211 | vmax=self.zmax, | |
199 | cmap=plt.get_cmap(self.colormap) |
|
212 | cmap=plt.get_cmap(self.colormap) | |
200 | ) |
|
213 | ) | |
201 |
|
214 | |||
202 | if self.showprofile: |
|
215 | if self.showprofile: | |
203 | ax.plt_profile = self.pf_axes[n].plot( |
|
216 | ax.plt_profile = self.pf_axes[n].plot( | |
204 | self.data['rti'][n][-1], y)[0] |
|
217 | self.data['rti'][n][-1], y)[0] | |
205 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, |
|
218 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, | |
206 | color="k", linestyle="dashed", lw=1)[0] |
|
219 | color="k", linestyle="dashed", lw=1)[0] | |
207 |
|
220 | |||
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) |
|
221 | 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) |
|
222 | 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) |
|
223 | 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 |
|
224 | |||
212 | else: |
|
225 | else: | |
213 | self.ploterr1.remove() |
|
226 | self.ploterr1.remove() | |
214 | self.ploterr2.remove() |
|
227 | self.ploterr2.remove() | |
215 | self.ploterr3.remove() |
|
228 | self.ploterr3.remove() | |
216 | ax.plt.set_array(z[n].T.ravel()) |
|
229 | ax.plt.set_array(z[n].T.ravel()) | |
217 | if self.showprofile: |
|
230 | if self.showprofile: | |
218 | ax.plt_profile.set_data(self.data['rti'][n][-1], y) |
|
231 | ax.plt_profile.set_data(self.data['rti'][n][-1], y) | |
219 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) |
|
232 | 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) |
|
233 | 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) |
|
234 | 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) |
|
235 | 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 |
|
236 | |||
224 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) |
|
237 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) | |
225 |
|
238 | |||
226 |
|
239 | |||
227 | class CrossSpectraPlot(Plot): |
|
240 | class CrossSpectraPlot(Plot): | |
228 |
|
241 | |||
229 | CODE = 'cspc' |
|
242 | CODE = 'cspc' | |
230 | colormap = 'jet' |
|
243 | colormap = 'jet' | |
231 | plot_type = 'pcolor' |
|
244 | plot_type = 'pcolor' | |
232 | zmin_coh = None |
|
245 | zmin_coh = None | |
233 | zmax_coh = None |
|
246 | zmax_coh = None | |
234 | zmin_phase = None |
|
247 | zmin_phase = None | |
235 | zmax_phase = None |
|
248 | zmax_phase = None | |
236 |
|
249 | |||
237 | def setup(self): |
|
250 | def setup(self): | |
238 |
|
251 | |||
239 | self.ncols = 4 |
|
252 | self.ncols = 4 | |
240 | self.nplots = len(self.data.pairs) * 2 |
|
253 | self.nplots = len(self.data.pairs) * 2 | |
241 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
254 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) | |
242 | self.width = 3.1 * self.ncols |
|
255 | self.width = 3.1 * self.ncols | |
243 | self.height = 5 * self.nrows |
|
256 | self.height = 5 * self.nrows | |
244 | self.ylabel = 'Range [km]' |
|
257 | self.ylabel = 'Range [km]' | |
245 | self.showprofile = False |
|
258 | self.showprofile = False | |
246 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
259 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |
247 |
|
260 | |||
248 | def update(self, dataOut): |
|
261 | def update(self, dataOut): | |
249 |
|
262 | |||
250 | data = {} |
|
263 | data = {} | |
251 | meta = {} |
|
264 | meta = {} | |
252 |
|
265 | |||
253 | spc = dataOut.data_spc |
|
266 | spc = dataOut.data_spc | |
254 | cspc = dataOut.data_cspc |
|
267 | cspc = dataOut.data_cspc | |
255 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
268 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |
256 | meta['pairs'] = dataOut.pairsList |
|
269 | meta['pairs'] = dataOut.pairsList | |
257 |
|
270 | |||
258 | tmp = [] |
|
271 | tmp = [] | |
259 |
|
272 | |||
260 | for n, pair in enumerate(meta['pairs']): |
|
273 | for n, pair in enumerate(meta['pairs']): | |
261 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
274 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) | |
262 | coh = numpy.abs(out) |
|
275 | coh = numpy.abs(out) | |
263 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
276 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi | |
264 | tmp.append(coh) |
|
277 | tmp.append(coh) | |
265 | tmp.append(phase) |
|
278 | tmp.append(phase) | |
266 |
|
279 | |||
267 | data['cspc'] = numpy.array(tmp) |
|
280 | data['cspc'] = numpy.array(tmp) | |
268 |
|
281 | |||
269 | return data, meta |
|
282 | return data, meta | |
270 |
|
283 | |||
271 | def plot(self): |
|
284 | def plot(self): | |
272 |
|
285 | |||
273 | if self.xaxis == "frequency": |
|
286 | if self.xaxis == "frequency": | |
274 | x = self.data.xrange[0] |
|
287 | x = self.data.xrange[0] | |
275 | self.xlabel = "Frequency (kHz)" |
|
288 | self.xlabel = "Frequency (kHz)" | |
276 | elif self.xaxis == "time": |
|
289 | elif self.xaxis == "time": | |
277 | x = self.data.xrange[1] |
|
290 | x = self.data.xrange[1] | |
278 | self.xlabel = "Time (ms)" |
|
291 | self.xlabel = "Time (ms)" | |
279 | else: |
|
292 | else: | |
280 | x = self.data.xrange[2] |
|
293 | x = self.data.xrange[2] | |
281 | self.xlabel = "Velocity (m/s)" |
|
294 | self.xlabel = "Velocity (m/s)" | |
282 |
|
295 | |||
283 | self.titles = [] |
|
296 | self.titles = [] | |
284 |
|
297 | |||
285 | y = self.data.yrange |
|
298 | y = self.data.yrange | |
286 | self.y = y |
|
299 | self.y = y | |
287 |
|
300 | |||
288 | data = self.data[-1] |
|
301 | data = self.data[-1] | |
289 | cspc = data['cspc'] |
|
302 | cspc = data['cspc'] | |
290 |
|
303 | |||
291 | for n in range(len(self.data.pairs)): |
|
304 | for n in range(len(self.data.pairs)): | |
292 | pair = self.data.pairs[n] |
|
305 | pair = self.data.pairs[n] | |
293 | coh = cspc[n*2] |
|
306 | coh = cspc[n*2] | |
294 | phase = cspc[n*2+1] |
|
307 | phase = cspc[n*2+1] | |
295 | ax = self.axes[2 * n] |
|
308 | ax = self.axes[2 * n] | |
296 | if ax.firsttime: |
|
309 | if ax.firsttime: | |
297 | ax.plt = ax.pcolormesh(x, y, coh.T, |
|
310 | ax.plt = ax.pcolormesh(x, y, coh.T, | |
298 | vmin=0, |
|
311 | vmin=0, | |
299 | vmax=1, |
|
312 | vmax=1, | |
300 | cmap=plt.get_cmap(self.colormap_coh) |
|
313 | cmap=plt.get_cmap(self.colormap_coh) | |
301 | ) |
|
314 | ) | |
302 | else: |
|
315 | else: | |
303 | ax.plt.set_array(coh.T.ravel()) |
|
316 | ax.plt.set_array(coh.T.ravel()) | |
304 | self.titles.append( |
|
317 | self.titles.append( | |
305 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
318 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) | |
306 |
|
319 | |||
307 | ax = self.axes[2 * n + 1] |
|
320 | ax = self.axes[2 * n + 1] | |
308 | if ax.firsttime: |
|
321 | if ax.firsttime: | |
309 | ax.plt = ax.pcolormesh(x, y, phase.T, |
|
322 | ax.plt = ax.pcolormesh(x, y, phase.T, | |
310 | vmin=-180, |
|
323 | vmin=-180, | |
311 | vmax=180, |
|
324 | vmax=180, | |
312 | cmap=plt.get_cmap(self.colormap_phase) |
|
325 | cmap=plt.get_cmap(self.colormap_phase) | |
313 | ) |
|
326 | ) | |
314 | else: |
|
327 | else: | |
315 | ax.plt.set_array(phase.T.ravel()) |
|
328 | ax.plt.set_array(phase.T.ravel()) | |
316 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) |
|
329 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) | |
317 |
|
330 | |||
318 |
|
331 | |||
319 | class CrossSpectra4Plot(Plot): |
|
332 | class CrossSpectra4Plot(Plot): | |
320 |
|
333 | |||
321 | CODE = 'cspc' |
|
334 | CODE = 'cspc' | |
322 | colormap = 'jet' |
|
335 | colormap = 'jet' | |
323 | plot_type = 'pcolor' |
|
336 | plot_type = 'pcolor' | |
324 | zmin_coh = None |
|
337 | zmin_coh = None | |
325 | zmax_coh = None |
|
338 | zmax_coh = None | |
326 | zmin_phase = None |
|
339 | zmin_phase = None | |
327 | zmax_phase = None |
|
340 | zmax_phase = None | |
328 |
|
341 | |||
329 | def setup(self): |
|
342 | def setup(self): | |
330 |
|
343 | |||
331 | self.ncols = 4 |
|
344 | self.ncols = 4 | |
332 | self.nrows = len(self.data.pairs) |
|
345 | self.nrows = len(self.data.pairs) | |
333 | self.nplots = self.nrows * 4 |
|
346 | self.nplots = self.nrows * 4 | |
334 | self.width = 3.1 * self.ncols |
|
347 | self.width = 3.1 * self.ncols | |
335 | self.height = 5 * self.nrows |
|
348 | self.height = 5 * self.nrows | |
336 | self.ylabel = 'Range [km]' |
|
349 | self.ylabel = 'Range [km]' | |
337 | self.showprofile = False |
|
350 | 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}) |
|
351 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |
339 |
|
352 | |||
340 | def plot(self): |
|
353 | def plot(self): | |
341 |
|
354 | |||
342 | if self.xaxis == "frequency": |
|
355 | if self.xaxis == "frequency": | |
343 | x = self.data.xrange[0] |
|
356 | x = self.data.xrange[0] | |
344 | self.xlabel = "Frequency (kHz)" |
|
357 | self.xlabel = "Frequency (kHz)" | |
345 | elif self.xaxis == "time": |
|
358 | elif self.xaxis == "time": | |
346 | x = self.data.xrange[1] |
|
359 | x = self.data.xrange[1] | |
347 | self.xlabel = "Time (ms)" |
|
360 | self.xlabel = "Time (ms)" | |
348 | else: |
|
361 | else: | |
349 | x = self.data.xrange[2] |
|
362 | x = self.data.xrange[2] | |
350 | self.xlabel = "Velocity (m/s)" |
|
363 | self.xlabel = "Velocity (m/s)" | |
351 |
|
364 | |||
352 | self.titles = [] |
|
365 | self.titles = [] | |
353 |
|
366 | |||
354 |
|
367 | |||
355 | y = self.data.heights |
|
368 | y = self.data.heights | |
356 | self.y = y |
|
369 | self.y = y | |
357 | nspc = self.data['spc'] |
|
370 | nspc = self.data['spc'] | |
358 | spc = self.data['cspc'][0] |
|
371 | spc = self.data['cspc'][0] | |
359 | cspc = self.data['cspc'][1] |
|
372 | cspc = self.data['cspc'][1] | |
360 |
|
373 | |||
361 | for n in range(self.nrows): |
|
374 | for n in range(self.nrows): | |
362 | noise = self.data['noise'][:,-1] |
|
375 | noise = self.data['noise'][:,-1] | |
363 | pair = self.data.pairs[n] |
|
376 | pair = self.data.pairs[n] | |
364 |
|
377 | |||
365 | ax = self.axes[4 * n] |
|
378 | ax = self.axes[4 * n] | |
366 | if ax.firsttime: |
|
379 | if ax.firsttime: | |
367 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
380 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
368 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
381 | self.xmin = self.xmin if self.xmin else -self.xmax | |
369 | self.zmin = self.zmin if self.zmin else numpy.nanmin(nspc) |
|
382 | self.zmin = self.zmin if self.zmin else numpy.nanmin(nspc) | |
370 | self.zmax = self.zmax if self.zmax else numpy.nanmax(nspc) |
|
383 | self.zmax = self.zmax if self.zmax else numpy.nanmax(nspc) | |
371 | ax.plt = ax.pcolormesh(x , y , nspc[pair[0]].T, |
|
384 | ax.plt = ax.pcolormesh(x , y , nspc[pair[0]].T, | |
372 | vmin=self.zmin, |
|
385 | vmin=self.zmin, | |
373 | vmax=self.zmax, |
|
386 | vmax=self.zmax, | |
374 | cmap=plt.get_cmap(self.colormap) |
|
387 | cmap=plt.get_cmap(self.colormap) | |
375 | ) |
|
388 | ) | |
376 | else: |
|
389 | else: | |
377 |
|
||||
378 | ax.plt.set_array(nspc[pair[0]].T.ravel()) |
|
390 | ax.plt.set_array(nspc[pair[0]].T.ravel()) | |
379 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[0], noise[pair[0]])) |
|
391 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[0], noise[pair[0]])) | |
380 |
|
392 | |||
381 | ax = self.axes[4 * n + 1] |
|
393 | ax = self.axes[4 * n + 1] | |
382 |
|
394 | |||
383 | if ax.firsttime: |
|
395 | if ax.firsttime: | |
384 | ax.plt = ax.pcolormesh(x , y, numpy.flip(nspc[pair[1]],axis=0).T, |
|
396 | ax.plt = ax.pcolormesh(x , y, numpy.flip(nspc[pair[1]],axis=0).T, | |
385 | vmin=self.zmin, |
|
397 | vmin=self.zmin, | |
386 | vmax=self.zmax, |
|
398 | vmax=self.zmax, | |
387 | cmap=plt.get_cmap(self.colormap) |
|
399 | cmap=plt.get_cmap(self.colormap) | |
388 | ) |
|
400 | ) | |
389 | else: |
|
401 | else: | |
390 |
|
402 | |||
391 | ax.plt.set_array(numpy.flip(nspc[pair[1]],axis=0).T.ravel()) |
|
403 | 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]])) |
|
404 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[1], noise[pair[1]])) | |
393 |
|
405 | |||
394 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
406 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) | |
395 | coh = numpy.abs(out) |
|
407 | coh = numpy.abs(out) | |
396 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
408 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi | |
397 |
|
409 | |||
398 | ax = self.axes[4 * n + 2] |
|
410 | ax = self.axes[4 * n + 2] | |
399 | if ax.firsttime: |
|
411 | if ax.firsttime: | |
400 | ax.plt = ax.pcolormesh(x, y, numpy.flip(coh,axis=0).T, |
|
412 | ax.plt = ax.pcolormesh(x, y, numpy.flip(coh,axis=0).T, | |
401 | vmin=0, |
|
413 | vmin=0, | |
402 | vmax=1, |
|
414 | vmax=1, | |
403 | cmap=plt.get_cmap(self.colormap_coh) |
|
415 | cmap=plt.get_cmap(self.colormap_coh) | |
404 | ) |
|
416 | ) | |
405 | else: |
|
417 | else: | |
406 | ax.plt.set_array(numpy.flip(coh,axis=0).T.ravel()) |
|
418 | ax.plt.set_array(numpy.flip(coh,axis=0).T.ravel()) | |
407 | self.titles.append( |
|
419 | self.titles.append( | |
408 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
420 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) | |
409 |
|
421 | |||
410 | ax = self.axes[4 * n + 3] |
|
422 | ax = self.axes[4 * n + 3] | |
411 | if ax.firsttime: |
|
423 | if ax.firsttime: | |
412 | ax.plt = ax.pcolormesh(x, y, numpy.flip(phase,axis=0).T, |
|
424 | ax.plt = ax.pcolormesh(x, y, numpy.flip(phase,axis=0).T, | |
413 | vmin=-180, |
|
425 | vmin=-180, | |
414 | vmax=180, |
|
426 | vmax=180, | |
415 | cmap=plt.get_cmap(self.colormap_phase) |
|
427 | cmap=plt.get_cmap(self.colormap_phase) | |
416 | ) |
|
428 | ) | |
417 | else: |
|
429 | else: | |
418 | ax.plt.set_array(numpy.flip(phase,axis=0).T.ravel()) |
|
430 | ax.plt.set_array(numpy.flip(phase,axis=0).T.ravel()) | |
419 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) |
|
431 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) | |
420 |
|
432 | |||
421 |
|
433 | |||
422 | class CrossSpectra2Plot(Plot): |
|
434 | class CrossSpectra2Plot(Plot): | |
423 |
|
435 | |||
424 | CODE = 'cspc' |
|
436 | CODE = 'cspc' | |
425 | colormap = 'jet' |
|
437 | colormap = 'jet' | |
426 | plot_type = 'pcolor' |
|
438 | plot_type = 'pcolor' | |
427 | zmin_coh = None |
|
439 | zmin_coh = None | |
428 | zmax_coh = None |
|
440 | zmax_coh = None | |
429 | zmin_phase = None |
|
441 | zmin_phase = None | |
430 | zmax_phase = None |
|
442 | zmax_phase = None | |
431 |
|
443 | |||
432 | def setup(self): |
|
444 | def setup(self): | |
433 |
|
445 | |||
434 | self.ncols = 1 |
|
446 | self.ncols = 1 | |
435 | self.nrows = len(self.data.pairs) |
|
447 | self.nrows = len(self.data.pairs) | |
436 | self.nplots = self.nrows * 1 |
|
448 | self.nplots = self.nrows * 1 | |
437 | self.width = 3.1 * self.ncols |
|
449 | self.width = 3.1 * self.ncols | |
438 | self.height = 5 * self.nrows |
|
450 | self.height = 5 * self.nrows | |
439 | self.ylabel = 'Range [km]' |
|
451 | self.ylabel = 'Range [km]' | |
440 | self.showprofile = False |
|
452 | 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}) |
|
453 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |
442 |
|
454 | |||
443 | def plot(self): |
|
455 | def plot(self): | |
444 |
|
456 | |||
445 | if self.xaxis == "frequency": |
|
457 | if self.xaxis == "frequency": | |
446 | x = self.data.xrange[0] |
|
458 | x = self.data.xrange[0] | |
447 | self.xlabel = "Frequency (kHz)" |
|
459 | self.xlabel = "Frequency (kHz)" | |
448 | elif self.xaxis == "time": |
|
460 | elif self.xaxis == "time": | |
449 | x = self.data.xrange[1] |
|
461 | x = self.data.xrange[1] | |
450 | self.xlabel = "Time (ms)" |
|
462 | self.xlabel = "Time (ms)" | |
451 | else: |
|
463 | else: | |
452 | x = self.data.xrange[2] |
|
464 | x = self.data.xrange[2] | |
453 | self.xlabel = "Velocity (m/s)" |
|
465 | self.xlabel = "Velocity (m/s)" | |
454 |
|
466 | |||
455 | self.titles = [] |
|
467 | self.titles = [] | |
456 |
|
468 | |||
457 |
|
469 | |||
458 | y = self.data.heights |
|
470 | y = self.data.heights | |
459 | self.y = y |
|
471 | self.y = y | |
460 | cspc = self.data['cspc'][1] |
|
472 | cspc = self.data['cspc'][1] | |
461 |
|
473 | |||
462 | for n in range(self.nrows): |
|
474 | for n in range(self.nrows): | |
463 | noise = self.data['noise'][:,-1] |
|
475 | noise = self.data['noise'][:,-1] | |
464 | pair = self.data.pairs[n] |
|
476 | pair = self.data.pairs[n] | |
465 | out = cspc[n] |
|
477 | out = cspc[n] | |
466 | cross = numpy.abs(out) |
|
478 | cross = numpy.abs(out) | |
467 | z = cross/self.data.nFactor |
|
479 | z = cross/self.data.nFactor | |
468 | cross = 10*numpy.log10(z) |
|
480 | cross = 10*numpy.log10(z) | |
469 |
|
481 | |||
470 | ax = self.axes[1 * n] |
|
482 | ax = self.axes[1 * n] | |
471 | if ax.firsttime: |
|
483 | if ax.firsttime: | |
472 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
484 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
473 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
485 | self.xmin = self.xmin if self.xmin else -self.xmax | |
474 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
486 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |
475 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
487 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |
476 | ax.plt = ax.pcolormesh(x, y, cross.T, |
|
488 | ax.plt = ax.pcolormesh(x, y, cross.T, | |
477 | vmin=self.zmin, |
|
489 | vmin=self.zmin, | |
478 | vmax=self.zmax, |
|
490 | vmax=self.zmax, | |
479 | cmap=plt.get_cmap(self.colormap) |
|
491 | cmap=plt.get_cmap(self.colormap) | |
480 | ) |
|
492 | ) | |
481 | else: |
|
493 | else: | |
482 | ax.plt.set_array(cross.T.ravel()) |
|
494 | ax.plt.set_array(cross.T.ravel()) | |
483 | self.titles.append( |
|
495 | self.titles.append( | |
484 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
496 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) | |
485 |
|
497 | |||
486 |
|
498 | |||
487 | class CrossSpectra3Plot(Plot): |
|
499 | class CrossSpectra3Plot(Plot): | |
488 |
|
500 | |||
489 | CODE = 'cspc' |
|
501 | CODE = 'cspc' | |
490 | colormap = 'jet' |
|
502 | colormap = 'jet' | |
491 | plot_type = 'pcolor' |
|
503 | plot_type = 'pcolor' | |
492 | zmin_coh = None |
|
504 | zmin_coh = None | |
493 | zmax_coh = None |
|
505 | zmax_coh = None | |
494 | zmin_phase = None |
|
506 | zmin_phase = None | |
495 | zmax_phase = None |
|
507 | zmax_phase = None | |
496 |
|
508 | |||
497 | def setup(self): |
|
509 | def setup(self): | |
498 |
|
510 | |||
499 | self.ncols = 3 |
|
511 | self.ncols = 3 | |
500 | self.nrows = len(self.data.pairs) |
|
512 | self.nrows = len(self.data.pairs) | |
501 | self.nplots = self.nrows * 3 |
|
513 | self.nplots = self.nrows * 3 | |
502 | self.width = 3.1 * self.ncols |
|
514 | self.width = 3.1 * self.ncols | |
503 | self.height = 5 * self.nrows |
|
515 | self.height = 5 * self.nrows | |
504 | self.ylabel = 'Range [km]' |
|
516 | self.ylabel = 'Range [km]' | |
505 | self.showprofile = False |
|
517 | 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}) |
|
518 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |
507 |
|
519 | |||
508 | def plot(self): |
|
520 | def plot(self): | |
509 |
|
521 | |||
510 | if self.xaxis == "frequency": |
|
522 | if self.xaxis == "frequency": | |
511 | x = self.data.xrange[0] |
|
523 | x = self.data.xrange[0] | |
512 | self.xlabel = "Frequency (kHz)" |
|
524 | self.xlabel = "Frequency (kHz)" | |
513 | elif self.xaxis == "time": |
|
525 | elif self.xaxis == "time": | |
514 | x = self.data.xrange[1] |
|
526 | x = self.data.xrange[1] | |
515 | self.xlabel = "Time (ms)" |
|
527 | self.xlabel = "Time (ms)" | |
516 | else: |
|
528 | else: | |
517 | x = self.data.xrange[2] |
|
529 | x = self.data.xrange[2] | |
518 | self.xlabel = "Velocity (m/s)" |
|
530 | self.xlabel = "Velocity (m/s)" | |
519 |
|
531 | |||
520 | self.titles = [] |
|
532 | self.titles = [] | |
521 |
|
533 | |||
522 |
|
534 | |||
523 | y = self.data.heights |
|
535 | y = self.data.heights | |
524 | self.y = y |
|
536 | self.y = y | |
525 |
|
537 | |||
526 | cspc = self.data['cspc'][1] |
|
538 | cspc = self.data['cspc'][1] | |
527 |
|
539 | |||
528 | for n in range(self.nrows): |
|
540 | for n in range(self.nrows): | |
529 | noise = self.data['noise'][:,-1] |
|
541 | noise = self.data['noise'][:,-1] | |
530 | pair = self.data.pairs[n] |
|
542 | pair = self.data.pairs[n] | |
531 | out = cspc[n] |
|
543 | out = cspc[n] | |
532 |
|
544 | |||
533 | cross = numpy.abs(out) |
|
545 | cross = numpy.abs(out) | |
534 | z = cross/self.data.nFactor |
|
546 | z = cross/self.data.nFactor | |
535 | cross = 10*numpy.log10(z) |
|
547 | cross = 10*numpy.log10(z) | |
536 |
|
548 | |||
537 | out_r= out.real/self.data.nFactor |
|
549 | out_r= out.real/self.data.nFactor | |
538 |
|
550 | |||
539 | out_i= out.imag/self.data.nFactor |
|
551 | out_i= out.imag/self.data.nFactor | |
540 |
|
552 | |||
541 | ax = self.axes[3 * n] |
|
553 | ax = self.axes[3 * n] | |
542 | if ax.firsttime: |
|
554 | if ax.firsttime: | |
543 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
555 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
544 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
556 | self.xmin = self.xmin if self.xmin else -self.xmax | |
545 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
557 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |
546 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
558 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |
547 | ax.plt = ax.pcolormesh(x, y, cross.T, |
|
559 | ax.plt = ax.pcolormesh(x, y, cross.T, | |
548 | vmin=self.zmin, |
|
560 | vmin=self.zmin, | |
549 | vmax=self.zmax, |
|
561 | vmax=self.zmax, | |
550 | cmap=plt.get_cmap(self.colormap) |
|
562 | cmap=plt.get_cmap(self.colormap) | |
551 | ) |
|
563 | ) | |
552 | else: |
|
564 | else: | |
553 | ax.plt.set_array(cross.T.ravel()) |
|
565 | ax.plt.set_array(cross.T.ravel()) | |
554 | self.titles.append( |
|
566 | self.titles.append( | |
555 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
567 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) | |
556 |
|
568 | |||
557 | ax = self.axes[3 * n + 1] |
|
569 | ax = self.axes[3 * n + 1] | |
558 | if ax.firsttime: |
|
570 | if ax.firsttime: | |
559 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
571 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
560 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
572 | self.xmin = self.xmin if self.xmin else -self.xmax | |
561 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
573 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |
562 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
574 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |
563 | ax.plt = ax.pcolormesh(x, y, out_r.T, |
|
575 | ax.plt = ax.pcolormesh(x, y, out_r.T, | |
564 | vmin=-1.e6, |
|
576 | vmin=-1.e6, | |
565 | vmax=0, |
|
577 | vmax=0, | |
566 | cmap=plt.get_cmap(self.colormap) |
|
578 | cmap=plt.get_cmap(self.colormap) | |
567 | ) |
|
579 | ) | |
568 | else: |
|
580 | else: | |
569 | ax.plt.set_array(out_r.T.ravel()) |
|
581 | ax.plt.set_array(out_r.T.ravel()) | |
570 | self.titles.append( |
|
582 | self.titles.append( | |
571 | 'Cross Spectra Real Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
583 | 'Cross Spectra Real Ch{} * Ch{}'.format(pair[0], pair[1])) | |
572 |
|
584 | |||
573 | ax = self.axes[3 * n + 2] |
|
585 | ax = self.axes[3 * n + 2] | |
574 |
|
586 | |||
575 |
|
587 | |||
576 | if ax.firsttime: |
|
588 | if ax.firsttime: | |
577 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
589 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
578 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
590 | self.xmin = self.xmin if self.xmin else -self.xmax | |
579 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
591 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |
580 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
592 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |
581 | ax.plt = ax.pcolormesh(x, y, out_i.T, |
|
593 | ax.plt = ax.pcolormesh(x, y, out_i.T, | |
582 | vmin=-1.e6, |
|
594 | vmin=-1.e6, | |
583 | vmax=1.e6, |
|
595 | vmax=1.e6, | |
584 | cmap=plt.get_cmap(self.colormap) |
|
596 | cmap=plt.get_cmap(self.colormap) | |
585 | ) |
|
597 | ) | |
586 | else: |
|
598 | else: | |
587 | ax.plt.set_array(out_i.T.ravel()) |
|
599 | ax.plt.set_array(out_i.T.ravel()) | |
588 | self.titles.append( |
|
600 | self.titles.append( | |
589 | 'Cross Spectra Imag Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
601 | 'Cross Spectra Imag Ch{} * Ch{}'.format(pair[0], pair[1])) | |
590 |
|
602 | |||
591 | class RTIPlot(Plot): |
|
603 | class RTIPlot(Plot): | |
592 | ''' |
|
604 | ''' | |
593 | Plot for RTI data |
|
605 | Plot for RTI data | |
594 | ''' |
|
606 | ''' | |
595 |
|
607 | |||
596 | CODE = 'rti' |
|
608 | CODE = 'rti' | |
597 | colormap = 'jet' |
|
609 | colormap = 'jet' | |
598 | plot_type = 'pcolorbuffer' |
|
610 | plot_type = 'pcolorbuffer' | |
599 |
|
611 | |||
600 | def setup(self): |
|
612 | def setup(self): | |
601 | self.xaxis = 'time' |
|
613 | self.xaxis = 'time' | |
602 | self.ncols = 1 |
|
614 | self.ncols = 1 | |
603 | self.nrows = len(self.data.channels) |
|
615 | self.nrows = len(self.data.channels) | |
604 | self.nplots = len(self.data.channels) |
|
616 | self.nplots = len(self.data.channels) | |
605 | self.ylabel = 'Range [km]' |
|
617 | self.ylabel = 'Range [km]' | |
606 | self.xlabel = 'Time' |
|
618 | self.xlabel = 'Time' | |
607 | self.cb_label = 'dB' |
|
619 | self.cb_label = 'dB' | |
608 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) |
|
620 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) | |
609 | self.titles = ['{} Channel {}'.format( |
|
621 | self.titles = ['{} Channel {}'.format( | |
610 | self.CODE.upper(), x) for x in range(self.nrows)] |
|
622 | self.CODE.upper(), x) for x in range(self.nrows)] | |
611 |
|
623 | |||
612 | def update(self, dataOut): |
|
624 | def update(self, dataOut): | |
613 |
|
625 | |||
614 | data = {} |
|
626 | data = {} | |
615 | meta = {} |
|
627 | meta = {} | |
616 | data['rti'] = dataOut.getPower() |
|
628 | data['rti'] = dataOut.getPower() | |
617 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
629 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) | |
618 |
|
630 | |||
619 | return data, meta |
|
631 | return data, meta | |
620 |
|
632 | |||
621 | def plot(self): |
|
633 | def plot(self): | |
622 |
|
634 | |||
623 | self.x = self.data.times |
|
635 | self.x = self.data.times | |
624 | self.y = self.data.yrange |
|
636 | self.y = self.data.yrange | |
625 | self.z = self.data[self.CODE] |
|
637 | self.z = self.data[self.CODE] | |
626 | self.z = numpy.ma.masked_invalid(self.z) |
|
638 | self.z = numpy.ma.masked_invalid(self.z) | |
627 |
|
639 | |||
628 | if self.decimation is None: |
|
640 | if self.decimation is None: | |
629 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
641 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
630 | else: |
|
642 | else: | |
631 | x, y, z = self.fill_gaps(*self.decimate()) |
|
643 | x, y, z = self.fill_gaps(*self.decimate()) | |
632 |
|
644 | |||
633 | for n, ax in enumerate(self.axes): |
|
645 | for n, ax in enumerate(self.axes): | |
634 |
|
646 | |||
635 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) |
|
647 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) | |
636 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) |
|
648 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) | |
637 | data = self.data[-1] |
|
649 | data = self.data[-1] | |
638 | if ax.firsttime: |
|
650 | if ax.firsttime: | |
639 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
651 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
640 | vmin=self.zmin, |
|
652 | vmin=self.zmin, | |
641 | vmax=self.zmax, |
|
653 | vmax=self.zmax, | |
642 | cmap=plt.get_cmap(self.colormap) |
|
654 | cmap=plt.get_cmap(self.colormap) | |
643 | ) |
|
655 | ) | |
644 | if self.showprofile: |
|
656 | if self.showprofile: | |
645 | ax.plot_profile = self.pf_axes[n].plot( |
|
657 | ax.plot_profile = self.pf_axes[n].plot( | |
646 | data['rti'][n], self.y)[0] |
|
658 | data['rti'][n], self.y)[0] | |
647 | ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(data['noise'][n], len(self.y)), self.y, |
|
659 | ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(data['noise'][n], len(self.y)), self.y, | |
648 | color="k", linestyle="dashed", lw=1)[0] |
|
660 | color="k", linestyle="dashed", lw=1)[0] | |
649 | else: |
|
661 | else: | |
650 | ax.collections.remove(ax.collections[0]) |
|
662 | ax.collections.remove(ax.collections[0]) | |
651 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
663 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
652 | vmin=self.zmin, |
|
664 | vmin=self.zmin, | |
653 | vmax=self.zmax, |
|
665 | vmax=self.zmax, | |
654 | cmap=plt.get_cmap(self.colormap) |
|
666 | cmap=plt.get_cmap(self.colormap) | |
655 | ) |
|
667 | ) | |
656 | if self.showprofile: |
|
668 | if self.showprofile: | |
657 | ax.plot_profile.set_data(data['rti'][n], self.y) |
|
669 | ax.plot_profile.set_data(data['rti'][n], self.y) | |
658 | ax.plot_noise.set_data(numpy.repeat( |
|
670 | ax.plot_noise.set_data(numpy.repeat( | |
659 | data['noise'][n], len(self.y)), self.y) |
|
671 | data['noise'][n], len(self.y)), self.y) | |
660 |
|
672 | |||
661 | class SpectrogramPlot(Plot): |
|
673 | class SpectrogramPlot(Plot): | |
662 | ''' |
|
674 | ''' | |
663 | Plot for Spectrogram data |
|
675 | Plot for Spectrogram data | |
664 | ''' |
|
676 | ''' | |
665 |
|
677 | |||
666 | CODE = 'Spectrogram_Profile' |
|
678 | CODE = 'Spectrogram_Profile' | |
667 | colormap = 'binary' |
|
679 | colormap = 'binary' | |
668 | plot_type = 'pcolorbuffer' |
|
680 | plot_type = 'pcolorbuffer' | |
669 |
|
681 | |||
670 | def setup(self): |
|
682 | def setup(self): | |
671 | self.xaxis = 'time' |
|
683 | self.xaxis = 'time' | |
672 | self.ncols = 1 |
|
684 | self.ncols = 1 | |
673 | self.nrows = len(self.data.channels) |
|
685 | self.nrows = len(self.data.channels) | |
674 | self.nplots = len(self.data.channels) |
|
686 | self.nplots = len(self.data.channels) | |
675 | self.xlabel = 'Time' |
|
687 | self.xlabel = 'Time' | |
676 | self.plots_adjust.update({'hspace':1.2, 'left': 0.1, 'bottom': 0.12, 'right':0.95}) |
|
688 | self.plots_adjust.update({'hspace':1.2, 'left': 0.1, 'bottom': 0.12, 'right':0.95}) | |
677 | self.titles = [] |
|
689 | self.titles = [] | |
678 |
|
690 | |||
679 | self.titles = ['{} Channel {}'.format( |
|
691 | self.titles = ['{} Channel {}'.format( | |
680 | self.CODE.upper(), x) for x in range(self.nrows)] |
|
692 | self.CODE.upper(), x) for x in range(self.nrows)] | |
681 |
|
693 | |||
682 |
|
694 | |||
683 | def update(self, dataOut): |
|
695 | def update(self, dataOut): | |
684 | data = {} |
|
696 | data = {} | |
685 | meta = {} |
|
697 | meta = {} | |
686 |
|
698 | |||
687 | maxHei = 1620#+12000 |
|
699 | maxHei = 1620#+12000 | |
688 | indb = numpy.where(dataOut.heightList <= maxHei) |
|
700 | indb = numpy.where(dataOut.heightList <= maxHei) | |
689 | hei = indb[0][-1] |
|
701 | hei = indb[0][-1] | |
690 |
|
702 | |||
691 | factor = dataOut.nIncohInt |
|
703 | factor = dataOut.nIncohInt | |
692 | z = dataOut.data_spc[:,:,hei] / factor |
|
704 | z = dataOut.data_spc[:,:,hei] / factor | |
693 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
705 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
694 |
|
706 | |||
695 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
707 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |
696 | data['Spectrogram_Profile'] = 10 * numpy.log10(z) |
|
708 | data['Spectrogram_Profile'] = 10 * numpy.log10(z) | |
697 |
|
709 | |||
698 | data['hei'] = hei |
|
710 | data['hei'] = hei | |
699 | data['DH'] = (dataOut.heightList[1] - dataOut.heightList[0])/dataOut.step |
|
711 | data['DH'] = (dataOut.heightList[1] - dataOut.heightList[0])/dataOut.step | |
700 | data['nProfiles'] = dataOut.nProfiles |
|
712 | data['nProfiles'] = dataOut.nProfiles | |
701 |
|
713 | |||
702 | return data, meta |
|
714 | return data, meta | |
703 |
|
715 | |||
704 | def plot(self): |
|
716 | def plot(self): | |
705 |
|
717 | |||
706 | self.x = self.data.times |
|
718 | self.x = self.data.times | |
707 | self.z = self.data[self.CODE] |
|
719 | self.z = self.data[self.CODE] | |
708 | self.y = self.data.xrange[0] |
|
720 | self.y = self.data.xrange[0] | |
709 |
|
721 | |||
710 | hei = self.data['hei'][-1] |
|
722 | hei = self.data['hei'][-1] | |
711 | DH = self.data['DH'][-1] |
|
723 | DH = self.data['DH'][-1] | |
712 | nProfiles = self.data['nProfiles'][-1] |
|
724 | nProfiles = self.data['nProfiles'][-1] | |
713 |
|
725 | |||
714 | self.ylabel = "Frequency (kHz)" |
|
726 | self.ylabel = "Frequency (kHz)" | |
715 |
|
727 | |||
716 | self.z = numpy.ma.masked_invalid(self.z) |
|
728 | self.z = numpy.ma.masked_invalid(self.z) | |
717 |
|
729 | |||
718 | if self.decimation is None: |
|
730 | if self.decimation is None: | |
719 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
731 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
720 | else: |
|
732 | else: | |
721 | x, y, z = self.fill_gaps(*self.decimate()) |
|
733 | x, y, z = self.fill_gaps(*self.decimate()) | |
722 |
|
734 | |||
723 | for n, ax in enumerate(self.axes): |
|
735 | for n, ax in enumerate(self.axes): | |
724 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) |
|
736 | 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) |
|
737 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) | |
726 | data = self.data[-1] |
|
738 | data = self.data[-1] | |
727 | if ax.firsttime: |
|
739 | if ax.firsttime: | |
728 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
740 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
729 | vmin=self.zmin, |
|
741 | vmin=self.zmin, | |
730 | vmax=self.zmax, |
|
742 | vmax=self.zmax, | |
731 | cmap=plt.get_cmap(self.colormap) |
|
743 | cmap=plt.get_cmap(self.colormap) | |
732 | ) |
|
744 | ) | |
733 | else: |
|
745 | else: | |
734 | ax.collections.remove(ax.collections[0]) |
|
746 | ax.collections.remove(ax.collections[0]) | |
735 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
747 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
736 | vmin=self.zmin, |
|
748 | vmin=self.zmin, | |
737 | vmax=self.zmax, |
|
749 | vmax=self.zmax, | |
738 | cmap=plt.get_cmap(self.colormap) |
|
750 | cmap=plt.get_cmap(self.colormap) | |
739 | ) |
|
751 | ) | |
740 |
|
752 | |||
741 |
|
753 | |||
742 |
|
754 | |||
743 | class CoherencePlot(RTIPlot): |
|
755 | class CoherencePlot(RTIPlot): | |
744 | ''' |
|
756 | ''' | |
745 | Plot for Coherence data |
|
757 | Plot for Coherence data | |
746 | ''' |
|
758 | ''' | |
747 |
|
759 | |||
748 | CODE = 'coh' |
|
760 | CODE = 'coh' | |
749 |
|
761 | |||
750 | def setup(self): |
|
762 | def setup(self): | |
751 | self.xaxis = 'time' |
|
763 | self.xaxis = 'time' | |
752 | self.ncols = 1 |
|
764 | self.ncols = 1 | |
753 | self.nrows = len(self.data.pairs) |
|
765 | self.nrows = len(self.data.pairs) | |
754 | self.nplots = len(self.data.pairs) |
|
766 | self.nplots = len(self.data.pairs) | |
755 | self.ylabel = 'Range [km]' |
|
767 | self.ylabel = 'Range [km]' | |
756 | self.xlabel = 'Time' |
|
768 | self.xlabel = 'Time' | |
757 | self.plots_adjust.update({'hspace':0.6, 'left': 0.1, 'bottom': 0.1,'right':0.95}) |
|
769 | self.plots_adjust.update({'hspace':0.6, 'left': 0.1, 'bottom': 0.1,'right':0.95}) | |
758 | if self.CODE == 'coh': |
|
770 | if self.CODE == 'coh': | |
759 | self.cb_label = '' |
|
771 | self.cb_label = '' | |
760 | self.titles = [ |
|
772 | self.titles = [ | |
761 | 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] |
|
773 | 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] | |
762 | else: |
|
774 | else: | |
763 | self.cb_label = 'Degrees' |
|
775 | self.cb_label = 'Degrees' | |
764 | self.titles = [ |
|
776 | self.titles = [ | |
765 | 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] |
|
777 | 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] | |
766 |
|
778 | |||
767 | def update(self, dataOut): |
|
779 | def update(self, dataOut): | |
768 |
|
780 | |||
769 | data = {} |
|
781 | data = {} | |
770 | meta = {} |
|
782 | meta = {} | |
771 | data['coh'] = dataOut.getCoherence() |
|
783 | data['coh'] = dataOut.getCoherence() | |
772 | meta['pairs'] = dataOut.pairsList |
|
784 | meta['pairs'] = dataOut.pairsList | |
773 |
|
785 | |||
774 | return data, meta |
|
786 | return data, meta | |
775 |
|
787 | |||
776 | class PhasePlot(CoherencePlot): |
|
788 | class PhasePlot(CoherencePlot): | |
777 | ''' |
|
789 | ''' | |
778 | Plot for Phase map data |
|
790 | Plot for Phase map data | |
779 | ''' |
|
791 | ''' | |
780 |
|
792 | |||
781 | CODE = 'phase' |
|
793 | CODE = 'phase' | |
782 | colormap = 'seismic' |
|
794 | colormap = 'seismic' | |
783 |
|
795 | |||
784 | def update(self, dataOut): |
|
796 | def update(self, dataOut): | |
785 |
|
797 | |||
786 | data = {} |
|
798 | data = {} | |
787 | meta = {} |
|
799 | meta = {} | |
788 | data['phase'] = dataOut.getCoherence(phase=True) |
|
800 | data['phase'] = dataOut.getCoherence(phase=True) | |
789 | meta['pairs'] = dataOut.pairsList |
|
801 | meta['pairs'] = dataOut.pairsList | |
790 |
|
802 | |||
791 | return data, meta |
|
803 | return data, meta | |
792 |
|
804 | |||
793 | class NoisePlot(Plot): |
|
805 | class NoisePlot(Plot): | |
794 | ''' |
|
806 | ''' | |
795 | Plot for noise |
|
807 | Plot for noise | |
796 | ''' |
|
808 | ''' | |
797 |
|
809 | |||
798 | CODE = 'noise' |
|
810 | CODE = 'noise' | |
799 | plot_type = 'scatterbuffer' |
|
811 | plot_type = 'scatterbuffer' | |
800 |
|
812 | |||
801 | def setup(self): |
|
813 | def setup(self): | |
802 | self.xaxis = 'time' |
|
814 | self.xaxis = 'time' | |
803 | self.ncols = 1 |
|
815 | self.ncols = 1 | |
804 | self.nrows = 1 |
|
816 | self.nrows = 1 | |
805 | self.nplots = 1 |
|
817 | self.nplots = 1 | |
806 | self.ylabel = 'Intensity [dB]' |
|
818 | self.ylabel = 'Intensity [dB]' | |
807 | self.xlabel = 'Time' |
|
819 | self.xlabel = 'Time' | |
808 | self.titles = ['Noise'] |
|
820 | self.titles = ['Noise'] | |
809 | self.colorbar = False |
|
821 | self.colorbar = False | |
810 | self.plots_adjust.update({'right': 0.85 }) |
|
822 | self.plots_adjust.update({'right': 0.85 }) | |
811 |
|
823 | |||
812 | def update(self, dataOut): |
|
824 | def update(self, dataOut): | |
813 |
|
825 | |||
814 | data = {} |
|
826 | data = {} | |
815 | meta = {} |
|
827 | meta = {} | |
816 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor).reshape(dataOut.nChannels, 1) |
|
828 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor).reshape(dataOut.nChannels, 1) | |
817 | meta['yrange'] = numpy.array([]) |
|
829 | meta['yrange'] = numpy.array([]) | |
818 |
|
830 | |||
819 | return data, meta |
|
831 | return data, meta | |
820 |
|
832 | |||
821 | def plot(self): |
|
833 | def plot(self): | |
822 |
|
834 | |||
823 | x = self.data.times |
|
835 | x = self.data.times | |
824 | xmin = self.data.min_time |
|
836 | xmin = self.data.min_time | |
825 | xmax = xmin + self.xrange * 60 * 60 |
|
837 | xmax = xmin + self.xrange * 60 * 60 | |
826 | Y = self.data['noise'] |
|
838 | Y = self.data['noise'] | |
827 |
|
839 | |||
828 | if self.axes[0].firsttime: |
|
840 | if self.axes[0].firsttime: | |
829 | self.ymin = numpy.nanmin(Y) - 5 |
|
841 | self.ymin = numpy.nanmin(Y) - 5 | |
830 | self.ymax = numpy.nanmax(Y) + 5 |
|
842 | self.ymax = numpy.nanmax(Y) + 5 | |
831 | for ch in self.data.channels: |
|
843 | for ch in self.data.channels: | |
832 | y = Y[ch] |
|
844 | y = Y[ch] | |
833 | self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch)) |
|
845 | self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch)) | |
834 | plt.legend(bbox_to_anchor=(1.18, 1.0)) |
|
846 | plt.legend(bbox_to_anchor=(1.18, 1.0)) | |
835 | else: |
|
847 | else: | |
836 | for ch in self.data.channels: |
|
848 | for ch in self.data.channels: | |
837 | y = Y[ch] |
|
849 | y = Y[ch] | |
838 | self.axes[0].lines[ch].set_data(x, y) |
|
850 | self.axes[0].lines[ch].set_data(x, y) | |
839 |
|
851 | |||
840 | class PowerProfilePlot(Plot): |
|
852 | class PowerProfilePlot(Plot): | |
841 |
|
853 | |||
842 | CODE = 'pow_profile' |
|
854 | CODE = 'pow_profile' | |
843 | plot_type = 'scatter' |
|
855 | plot_type = 'scatter' | |
844 |
|
856 | |||
845 | def setup(self): |
|
857 | def setup(self): | |
846 |
|
858 | |||
847 | self.ncols = 1 |
|
859 | self.ncols = 1 | |
848 | self.nrows = 1 |
|
860 | self.nrows = 1 | |
849 | self.nplots = 1 |
|
861 | self.nplots = 1 | |
850 | self.height = 4 |
|
862 | self.height = 4 | |
851 | self.width = 3 |
|
863 | self.width = 3 | |
852 | self.ylabel = 'Range [km]' |
|
864 | self.ylabel = 'Range [km]' | |
853 | self.xlabel = 'Intensity [dB]' |
|
865 | self.xlabel = 'Intensity [dB]' | |
854 | self.titles = ['Power Profile'] |
|
866 | self.titles = ['Power Profile'] | |
855 | self.colorbar = False |
|
867 | self.colorbar = False | |
856 |
|
868 | |||
857 | def update(self, dataOut): |
|
869 | def update(self, dataOut): | |
858 |
|
870 | |||
859 | data = {} |
|
871 | data = {} | |
860 | meta = {} |
|
872 | meta = {} | |
861 | data[self.CODE] = dataOut.getPower() |
|
873 | data[self.CODE] = dataOut.getPower() | |
862 |
|
874 | |||
863 | return data, meta |
|
875 | return data, meta | |
864 |
|
876 | |||
865 | def plot(self): |
|
877 | def plot(self): | |
866 |
|
878 | |||
867 | y = self.data.yrange |
|
879 | y = self.data.yrange | |
868 | self.y = y |
|
880 | self.y = y | |
869 |
|
881 | |||
870 | x = self.data[-1][self.CODE] |
|
882 | x = self.data[-1][self.CODE] | |
871 |
|
883 | |||
872 | if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9 |
|
884 | if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9 | |
873 | if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1 |
|
885 | if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1 | |
874 |
|
886 | |||
875 | if self.axes[0].firsttime: |
|
887 | if self.axes[0].firsttime: | |
876 | for ch in self.data.channels: |
|
888 | for ch in self.data.channels: | |
877 | self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch)) |
|
889 | self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch)) | |
878 | plt.legend() |
|
890 | plt.legend() | |
879 | else: |
|
891 | else: | |
880 | for ch in self.data.channels: |
|
892 | for ch in self.data.channels: | |
881 | self.axes[0].lines[ch].set_data(x[ch], y) |
|
893 | self.axes[0].lines[ch].set_data(x[ch], y) | |
882 |
|
894 | |||
883 |
|
895 | |||
884 | class SpectraCutPlot(Plot): |
|
896 | class SpectraCutPlot(Plot): | |
885 |
|
897 | |||
886 | CODE = 'spc_cut' |
|
898 | CODE = 'spc_cut' | |
887 | plot_type = 'scatter' |
|
899 | plot_type = 'scatter' | |
888 | buffering = False |
|
900 | buffering = False | |
889 |
|
901 | |||
890 | def setup(self): |
|
902 | def setup(self): | |
891 |
|
903 | |||
892 | self.nplots = len(self.data.channels) |
|
904 | self.nplots = len(self.data.channels) | |
893 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
905 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) | |
894 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
906 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) | |
895 | self.width = 3.4 * self.ncols + 1.5 |
|
907 | self.width = 3.4 * self.ncols + 1.5 | |
896 | self.height = 3 * self.nrows |
|
908 | self.height = 3 * self.nrows | |
897 | self.ylabel = 'Power [dB]' |
|
909 | self.ylabel = 'Power [dB]' | |
898 | self.colorbar = False |
|
910 | self.colorbar = False | |
899 | self.plots_adjust.update({'left':0.1, 'hspace':0.3, 'right': 0.75, 'bottom':0.08}) |
|
911 | self.plots_adjust.update({'left':0.1, 'hspace':0.3, 'right': 0.75, 'bottom':0.08}) | |
900 |
|
912 | |||
901 | def update(self, dataOut): |
|
913 | def update(self, dataOut): | |
902 |
|
914 | |||
903 | data = {} |
|
915 | data = {} | |
904 | meta = {} |
|
916 | meta = {} | |
905 | try: |
|
917 | try: | |
906 | spc = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor) |
|
918 | spc = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor) | |
907 | except: |
|
919 | except: | |
908 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) |
|
920 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) | |
909 | data['spc'] = spc |
|
921 | data['spc'] = spc | |
910 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
922 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |
911 | if self.CODE == 'cut_gaussian_fit': |
|
923 | if self.CODE == 'cut_gaussian_fit': | |
912 | data['gauss_fit0'] = 10*numpy.log10(dataOut.GaussFit0/dataOut.normFactor) |
|
924 | data['gauss_fit0'] = 10*numpy.log10(dataOut.GaussFit0/dataOut.normFactor) | |
913 | data['gauss_fit1'] = 10*numpy.log10(dataOut.GaussFit1/dataOut.normFactor) |
|
925 | data['gauss_fit1'] = 10*numpy.log10(dataOut.GaussFit1/dataOut.normFactor) | |
914 | return data, meta |
|
926 | return data, meta | |
915 |
|
927 | |||
916 | def plot(self): |
|
928 | def plot(self): | |
917 | if self.xaxis == "frequency": |
|
929 | if self.xaxis == "frequency": | |
918 | x = self.data.xrange[0][1:] |
|
930 | x = self.data.xrange[0][1:] | |
919 | self.xlabel = "Frequency (kHz)" |
|
931 | self.xlabel = "Frequency (kHz)" | |
920 | elif self.xaxis == "time": |
|
932 | elif self.xaxis == "time": | |
921 | x = self.data.xrange[1] |
|
933 | x = self.data.xrange[1] | |
922 | self.xlabel = "Time (ms)" |
|
934 | self.xlabel = "Time (ms)" | |
923 | else: |
|
935 | else: | |
924 | x = self.data.xrange[2][:-1] |
|
936 | x = self.data.xrange[2][:-1] | |
925 | self.xlabel = "Velocity (m/s)" |
|
937 | self.xlabel = "Velocity (m/s)" | |
926 |
|
938 | |||
927 | if self.CODE == 'cut_gaussian_fit': |
|
939 | if self.CODE == 'cut_gaussian_fit': | |
928 | x = self.data.xrange[2][:-1] |
|
940 | x = self.data.xrange[2][:-1] | |
929 | self.xlabel = "Velocity (m/s)" |
|
941 | self.xlabel = "Velocity (m/s)" | |
930 |
|
942 | |||
931 | self.titles = [] |
|
943 | self.titles = [] | |
932 |
|
944 | |||
933 | y = self.data.yrange |
|
945 | y = self.data.yrange | |
934 | data = self.data[-1] |
|
946 | data = self.data[-1] | |
935 | z = data['spc'] |
|
947 | z = data['spc'] | |
936 |
|
948 | |||
937 | if self.height_index: |
|
949 | if self.height_index: | |
938 | index = numpy.array(self.height_index) |
|
950 | index = numpy.array(self.height_index) | |
939 | else: |
|
951 | else: | |
940 | index = numpy.arange(0, len(y), int((len(y))/9)) |
|
952 | index = numpy.arange(0, len(y), int((len(y))/9)) | |
941 |
|
953 | |||
942 | for n, ax in enumerate(self.axes): |
|
954 | for n, ax in enumerate(self.axes): | |
943 | if self.CODE == 'cut_gaussian_fit': |
|
955 | if self.CODE == 'cut_gaussian_fit': | |
944 | gau0 = data['gauss_fit0'] |
|
956 | gau0 = data['gauss_fit0'] | |
945 | gau1 = data['gauss_fit1'] |
|
957 | gau1 = data['gauss_fit1'] | |
946 | if ax.firsttime: |
|
958 | if ax.firsttime: | |
947 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
959 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
948 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
960 | self.xmin = self.xmin if self.xmin else -self.xmax | |
949 | self.ymin = self.ymin if self.ymin else numpy.nanmin(z[:,:,index]) |
|
961 | self.ymin = self.ymin if self.ymin else numpy.nanmin(z[:,:,index]) | |
950 | self.ymax = self.ymax if self.ymax else numpy.nanmax(z[:,:,index]) |
|
962 | self.ymax = self.ymax if self.ymax else numpy.nanmax(z[:,:,index]) | |
951 | ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25) |
|
963 | ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25) | |
952 | if self.CODE == 'cut_gaussian_fit': |
|
964 | if self.CODE == 'cut_gaussian_fit': | |
953 | ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.') |
|
965 | ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.') | |
954 | for i, line in enumerate(ax.plt_gau0): |
|
966 | for i, line in enumerate(ax.plt_gau0): | |
955 | line.set_color(ax.plt[i].get_color()) |
|
967 | line.set_color(ax.plt[i].get_color()) | |
956 | ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--') |
|
968 | ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--') | |
957 | for i, line in enumerate(ax.plt_gau1): |
|
969 | for i, line in enumerate(ax.plt_gau1): | |
958 | line.set_color(ax.plt[i].get_color()) |
|
970 | line.set_color(ax.plt[i].get_color()) | |
959 | labels = ['Range = {:2.1f}km'.format(y[i]) for i in index] |
|
971 | labels = ['Range = {:2.1f}km'.format(y[i]) for i in index] | |
960 | self.figures[0].legend(ax.plt, labels, loc='center right') |
|
972 | self.figures[0].legend(ax.plt, labels, loc='center right') | |
961 | else: |
|
973 | else: | |
962 | for i, line in enumerate(ax.plt): |
|
974 | for i, line in enumerate(ax.plt): | |
963 | line.set_data(x, z[n, :, index[i]].T) |
|
975 | line.set_data(x, z[n, :, index[i]].T) | |
964 | for i, line in enumerate(ax.plt_gau0): |
|
976 | for i, line in enumerate(ax.plt_gau0): | |
965 | line.set_data(x, gau0[n, :, index[i]].T) |
|
977 | line.set_data(x, gau0[n, :, index[i]].T) | |
966 | line.set_color(ax.plt[i].get_color()) |
|
978 | line.set_color(ax.plt[i].get_color()) | |
967 | for i, line in enumerate(ax.plt_gau1): |
|
979 | for i, line in enumerate(ax.plt_gau1): | |
968 | line.set_data(x, gau1[n, :, index[i]].T) |
|
980 | line.set_data(x, gau1[n, :, index[i]].T) | |
969 | line.set_color(ax.plt[i].get_color()) |
|
981 | line.set_color(ax.plt[i].get_color()) | |
970 | self.titles.append('CH {}'.format(n)) |
|
982 | self.titles.append('CH {}'.format(n)) | |
971 |
|
983 | |||
972 |
|
984 | |||
973 | class BeaconPhase(Plot): |
|
985 | class BeaconPhase(Plot): | |
974 |
|
986 | |||
975 | __isConfig = None |
|
987 | __isConfig = None | |
976 | __nsubplots = None |
|
988 | __nsubplots = None | |
977 |
|
989 | |||
978 | PREFIX = 'beacon_phase' |
|
990 | PREFIX = 'beacon_phase' | |
979 |
|
991 | |||
980 | def __init__(self): |
|
992 | def __init__(self): | |
981 | Plot.__init__(self) |
|
993 | Plot.__init__(self) | |
982 | self.timerange = 24*60*60 |
|
994 | self.timerange = 24*60*60 | |
983 | self.isConfig = False |
|
995 | self.isConfig = False | |
984 | self.__nsubplots = 1 |
|
996 | self.__nsubplots = 1 | |
985 | self.counter_imagwr = 0 |
|
997 | self.counter_imagwr = 0 | |
986 | self.WIDTH = 800 |
|
998 | self.WIDTH = 800 | |
987 | self.HEIGHT = 400 |
|
999 | self.HEIGHT = 400 | |
988 | self.WIDTHPROF = 120 |
|
1000 | self.WIDTHPROF = 120 | |
989 | self.HEIGHTPROF = 0 |
|
1001 | self.HEIGHTPROF = 0 | |
990 | self.xdata = None |
|
1002 | self.xdata = None | |
991 | self.ydata = None |
|
1003 | self.ydata = None | |
992 |
|
1004 | |||
993 | self.PLOT_CODE = BEACON_CODE |
|
1005 | self.PLOT_CODE = BEACON_CODE | |
994 |
|
1006 | |||
995 | self.FTP_WEI = None |
|
1007 | self.FTP_WEI = None | |
996 | self.EXP_CODE = None |
|
1008 | self.EXP_CODE = None | |
997 | self.SUB_EXP_CODE = None |
|
1009 | self.SUB_EXP_CODE = None | |
998 | self.PLOT_POS = None |
|
1010 | self.PLOT_POS = None | |
999 |
|
1011 | |||
1000 | self.filename_phase = None |
|
1012 | self.filename_phase = None | |
1001 |
|
1013 | |||
1002 | self.figfile = None |
|
1014 | self.figfile = None | |
1003 |
|
1015 | |||
1004 | self.xmin = None |
|
1016 | self.xmin = None | |
1005 | self.xmax = None |
|
1017 | self.xmax = None | |
1006 |
|
1018 | |||
1007 | def getSubplots(self): |
|
1019 | def getSubplots(self): | |
1008 |
|
1020 | |||
1009 | ncol = 1 |
|
1021 | ncol = 1 | |
1010 | nrow = 1 |
|
1022 | nrow = 1 | |
1011 |
|
1023 | |||
1012 | return nrow, ncol |
|
1024 | return nrow, ncol | |
1013 |
|
1025 | |||
1014 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1026 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1015 |
|
1027 | |||
1016 | self.__showprofile = showprofile |
|
1028 | self.__showprofile = showprofile | |
1017 | self.nplots = nplots |
|
1029 | self.nplots = nplots | |
1018 |
|
1030 | |||
1019 | ncolspan = 7 |
|
1031 | ncolspan = 7 | |
1020 | colspan = 6 |
|
1032 | colspan = 6 | |
1021 | self.__nsubplots = 2 |
|
1033 | self.__nsubplots = 2 | |
1022 |
|
1034 | |||
1023 | self.createFigure(id = id, |
|
1035 | self.createFigure(id = id, | |
1024 | wintitle = wintitle, |
|
1036 | wintitle = wintitle, | |
1025 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1037 | widthplot = self.WIDTH+self.WIDTHPROF, | |
1026 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1038 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
1027 | show=show) |
|
1039 | show=show) | |
1028 |
|
1040 | |||
1029 | nrow, ncol = self.getSubplots() |
|
1041 | nrow, ncol = self.getSubplots() | |
1030 |
|
1042 | |||
1031 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1043 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
1032 |
|
1044 | |||
1033 | def save_phase(self, filename_phase): |
|
1045 | def save_phase(self, filename_phase): | |
1034 | f = open(filename_phase,'w+') |
|
1046 | f = open(filename_phase,'w+') | |
1035 | f.write('\n\n') |
|
1047 | f.write('\n\n') | |
1036 | f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n') |
|
1048 | f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n') | |
1037 | f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' ) |
|
1049 | f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' ) | |
1038 | f.close() |
|
1050 | f.close() | |
1039 |
|
1051 | |||
1040 | def save_data(self, filename_phase, data, data_datetime): |
|
1052 | def save_data(self, filename_phase, data, data_datetime): | |
1041 | f=open(filename_phase,'a') |
|
1053 | f=open(filename_phase,'a') | |
1042 | timetuple_data = data_datetime.timetuple() |
|
1054 | timetuple_data = data_datetime.timetuple() | |
1043 | day = str(timetuple_data.tm_mday) |
|
1055 | day = str(timetuple_data.tm_mday) | |
1044 | month = str(timetuple_data.tm_mon) |
|
1056 | month = str(timetuple_data.tm_mon) | |
1045 | year = str(timetuple_data.tm_year) |
|
1057 | year = str(timetuple_data.tm_year) | |
1046 | hour = str(timetuple_data.tm_hour) |
|
1058 | hour = str(timetuple_data.tm_hour) | |
1047 | minute = str(timetuple_data.tm_min) |
|
1059 | minute = str(timetuple_data.tm_min) | |
1048 | second = str(timetuple_data.tm_sec) |
|
1060 | second = str(timetuple_data.tm_sec) | |
1049 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') |
|
1061 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') | |
1050 | f.close() |
|
1062 | f.close() | |
1051 |
|
1063 | |||
1052 | def plot(self): |
|
1064 | def plot(self): | |
1053 | log.warning('TODO: Not yet implemented...') |
|
1065 | log.warning('TODO: Not yet implemented...') | |
1054 |
|
1066 | |||
1055 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
1067 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
1056 | xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None, |
|
1068 | xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None, | |
1057 | timerange=None, |
|
1069 | timerange=None, | |
1058 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1070 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
1059 | server=None, folder=None, username=None, password=None, |
|
1071 | server=None, folder=None, username=None, password=None, | |
1060 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1072 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1061 |
|
1073 | |||
1062 | if dataOut.flagNoData: |
|
1074 | if dataOut.flagNoData: | |
1063 | return dataOut |
|
1075 | return dataOut | |
1064 |
|
1076 | |||
1065 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
1077 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | |
1066 | return |
|
1078 | return | |
1067 |
|
1079 | |||
1068 | if pairsList == None: |
|
1080 | if pairsList == None: | |
1069 | pairsIndexList = dataOut.pairsIndexList[:10] |
|
1081 | pairsIndexList = dataOut.pairsIndexList[:10] | |
1070 | else: |
|
1082 | else: | |
1071 | pairsIndexList = [] |
|
1083 | pairsIndexList = [] | |
1072 | for pair in pairsList: |
|
1084 | for pair in pairsList: | |
1073 | if pair not in dataOut.pairsList: |
|
1085 | if pair not in dataOut.pairsList: | |
1074 | raise ValueError("Pair %s is not in dataOut.pairsList" %(pair)) |
|
1086 | raise ValueError("Pair %s is not in dataOut.pairsList" %(pair)) | |
1075 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
1087 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
1076 |
|
1088 | |||
1077 | if pairsIndexList == []: |
|
1089 | if pairsIndexList == []: | |
1078 | return |
|
1090 | return | |
1079 |
|
1091 | |||
1080 | # if len(pairsIndexList) > 4: |
|
1092 | # if len(pairsIndexList) > 4: | |
1081 | # pairsIndexList = pairsIndexList[0:4] |
|
1093 | # pairsIndexList = pairsIndexList[0:4] | |
1082 |
|
1094 | |||
1083 | hmin_index = None |
|
1095 | hmin_index = None | |
1084 | hmax_index = None |
|
1096 | hmax_index = None | |
1085 |
|
1097 | |||
1086 | if hmin != None and hmax != None: |
|
1098 | if hmin != None and hmax != None: | |
1087 | indexes = numpy.arange(dataOut.nHeights) |
|
1099 | indexes = numpy.arange(dataOut.nHeights) | |
1088 | hmin_list = indexes[dataOut.heightList >= hmin] |
|
1100 | hmin_list = indexes[dataOut.heightList >= hmin] | |
1089 | hmax_list = indexes[dataOut.heightList <= hmax] |
|
1101 | hmax_list = indexes[dataOut.heightList <= hmax] | |
1090 |
|
1102 | |||
1091 | if hmin_list.any(): |
|
1103 | if hmin_list.any(): | |
1092 | hmin_index = hmin_list[0] |
|
1104 | hmin_index = hmin_list[0] | |
1093 |
|
1105 | |||
1094 | if hmax_list.any(): |
|
1106 | if hmax_list.any(): | |
1095 | hmax_index = hmax_list[-1]+1 |
|
1107 | hmax_index = hmax_list[-1]+1 | |
1096 |
|
1108 | |||
1097 | x = dataOut.getTimeRange() |
|
1109 | x = dataOut.getTimeRange() | |
1098 |
|
1110 | |||
1099 | thisDatetime = dataOut.datatime |
|
1111 | thisDatetime = dataOut.datatime | |
1100 |
|
1112 | |||
1101 | title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1113 | title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1102 | xlabel = "Local Time" |
|
1114 | xlabel = "Local Time" | |
1103 | ylabel = "Phase (degrees)" |
|
1115 | ylabel = "Phase (degrees)" | |
1104 |
|
1116 | |||
1105 | update_figfile = False |
|
1117 | update_figfile = False | |
1106 |
|
1118 | |||
1107 | nplots = len(pairsIndexList) |
|
1119 | nplots = len(pairsIndexList) | |
1108 | phase_beacon = numpy.zeros(len(pairsIndexList)) |
|
1120 | phase_beacon = numpy.zeros(len(pairsIndexList)) | |
1109 | for i in range(nplots): |
|
1121 | for i in range(nplots): | |
1110 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
1122 | pair = dataOut.pairsList[pairsIndexList[i]] | |
1111 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0) |
|
1123 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0) | |
1112 | powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0) |
|
1124 | powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0) | |
1113 | powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0) |
|
1125 | powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0) | |
1114 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) |
|
1126 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) | |
1115 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
1127 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
1116 |
|
1128 | |||
1117 | if dataOut.beacon_heiIndexList: |
|
1129 | if dataOut.beacon_heiIndexList: | |
1118 | phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList]) |
|
1130 | phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList]) | |
1119 | else: |
|
1131 | else: | |
1120 | phase_beacon[i] = numpy.average(phase) |
|
1132 | phase_beacon[i] = numpy.average(phase) | |
1121 |
|
1133 | |||
1122 | if not self.isConfig: |
|
1134 | if not self.isConfig: | |
1123 |
|
1135 | |||
1124 | nplots = len(pairsIndexList) |
|
1136 | nplots = len(pairsIndexList) | |
1125 |
|
1137 | |||
1126 | self.setup(id=id, |
|
1138 | self.setup(id=id, | |
1127 | nplots=nplots, |
|
1139 | nplots=nplots, | |
1128 | wintitle=wintitle, |
|
1140 | wintitle=wintitle, | |
1129 | showprofile=showprofile, |
|
1141 | showprofile=showprofile, | |
1130 | show=show) |
|
1142 | show=show) | |
1131 |
|
1143 | |||
1132 | if timerange != None: |
|
1144 | if timerange != None: | |
1133 | self.timerange = timerange |
|
1145 | self.timerange = timerange | |
1134 |
|
1146 | |||
1135 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1147 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1136 |
|
1148 | |||
1137 | if ymin == None: ymin = 0 |
|
1149 | if ymin == None: ymin = 0 | |
1138 | if ymax == None: ymax = 360 |
|
1150 | if ymax == None: ymax = 360 | |
1139 |
|
1151 | |||
1140 | self.FTP_WEI = ftp_wei |
|
1152 | self.FTP_WEI = ftp_wei | |
1141 | self.EXP_CODE = exp_code |
|
1153 | self.EXP_CODE = exp_code | |
1142 | self.SUB_EXP_CODE = sub_exp_code |
|
1154 | self.SUB_EXP_CODE = sub_exp_code | |
1143 | self.PLOT_POS = plot_pos |
|
1155 | self.PLOT_POS = plot_pos | |
1144 |
|
1156 | |||
1145 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1157 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1146 | self.isConfig = True |
|
1158 | self.isConfig = True | |
1147 | self.figfile = figfile |
|
1159 | self.figfile = figfile | |
1148 | self.xdata = numpy.array([]) |
|
1160 | self.xdata = numpy.array([]) | |
1149 | self.ydata = numpy.array([]) |
|
1161 | self.ydata = numpy.array([]) | |
1150 |
|
1162 | |||
1151 | update_figfile = True |
|
1163 | update_figfile = True | |
1152 |
|
1164 | |||
1153 | #open file beacon phase |
|
1165 | #open file beacon phase | |
1154 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1166 | path = '%s%03d' %(self.PREFIX, self.id) | |
1155 | beacon_file = os.path.join(path,'%s.txt'%self.name) |
|
1167 | beacon_file = os.path.join(path,'%s.txt'%self.name) | |
1156 | self.filename_phase = os.path.join(figpath,beacon_file) |
|
1168 | self.filename_phase = os.path.join(figpath,beacon_file) | |
1157 |
|
1169 | |||
1158 | self.setWinTitle(title) |
|
1170 | self.setWinTitle(title) | |
1159 |
|
1171 | |||
1160 |
|
1172 | |||
1161 | title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1173 | title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1162 |
|
1174 | |||
1163 | legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList] |
|
1175 | legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList] | |
1164 |
|
1176 | |||
1165 | axes = self.axesList[0] |
|
1177 | axes = self.axesList[0] | |
1166 |
|
1178 | |||
1167 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1179 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
1168 |
|
1180 | |||
1169 | if len(self.ydata)==0: |
|
1181 | if len(self.ydata)==0: | |
1170 | self.ydata = phase_beacon.reshape(-1,1) |
|
1182 | self.ydata = phase_beacon.reshape(-1,1) | |
1171 | else: |
|
1183 | else: | |
1172 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) |
|
1184 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) | |
1173 |
|
1185 | |||
1174 |
|
1186 | |||
1175 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1187 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1176 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, |
|
1188 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, | |
1177 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1189 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
1178 | XAxisAsTime=True, grid='both' |
|
1190 | XAxisAsTime=True, grid='both' | |
1179 | ) |
|
1191 | ) | |
1180 |
|
1192 | |||
1181 | self.draw() |
|
1193 | self.draw() | |
1182 |
|
1194 | |||
1183 | if dataOut.ltctime >= self.xmax: |
|
1195 | if dataOut.ltctime >= self.xmax: | |
1184 | self.counter_imagwr = wr_period |
|
1196 | self.counter_imagwr = wr_period | |
1185 | self.isConfig = False |
|
1197 | self.isConfig = False | |
1186 | update_figfile = True |
|
1198 | update_figfile = True | |
1187 |
|
1199 | |||
1188 | self.save(figpath=figpath, |
|
1200 | self.save(figpath=figpath, | |
1189 | figfile=figfile, |
|
1201 | figfile=figfile, | |
1190 | save=save, |
|
1202 | save=save, | |
1191 | ftp=ftp, |
|
1203 | ftp=ftp, | |
1192 | wr_period=wr_period, |
|
1204 | wr_period=wr_period, | |
1193 | thisDatetime=thisDatetime, |
|
1205 | thisDatetime=thisDatetime, | |
1194 | update_figfile=update_figfile) |
|
1206 | update_figfile=update_figfile) | |
1195 |
|
1207 | |||
1196 | return dataOut No newline at end of file |
|
1208 | return dataOut |
General Comments 0
You need to be logged in to leave comments.
Login now