##// END OF EJS Templates
fix faraday plots
rflores -
r1733:67f6900b4a62
parent child
Show More
@@ -1,1302 +1,1302
1 # Copyright (c) 2012-2021 Jicamarca Radio Observatory
1 # Copyright (c) 2012-2021 Jicamarca Radio Observatory
2 # All rights reserved.
2 # All rights reserved.
3 #
3 #
4 # Distributed under the terms of the BSD 3-clause license.
4 # Distributed under the terms of the BSD 3-clause license.
5 """Classes to plot Spectra data
5 """Classes to plot Spectra data
6
6
7 """
7 """
8
8
9 import os
9 import os
10 import numpy
10 import numpy
11
11
12 from schainpy.model.graphics.jroplot_base import Plot, plt, log
12 from schainpy.model.graphics.jroplot_base import Plot, plt, log
13
13
14 from matplotlib import __version__ as plt_version
14 from matplotlib import __version__ as plt_version
15
15
16 if plt_version >='3.3.4':
16 if plt_version >='3.3.4':
17 EXTRA_POINTS = 0
17 EXTRA_POINTS = 0
18 else:
18 else:
19 EXTRA_POINTS = 1
19 EXTRA_POINTS = 1
20
20
21
21
22 class SpectraPlot(Plot):
22 class SpectraPlot(Plot):
23 '''
23 '''
24 Plot for Spectra data
24 Plot for Spectra data
25 '''
25 '''
26
26
27 CODE = 'spc'
27 CODE = 'spc'
28 colormap = 'jet'
28 colormap = 'jet'
29 plot_type = 'pcolor'
29 plot_type = 'pcolor'
30 buffering = False
30 buffering = False
31
31
32 def setup(self):
32 def setup(self):
33
33
34 self.nplots = len(self.data.channels)
34 self.nplots = len(self.data.channels)
35 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
35 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
36 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
36 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
37 self.height = 2.6 * self.nrows
37 self.height = 2.6 * self.nrows
38 self.cb_label = 'dB'
38 self.cb_label = 'dB'
39 if self.showprofile:
39 if self.showprofile:
40 self.width = 4 * self.ncols
40 self.width = 4 * self.ncols
41 else:
41 else:
42 self.width = 3.5 * self.ncols
42 self.width = 3.5 * self.ncols
43 self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18})
43 self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18})
44 self.ylabel = 'Range [km]'
44 self.ylabel = 'Range [km]'
45
45
46 def update(self, dataOut):
46 def update(self, dataOut):
47
47
48 data = {}
48 data = {}
49 meta = {}
49 meta = {}
50 spc = 10 * numpy.log10(dataOut.data_spc / dataOut.normFactor)
50 spc = 10 * numpy.log10(dataOut.data_spc / dataOut.normFactor)
51 data['spc'] = spc
51 data['spc'] = spc
52 data['rti'] = dataOut.getPower()
52 data['rti'] = dataOut.getPower()
53 if hasattr(dataOut, 'LagPlot'): #Double Pulse
53 if hasattr(dataOut, 'LagPlot'): #Double Pulse
54 max_hei_id = dataOut.nHeights - 2*dataOut.LagPlot
54 max_hei_id = dataOut.nHeights - 2*dataOut.LagPlot
55 data['noise'] = 10*numpy.log10(dataOut.getNoise(ymin_index=53,ymax_index=max_hei_id)/dataOut.normFactor)
55 data['noise'] = 10*numpy.log10(dataOut.getNoise(ymin_index=53,ymax_index=max_hei_id)/dataOut.normFactor)
56 data['noise'][0] = 10*numpy.log10(dataOut.getNoise(ymin_index=53)[0]/dataOut.normFactor)
56 data['noise'][0] = 10*numpy.log10(dataOut.getNoise(ymin_index=53)[0]/dataOut.normFactor)
57 else:
57 else:
58 data['noise'] = 10 * numpy.log10(dataOut.getNoise() / dataOut.normFactor)
58 data['noise'] = 10 * numpy.log10(dataOut.getNoise() / dataOut.normFactor)
59 extrapoints = spc.shape[1] % dataOut.nFFTPoints
59 extrapoints = spc.shape[1] % dataOut.nFFTPoints
60 extrapoints=1
60 extrapoints=1
61 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS) / 1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
61 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS) / 1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
62 if self.CODE == 'spc_moments':
62 if self.CODE == 'spc_moments':
63 data['moments'] = dataOut.moments
63 data['moments'] = dataOut.moments
64 if self.CODE == 'gaussian_fit':
64 if self.CODE == 'gaussian_fit':
65 data['gaussfit'] = dataOut.DGauFitParams
65 data['gaussfit'] = dataOut.DGauFitParams
66
66
67 return data, meta
67 return data, meta
68
68
69 def plot(self):
69 def plot(self):
70
70
71 if self.xaxis == "frequency":
71 if self.xaxis == "frequency":
72 x = self.data.xrange[0]
72 x = self.data.xrange[0]
73 self.xlabel = "Frequency (kHz)"
73 self.xlabel = "Frequency (kHz)"
74 elif self.xaxis == "time":
74 elif self.xaxis == "time":
75 x = self.data.xrange[1]
75 x = self.data.xrange[1]
76 self.xlabel = "Time (ms)"
76 self.xlabel = "Time (ms)"
77 else:
77 else:
78 x = self.data.xrange[2]
78 x = self.data.xrange[2]
79 self.xlabel = "Velocity (m/s)"
79 self.xlabel = "Velocity (m/s)"
80
80
81 if (self.CODE == 'spc_moments') | (self.CODE == 'gaussian_fit'):
81 if (self.CODE == 'spc_moments') | (self.CODE == 'gaussian_fit'):
82 x = self.data.xrange[2]
82 x = self.data.xrange[2]
83 self.xlabel = "Velocity (m/s)"
83 self.xlabel = "Velocity (m/s)"
84
84
85 self.titles = []
85 self.titles = []
86
86
87 y = self.data.yrange
87 y = self.data.yrange
88 self.y = y
88 self.y = y
89
89
90 data = self.data[-1]
90 data = self.data[-1]
91 z = data['spc']
91 z = data['spc']
92
92
93 for n, ax in enumerate(self.axes):
93 for n, ax in enumerate(self.axes):
94 noise = data['noise'][n]
94 noise = data['noise'][n]
95
95
96 if self.CODE == 'spc_moments':
96 if self.CODE == 'spc_moments':
97 mean = data['moments'][n, 1]
97 mean = data['moments'][n, 1]
98 if self.CODE == 'gaussian_fit':
98 if self.CODE == 'gaussian_fit':
99 gau0 = data['gaussfit'][n][2,:,0]
99 gau0 = data['gaussfit'][n][2,:,0]
100 gau1 = data['gaussfit'][n][2,:,1]
100 gau1 = data['gaussfit'][n][2,:,1]
101 if ax.firsttime:
101 if ax.firsttime:
102 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
102 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
103 self.xmin = self.xmin if self.xmin else numpy.nanmin(x)#-self.xmax
103 self.xmin = self.xmin if self.xmin else numpy.nanmin(x)#-self.xmax
104 #self.zmin = self.zmin if self.zmin else numpy.nanmin(z)
104 #self.zmin = self.zmin if self.zmin else numpy.nanmin(z)
105 #self.zmax = self.zmax if self.zmax else numpy.nanmax(z)
105 #self.zmax = self.zmax if self.zmax else numpy.nanmax(z)
106 if self.zlimits is not None:
106 if self.zlimits is not None:
107 self.zmin, self.zmax = self.zlimits[n]
107 self.zmin, self.zmax = self.zlimits[n]
108 ax.plt = ax.pcolormesh(x, y, z[n].T,
108 ax.plt = ax.pcolormesh(x, y, z[n].T,
109 vmin=self.zmin,
109 vmin=self.zmin,
110 vmax=self.zmax,
110 vmax=self.zmax,
111 cmap=plt.get_cmap(self.colormap)
111 cmap=plt.get_cmap(self.colormap)
112 )
112 )
113
113
114 if self.showprofile:
114 if self.showprofile:
115 ax.plt_profile = self.pf_axes[n].plot(
115 ax.plt_profile = self.pf_axes[n].plot(
116 data['rti'][n], y)[0]
116 data['rti'][n], y)[0]
117 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
117 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
118 color="k", linestyle="dashed", lw=1)[0]
118 color="k", linestyle="dashed", lw=1)[0]
119 if self.CODE == 'spc_moments':
119 if self.CODE == 'spc_moments':
120 ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0]
120 ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0]
121 if self.CODE == 'gaussian_fit':
121 if self.CODE == 'gaussian_fit':
122 ax.plt_gau0 = ax.plot(gau0, y, color='r', lw=1)[0]
122 ax.plt_gau0 = ax.plot(gau0, y, color='r', lw=1)[0]
123 ax.plt_gau1 = ax.plot(gau1, y, color='y', lw=1)[0]
123 ax.plt_gau1 = ax.plot(gau1, y, color='y', lw=1)[0]
124 else:
124 else:
125 if self.zlimits is not None:
125 if self.zlimits is not None:
126 self.zmin, self.zmax = self.zlimits[n]
126 self.zmin, self.zmax = self.zlimits[n]
127 ax.plt.set_array(z[n].T.ravel())
127 ax.plt.set_array(z[n].T.ravel())
128 if self.showprofile:
128 if self.showprofile:
129 ax.plt_profile.set_data(data['rti'][n], y)
129 ax.plt_profile.set_data(data['rti'][n], y)
130 ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y)
130 ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y)
131 if self.CODE == 'spc_moments':
131 if self.CODE == 'spc_moments':
132 ax.plt_mean.set_data(mean, y)
132 ax.plt_mean.set_data(mean, y)
133 if self.CODE == 'gaussian_fit':
133 if self.CODE == 'gaussian_fit':
134 ax.plt_gau0.set_data(gau0, y)
134 ax.plt_gau0.set_data(gau0, y)
135 ax.plt_gau1.set_data(gau1, y)
135 ax.plt_gau1.set_data(gau1, y)
136 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
136 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
137
137
138 class SpectraObliquePlot(Plot):
138 class SpectraObliquePlot(Plot):
139 '''
139 '''
140 Plot for Spectra data
140 Plot for Spectra data
141
141
142 Written by R. Flores
142 Written by R. Flores
143 '''
143 '''
144
144
145 CODE = 'spc_oblique'
145 CODE = 'spc_oblique'
146 colormap = 'jet'
146 colormap = 'jet'
147 plot_type = 'pcolor'
147 plot_type = 'pcolor'
148
148
149 def setup(self):
149 def setup(self):
150 self.xaxis = "oblique"
150 self.xaxis = "oblique"
151 self.nplots = len(self.data.channels)
151 self.nplots = len(self.data.channels)
152 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
152 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
153 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
153 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
154 self.height = 2.6 * self.nrows
154 self.height = 2.6 * self.nrows
155 self.cb_label = 'dB'
155 self.cb_label = 'dB'
156 if self.showprofile:
156 if self.showprofile:
157 self.width = 4 * self.ncols
157 self.width = 4 * self.ncols
158 else:
158 else:
159 self.width = 3.5 * self.ncols
159 self.width = 3.5 * self.ncols
160 self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18})
160 self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18})
161 self.ylabel = 'Range [km]'
161 self.ylabel = 'Range [km]'
162
162
163 def update(self, dataOut):
163 def update(self, dataOut):
164
164
165 data = {}
165 data = {}
166 meta = {}
166 meta = {}
167 spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor)
167 spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor)
168 data['spc'] = spc
168 data['spc'] = spc
169 data['rti'] = dataOut.getPower()
169 data['rti'] = dataOut.getPower()
170 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
170 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
171 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS)/1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
171 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS)/1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
172
172
173 data['shift1'] = dataOut.Dop_EEJ_T1[0]
173 data['shift1'] = dataOut.Dop_EEJ_T1[0]
174 data['shift2'] = dataOut.Dop_EEJ_T2[0]
174 data['shift2'] = dataOut.Dop_EEJ_T2[0]
175 data['max_val_2'] = dataOut.Oblique_params[0,-1,:]
175 data['max_val_2'] = dataOut.Oblique_params[0,-1,:]
176 data['shift1_error'] = dataOut.Err_Dop_EEJ_T1[0]
176 data['shift1_error'] = dataOut.Err_Dop_EEJ_T1[0]
177 data['shift2_error'] = dataOut.Err_Dop_EEJ_T2[0]
177 data['shift2_error'] = dataOut.Err_Dop_EEJ_T2[0]
178
178
179 return data, meta
179 return data, meta
180
180
181 def plot(self):
181 def plot(self):
182
182
183 if self.xaxis == "frequency":
183 if self.xaxis == "frequency":
184 x = self.data.xrange[0]
184 x = self.data.xrange[0]
185 self.xlabel = "Frequency (kHz)"
185 self.xlabel = "Frequency (kHz)"
186 elif self.xaxis == "time":
186 elif self.xaxis == "time":
187 x = self.data.xrange[1]
187 x = self.data.xrange[1]
188 self.xlabel = "Time (ms)"
188 self.xlabel = "Time (ms)"
189 else:
189 else:
190 x = self.data.xrange[2]
190 x = self.data.xrange[2]
191 self.xlabel = "Velocity (m/s)"
191 self.xlabel = "Velocity (m/s)"
192
192
193 self.titles = []
193 self.titles = []
194
194
195 y = self.data.yrange
195 y = self.data.yrange
196 self.y = y
196 self.y = y
197 data = self.data[-1]
197 data = self.data[-1]
198 z = data['spc']
198 z = data['spc']
199
199
200 for n, ax in enumerate(self.axes):
200 for n, ax in enumerate(self.axes):
201 noise = self.data['noise'][n][-1]
201 noise = self.data['noise'][n][-1]
202 shift1 = data['shift1']
202 shift1 = data['shift1']
203 shift2 = data['shift2']
203 shift2 = data['shift2']
204 max_val_2 = data['max_val_2']
204 max_val_2 = data['max_val_2']
205 err1 = data['shift1_error']
205 err1 = data['shift1_error']
206 err2 = data['shift2_error']
206 err2 = data['shift2_error']
207 if ax.firsttime:
207 if ax.firsttime:
208 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
208 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
209 self.xmin = self.xmin if self.xmin else -self.xmax
209 self.xmin = self.xmin if self.xmin else -self.xmax
210 self.zmin = self.zmin if self.zmin else numpy.nanmin(z)
210 self.zmin = self.zmin if self.zmin else numpy.nanmin(z)
211 self.zmax = self.zmax if self.zmax else numpy.nanmax(z)
211 self.zmax = self.zmax if self.zmax else numpy.nanmax(z)
212 ax.plt = ax.pcolormesh(x, y, z[n].T,
212 ax.plt = ax.pcolormesh(x, y, z[n].T,
213 vmin=self.zmin,
213 vmin=self.zmin,
214 vmax=self.zmax,
214 vmax=self.zmax,
215 cmap=plt.get_cmap(self.colormap)
215 cmap=plt.get_cmap(self.colormap)
216 )
216 )
217
217
218 if self.showprofile:
218 if self.showprofile:
219 ax.plt_profile = self.pf_axes[n].plot(
219 ax.plt_profile = self.pf_axes[n].plot(
220 self.data['rti'][n][-1], y)[0]
220 self.data['rti'][n][-1], y)[0]
221 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
221 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
222 color="k", linestyle="dashed", lw=1)[0]
222 color="k", linestyle="dashed", lw=1)[0]
223
223
224 self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^', elinewidth=2.2, marker='o', linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2)
224 self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^', elinewidth=2.2, marker='o', linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2)
225 self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2)
225 self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2)
226 self.ploterr3 = ax.errorbar(max_val_2, y, xerr=0, fmt='g^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2)
226 self.ploterr3 = ax.errorbar(max_val_2, y, xerr=0, fmt='g^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2)
227 else:
227 else:
228 self.ploterr1.remove()
228 self.ploterr1.remove()
229 self.ploterr2.remove()
229 self.ploterr2.remove()
230 self.ploterr3.remove()
230 self.ploterr3.remove()
231 ax.plt.set_array(z[n].T.ravel())
231 ax.plt.set_array(z[n].T.ravel())
232 if self.showprofile:
232 if self.showprofile:
233 ax.plt_profile.set_data(self.data['rti'][n][-1], y)
233 ax.plt_profile.set_data(self.data['rti'][n][-1], y)
234 ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y)
234 ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y)
235 self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^', elinewidth=2.2, marker='o', linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2)
235 self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^', elinewidth=2.2, marker='o', linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2)
236 self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2)
236 self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2)
237 self.ploterr3 = ax.errorbar(max_val_2, y, xerr=0, fmt='g^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2)
237 self.ploterr3 = ax.errorbar(max_val_2, y, xerr=0, fmt='g^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2)
238
238
239 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
239 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
240
240
241
241
242 class CrossSpectraPlot(Plot):
242 class CrossSpectraPlot(Plot):
243
243
244 CODE = 'cspc'
244 CODE = 'cspc'
245 colormap = 'jet'
245 colormap = 'jet'
246 plot_type = 'pcolor'
246 plot_type = 'pcolor'
247 zmin_coh = None
247 zmin_coh = None
248 zmax_coh = None
248 zmax_coh = None
249 zmin_phase = None
249 zmin_phase = None
250 zmax_phase = None
250 zmax_phase = None
251
251
252 def setup(self):
252 def setup(self):
253
253
254 self.ncols = 4
254 self.ncols = 4
255 self.nplots = len(self.data.pairs) * 2
255 self.nplots = len(self.data.pairs) * 2
256 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
256 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
257 self.width = 3.1 * self.ncols
257 self.width = 3.1 * self.ncols
258 self.height = 5 * self.nrows
258 self.height = 5 * self.nrows
259 self.ylabel = 'Range [km]'
259 self.ylabel = 'Range [km]'
260 self.showprofile = False
260 self.showprofile = False
261 self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08})
261 self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08})
262
262
263 def update(self, dataOut):
263 def update(self, dataOut):
264
264
265 data = {}
265 data = {}
266 meta = {}
266 meta = {}
267
267
268 spc = dataOut.data_spc
268 spc = dataOut.data_spc
269 cspc = dataOut.data_cspc
269 cspc = dataOut.data_cspc
270 extrapoints = spc.shape[1] % dataOut.nFFTPoints
270 extrapoints = spc.shape[1] % dataOut.nFFTPoints
271 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS) / 1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
271 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS) / 1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
272 meta['pairs'] = dataOut.pairsList
272 meta['pairs'] = dataOut.pairsList
273
273
274 tmp = []
274 tmp = []
275
275
276 for n, pair in enumerate(meta['pairs']):
276 for n, pair in enumerate(meta['pairs']):
277 out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
277 out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
278 coh = numpy.abs(out)
278 coh = numpy.abs(out)
279 phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
279 phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
280 tmp.append(coh)
280 tmp.append(coh)
281 tmp.append(phase)
281 tmp.append(phase)
282
282
283 data['cspc'] = numpy.array(tmp)
283 data['cspc'] = numpy.array(tmp)
284
284
285 return data, meta
285 return data, meta
286
286
287 def plot(self):
287 def plot(self):
288
288
289 if self.xaxis == "frequency":
289 if self.xaxis == "frequency":
290 x = self.data.xrange[0]
290 x = self.data.xrange[0]
291 self.xlabel = "Frequency (kHz)"
291 self.xlabel = "Frequency (kHz)"
292 elif self.xaxis == "time":
292 elif self.xaxis == "time":
293 x = self.data.xrange[1]
293 x = self.data.xrange[1]
294 self.xlabel = "Time (ms)"
294 self.xlabel = "Time (ms)"
295 else:
295 else:
296 x = self.data.xrange[2]
296 x = self.data.xrange[2]
297 self.xlabel = "Velocity (m/s)"
297 self.xlabel = "Velocity (m/s)"
298
298
299 self.titles = []
299 self.titles = []
300
300
301 y = self.data.yrange
301 y = self.data.yrange
302 self.y = y
302 self.y = y
303
303
304 data = self.data[-1]
304 data = self.data[-1]
305 cspc = data['cspc']
305 cspc = data['cspc']
306
306
307 for n in range(len(self.data.pairs)):
307 for n in range(len(self.data.pairs)):
308 pair = self.data.pairs[n]
308 pair = self.data.pairs[n]
309 coh = cspc[n * 2]
309 coh = cspc[n * 2]
310 phase = cspc[n * 2 + 1]
310 phase = cspc[n * 2 + 1]
311 ax = self.axes[2 * n]
311 ax = self.axes[2 * n]
312 if ax.firsttime:
312 if ax.firsttime:
313 ax.plt = ax.pcolormesh(x, y, coh.T,
313 ax.plt = ax.pcolormesh(x, y, coh.T,
314 vmin=0,
314 vmin=0,
315 vmax=1,
315 vmax=1,
316 cmap=plt.get_cmap(self.colormap_coh)
316 cmap=plt.get_cmap(self.colormap_coh)
317 )
317 )
318 else:
318 else:
319 ax.plt.set_array(coh.T.ravel())
319 ax.plt.set_array(coh.T.ravel())
320 self.titles.append(
320 self.titles.append(
321 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
321 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
322
322
323 ax = self.axes[2 * n + 1]
323 ax = self.axes[2 * n + 1]
324 if ax.firsttime:
324 if ax.firsttime:
325 ax.plt = ax.pcolormesh(x, y, phase.T,
325 ax.plt = ax.pcolormesh(x, y, phase.T,
326 vmin=-180,
326 vmin=-180,
327 vmax=180,
327 vmax=180,
328 cmap=plt.get_cmap(self.colormap_phase)
328 cmap=plt.get_cmap(self.colormap_phase)
329 )
329 )
330 else:
330 else:
331 ax.plt.set_array(phase.T.ravel())
331 ax.plt.set_array(phase.T.ravel())
332 self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1]))
332 self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1]))
333
333
334
334
335 class CrossSpectra4Plot(Plot):
335 class CrossSpectra4Plot(Plot):
336
336
337 CODE = 'cspc'
337 CODE = 'cspc'
338 colormap = 'jet'
338 colormap = 'jet'
339 plot_type = 'pcolor'
339 plot_type = 'pcolor'
340 zmin_coh = None
340 zmin_coh = None
341 zmax_coh = None
341 zmax_coh = None
342 zmin_phase = None
342 zmin_phase = None
343 zmax_phase = None
343 zmax_phase = None
344
344
345 def setup(self):
345 def setup(self):
346
346
347 self.ncols = 4
347 self.ncols = 4
348 self.nrows = len(self.data.pairs)
348 self.nrows = len(self.data.pairs)
349 self.nplots = self.nrows * 4
349 self.nplots = self.nrows * 4
350 self.width = 3.1 * self.ncols
350 self.width = 3.1 * self.ncols
351 self.height = 5 * self.nrows
351 self.height = 5 * self.nrows
352 self.ylabel = 'Range [km]'
352 self.ylabel = 'Range [km]'
353 self.showprofile = False
353 self.showprofile = False
354 self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08})
354 self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08})
355
355
356 def plot(self):
356 def plot(self):
357
357
358 if self.xaxis == "frequency":
358 if self.xaxis == "frequency":
359 x = self.data.xrange[0]
359 x = self.data.xrange[0]
360 self.xlabel = "Frequency (kHz)"
360 self.xlabel = "Frequency (kHz)"
361 elif self.xaxis == "time":
361 elif self.xaxis == "time":
362 x = self.data.xrange[1]
362 x = self.data.xrange[1]
363 self.xlabel = "Time (ms)"
363 self.xlabel = "Time (ms)"
364 else:
364 else:
365 x = self.data.xrange[2]
365 x = self.data.xrange[2]
366 self.xlabel = "Velocity (m/s)"
366 self.xlabel = "Velocity (m/s)"
367
367
368 self.titles = []
368 self.titles = []
369
369
370
370
371 y = self.data.heights
371 y = self.data.heights
372 self.y = y
372 self.y = y
373 nspc = self.data['spc']
373 nspc = self.data['spc']
374 #print(numpy.shape(self.data['spc']))
374 #print(numpy.shape(self.data['spc']))
375 spc = self.data['cspc'][0]
375 spc = self.data['cspc'][0]
376 #print(numpy.shape(nspc))
376 #print(numpy.shape(nspc))
377 #exit()
377 #exit()
378 #nspc[1,:,:] = numpy.flip(nspc[1,:,:],axis=0)
378 #nspc[1,:,:] = numpy.flip(nspc[1,:,:],axis=0)
379 #print(numpy.shape(spc))
379 #print(numpy.shape(spc))
380 #exit()
380 #exit()
381 cspc = self.data['cspc'][1]
381 cspc = self.data['cspc'][1]
382
382
383 #xflip=numpy.flip(x)
383 #xflip=numpy.flip(x)
384 #print(numpy.shape(cspc))
384 #print(numpy.shape(cspc))
385 #exit()
385 #exit()
386
386
387 for n in range(self.nrows):
387 for n in range(self.nrows):
388 noise = self.data['noise'][:,-1]
388 noise = self.data['noise'][:,-1]
389 pair = self.data.pairs[n]
389 pair = self.data.pairs[n]
390 #print(pair)
390 #print(pair)
391 #exit()
391 #exit()
392 ax = self.axes[4 * n]
392 ax = self.axes[4 * n]
393 if ax.firsttime:
393 if ax.firsttime:
394 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
394 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
395 self.xmin = self.xmin if self.xmin else -self.xmax
395 self.xmin = self.xmin if self.xmin else -self.xmax
396 self.zmin = self.zmin if self.zmin else numpy.nanmin(nspc)
396 self.zmin = self.zmin if self.zmin else numpy.nanmin(nspc)
397 self.zmax = self.zmax if self.zmax else numpy.nanmax(nspc)
397 self.zmax = self.zmax if self.zmax else numpy.nanmax(nspc)
398 ax.plt = ax.pcolormesh(x , y , nspc[pair[0]].T,
398 ax.plt = ax.pcolormesh(x , y , nspc[pair[0]].T,
399 vmin=self.zmin,
399 vmin=self.zmin,
400 vmax=self.zmax,
400 vmax=self.zmax,
401 cmap=plt.get_cmap(self.colormap)
401 cmap=plt.get_cmap(self.colormap)
402 )
402 )
403 else:
403 else:
404 #print(numpy.shape(nspc[pair[0]].T))
404 #print(numpy.shape(nspc[pair[0]].T))
405 #exit()
405 #exit()
406 ax.plt.set_array(nspc[pair[0]].T.ravel())
406 ax.plt.set_array(nspc[pair[0]].T.ravel())
407 self.titles.append('CH {}: {:3.2f}dB'.format(pair[0], noise[pair[0]]))
407 self.titles.append('CH {}: {:3.2f}dB'.format(pair[0], noise[pair[0]]))
408
408
409 ax = self.axes[4 * n + 1]
409 ax = self.axes[4 * n + 1]
410
410
411 if ax.firsttime:
411 if ax.firsttime:
412 ax.plt = ax.pcolormesh(x , y, numpy.flip(nspc[pair[1]],axis=0).T,
412 ax.plt = ax.pcolormesh(x , y, numpy.flip(nspc[pair[1]],axis=0).T,
413 vmin=self.zmin,
413 vmin=self.zmin,
414 vmax=self.zmax,
414 vmax=self.zmax,
415 cmap=plt.get_cmap(self.colormap)
415 cmap=plt.get_cmap(self.colormap)
416 )
416 )
417 else:
417 else:
418
418
419 ax.plt.set_array(numpy.flip(nspc[pair[1]],axis=0).T.ravel())
419 ax.plt.set_array(numpy.flip(nspc[pair[1]],axis=0).T.ravel())
420 self.titles.append('CH {}: {:3.2f}dB'.format(pair[1], noise[pair[1]]))
420 self.titles.append('CH {}: {:3.2f}dB'.format(pair[1], noise[pair[1]]))
421
421
422 out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
422 out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
423 coh = numpy.abs(out)
423 coh = numpy.abs(out)
424 phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
424 phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
425
425
426 ax = self.axes[4 * n + 2]
426 ax = self.axes[4 * n + 2]
427 if ax.firsttime:
427 if ax.firsttime:
428 ax.plt = ax.pcolormesh(x, y, numpy.flip(coh,axis=0).T,
428 ax.plt = ax.pcolormesh(x, y, numpy.flip(coh,axis=0).T,
429 vmin=0,
429 vmin=0,
430 vmax=1,
430 vmax=1,
431 cmap=plt.get_cmap(self.colormap_coh)
431 cmap=plt.get_cmap(self.colormap_coh)
432 )
432 )
433 else:
433 else:
434 ax.plt.set_array(numpy.flip(coh,axis=0).T.ravel())
434 ax.plt.set_array(numpy.flip(coh,axis=0).T.ravel())
435 self.titles.append(
435 self.titles.append(
436 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
436 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
437
437
438 ax = self.axes[4 * n + 3]
438 ax = self.axes[4 * n + 3]
439 if ax.firsttime:
439 if ax.firsttime:
440 ax.plt = ax.pcolormesh(x, y, numpy.flip(phase,axis=0).T,
440 ax.plt = ax.pcolormesh(x, y, numpy.flip(phase,axis=0).T,
441 vmin=-180,
441 vmin=-180,
442 vmax=180,
442 vmax=180,
443 cmap=plt.get_cmap(self.colormap_phase)
443 cmap=plt.get_cmap(self.colormap_phase)
444 )
444 )
445 else:
445 else:
446 ax.plt.set_array(numpy.flip(phase,axis=0).T.ravel())
446 ax.plt.set_array(numpy.flip(phase,axis=0).T.ravel())
447 self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1]))
447 self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1]))
448
448
449
449
450 class CrossSpectra2Plot(Plot):
450 class CrossSpectra2Plot(Plot):
451
451
452 CODE = 'cspc'
452 CODE = 'cspc'
453 colormap = 'jet'
453 colormap = 'jet'
454 plot_type = 'pcolor'
454 plot_type = 'pcolor'
455 zmin_coh = None
455 zmin_coh = None
456 zmax_coh = None
456 zmax_coh = None
457 zmin_phase = None
457 zmin_phase = None
458 zmax_phase = None
458 zmax_phase = None
459
459
460 def setup(self):
460 def setup(self):
461
461
462 self.ncols = 1
462 self.ncols = 1
463 self.nrows = len(self.data.pairs)
463 self.nrows = len(self.data.pairs)
464 self.nplots = self.nrows * 1
464 self.nplots = self.nrows * 1
465 self.width = 3.1 * self.ncols
465 self.width = 3.1 * self.ncols
466 self.height = 5 * self.nrows
466 self.height = 5 * self.nrows
467 self.ylabel = 'Range [km]'
467 self.ylabel = 'Range [km]'
468 self.showprofile = False
468 self.showprofile = False
469 self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08})
469 self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08})
470
470
471 def plot(self):
471 def plot(self):
472
472
473 if self.xaxis == "frequency":
473 if self.xaxis == "frequency":
474 x = self.data.xrange[0]
474 x = self.data.xrange[0]
475 self.xlabel = "Frequency (kHz)"
475 self.xlabel = "Frequency (kHz)"
476 elif self.xaxis == "time":
476 elif self.xaxis == "time":
477 x = self.data.xrange[1]
477 x = self.data.xrange[1]
478 self.xlabel = "Time (ms)"
478 self.xlabel = "Time (ms)"
479 else:
479 else:
480 x = self.data.xrange[2]
480 x = self.data.xrange[2]
481 self.xlabel = "Velocity (m/s)"
481 self.xlabel = "Velocity (m/s)"
482
482
483 self.titles = []
483 self.titles = []
484
484
485
485
486 y = self.data.heights
486 y = self.data.heights
487 self.y = y
487 self.y = y
488 #nspc = self.data['spc']
488 #nspc = self.data['spc']
489 #print(numpy.shape(self.data['spc']))
489 #print(numpy.shape(self.data['spc']))
490 #spc = self.data['cspc'][0]
490 #spc = self.data['cspc'][0]
491 #print(numpy.shape(spc))
491 #print(numpy.shape(spc))
492 #exit()
492 #exit()
493 cspc = self.data['cspc'][1]
493 cspc = self.data['cspc'][1]
494 #print(numpy.shape(cspc))
494 #print(numpy.shape(cspc))
495 #exit()
495 #exit()
496
496
497 for n in range(self.nrows):
497 for n in range(self.nrows):
498 noise = self.data['noise'][:,-1]
498 noise = self.data['noise'][:,-1]
499 pair = self.data.pairs[n]
499 pair = self.data.pairs[n]
500 #print(pair) #exit()
500 #print(pair) #exit()
501
501
502
502
503
503
504 out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
504 out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
505
505
506 #print(out[:,53])
506 #print(out[:,53])
507 #exit()
507 #exit()
508 cross = numpy.abs(out)
508 cross = numpy.abs(out)
509 z = cross/self.data.nFactor
509 z = cross/self.data.nFactor
510 #print("here")
510 #print("here")
511 #print(dataOut.data_spc[0,0,0])
511 #print(dataOut.data_spc[0,0,0])
512 #exit()
512 #exit()
513
513
514 cross = 10*numpy.log10(z)
514 cross = 10*numpy.log10(z)
515 #print(numpy.shape(cross))
515 #print(numpy.shape(cross))
516 #print(cross[0,:])
516 #print(cross[0,:])
517 #print(self.data.nFactor)
517 #print(self.data.nFactor)
518 #exit()
518 #exit()
519 #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
519 #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
520
520
521 ax = self.axes[1 * n]
521 ax = self.axes[1 * n]
522 if ax.firsttime:
522 if ax.firsttime:
523 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
523 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
524 self.xmin = self.xmin if self.xmin else -self.xmax
524 self.xmin = self.xmin if self.xmin else -self.xmax
525 self.zmin = self.zmin if self.zmin else numpy.nanmin(cross)
525 self.zmin = self.zmin if self.zmin else numpy.nanmin(cross)
526 self.zmax = self.zmax if self.zmax else numpy.nanmax(cross)
526 self.zmax = self.zmax if self.zmax else numpy.nanmax(cross)
527 ax.plt = ax.pcolormesh(x, y, cross.T,
527 ax.plt = ax.pcolormesh(x, y, cross.T,
528 vmin=self.zmin,
528 vmin=self.zmin,
529 vmax=self.zmax,
529 vmax=self.zmax,
530 cmap=plt.get_cmap(self.colormap)
530 cmap=plt.get_cmap(self.colormap)
531 )
531 )
532 else:
532 else:
533 ax.plt.set_array(cross.T.ravel())
533 ax.plt.set_array(cross.T.ravel())
534 self.titles.append(
534 self.titles.append(
535 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1]))
535 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1]))
536
536
537
537
538 class CrossSpectra3Plot(Plot):
538 class CrossSpectra3Plot(Plot):
539
539
540 CODE = 'cspc'
540 CODE = 'cspc'
541 colormap = 'jet'
541 colormap = 'jet'
542 plot_type = 'pcolor'
542 plot_type = 'pcolor'
543 zmin_coh = None
543 zmin_coh = None
544 zmax_coh = None
544 zmax_coh = None
545 zmin_phase = None
545 zmin_phase = None
546 zmax_phase = None
546 zmax_phase = None
547
547
548 def setup(self):
548 def setup(self):
549
549
550 self.ncols = 3
550 self.ncols = 3
551 self.nrows = len(self.data.pairs)
551 self.nrows = len(self.data.pairs)
552 self.nplots = self.nrows * 3
552 self.nplots = self.nrows * 3
553 self.width = 3.1 * self.ncols
553 self.width = 3.1 * self.ncols
554 self.height = 5 * self.nrows
554 self.height = 5 * self.nrows
555 self.ylabel = 'Range [km]'
555 self.ylabel = 'Range [km]'
556 self.showprofile = False
556 self.showprofile = False
557 self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08})
557 self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08})
558
558
559 def plot(self):
559 def plot(self):
560
560
561 if self.xaxis == "frequency":
561 if self.xaxis == "frequency":
562 x = self.data.xrange[0]
562 x = self.data.xrange[0]
563 self.xlabel = "Frequency (kHz)"
563 self.xlabel = "Frequency (kHz)"
564 elif self.xaxis == "time":
564 elif self.xaxis == "time":
565 x = self.data.xrange[1]
565 x = self.data.xrange[1]
566 self.xlabel = "Time (ms)"
566 self.xlabel = "Time (ms)"
567 else:
567 else:
568 x = self.data.xrange[2]
568 x = self.data.xrange[2]
569 self.xlabel = "Velocity (m/s)"
569 self.xlabel = "Velocity (m/s)"
570
570
571 self.titles = []
571 self.titles = []
572
572
573
573
574 y = self.data.heights
574 y = self.data.heights
575 self.y = y
575 self.y = y
576 #nspc = self.data['spc']
576 #nspc = self.data['spc']
577 #print(numpy.shape(self.data['spc']))
577 #print(numpy.shape(self.data['spc']))
578 #spc = self.data['cspc'][0]
578 #spc = self.data['cspc'][0]
579 #print(numpy.shape(spc))
579 #print(numpy.shape(spc))
580 #exit()
580 #exit()
581 cspc = self.data['cspc'][1]
581 cspc = self.data['cspc'][1]
582 #print(numpy.shape(cspc))
582 #print(numpy.shape(cspc))
583 #exit()
583 #exit()
584
584
585 for n in range(self.nrows):
585 for n in range(self.nrows):
586 noise = self.data['noise'][:,-1]
586 noise = self.data['noise'][:,-1]
587 pair = self.data.pairs[n]
587 pair = self.data.pairs[n]
588 #print(pair) #exit()
588 #print(pair) #exit()
589
589
590
590
591
591
592 out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
592 out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
593
593
594 #print(out[:,53])
594 #print(out[:,53])
595 #exit()
595 #exit()
596 cross = numpy.abs(out)
596 cross = numpy.abs(out)
597 z = cross/self.data.nFactor
597 z = cross/self.data.nFactor
598 cross = 10*numpy.log10(z)
598 cross = 10*numpy.log10(z)
599
599
600 out_r= out.real/self.data.nFactor
600 out_r= out.real/self.data.nFactor
601 #out_r = 10*numpy.log10(out_r)
601 #out_r = 10*numpy.log10(out_r)
602
602
603 out_i= out.imag/self.data.nFactor
603 out_i= out.imag/self.data.nFactor
604 #out_i = 10*numpy.log10(out_i)
604 #out_i = 10*numpy.log10(out_i)
605 #print(numpy.shape(cross))
605 #print(numpy.shape(cross))
606 #print(cross[0,:])
606 #print(cross[0,:])
607 #print(self.data.nFactor)
607 #print(self.data.nFactor)
608 #exit()
608 #exit()
609 #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
609 #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
610
610
611 ax = self.axes[3 * n]
611 ax = self.axes[3 * n]
612 if ax.firsttime:
612 if ax.firsttime:
613 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
613 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
614 self.xmin = self.xmin if self.xmin else -self.xmax
614 self.xmin = self.xmin if self.xmin else -self.xmax
615 self.zmin = self.zmin if self.zmin else numpy.nanmin(cross)
615 self.zmin = self.zmin if self.zmin else numpy.nanmin(cross)
616 self.zmax = self.zmax if self.zmax else numpy.nanmax(cross)
616 self.zmax = self.zmax if self.zmax else numpy.nanmax(cross)
617 ax.plt = ax.pcolormesh(x, y, cross.T,
617 ax.plt = ax.pcolormesh(x, y, cross.T,
618 vmin=self.zmin,
618 vmin=self.zmin,
619 vmax=self.zmax,
619 vmax=self.zmax,
620 cmap=plt.get_cmap(self.colormap)
620 cmap=plt.get_cmap(self.colormap)
621 )
621 )
622 else:
622 else:
623 ax.plt.set_array(cross.T.ravel())
623 ax.plt.set_array(cross.T.ravel())
624 self.titles.append(
624 self.titles.append(
625 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1]))
625 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1]))
626
626
627 ax = self.axes[3 * n + 1]
627 ax = self.axes[3 * n + 1]
628 if ax.firsttime:
628 if ax.firsttime:
629 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
629 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
630 self.xmin = self.xmin if self.xmin else -self.xmax
630 self.xmin = self.xmin if self.xmin else -self.xmax
631 self.zmin = self.zmin if self.zmin else numpy.nanmin(cross)
631 self.zmin = self.zmin if self.zmin else numpy.nanmin(cross)
632 self.zmax = self.zmax if self.zmax else numpy.nanmax(cross)
632 self.zmax = self.zmax if self.zmax else numpy.nanmax(cross)
633 ax.plt = ax.pcolormesh(x, y, out_r.T,
633 ax.plt = ax.pcolormesh(x, y, out_r.T,
634 vmin=-1.e6,
634 vmin=-1.e6,
635 vmax=0,
635 vmax=0,
636 cmap=plt.get_cmap(self.colormap)
636 cmap=plt.get_cmap(self.colormap)
637 )
637 )
638 else:
638 else:
639 ax.plt.set_array(out_r.T.ravel())
639 ax.plt.set_array(out_r.T.ravel())
640 self.titles.append(
640 self.titles.append(
641 'Cross Spectra Real Ch{} * Ch{}'.format(pair[0], pair[1]))
641 'Cross Spectra Real Ch{} * Ch{}'.format(pair[0], pair[1]))
642
642
643 ax = self.axes[3 * n + 2]
643 ax = self.axes[3 * n + 2]
644
644
645
645
646 if ax.firsttime:
646 if ax.firsttime:
647 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
647 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
648 self.xmin = self.xmin if self.xmin else -self.xmax
648 self.xmin = self.xmin if self.xmin else -self.xmax
649 self.zmin = self.zmin if self.zmin else numpy.nanmin(cross)
649 self.zmin = self.zmin if self.zmin else numpy.nanmin(cross)
650 self.zmax = self.zmax if self.zmax else numpy.nanmax(cross)
650 self.zmax = self.zmax if self.zmax else numpy.nanmax(cross)
651 ax.plt = ax.pcolormesh(x, y, out_i.T,
651 ax.plt = ax.pcolormesh(x, y, out_i.T,
652 vmin=-1.e6,
652 vmin=-1.e6,
653 vmax=1.e6,
653 vmax=1.e6,
654 cmap=plt.get_cmap(self.colormap)
654 cmap=plt.get_cmap(self.colormap)
655 )
655 )
656 else:
656 else:
657 ax.plt.set_array(out_i.T.ravel())
657 ax.plt.set_array(out_i.T.ravel())
658 self.titles.append(
658 self.titles.append(
659 'Cross Spectra Imag Ch{} * Ch{}'.format(pair[0], pair[1]))
659 'Cross Spectra Imag Ch{} * Ch{}'.format(pair[0], pair[1]))
660
660
661 class RTIPlot(Plot):
661 class RTIPlot(Plot):
662 '''
662 '''
663 Plot for RTI data
663 Plot for RTI data
664 '''
664 '''
665
665
666 CODE = 'rti'
666 CODE = 'rti'
667 colormap = 'jet'
667 colormap = 'jet'
668 plot_type = 'pcolorbuffer'
668 plot_type = 'pcolorbuffer'
669
669
670 def setup(self):
670 def setup(self):
671 self.xaxis = 'time'
671 self.xaxis = 'time'
672 self.ncols = 1
672 self.ncols = 1
673 self.nrows = len(self.data.channels)
673 self.nrows = len(self.data.channels)
674 self.nplots = len(self.data.channels)
674 self.nplots = len(self.data.channels)
675 self.ylabel = 'Range [km]'
675 self.ylabel = 'Range [km]'
676 self.xlabel = 'Time'
676 self.xlabel = 'Time'
677 self.cb_label = 'dB'
677 self.cb_label = 'dB'
678 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95})
678 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95})
679 self.titles = ['{} Channel {}'.format(
679 self.titles = ['{} Channel {}'.format(
680 self.CODE.upper(), x) for x in range(self.nrows)]
680 self.CODE.upper(), x) for x in range(self.nrows)]
681
681
682 def update(self, dataOut):
682 def update(self, dataOut):
683
683
684 data = {}
684 data = {}
685 meta = {}
685 meta = {}
686 data['rti'] = dataOut.getPower()
686 data['rti'] = dataOut.getPower()
687 data['noise'] = 10 * numpy.log10(dataOut.getNoise() / dataOut.normFactor)
687 data['noise'] = 10 * numpy.log10(dataOut.getNoise() / dataOut.normFactor)
688
688
689 return data, meta
689 return data, meta
690
690
691 def plot(self):
691 def plot(self):
692 self.x = self.data.times
692 self.x = self.data.times
693 self.y = self.data.yrange
693 self.y = self.data.yrange
694 self.z = self.data[self.CODE]
694 self.z = self.data[self.CODE]
695
695
696 self.z = numpy.ma.masked_invalid(self.z)
696 self.z = numpy.ma.masked_invalid(self.z)
697
697
698 if self.decimation is None:
698 if self.decimation is None:
699 x, y, z = self.fill_gaps(self.x, self.y, self.z)
699 x, y, z = self.fill_gaps(self.x, self.y, self.z)
700 else:
700 else:
701 x, y, z = self.fill_gaps(*self.decimate())
701 x, y, z = self.fill_gaps(*self.decimate())
702
702
703 for n, ax in enumerate(self.axes):
703 for n, ax in enumerate(self.axes):
704 self.zmin = self.zmin if self.zmin else numpy.min(self.z)
704 self.zmin = self.zmin if self.zmin else numpy.min(self.z)
705 self.zmax = self.zmax if self.zmax else numpy.max(self.z)
705 self.zmax = self.zmax if self.zmax else numpy.max(self.z)
706 if ax.firsttime:
706 if ax.firsttime:
707 if self.zlimits is not None:
707 if self.zlimits is not None:
708 self.zmin, self.zmax = self.zlimits[n]
708 self.zmin, self.zmax = self.zlimits[n]
709 ax.plt = ax.pcolormesh(x, y, z[n].T,
709 ax.plt = ax.pcolormesh(x, y, z[n].T,
710 vmin=self.zmin,
710 vmin=self.zmin,
711 vmax=self.zmax,
711 vmax=self.zmax,
712 cmap=plt.get_cmap(self.colormap)
712 cmap=plt.get_cmap(self.colormap)
713 )
713 )
714 if self.showprofile:
714 if self.showprofile:
715 ax.plot_profile = self.pf_axes[n].plot(
715 ax.plot_profile = self.pf_axes[n].plot(
716 self.data['rti'][n][-1], self.y)[0]
716 self.data['rti'][n][-1], self.y)[0]
717 ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y,
717 ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y,
718 color="k", linestyle="dashed", lw=1)[0]
718 color="k", linestyle="dashed", lw=1)[0]
719 else:
719 else:
720 if self.zlimits is not None:
720 if self.zlimits is not None:
721 self.zmin, self.zmax = self.zlimits[n]
721 self.zmin, self.zmax = self.zlimits[n]
722 ax.plt.remove()
722 ax.plt.remove()
723 ax.plt = ax.pcolormesh(x, y, z[n].T,
723 ax.plt = ax.pcolormesh(x, y, z[n].T,
724 vmin=self.zmin,
724 vmin=self.zmin,
725 vmax=self.zmax,
725 vmax=self.zmax,
726 cmap=plt.get_cmap(self.colormap)
726 cmap=plt.get_cmap(self.colormap)
727 )
727 )
728 if self.showprofile:
728 if self.showprofile:
729 ax.plot_profile.set_data(self.data['rti'][n][-1], self.y)
729 ax.plot_profile.set_data(self.data['rti'][n][-1], self.y)
730 ax.plot_noise.set_data(numpy.repeat(
730 ax.plot_noise.set_data(numpy.repeat(
731 self.data['noise'][n][-1], len(self.y)), self.y)
731 self.data['noise'][n][-1], len(self.y)), self.y)
732
732
733
733
734 class SpectrogramPlot(Plot):
734 class SpectrogramPlot(Plot):
735 '''
735 '''
736 Plot for Spectrogram data
736 Plot for Spectrogram data
737 '''
737 '''
738
738
739 CODE = 'Spectrogram_Profile'
739 CODE = 'Spectrogram_Profile'
740 colormap = 'binary'
740 colormap = 'binary'
741 plot_type = 'pcolorbuffer'
741 plot_type = 'pcolorbuffer'
742
742
743 def setup(self):
743 def setup(self):
744 self.xaxis = 'time'
744 self.xaxis = 'time'
745 self.ncols = 1
745 self.ncols = 1
746 self.nrows = len(self.data.channels)
746 self.nrows = len(self.data.channels)
747 self.nplots = len(self.data.channels)
747 self.nplots = len(self.data.channels)
748 self.xlabel = 'Time'
748 self.xlabel = 'Time'
749 #self.cb_label = 'dB'
749 #self.cb_label = 'dB'
750 self.plots_adjust.update({'hspace':1.2, 'left': 0.1, 'bottom': 0.12, 'right':0.95})
750 self.plots_adjust.update({'hspace':1.2, 'left': 0.1, 'bottom': 0.12, 'right':0.95})
751 self.titles = []
751 self.titles = []
752
752
753 #self.titles = ['{} Channel {} \n H = {} km ({} - {})'.format(
753 #self.titles = ['{} Channel {} \n H = {} km ({} - {})'.format(
754 #self.CODE.upper(), x, self.data.heightList[self.data.hei], self.data.heightList[self.data.hei],self.data.heightList[self.data.hei]+(self.data.DH*self.data.nProfiles)) for x in range(self.nrows)]
754 #self.CODE.upper(), x, self.data.heightList[self.data.hei], self.data.heightList[self.data.hei],self.data.heightList[self.data.hei]+(self.data.DH*self.data.nProfiles)) for x in range(self.nrows)]
755
755
756 self.titles = ['{} Channel {}'.format(
756 self.titles = ['{} Channel {}'.format(
757 self.CODE.upper(), x) for x in range(self.nrows)]
757 self.CODE.upper(), x) for x in range(self.nrows)]
758
758
759
759
760 def update(self, dataOut):
760 def update(self, dataOut):
761 data = {}
761 data = {}
762 meta = {}
762 meta = {}
763
763
764 maxHei = 1620#+12000
764 maxHei = 1620#+12000
765 maxHei = 1180
765 maxHei = 1180
766 indb = numpy.where(dataOut.heightList <= maxHei)
766 indb = numpy.where(dataOut.heightList <= maxHei)
767 hei = indb[0][-1]
767 hei = indb[0][-1]
768 #print(dataOut.heightList)
768 #print(dataOut.heightList)
769
769
770 factor = dataOut.nIncohInt
770 factor = dataOut.nIncohInt
771 z = dataOut.data_spc[:,:,hei] / factor
771 z = dataOut.data_spc[:,:,hei] / factor
772 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
772 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
773 #buffer = 10 * numpy.log10(z)
773 #buffer = 10 * numpy.log10(z)
774
774
775 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS)/1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
775 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS)/1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
776
776
777
777
778 #self.hei = hei
778 #self.hei = hei
779 #self.heightList = dataOut.heightList
779 #self.heightList = dataOut.heightList
780 #self.DH = (dataOut.heightList[1] - dataOut.heightList[0])/dataOut.step
780 #self.DH = (dataOut.heightList[1] - dataOut.heightList[0])/dataOut.step
781 #self.nProfiles = dataOut.nProfiles
781 #self.nProfiles = dataOut.nProfiles
782
782
783 data['Spectrogram_Profile'] = 10 * numpy.log10(z)
783 data['Spectrogram_Profile'] = 10 * numpy.log10(z)
784
784
785 data['hei'] = hei
785 data['hei'] = hei
786 data['DH'] = (dataOut.heightList[1] - dataOut.heightList[0])/dataOut.step
786 data['DH'] = (dataOut.heightList[1] - dataOut.heightList[0])/dataOut.step
787 data['nProfiles'] = dataOut.nProfiles
787 data['nProfiles'] = dataOut.nProfiles
788 #meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS]
788 #meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS]
789 '''
789 '''
790 import matplotlib.pyplot as plt
790 import matplotlib.pyplot as plt
791 plt.plot(10 * numpy.log10(z[0,:]))
791 plt.plot(10 * numpy.log10(z[0,:]))
792 plt.show()
792 plt.show()
793
793
794 from time import sleep
794 from time import sleep
795 sleep(10)
795 sleep(10)
796 '''
796 '''
797 return data, meta
797 return data, meta
798
798
799 def plot(self):
799 def plot(self):
800
800
801 self.x = self.data.times
801 self.x = self.data.times
802 self.z = self.data[self.CODE]
802 self.z = self.data[self.CODE]
803 self.y = self.data.xrange[0]
803 self.y = self.data.xrange[0]
804
804
805 hei = self.data['hei'][-1]
805 hei = self.data['hei'][-1]
806 DH = self.data['DH'][-1]
806 DH = self.data['DH'][-1]
807 nProfiles = self.data['nProfiles'][-1]
807 nProfiles = self.data['nProfiles'][-1]
808
808
809 self.ylabel = "Frequency (kHz)"
809 self.ylabel = "Frequency (kHz)"
810
810
811 self.z = numpy.ma.masked_invalid(self.z)
811 self.z = numpy.ma.masked_invalid(self.z)
812
812
813 if self.decimation is None:
813 if self.decimation is None:
814 x, y, z = self.fill_gaps(self.x, self.y, self.z)
814 x, y, z = self.fill_gaps(self.x, self.y, self.z)
815 else:
815 else:
816 x, y, z = self.fill_gaps(*self.decimate())
816 x, y, z = self.fill_gaps(*self.decimate())
817
817
818 for n, ax in enumerate(self.axes):
818 for n, ax in enumerate(self.axes):
819 self.zmin = self.zmin if self.zmin else numpy.min(self.z)
819 self.zmin = self.zmin if self.zmin else numpy.min(self.z)
820 self.zmax = self.zmax if self.zmax else numpy.max(self.z)
820 self.zmax = self.zmax if self.zmax else numpy.max(self.z)
821 data = self.data[-1]
821 data = self.data[-1]
822 if ax.firsttime:
822 if ax.firsttime:
823 ax.plt = ax.pcolormesh(x, y, z[n].T,
823 ax.plt = ax.pcolormesh(x, y, z[n].T,
824 vmin=self.zmin,
824 vmin=self.zmin,
825 vmax=self.zmax,
825 vmax=self.zmax,
826 cmap=plt.get_cmap(self.colormap)
826 cmap=plt.get_cmap(self.colormap)
827 )
827 )
828 else:
828 else:
829 ax.collections.remove(ax.collections[0])
829 ax.plt.remove()
830 ax.plt = ax.pcolormesh(x, y, z[n].T,
830 ax.plt = ax.pcolormesh(x, y, z[n].T,
831 vmin=self.zmin,
831 vmin=self.zmin,
832 vmax=self.zmax,
832 vmax=self.zmax,
833 cmap=plt.get_cmap(self.colormap)
833 cmap=plt.get_cmap(self.colormap)
834 )
834 )
835
835
836 #self.titles.append('Spectrogram')
836 #self.titles.append('Spectrogram')
837
837
838 #self.titles.append('{} Channel {} \n H = {} km ({} - {})'.format(
838 #self.titles.append('{} Channel {} \n H = {} km ({} - {})'.format(
839 #self.CODE.upper(), x, y[hei], y[hei],y[hei]+(DH*nProfiles)))
839 #self.CODE.upper(), x, y[hei], y[hei],y[hei]+(DH*nProfiles)))
840
840
841 class CoherencePlot(RTIPlot):
841 class CoherencePlot(RTIPlot):
842 '''
842 '''
843 Plot for Coherence data
843 Plot for Coherence data
844 '''
844 '''
845
845
846 CODE = 'coh'
846 CODE = 'coh'
847
847
848 def setup(self):
848 def setup(self):
849 self.xaxis = 'time'
849 self.xaxis = 'time'
850 self.ncols = 1
850 self.ncols = 1
851 self.nrows = len(self.data.pairs)
851 self.nrows = len(self.data.pairs)
852 self.nplots = len(self.data.pairs)
852 self.nplots = len(self.data.pairs)
853 self.ylabel = 'Range [km]'
853 self.ylabel = 'Range [km]'
854 self.xlabel = 'Time'
854 self.xlabel = 'Time'
855 self.plots_adjust.update({'hspace':0.6, 'left': 0.1, 'bottom': 0.1, 'right':0.95})
855 self.plots_adjust.update({'hspace':0.6, 'left': 0.1, 'bottom': 0.1, 'right':0.95})
856 if self.CODE == 'coh':
856 if self.CODE == 'coh':
857 self.cb_label = ''
857 self.cb_label = ''
858 self.titles = [
858 self.titles = [
859 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
859 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
860 else:
860 else:
861 self.cb_label = 'Degrees'
861 self.cb_label = 'Degrees'
862 self.titles = [
862 self.titles = [
863 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
863 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
864
864
865 def update(self, dataOut):
865 def update(self, dataOut):
866
866
867 data = {}
867 data = {}
868 meta = {}
868 meta = {}
869 data['coh'] = dataOut.getCoherence()
869 data['coh'] = dataOut.getCoherence()
870 meta['pairs'] = dataOut.pairsList
870 meta['pairs'] = dataOut.pairsList
871
871
872 return data, meta
872 return data, meta
873
873
874 class PhasePlot(CoherencePlot):
874 class PhasePlot(CoherencePlot):
875 '''
875 '''
876 Plot for Phase map data
876 Plot for Phase map data
877 '''
877 '''
878
878
879 CODE = 'phase'
879 CODE = 'phase'
880 colormap = 'seismic'
880 colormap = 'seismic'
881
881
882 def update(self, dataOut):
882 def update(self, dataOut):
883
883
884 data = {}
884 data = {}
885 meta = {}
885 meta = {}
886 data['phase'] = dataOut.getCoherence(phase=True)
886 data['phase'] = dataOut.getCoherence(phase=True)
887 meta['pairs'] = dataOut.pairsList
887 meta['pairs'] = dataOut.pairsList
888
888
889 return data, meta
889 return data, meta
890
890
891 class NoisePlot(Plot):
891 class NoisePlot(Plot):
892 '''
892 '''
893 Plot for noise
893 Plot for noise
894 '''
894 '''
895
895
896 CODE = 'noise'
896 CODE = 'noise'
897 plot_type = 'scatterbuffer'
897 plot_type = 'scatterbuffer'
898
898
899 def setup(self):
899 def setup(self):
900 self.xaxis = 'time'
900 self.xaxis = 'time'
901 self.ncols = 1
901 self.ncols = 1
902 self.nrows = 1
902 self.nrows = 1
903 self.nplots = 1
903 self.nplots = 1
904 self.ylabel = 'Intensity [dB]'
904 self.ylabel = 'Intensity [dB]'
905 self.xlabel = 'Time'
905 self.xlabel = 'Time'
906 self.titles = ['Noise']
906 self.titles = ['Noise']
907 self.colorbar = False
907 self.colorbar = False
908 self.plots_adjust.update({'right': 0.85 })
908 self.plots_adjust.update({'right': 0.85 })
909
909
910 def update(self, dataOut):
910 def update(self, dataOut):
911
911
912 data = {}
912 data = {}
913 meta = {}
913 meta = {}
914 data['noise'] = 10 * numpy.log10(dataOut.getNoise() / dataOut.normFactor).reshape(dataOut.nChannels, 1)
914 data['noise'] = 10 * numpy.log10(dataOut.getNoise() / dataOut.normFactor).reshape(dataOut.nChannels, 1)
915 meta['yrange'] = numpy.array([])
915 meta['yrange'] = numpy.array([])
916
916
917 return data, meta
917 return data, meta
918
918
919 def plot(self):
919 def plot(self):
920
920
921 x = self.data.times
921 x = self.data.times
922 xmin = self.data.min_time
922 xmin = self.data.min_time
923 xmax = xmin + self.xrange * 60 * 60
923 xmax = xmin + self.xrange * 60 * 60
924 Y = self.data['noise']
924 Y = self.data['noise']
925
925
926 if self.axes[0].firsttime:
926 if self.axes[0].firsttime:
927 self.ymin = numpy.nanmin(Y) - 5
927 self.ymin = numpy.nanmin(Y) - 5
928 self.ymax = numpy.nanmax(Y) + 5
928 self.ymax = numpy.nanmax(Y) + 5
929 for ch in self.data.channels:
929 for ch in self.data.channels:
930 y = Y[ch]
930 y = Y[ch]
931 self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch))
931 self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch))
932 plt.legend(bbox_to_anchor=(1.18, 1.0))
932 plt.legend(bbox_to_anchor=(1.18, 1.0))
933 else:
933 else:
934 for ch in self.data.channels:
934 for ch in self.data.channels:
935 y = Y[ch]
935 y = Y[ch]
936 self.axes[0].lines[ch].set_data(x, y)
936 self.axes[0].lines[ch].set_data(x, y)
937
937
938 self.ymin = numpy.nanmin(Y) - 5
938 self.ymin = numpy.nanmin(Y) - 5
939 self.ymax = numpy.nanmax(Y) + 10
939 self.ymax = numpy.nanmax(Y) + 10
940
940
941
941
942 class PowerProfilePlot(Plot):
942 class PowerProfilePlot(Plot):
943
943
944 CODE = 'pow_profile'
944 CODE = 'pow_profile'
945 plot_type = 'scatter'
945 plot_type = 'scatter'
946
946
947 def setup(self):
947 def setup(self):
948
948
949 self.ncols = 1
949 self.ncols = 1
950 self.nrows = 1
950 self.nrows = 1
951 self.nplots = 1
951 self.nplots = 1
952 self.height = 4
952 self.height = 4
953 self.width = 3
953 self.width = 3
954 self.ylabel = 'Range [km]'
954 self.ylabel = 'Range [km]'
955 self.xlabel = 'Intensity [dB]'
955 self.xlabel = 'Intensity [dB]'
956 self.titles = ['Power Profile']
956 self.titles = ['Power Profile']
957 self.colorbar = False
957 self.colorbar = False
958
958
959 def update(self, dataOut):
959 def update(self, dataOut):
960
960
961 data = {}
961 data = {}
962 meta = {}
962 meta = {}
963 data[self.CODE] = dataOut.getPower()
963 data[self.CODE] = dataOut.getPower()
964
964
965 return data, meta
965 return data, meta
966
966
967 def plot(self):
967 def plot(self):
968
968
969 y = self.data.yrange
969 y = self.data.yrange
970 self.y = y
970 self.y = y
971
971
972 x = self.data[-1][self.CODE]
972 x = self.data[-1][self.CODE]
973
973
974 if self.xmin is None: self.xmin = numpy.nanmin(x) * 0.9
974 if self.xmin is None: self.xmin = numpy.nanmin(x) * 0.9
975 if self.xmax is None: self.xmax = numpy.nanmax(x) * 1.1
975 if self.xmax is None: self.xmax = numpy.nanmax(x) * 1.1
976
976
977 if self.axes[0].firsttime:
977 if self.axes[0].firsttime:
978 for ch in self.data.channels:
978 for ch in self.data.channels:
979 self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch))
979 self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch))
980 plt.legend()
980 plt.legend()
981 else:
981 else:
982 for ch in self.data.channels:
982 for ch in self.data.channels:
983 self.axes[0].lines[ch].set_data(x[ch], y)
983 self.axes[0].lines[ch].set_data(x[ch], y)
984
984
985
985
986 class SpectraCutPlot(Plot):
986 class SpectraCutPlot(Plot):
987
987
988 CODE = 'spc_cut'
988 CODE = 'spc_cut'
989 plot_type = 'scatter'
989 plot_type = 'scatter'
990 buffering = False
990 buffering = False
991
991
992 def setup(self):
992 def setup(self):
993
993
994 self.nplots = len(self.data.channels)
994 self.nplots = len(self.data.channels)
995 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
995 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
996 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
996 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
997 self.width = 3.4 * self.ncols + 1.5
997 self.width = 3.4 * self.ncols + 1.5
998 self.height = 3 * self.nrows
998 self.height = 3 * self.nrows
999 self.ylabel = 'Power [dB]'
999 self.ylabel = 'Power [dB]'
1000 self.colorbar = False
1000 self.colorbar = False
1001 self.plots_adjust.update({'left':0.1, 'hspace':0.3, 'right': 0.75, 'bottom':0.08})
1001 self.plots_adjust.update({'left':0.1, 'hspace':0.3, 'right': 0.75, 'bottom':0.08})
1002
1002
1003 def update(self, dataOut):
1003 def update(self, dataOut):
1004
1004
1005 data = {}
1005 data = {}
1006 meta = {}
1006 meta = {}
1007 spc = 10 * numpy.log10(dataOut.data_pre[0] / dataOut.normFactor)
1007 spc = 10 * numpy.log10(dataOut.data_pre[0] / dataOut.normFactor)
1008 data['spc'] = spc
1008 data['spc'] = spc
1009 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS) / 1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
1009 meta['xrange'] = (dataOut.getFreqRange(EXTRA_POINTS) / 1000., dataOut.getAcfRange(EXTRA_POINTS), dataOut.getVelRange(EXTRA_POINTS))
1010 if self.CODE == 'cut_gaussian_fit':
1010 if self.CODE == 'cut_gaussian_fit':
1011 data['gauss_fit0'] = 10 * numpy.log10(dataOut.GaussFit0 / dataOut.normFactor)
1011 data['gauss_fit0'] = 10 * numpy.log10(dataOut.GaussFit0 / dataOut.normFactor)
1012 data['gauss_fit1'] = 10 * numpy.log10(dataOut.GaussFit1 / dataOut.normFactor)
1012 data['gauss_fit1'] = 10 * numpy.log10(dataOut.GaussFit1 / dataOut.normFactor)
1013 return data, meta
1013 return data, meta
1014
1014
1015 def plot(self):
1015 def plot(self):
1016 if self.xaxis == "frequency":
1016 if self.xaxis == "frequency":
1017 x = self.data.xrange[0][1:]
1017 x = self.data.xrange[0][1:]
1018 self.xlabel = "Frequency (kHz)"
1018 self.xlabel = "Frequency (kHz)"
1019 elif self.xaxis == "time":
1019 elif self.xaxis == "time":
1020 x = self.data.xrange[1]
1020 x = self.data.xrange[1]
1021 self.xlabel = "Time (ms)"
1021 self.xlabel = "Time (ms)"
1022 else:
1022 else:
1023 x = self.data.xrange[2][:-1]
1023 x = self.data.xrange[2][:-1]
1024 self.xlabel = "Velocity (m/s)"
1024 self.xlabel = "Velocity (m/s)"
1025
1025
1026 if self.CODE == 'cut_gaussian_fit':
1026 if self.CODE == 'cut_gaussian_fit':
1027 x = self.data.xrange[2][:-1]
1027 x = self.data.xrange[2][:-1]
1028 self.xlabel = "Velocity (m/s)"
1028 self.xlabel = "Velocity (m/s)"
1029
1029
1030 self.titles = []
1030 self.titles = []
1031
1031
1032 y = self.data.yrange
1032 y = self.data.yrange
1033 data = self.data[-1]
1033 data = self.data[-1]
1034 z = data['spc']
1034 z = data['spc']
1035
1035
1036 if self.height_index:
1036 if self.height_index:
1037 index = numpy.array(self.height_index)
1037 index = numpy.array(self.height_index)
1038 else:
1038 else:
1039 index = numpy.arange(0, len(y), int((len(y)) / 9))
1039 index = numpy.arange(0, len(y), int((len(y)) / 9))
1040
1040
1041 for n, ax in enumerate(self.axes):
1041 for n, ax in enumerate(self.axes):
1042 if self.CODE == 'cut_gaussian_fit':
1042 if self.CODE == 'cut_gaussian_fit':
1043 gau0 = data['gauss_fit0']
1043 gau0 = data['gauss_fit0']
1044 gau1 = data['gauss_fit1']
1044 gau1 = data['gauss_fit1']
1045 if ax.firsttime:
1045 if ax.firsttime:
1046 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
1046 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
1047 self.xmin = self.xmin if self.xmin else -self.xmax
1047 self.xmin = self.xmin if self.xmin else -self.xmax
1048 self.ymin = self.ymin if self.ymin else numpy.nanmin(z[:,:,index])
1048 self.ymin = self.ymin if self.ymin else numpy.nanmin(z[:,:,index])
1049 self.ymax = self.ymax if self.ymax else numpy.nanmax(z[:,:,index])
1049 self.ymax = self.ymax if self.ymax else numpy.nanmax(z[:,:,index])
1050
1050
1051 ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25)
1051 ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25)
1052 if self.CODE == 'cut_gaussian_fit':
1052 if self.CODE == 'cut_gaussian_fit':
1053 ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.')
1053 ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.')
1054 for i, line in enumerate(ax.plt_gau0):
1054 for i, line in enumerate(ax.plt_gau0):
1055 line.set_color(ax.plt[i].get_color())
1055 line.set_color(ax.plt[i].get_color())
1056 ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--')
1056 ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--')
1057 for i, line in enumerate(ax.plt_gau1):
1057 for i, line in enumerate(ax.plt_gau1):
1058 line.set_color(ax.plt[i].get_color())
1058 line.set_color(ax.plt[i].get_color())
1059 labels = ['Range = {:2.1f}km'.format(y[i]) for i in index]
1059 labels = ['Range = {:2.1f}km'.format(y[i]) for i in index]
1060 self.figures[0].legend(ax.plt, labels, loc='center right')
1060 self.figures[0].legend(ax.plt, labels, loc='center right')
1061 else:
1061 else:
1062 for i, line in enumerate(ax.plt):
1062 for i, line in enumerate(ax.plt):
1063 line.set_data(x, z[n, :, index[i]].T)
1063 line.set_data(x, z[n, :, index[i]].T)
1064 for i, line in enumerate(ax.plt_gau0):
1064 for i, line in enumerate(ax.plt_gau0):
1065 line.set_data(x, gau0[n, :, index[i]].T)
1065 line.set_data(x, gau0[n, :, index[i]].T)
1066 line.set_color(ax.plt[i].get_color())
1066 line.set_color(ax.plt[i].get_color())
1067 for i, line in enumerate(ax.plt_gau1):
1067 for i, line in enumerate(ax.plt_gau1):
1068 line.set_data(x, gau1[n, :, index[i]].T)
1068 line.set_data(x, gau1[n, :, index[i]].T)
1069 line.set_color(ax.plt[i].get_color())
1069 line.set_color(ax.plt[i].get_color())
1070 self.titles.append('CH {}'.format(n))
1070 self.titles.append('CH {}'.format(n))
1071
1071
1072
1072
1073 class BeaconPhase(Plot):
1073 class BeaconPhase(Plot):
1074
1074
1075 __isConfig = None
1075 __isConfig = None
1076 __nsubplots = None
1076 __nsubplots = None
1077
1077
1078 PREFIX = 'beacon_phase'
1078 PREFIX = 'beacon_phase'
1079
1079
1080 def __init__(self):
1080 def __init__(self):
1081 Plot.__init__(self)
1081 Plot.__init__(self)
1082 self.timerange = 24 * 60 * 60
1082 self.timerange = 24 * 60 * 60
1083 self.isConfig = False
1083 self.isConfig = False
1084 self.__nsubplots = 1
1084 self.__nsubplots = 1
1085 self.counter_imagwr = 0
1085 self.counter_imagwr = 0
1086 self.WIDTH = 800
1086 self.WIDTH = 800
1087 self.HEIGHT = 400
1087 self.HEIGHT = 400
1088 self.WIDTHPROF = 120
1088 self.WIDTHPROF = 120
1089 self.HEIGHTPROF = 0
1089 self.HEIGHTPROF = 0
1090 self.xdata = None
1090 self.xdata = None
1091 self.ydata = None
1091 self.ydata = None
1092
1092
1093 self.PLOT_CODE = BEACON_CODE
1093 self.PLOT_CODE = BEACON_CODE
1094
1094
1095 self.FTP_WEI = None
1095 self.FTP_WEI = None
1096 self.EXP_CODE = None
1096 self.EXP_CODE = None
1097 self.SUB_EXP_CODE = None
1097 self.SUB_EXP_CODE = None
1098 self.PLOT_POS = None
1098 self.PLOT_POS = None
1099
1099
1100 self.filename_phase = None
1100 self.filename_phase = None
1101
1101
1102 self.figfile = None
1102 self.figfile = None
1103
1103
1104 self.xmin = None
1104 self.xmin = None
1105 self.xmax = None
1105 self.xmax = None
1106
1106
1107 def getSubplots(self):
1107 def getSubplots(self):
1108
1108
1109 ncol = 1
1109 ncol = 1
1110 nrow = 1
1110 nrow = 1
1111
1111
1112 return nrow, ncol
1112 return nrow, ncol
1113
1113
1114 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1114 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1115
1115
1116 self.__showprofile = showprofile
1116 self.__showprofile = showprofile
1117 self.nplots = nplots
1117 self.nplots = nplots
1118
1118
1119 ncolspan = 7
1119 ncolspan = 7
1120 colspan = 6
1120 colspan = 6
1121 self.__nsubplots = 2
1121 self.__nsubplots = 2
1122
1122
1123 self.createFigure(id=id,
1123 self.createFigure(id=id,
1124 wintitle=wintitle,
1124 wintitle=wintitle,
1125 widthplot=self.WIDTH + self.WIDTHPROF,
1125 widthplot=self.WIDTH + self.WIDTHPROF,
1126 heightplot=self.HEIGHT + self.HEIGHTPROF,
1126 heightplot=self.HEIGHT + self.HEIGHTPROF,
1127 show=show)
1127 show=show)
1128
1128
1129 nrow, ncol = self.getSubplots()
1129 nrow, ncol = self.getSubplots()
1130
1130
1131 self.addAxes(nrow, ncol * ncolspan, 0, 0, colspan, 1)
1131 self.addAxes(nrow, ncol * ncolspan, 0, 0, colspan, 1)
1132
1132
1133 def save_phase(self, filename_phase):
1133 def save_phase(self, filename_phase):
1134 f = open(filename_phase, 'w+')
1134 f = open(filename_phase, 'w+')
1135 f.write('\n\n')
1135 f.write('\n\n')
1136 f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n')
1136 f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n')
1137 f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n')
1137 f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n')
1138 f.close()
1138 f.close()
1139
1139
1140 def save_data(self, filename_phase, data, data_datetime):
1140 def save_data(self, filename_phase, data, data_datetime):
1141 f = open(filename_phase, 'a')
1141 f = open(filename_phase, 'a')
1142 timetuple_data = data_datetime.timetuple()
1142 timetuple_data = data_datetime.timetuple()
1143 day = str(timetuple_data.tm_mday)
1143 day = str(timetuple_data.tm_mday)
1144 month = str(timetuple_data.tm_mon)
1144 month = str(timetuple_data.tm_mon)
1145 year = str(timetuple_data.tm_year)
1145 year = str(timetuple_data.tm_year)
1146 hour = str(timetuple_data.tm_hour)
1146 hour = str(timetuple_data.tm_hour)
1147 minute = str(timetuple_data.tm_min)
1147 minute = str(timetuple_data.tm_min)
1148 second = str(timetuple_data.tm_sec)
1148 second = str(timetuple_data.tm_sec)
1149 f.write(day + ' ' + month + ' ' + year + ' ' + hour + ' ' + minute + ' ' + second + ' ' + str(data[0]) + ' ' + str(data[1]) + ' ' + str(data[2]) + ' ' + str(data[3]) + '\n')
1149 f.write(day + ' ' + month + ' ' + year + ' ' + hour + ' ' + minute + ' ' + second + ' ' + str(data[0]) + ' ' + str(data[1]) + ' ' + str(data[2]) + ' ' + str(data[3]) + '\n')
1150 f.close()
1150 f.close()
1151
1151
1152 def plot(self):
1152 def plot(self):
1153 log.warning('TODO: Not yet implemented...')
1153 log.warning('TODO: Not yet implemented...')
1154
1154
1155 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1155 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1156 xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None,
1156 xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None,
1157 timerange=None,
1157 timerange=None,
1158 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1158 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1159 server=None, folder=None, username=None, password=None,
1159 server=None, folder=None, username=None, password=None,
1160 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1160 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1161
1161
1162 if dataOut.flagNoData:
1162 if dataOut.flagNoData:
1163 return dataOut
1163 return dataOut
1164
1164
1165 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
1165 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
1166 return
1166 return
1167
1167
1168 if pairsList == None:
1168 if pairsList == None:
1169 pairsIndexList = dataOut.pairsIndexList[:10]
1169 pairsIndexList = dataOut.pairsIndexList[:10]
1170 else:
1170 else:
1171 pairsIndexList = []
1171 pairsIndexList = []
1172 for pair in pairsList:
1172 for pair in pairsList:
1173 if pair not in dataOut.pairsList:
1173 if pair not in dataOut.pairsList:
1174 raise ValueError("Pair %s is not in dataOut.pairsList" % (pair))
1174 raise ValueError("Pair %s is not in dataOut.pairsList" % (pair))
1175 pairsIndexList.append(dataOut.pairsList.index(pair))
1175 pairsIndexList.append(dataOut.pairsList.index(pair))
1176
1176
1177 if pairsIndexList == []:
1177 if pairsIndexList == []:
1178 return
1178 return
1179
1179
1180 # if len(pairsIndexList) > 4:
1180 # if len(pairsIndexList) > 4:
1181 # pairsIndexList = pairsIndexList[0:4]
1181 # pairsIndexList = pairsIndexList[0:4]
1182
1182
1183 hmin_index = None
1183 hmin_index = None
1184 hmax_index = None
1184 hmax_index = None
1185
1185
1186 if hmin != None and hmax != None:
1186 if hmin != None and hmax != None:
1187 indexes = numpy.arange(dataOut.nHeights)
1187 indexes = numpy.arange(dataOut.nHeights)
1188 hmin_list = indexes[dataOut.heightList >= hmin]
1188 hmin_list = indexes[dataOut.heightList >= hmin]
1189 hmax_list = indexes[dataOut.heightList <= hmax]
1189 hmax_list = indexes[dataOut.heightList <= hmax]
1190
1190
1191 if hmin_list.any():
1191 if hmin_list.any():
1192 hmin_index = hmin_list[0]
1192 hmin_index = hmin_list[0]
1193
1193
1194 if hmax_list.any():
1194 if hmax_list.any():
1195 hmax_index = hmax_list[-1] + 1
1195 hmax_index = hmax_list[-1] + 1
1196
1196
1197 x = dataOut.getTimeRange()
1197 x = dataOut.getTimeRange()
1198
1198
1199 thisDatetime = dataOut.datatime
1199 thisDatetime = dataOut.datatime
1200
1200
1201 title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1201 title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1202 xlabel = "Local Time"
1202 xlabel = "Local Time"
1203 ylabel = "Phase (degrees)"
1203 ylabel = "Phase (degrees)"
1204
1204
1205 update_figfile = False
1205 update_figfile = False
1206
1206
1207 nplots = len(pairsIndexList)
1207 nplots = len(pairsIndexList)
1208 # phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1208 # phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1209 phase_beacon = numpy.zeros(len(pairsIndexList))
1209 phase_beacon = numpy.zeros(len(pairsIndexList))
1210 for i in range(nplots):
1210 for i in range(nplots):
1211 pair = dataOut.pairsList[pairsIndexList[i]]
1211 pair = dataOut.pairsList[pairsIndexList[i]]
1212 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0)
1212 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0)
1213 powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0)
1213 powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0)
1214 powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0)
1214 powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0)
1215 avgcoherenceComplex = ccf / numpy.sqrt(powa * powb)
1215 avgcoherenceComplex = ccf / numpy.sqrt(powa * powb)
1216 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real) * 180 / numpy.pi
1216 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real) * 180 / numpy.pi
1217
1217
1218 if dataOut.beacon_heiIndexList:
1218 if dataOut.beacon_heiIndexList:
1219 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
1219 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
1220 else:
1220 else:
1221 phase_beacon[i] = numpy.average(phase)
1221 phase_beacon[i] = numpy.average(phase)
1222
1222
1223 if not self.isConfig:
1223 if not self.isConfig:
1224
1224
1225 nplots = len(pairsIndexList)
1225 nplots = len(pairsIndexList)
1226
1226
1227 self.setup(id=id,
1227 self.setup(id=id,
1228 nplots=nplots,
1228 nplots=nplots,
1229 wintitle=wintitle,
1229 wintitle=wintitle,
1230 showprofile=showprofile,
1230 showprofile=showprofile,
1231 show=show)
1231 show=show)
1232
1232
1233 if timerange != None:
1233 if timerange != None:
1234 self.timerange = timerange
1234 self.timerange = timerange
1235
1235
1236 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1236 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1237
1237
1238 if ymin == None: ymin = 0
1238 if ymin == None: ymin = 0
1239 if ymax == None: ymax = 360
1239 if ymax == None: ymax = 360
1240
1240
1241 self.FTP_WEI = ftp_wei
1241 self.FTP_WEI = ftp_wei
1242 self.EXP_CODE = exp_code
1242 self.EXP_CODE = exp_code
1243 self.SUB_EXP_CODE = sub_exp_code
1243 self.SUB_EXP_CODE = sub_exp_code
1244 self.PLOT_POS = plot_pos
1244 self.PLOT_POS = plot_pos
1245
1245
1246 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1246 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1247 self.isConfig = True
1247 self.isConfig = True
1248 self.figfile = figfile
1248 self.figfile = figfile
1249 self.xdata = numpy.array([])
1249 self.xdata = numpy.array([])
1250 self.ydata = numpy.array([])
1250 self.ydata = numpy.array([])
1251
1251
1252 update_figfile = True
1252 update_figfile = True
1253
1253
1254 # open file beacon phase
1254 # open file beacon phase
1255 path = '%s%03d' % (self.PREFIX, self.id)
1255 path = '%s%03d' % (self.PREFIX, self.id)
1256 beacon_file = os.path.join(path, '%s.txt' % self.name)
1256 beacon_file = os.path.join(path, '%s.txt' % self.name)
1257 self.filename_phase = os.path.join(figpath, beacon_file)
1257 self.filename_phase = os.path.join(figpath, beacon_file)
1258 # self.save_phase(self.filename_phase)
1258 # self.save_phase(self.filename_phase)
1259
1259
1260
1260
1261 # store data beacon phase
1261 # store data beacon phase
1262 # self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1262 # self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1263
1263
1264 self.setWinTitle(title)
1264 self.setWinTitle(title)
1265
1265
1266
1266
1267 title = "Phase Plot %s" % (thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1267 title = "Phase Plot %s" % (thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1268
1268
1269 legendlabels = ["Pair (%d,%d)" % (pair[0], pair[1]) for pair in dataOut.pairsList]
1269 legendlabels = ["Pair (%d,%d)" % (pair[0], pair[1]) for pair in dataOut.pairsList]
1270
1270
1271 axes = self.axesList[0]
1271 axes = self.axesList[0]
1272
1272
1273 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1273 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1274
1274
1275 if len(self.ydata) == 0:
1275 if len(self.ydata) == 0:
1276 self.ydata = phase_beacon.reshape(-1, 1)
1276 self.ydata = phase_beacon.reshape(-1, 1)
1277 else:
1277 else:
1278 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1, 1)))
1278 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1, 1)))
1279
1279
1280
1280
1281 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1281 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1282 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1282 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1283 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1283 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1284 XAxisAsTime=True, grid='both'
1284 XAxisAsTime=True, grid='both'
1285 )
1285 )
1286
1286
1287 self.draw()
1287 self.draw()
1288
1288
1289 if dataOut.ltctime >= self.xmax:
1289 if dataOut.ltctime >= self.xmax:
1290 self.counter_imagwr = wr_period
1290 self.counter_imagwr = wr_period
1291 self.isConfig = False
1291 self.isConfig = False
1292 update_figfile = True
1292 update_figfile = True
1293
1293
1294 self.save(figpath=figpath,
1294 self.save(figpath=figpath,
1295 figfile=figfile,
1295 figfile=figfile,
1296 save=save,
1296 save=save,
1297 ftp=ftp,
1297 ftp=ftp,
1298 wr_period=wr_period,
1298 wr_period=wr_period,
1299 thisDatetime=thisDatetime,
1299 thisDatetime=thisDatetime,
1300 update_figfile=update_figfile)
1300 update_figfile=update_figfile)
1301
1301
1302 return dataOut
1302 return dataOut
@@ -1,1425 +1,1425
1
1
2 import os
2 import os
3 import time
3 import time
4 import math
4 import math
5 import datetime
5 import datetime
6 import numpy
6 import numpy
7 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator #YONG
7 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator #YONG
8
8
9 from .jroplot_spectra import RTIPlot, NoisePlot
9 from .jroplot_spectra import RTIPlot, NoisePlot
10
10
11 from schainpy.utils import log
11 from schainpy.utils import log
12 from .plotting_codes import *
12 from .plotting_codes import *
13
13
14 from schainpy.model.graphics.jroplot_base import Plot, plt
14 from schainpy.model.graphics.jroplot_base import Plot, plt
15
15
16 import matplotlib.pyplot as plt
16 import matplotlib.pyplot as plt
17 import matplotlib.colors as colors
17 import matplotlib.colors as colors
18 from matplotlib.ticker import MultipleLocator, LogLocator, NullFormatter
18 from matplotlib.ticker import MultipleLocator, LogLocator, NullFormatter
19
19
20
20
21 class RTIDPPlot(RTIPlot):
21 class RTIDPPlot(RTIPlot):
22 '''
22 '''
23 Written by R. Flores
23 Written by R. Flores
24 '''
24 '''
25 '''Plot for RTI Double Pulse Experiment Using Cross Products Analysis
25 '''Plot for RTI Double Pulse Experiment Using Cross Products Analysis
26 '''
26 '''
27
27
28 CODE = 'RTIDP'
28 CODE = 'RTIDP'
29 colormap = 'jro'
29 colormap = 'jro'
30 plot_name = 'RTI'
30 plot_name = 'RTI'
31
31
32 def setup(self):
32 def setup(self):
33 self.xaxis = 'time'
33 self.xaxis = 'time'
34 self.ncols = 1
34 self.ncols = 1
35 self.nrows = 3
35 self.nrows = 3
36 self.nplots = self.nrows
36 self.nplots = self.nrows
37 #self.height=10
37 #self.height=10
38 if self.showSNR:
38 if self.showSNR:
39 self.nrows += 1
39 self.nrows += 1
40 self.nplots += 1
40 self.nplots += 1
41
41
42 self.ylabel = 'Height [km]'
42 self.ylabel = 'Height [km]'
43 self.xlabel = 'Time (LT)'
43 self.xlabel = 'Time (LT)'
44
44
45 self.cb_label = 'Intensity (dB)'
45 self.cb_label = 'Intensity (dB)'
46
46
47 self.titles = ['{} Channel {}'.format(
47 self.titles = ['{} Channel {}'.format(
48 self.plot_name.upper(), '0x1'),'{} Channel {}'.format(
48 self.plot_name.upper(), '0x1'),'{} Channel {}'.format(
49 self.plot_name.upper(), '0'),'{} Channel {}'.format(
49 self.plot_name.upper(), '0'),'{} Channel {}'.format(
50 self.plot_name.upper(), '1')]
50 self.plot_name.upper(), '1')]
51
51
52 def update(self, dataOut):
52 def update(self, dataOut):
53
53
54 data = {}
54 data = {}
55 meta = {}
55 meta = {}
56 data[self.CODE] = dataOut.data_for_RTI_DP
56 data[self.CODE] = dataOut.data_for_RTI_DP
57 data['NRANGE'] = dataOut.NDP
57 data['NRANGE'] = dataOut.NDP
58
58
59 return data, meta
59 return data, meta
60
60
61 def plot(self):
61 def plot(self):
62
62
63 self.x = self.data.times
63 self.x = self.data.times
64 self.y = self.data.yrange[0: self.data['NRANGE']]
64 self.y = self.data.yrange[0: self.data['NRANGE']]
65 self.z = self.data[self.CODE]
65 self.z = self.data[self.CODE]
66 self.z = numpy.ma.masked_invalid(self.z)
66 self.z = numpy.ma.masked_invalid(self.z)
67
67
68 if self.decimation is None:
68 if self.decimation is None:
69 x, y, z = self.fill_gaps(self.x, self.y, self.z)
69 x, y, z = self.fill_gaps(self.x, self.y, self.z)
70 else:
70 else:
71 x, y, z = self.fill_gaps(*self.decimate())
71 x, y, z = self.fill_gaps(*self.decimate())
72
72
73 for n, ax in enumerate(self.axes):
73 for n, ax in enumerate(self.axes):
74
74
75 self.zmax = self.zmax if self.zmax is not None else numpy.max(
75 self.zmax = self.zmax if self.zmax is not None else numpy.max(
76 self.z[1][0,12:40])
76 self.z[1][0,12:40])
77 self.zmin = self.zmin if self.zmin is not None else numpy.min(
77 self.zmin = self.zmin if self.zmin is not None else numpy.min(
78 self.z[1][0,12:40])
78 self.z[1][0,12:40])
79
79
80 if ax.firsttime:
80 if ax.firsttime:
81
81
82 if self.zlimits is not None:
82 if self.zlimits is not None:
83 self.zmin, self.zmax = self.zlimits[n]
83 self.zmin, self.zmax = self.zlimits[n]
84
84
85 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
85 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
86 vmin=self.zmin,
86 vmin=self.zmin,
87 vmax=self.zmax,
87 vmax=self.zmax,
88 cmap=self.cmaps[n]
88 cmap=self.cmaps[n]
89 )
89 )
90 else:
90 else:
91 if self.zlimits is not None:
91 if self.zlimits is not None:
92 self.zmin, self.zmax = self.zlimits[n]
92 self.zmin, self.zmax = self.zlimits[n]
93 ax.collections.remove(ax.collections[0])
93 ax.plt.remove()
94 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
94 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
95 vmin=self.zmin,
95 vmin=self.zmin,
96 vmax=self.zmax,
96 vmax=self.zmax,
97 cmap=self.cmaps[n]
97 cmap=self.cmaps[n]
98 )
98 )
99
99
100
100
101 class RTILPPlot(RTIPlot):
101 class RTILPPlot(RTIPlot):
102
102
103 '''
103 '''
104 Written by R. Flores
104 Written by R. Flores
105 '''
105 '''
106 '''
106 '''
107 Plot for RTI Long Pulse Using Cross Products Analysis
107 Plot for RTI Long Pulse Using Cross Products Analysis
108 '''
108 '''
109
109
110 CODE = 'RTILP'
110 CODE = 'RTILP'
111 colormap = 'jro'
111 colormap = 'jro'
112 plot_name = 'RTI LP'
112 plot_name = 'RTI LP'
113
113
114 def setup(self):
114 def setup(self):
115 self.xaxis = 'time'
115 self.xaxis = 'time'
116 self.ncols = 1
116 self.ncols = 1
117 self.nrows = 2
117 self.nrows = 2
118 self.nplots = self.nrows
118 self.nplots = self.nrows
119 if self.showSNR:
119 if self.showSNR:
120 self.nrows += 1
120 self.nrows += 1
121 self.nplots += 1
121 self.nplots += 1
122
122
123 self.ylabel = 'Height [km]'
123 self.ylabel = 'Height [km]'
124 self.xlabel = 'Time (LT)'
124 self.xlabel = 'Time (LT)'
125
125
126 self.cb_label = 'Intensity (dB)'
126 self.cb_label = 'Intensity (dB)'
127
127
128 self.titles = ['{} Channel {}'.format(
128 self.titles = ['{} Channel {}'.format(
129 self.plot_name.upper(), '0'),'{} Channel {}'.format(
129 self.plot_name.upper(), '0'),'{} Channel {}'.format(
130 self.plot_name.upper(), '1'),'{} Channel {}'.format(
130 self.plot_name.upper(), '1'),'{} Channel {}'.format(
131 self.plot_name.upper(), '2'),'{} Channel {}'.format(
131 self.plot_name.upper(), '2'),'{} Channel {}'.format(
132 self.plot_name.upper(), '3')]
132 self.plot_name.upper(), '3')]
133
133
134
134
135 def update(self, dataOut):
135 def update(self, dataOut):
136
136
137 data = {}
137 data = {}
138 meta = {}
138 meta = {}
139 data['rti'] = dataOut.data_for_RTI_LP
139 data['rti'] = dataOut.data_for_RTI_LP
140 data['NRANGE'] = dataOut.NRANGE
140 data['NRANGE'] = dataOut.NRANGE
141
141
142 return data, meta
142 return data, meta
143 def plot(self):
143 def plot(self):
144
144
145 NRANGE = self.data['NRANGE'][-1]
145 NRANGE = self.data['NRANGE'][-1]
146 self.x = self.data.times
146 self.x = self.data.times
147 self.y = self.data.yrange[0:NRANGE]
147 self.y = self.data.yrange[0:NRANGE]
148
148
149 self.z = self.data['rti']
149 self.z = self.data['rti']
150
150
151 self.z = numpy.ma.masked_invalid(self.z)
151 self.z = numpy.ma.masked_invalid(self.z)
152
152
153 if self.decimation is None:
153 if self.decimation is None:
154 x, y, z = self.fill_gaps(self.x, self.y, self.z)
154 x, y, z = self.fill_gaps(self.x, self.y, self.z)
155 else:
155 else:
156 x, y, z = self.fill_gaps(*self.decimate())
156 x, y, z = self.fill_gaps(*self.decimate())
157
157
158 for n, ax in enumerate(self.axes):
158 for n, ax in enumerate(self.axes):
159
159
160 self.zmax = self.zmax if self.zmax is not None else numpy.max(
160 self.zmax = self.zmax if self.zmax is not None else numpy.max(
161 self.z[1][0,12:40])
161 self.z[1][0,12:40])
162 self.zmin = self.zmin if self.zmin is not None else numpy.min(
162 self.zmin = self.zmin if self.zmin is not None else numpy.min(
163 self.z[1][0,12:40])
163 self.z[1][0,12:40])
164
164
165 if ax.firsttime:
165 if ax.firsttime:
166
166
167 if self.zlimits is not None:
167 if self.zlimits is not None:
168 self.zmin, self.zmax = self.zlimits[n]
168 self.zmin, self.zmax = self.zlimits[n]
169
169
170
170
171 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
171 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
172 vmin=self.zmin,
172 vmin=self.zmin,
173 vmax=self.zmax,
173 vmax=self.zmax,
174 cmap=self.cmaps[n]
174 cmap=self.cmaps[n]
175 )
175 )
176 #plt.tight_layout()
176 #plt.tight_layout()
177 else:
177 else:
178 if self.zlimits is not None:
178 if self.zlimits is not None:
179 self.zmin, self.zmax = self.zlimits[n]
179 self.zmin, self.zmax = self.zlimits[n]
180 ax.collections.remove(ax.collections[0])
180 ax.plt.remove()
181 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
181 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
182 vmin=self.zmin,
182 vmin=self.zmin,
183 vmax=self.zmax,
183 vmax=self.zmax,
184 cmap=self.cmaps[n]
184 cmap=self.cmaps[n]
185 )
185 )
186 #plt.tight_layout()
186 #plt.tight_layout()
187
187
188
188
189 class DenRTIPlot(RTIPlot):
189 class DenRTIPlot(RTIPlot):
190 '''
190 '''
191 Written by R. Flores
191 Written by R. Flores
192 '''
192 '''
193 '''
193 '''
194 RTI Plot for Electron Densities
194 RTI Plot for Electron Densities
195 '''
195 '''
196
196
197 CODE = 'denrti'
197 CODE = 'denrti'
198 colormap = 'jet'
198 colormap = 'jet'
199
199
200 def setup(self):
200 def setup(self):
201 self.xaxis = 'time'
201 self.xaxis = 'time'
202 self.ncols = 1
202 self.ncols = 1
203 self.nrows = self.data.shape(self.CODE)[0]
203 self.nrows = self.data.shape(self.CODE)[0]
204 self.nplots = self.nrows
204 self.nplots = self.nrows
205
205
206 self.ylabel = 'Range [km]'
206 self.ylabel = 'Range [km]'
207 self.xlabel = 'Time (LT)'
207 self.xlabel = 'Time (LT)'
208
208
209 self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18})
209 self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18})
210
210
211 if self.CODE == 'denrti':
211 if self.CODE == 'denrti':
212 self.cb_label = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)'
212 self.cb_label = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)'
213
213
214 self.titles = ['Electron Density RTI']
214 self.titles = ['Electron Density RTI']
215
215
216 def update(self, dataOut):
216 def update(self, dataOut):
217
217
218 data = {}
218 data = {}
219 meta = {}
219 meta = {}
220
220
221 data['denrti'] = dataOut.DensityFinal*1.e-6 #To Plot in cm^-3
221 data['denrti'] = dataOut.DensityFinal*1.e-6 #To Plot in cm^-3
222
222
223 return data, meta
223 return data, meta
224
224
225 def plot(self):
225 def plot(self):
226
226
227 self.x = self.data.times
227 self.x = self.data.times
228 self.y = self.data.yrange
228 self.y = self.data.yrange
229
229
230 self.z = self.data[self.CODE]
230 self.z = self.data[self.CODE]
231
231
232 self.z = numpy.ma.masked_invalid(self.z)
232 self.z = numpy.ma.masked_invalid(self.z)
233
233
234 if self.decimation is None:
234 if self.decimation is None:
235 x, y, z = self.fill_gaps(self.x, self.y, self.z)
235 x, y, z = self.fill_gaps(self.x, self.y, self.z)
236 else:
236 else:
237 x, y, z = self.fill_gaps(*self.decimate())
237 x, y, z = self.fill_gaps(*self.decimate())
238
238
239 for n, ax in enumerate(self.axes):
239 for n, ax in enumerate(self.axes):
240
240
241 self.zmax = self.zmax if self.zmax is not None else numpy.max(
241 self.zmax = self.zmax if self.zmax is not None else numpy.max(
242 self.z[n])
242 self.z[n])
243 self.zmin = self.zmin if self.zmin is not None else numpy.min(
243 self.zmin = self.zmin if self.zmin is not None else numpy.min(
244 self.z[n])
244 self.z[n])
245
245
246 if ax.firsttime:
246 if ax.firsttime:
247
247
248 if self.zlimits is not None:
248 if self.zlimits is not None:
249 self.zmin, self.zmax = self.zlimits[n]
249 self.zmin, self.zmax = self.zlimits[n]
250 if numpy.log10(self.zmin)<0:
250 if numpy.log10(self.zmin)<0:
251 self.zmin=1
251 self.zmin=1
252 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
252 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
253 vmin=self.zmin,
253 vmin=self.zmin,
254 vmax=self.zmax,
254 vmax=self.zmax,
255 cmap=self.cmaps[n],
255 cmap=self.cmaps[n],
256 norm=colors.LogNorm()
256 norm=colors.LogNorm()
257 )
257 )
258
258
259 else:
259 else:
260 if self.zlimits is not None:
260 if self.zlimits is not None:
261 self.zmin, self.zmax = self.zlimits[n]
261 self.zmin, self.zmax = self.zlimits[n]
262 ax.collections.remove(ax.collections[0])
262 ax.plt.remove()
263 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
263 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
264 vmin=self.zmin,
264 vmin=self.zmin,
265 vmax=self.zmax,
265 vmax=self.zmax,
266 cmap=self.cmaps[n],
266 cmap=self.cmaps[n],
267 norm=colors.LogNorm()
267 norm=colors.LogNorm()
268 )
268 )
269
269
270
270
271 class ETempRTIPlot(RTIPlot):
271 class ETempRTIPlot(RTIPlot):
272 '''
272 '''
273 Written by R. Flores
273 Written by R. Flores
274 '''
274 '''
275 '''
275 '''
276 Plot for Electron Temperature
276 Plot for Electron Temperature
277 '''
277 '''
278
278
279 CODE = 'ETemp'
279 CODE = 'ETemp'
280 colormap = 'jet'
280 colormap = 'jet'
281
281
282 def setup(self):
282 def setup(self):
283 self.xaxis = 'time'
283 self.xaxis = 'time'
284 self.ncols = 1
284 self.ncols = 1
285 self.nrows = self.data.shape(self.CODE)[0]
285 self.nrows = self.data.shape(self.CODE)[0]
286 self.nplots = self.nrows
286 self.nplots = self.nrows
287
287
288 self.ylabel = 'Range [km]'
288 self.ylabel = 'Range [km]'
289 self.xlabel = 'Time (LT)'
289 self.xlabel = 'Time (LT)'
290 self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18})
290 self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18})
291 if self.CODE == 'ETemp':
291 if self.CODE == 'ETemp':
292 self.cb_label = 'Electron Temperature (K)'
292 self.cb_label = 'Electron Temperature (K)'
293 self.titles = ['Electron Temperature RTI']
293 self.titles = ['Electron Temperature RTI']
294 if self.CODE == 'ITemp':
294 if self.CODE == 'ITemp':
295 self.cb_label = 'Ion Temperature (K)'
295 self.cb_label = 'Ion Temperature (K)'
296 self.titles = ['Ion Temperature RTI']
296 self.titles = ['Ion Temperature RTI']
297 if self.CODE == 'HeFracLP':
297 if self.CODE == 'HeFracLP':
298 self.cb_label ='He+ Fraction'
298 self.cb_label ='He+ Fraction'
299 self.titles = ['He+ Fraction RTI']
299 self.titles = ['He+ Fraction RTI']
300 self.zmax=0.16
300 self.zmax=0.16
301 if self.CODE == 'HFracLP':
301 if self.CODE == 'HFracLP':
302 self.cb_label ='H+ Fraction'
302 self.cb_label ='H+ Fraction'
303 self.titles = ['H+ Fraction RTI']
303 self.titles = ['H+ Fraction RTI']
304
304
305 def update(self, dataOut):
305 def update(self, dataOut):
306
306
307 data = {}
307 data = {}
308 meta = {}
308 meta = {}
309
309
310 data['ETemp'] = dataOut.ElecTempFinal
310 data['ETemp'] = dataOut.ElecTempFinal
311
311
312 return data, meta
312 return data, meta
313
313
314 def plot(self):
314 def plot(self):
315
315
316 self.x = self.data.times
316 self.x = self.data.times
317 self.y = self.data.yrange
317 self.y = self.data.yrange
318 self.z = self.data[self.CODE]
318 self.z = self.data[self.CODE]
319
319
320 self.z = numpy.ma.masked_invalid(self.z)
320 self.z = numpy.ma.masked_invalid(self.z)
321
321
322 if self.decimation is None:
322 if self.decimation is None:
323 x, y, z = self.fill_gaps(self.x, self.y, self.z)
323 x, y, z = self.fill_gaps(self.x, self.y, self.z)
324 else:
324 else:
325 x, y, z = self.fill_gaps(*self.decimate())
325 x, y, z = self.fill_gaps(*self.decimate())
326
326
327 for n, ax in enumerate(self.axes):
327 for n, ax in enumerate(self.axes):
328
328
329 self.zmax = self.zmax if self.zmax is not None else numpy.max(
329 self.zmax = self.zmax if self.zmax is not None else numpy.max(
330 self.z[n])
330 self.z[n])
331 self.zmin = self.zmin if self.zmin is not None else numpy.min(
331 self.zmin = self.zmin if self.zmin is not None else numpy.min(
332 self.z[n])
332 self.z[n])
333
333
334 if ax.firsttime:
334 if ax.firsttime:
335
335
336 if self.zlimits is not None:
336 if self.zlimits is not None:
337 self.zmin, self.zmax = self.zlimits[n]
337 self.zmin, self.zmax = self.zlimits[n]
338
338
339 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
339 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
340 vmin=self.zmin,
340 vmin=self.zmin,
341 vmax=self.zmax,
341 vmax=self.zmax,
342 cmap=self.cmaps[n]
342 cmap=self.cmaps[n]
343 )
343 )
344 #plt.tight_layout()
344 #plt.tight_layout()
345
345
346 else:
346 else:
347 if self.zlimits is not None:
347 if self.zlimits is not None:
348 self.zmin, self.zmax = self.zlimits[n]
348 self.zmin, self.zmax = self.zlimits[n]
349 ax.collections.remove(ax.collections[0])
349 ax.plt.remove()
350 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
350 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
351 vmin=self.zmin,
351 vmin=self.zmin,
352 vmax=self.zmax,
352 vmax=self.zmax,
353 cmap=self.cmaps[n]
353 cmap=self.cmaps[n]
354 )
354 )
355
355
356
356
357 class ITempRTIPlot(ETempRTIPlot):
357 class ITempRTIPlot(ETempRTIPlot):
358 '''
358 '''
359 Written by R. Flores
359 Written by R. Flores
360 '''
360 '''
361 '''
361 '''
362 Plot for Ion Temperature
362 Plot for Ion Temperature
363 '''
363 '''
364
364
365 CODE = 'ITemp'
365 CODE = 'ITemp'
366 colormap = 'jet'
366 colormap = 'jet'
367 plot_name = 'Ion Temperature'
367 plot_name = 'Ion Temperature'
368
368
369 def update(self, dataOut):
369 def update(self, dataOut):
370
370
371 data = {}
371 data = {}
372 meta = {}
372 meta = {}
373
373
374 data['ITemp'] = dataOut.IonTempFinal
374 data['ITemp'] = dataOut.IonTempFinal
375
375
376 return data, meta
376 return data, meta
377
377
378
378
379 class HFracRTIPlot(ETempRTIPlot):
379 class HFracRTIPlot(ETempRTIPlot):
380 '''
380 '''
381 Written by R. Flores
381 Written by R. Flores
382 '''
382 '''
383 '''
383 '''
384 Plot for H+ LP
384 Plot for H+ LP
385 '''
385 '''
386
386
387 CODE = 'HFracLP'
387 CODE = 'HFracLP'
388 colormap = 'jet'
388 colormap = 'jet'
389 plot_name = 'H+ Frac'
389 plot_name = 'H+ Frac'
390
390
391 def update(self, dataOut):
391 def update(self, dataOut):
392
392
393 data = {}
393 data = {}
394 meta = {}
394 meta = {}
395 data['HFracLP'] = dataOut.PhyFinal
395 data['HFracLP'] = dataOut.PhyFinal
396
396
397 return data, meta
397 return data, meta
398
398
399
399
400 class HeFracRTIPlot(ETempRTIPlot):
400 class HeFracRTIPlot(ETempRTIPlot):
401 '''
401 '''
402 Written by R. Flores
402 Written by R. Flores
403 '''
403 '''
404 '''
404 '''
405 Plot for He+ LP
405 Plot for He+ LP
406 '''
406 '''
407
407
408 CODE = 'HeFracLP'
408 CODE = 'HeFracLP'
409 colormap = 'jet'
409 colormap = 'jet'
410 plot_name = 'He+ Frac'
410 plot_name = 'He+ Frac'
411
411
412 def update(self, dataOut):
412 def update(self, dataOut):
413
413
414 data = {}
414 data = {}
415 meta = {}
415 meta = {}
416 data['HeFracLP'] = dataOut.PheFinal
416 data['HeFracLP'] = dataOut.PheFinal
417
417
418 return data, meta
418 return data, meta
419
419
420
420
421 class TempsDPPlot(Plot):
421 class TempsDPPlot(Plot):
422 '''
422 '''
423 Written by R. Flores
423 Written by R. Flores
424 '''
424 '''
425 '''
425 '''
426 Plot for Electron - Ion Temperatures
426 Plot for Electron - Ion Temperatures
427 '''
427 '''
428
428
429 CODE = 'tempsDP'
429 CODE = 'tempsDP'
430 #plot_name = 'Temperatures'
430 #plot_name = 'Temperatures'
431 plot_type = 'scatterbuffer'
431 plot_type = 'scatterbuffer'
432
432
433 def setup(self):
433 def setup(self):
434
434
435 self.ncols = 1
435 self.ncols = 1
436 self.nrows = 1
436 self.nrows = 1
437 self.nplots = 1
437 self.nplots = 1
438 self.ylabel = 'Range [km]'
438 self.ylabel = 'Range [km]'
439 self.xlabel = 'Temperature (K)'
439 self.xlabel = 'Temperature (K)'
440 self.titles = ['Electron/Ion Temperatures']
440 self.titles = ['Electron/Ion Temperatures']
441 self.width = 3.5
441 self.width = 3.5
442 self.height = 5.5
442 self.height = 5.5
443 self.colorbar = False
443 self.colorbar = False
444 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
444 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
445
445
446 def update(self, dataOut):
446 def update(self, dataOut):
447 data = {}
447 data = {}
448 meta = {}
448 meta = {}
449
449
450 data['Te'] = dataOut.te2
450 data['Te'] = dataOut.te2
451 data['Ti'] = dataOut.ti2
451 data['Ti'] = dataOut.ti2
452 data['Te_error'] = dataOut.ete2
452 data['Te_error'] = dataOut.ete2
453 data['Ti_error'] = dataOut.eti2
453 data['Ti_error'] = dataOut.eti2
454
454
455 meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS]
455 meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS]
456
456
457 return data, meta
457 return data, meta
458
458
459 def plot(self):
459 def plot(self):
460
460
461 y = self.data.yrange
461 y = self.data.yrange
462
462
463 self.xmin = -100
463 self.xmin = -100
464 self.xmax = 5000
464 self.xmax = 5000
465
465
466 ax = self.axes[0]
466 ax = self.axes[0]
467
467
468 data = self.data[-1]
468 data = self.data[-1]
469
469
470 Te = data['Te']
470 Te = data['Te']
471 Ti = data['Ti']
471 Ti = data['Ti']
472 errTe = data['Te_error']
472 errTe = data['Te_error']
473 errTi = data['Ti_error']
473 errTi = data['Ti_error']
474
474
475 if ax.firsttime:
475 if ax.firsttime:
476 ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te')
476 ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te')
477 ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti')
477 ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti')
478 plt.legend(loc='lower right')
478 plt.legend(loc='lower right')
479 self.ystep_given = 50
479 self.ystep_given = 50
480 ax.yaxis.set_minor_locator(MultipleLocator(15))
480 ax.yaxis.set_minor_locator(MultipleLocator(15))
481 ax.grid(which='minor')
481 ax.grid(which='minor')
482
482
483 else:
483 else:
484 self.clear_figures()
484 self.clear_figures()
485 ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te')
485 ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te')
486 ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti')
486 ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti')
487 plt.legend(loc='lower right')
487 plt.legend(loc='lower right')
488 ax.yaxis.set_minor_locator(MultipleLocator(15))
488 ax.yaxis.set_minor_locator(MultipleLocator(15))
489
489
490
490
491 class TempsHPPlot(Plot):
491 class TempsHPPlot(Plot):
492 '''
492 '''
493 Written by R. Flores
493 Written by R. Flores
494 '''
494 '''
495 '''
495 '''
496 Plot for Temperatures Hybrid Experiment
496 Plot for Temperatures Hybrid Experiment
497 '''
497 '''
498
498
499 CODE = 'temps_LP'
499 CODE = 'temps_LP'
500 #plot_name = 'Temperatures'
500 #plot_name = 'Temperatures'
501 plot_type = 'scatterbuffer'
501 plot_type = 'scatterbuffer'
502
502
503
503
504 def setup(self):
504 def setup(self):
505
505
506 self.ncols = 1
506 self.ncols = 1
507 self.nrows = 1
507 self.nrows = 1
508 self.nplots = 1
508 self.nplots = 1
509 self.ylabel = 'Range [km]'
509 self.ylabel = 'Range [km]'
510 self.xlabel = 'Temperature (K)'
510 self.xlabel = 'Temperature (K)'
511 self.titles = ['Electron/Ion Temperatures']
511 self.titles = ['Electron/Ion Temperatures']
512 self.width = 3.5
512 self.width = 3.5
513 self.height = 6.5
513 self.height = 6.5
514 self.colorbar = False
514 self.colorbar = False
515 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
515 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
516
516
517 def update(self, dataOut):
517 def update(self, dataOut):
518 data = {}
518 data = {}
519 meta = {}
519 meta = {}
520
520
521
521
522 data['Te'] = numpy.concatenate((dataOut.te2[:dataOut.cut],dataOut.te[dataOut.cut:]))
522 data['Te'] = numpy.concatenate((dataOut.te2[:dataOut.cut],dataOut.te[dataOut.cut:]))
523 data['Ti'] = numpy.concatenate((dataOut.ti2[:dataOut.cut],dataOut.ti[dataOut.cut:]))
523 data['Ti'] = numpy.concatenate((dataOut.ti2[:dataOut.cut],dataOut.ti[dataOut.cut:]))
524 data['Te_error'] = numpy.concatenate((dataOut.ete2[:dataOut.cut],dataOut.ete[dataOut.cut:]))
524 data['Te_error'] = numpy.concatenate((dataOut.ete2[:dataOut.cut],dataOut.ete[dataOut.cut:]))
525 data['Ti_error'] = numpy.concatenate((dataOut.eti2[:dataOut.cut],dataOut.eti[dataOut.cut:]))
525 data['Ti_error'] = numpy.concatenate((dataOut.eti2[:dataOut.cut],dataOut.eti[dataOut.cut:]))
526
526
527 meta['yrange'] = dataOut.heightList[0:dataOut.NACF]
527 meta['yrange'] = dataOut.heightList[0:dataOut.NACF]
528
528
529 return data, meta
529 return data, meta
530
530
531 def plot(self):
531 def plot(self):
532
532
533
533
534 self.y = self.data.yrange
534 self.y = self.data.yrange
535 self.xmin = -100
535 self.xmin = -100
536 self.xmax = 4500
536 self.xmax = 4500
537 ax = self.axes[0]
537 ax = self.axes[0]
538
538
539 data = self.data[-1]
539 data = self.data[-1]
540
540
541 Te = data['Te']
541 Te = data['Te']
542 Ti = data['Ti']
542 Ti = data['Ti']
543 errTe = data['Te_error']
543 errTe = data['Te_error']
544 errTi = data['Ti_error']
544 errTi = data['Ti_error']
545
545
546 if ax.firsttime:
546 if ax.firsttime:
547
547
548 ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te')
548 ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te')
549 ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti')
549 ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti')
550 plt.legend(loc='lower right')
550 plt.legend(loc='lower right')
551 self.ystep_given = 200
551 self.ystep_given = 200
552 ax.yaxis.set_minor_locator(MultipleLocator(15))
552 ax.yaxis.set_minor_locator(MultipleLocator(15))
553 ax.grid(which='minor')
553 ax.grid(which='minor')
554
554
555 else:
555 else:
556 self.clear_figures()
556 self.clear_figures()
557 ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te')
557 ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te')
558 ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti')
558 ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti')
559 plt.legend(loc='lower right')
559 plt.legend(loc='lower right')
560 ax.yaxis.set_minor_locator(MultipleLocator(15))
560 ax.yaxis.set_minor_locator(MultipleLocator(15))
561 ax.grid(which='minor')
561 ax.grid(which='minor')
562
562
563
563
564 class FracsHPPlot(Plot):
564 class FracsHPPlot(Plot):
565 '''
565 '''
566 Written by R. Flores
566 Written by R. Flores
567 '''
567 '''
568 '''
568 '''
569 Plot for Composition LP
569 Plot for Composition LP
570 '''
570 '''
571
571
572 CODE = 'fracs_LP'
572 CODE = 'fracs_LP'
573 plot_type = 'scatterbuffer'
573 plot_type = 'scatterbuffer'
574
574
575
575
576 def setup(self):
576 def setup(self):
577
577
578 self.ncols = 1
578 self.ncols = 1
579 self.nrows = 1
579 self.nrows = 1
580 self.nplots = 1
580 self.nplots = 1
581 self.ylabel = 'Range [km]'
581 self.ylabel = 'Range [km]'
582 self.xlabel = 'Frac'
582 self.xlabel = 'Frac'
583 self.titles = ['Composition']
583 self.titles = ['Composition']
584 self.width = 3.5
584 self.width = 3.5
585 self.height = 6.5
585 self.height = 6.5
586 self.colorbar = False
586 self.colorbar = False
587 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
587 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
588
588
589 def update(self, dataOut):
589 def update(self, dataOut):
590 data = {}
590 data = {}
591 meta = {}
591 meta = {}
592
592
593 #aux_nan=numpy.zeros(dataOut.cut,'float32')
593 #aux_nan=numpy.zeros(dataOut.cut,'float32')
594 #aux_nan[:]=numpy.nan
594 #aux_nan[:]=numpy.nan
595 #data['ph'] = numpy.concatenate((aux_nan,dataOut.ph[dataOut.cut:]))
595 #data['ph'] = numpy.concatenate((aux_nan,dataOut.ph[dataOut.cut:]))
596 #data['eph'] = numpy.concatenate((aux_nan,dataOut.eph[dataOut.cut:]))
596 #data['eph'] = numpy.concatenate((aux_nan,dataOut.eph[dataOut.cut:]))
597
597
598 data['ph'] = dataOut.ph[dataOut.cut:]
598 data['ph'] = dataOut.ph[dataOut.cut:]
599 data['eph'] = dataOut.eph[dataOut.cut:]
599 data['eph'] = dataOut.eph[dataOut.cut:]
600 data['phe'] = dataOut.phe[dataOut.cut:]
600 data['phe'] = dataOut.phe[dataOut.cut:]
601 data['ephe'] = dataOut.ephe[dataOut.cut:]
601 data['ephe'] = dataOut.ephe[dataOut.cut:]
602
602
603 data['cut'] = dataOut.cut
603 data['cut'] = dataOut.cut
604
604
605 meta['yrange'] = dataOut.heightList[0:dataOut.NACF]
605 meta['yrange'] = dataOut.heightList[0:dataOut.NACF]
606
606
607
607
608 return data, meta
608 return data, meta
609
609
610 def plot(self):
610 def plot(self):
611
611
612 data = self.data[-1]
612 data = self.data[-1]
613
613
614 ph = data['ph']
614 ph = data['ph']
615 eph = data['eph']
615 eph = data['eph']
616 phe = data['phe']
616 phe = data['phe']
617 ephe = data['ephe']
617 ephe = data['ephe']
618 cut = data['cut']
618 cut = data['cut']
619 self.y = self.data.yrange
619 self.y = self.data.yrange
620
620
621 self.xmin = 0
621 self.xmin = 0
622 self.xmax = 1
622 self.xmax = 1
623 ax = self.axes[0]
623 ax = self.axes[0]
624
624
625 if ax.firsttime:
625 if ax.firsttime:
626
626
627 ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+')
627 ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+')
628 ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+')
628 ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+')
629 plt.legend(loc='lower right')
629 plt.legend(loc='lower right')
630 self.xstep_given = 0.2
630 self.xstep_given = 0.2
631 self.ystep_given = 200
631 self.ystep_given = 200
632 ax.yaxis.set_minor_locator(MultipleLocator(15))
632 ax.yaxis.set_minor_locator(MultipleLocator(15))
633 ax.grid(which='minor')
633 ax.grid(which='minor')
634
634
635 else:
635 else:
636 self.clear_figures()
636 self.clear_figures()
637 ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+')
637 ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+')
638 ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+')
638 ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+')
639 plt.legend(loc='lower right')
639 plt.legend(loc='lower right')
640 ax.yaxis.set_minor_locator(MultipleLocator(15))
640 ax.yaxis.set_minor_locator(MultipleLocator(15))
641 ax.grid(which='minor')
641 ax.grid(which='minor')
642
642
643 class EDensityPlot(Plot):
643 class EDensityPlot(Plot):
644 '''
644 '''
645 Written by R. Flores
645 Written by R. Flores
646 '''
646 '''
647 '''
647 '''
648 Plot for electron density
648 Plot for electron density
649 '''
649 '''
650
650
651 CODE = 'den'
651 CODE = 'den'
652 #plot_name = 'Electron Density'
652 #plot_name = 'Electron Density'
653 plot_type = 'scatterbuffer'
653 plot_type = 'scatterbuffer'
654
654
655 def setup(self):
655 def setup(self):
656
656
657 self.ncols = 1
657 self.ncols = 1
658 self.nrows = 1
658 self.nrows = 1
659 self.nplots = 1
659 self.nplots = 1
660 self.ylabel = 'Range [km]'
660 self.ylabel = 'Range [km]'
661 self.xlabel = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)'
661 self.xlabel = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)'
662 self.titles = ['Electron Density']
662 self.titles = ['Electron Density']
663 self.width = 3.5
663 self.width = 3.5
664 self.height = 5.5
664 self.height = 5.5
665 self.colorbar = False
665 self.colorbar = False
666 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
666 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
667
667
668 def update(self, dataOut):
668 def update(self, dataOut):
669 data = {}
669 data = {}
670 meta = {}
670 meta = {}
671
671
672 data['den_power'] = dataOut.ph2[:dataOut.NSHTS]
672 data['den_power'] = dataOut.ph2[:dataOut.NSHTS]
673 data['den_Faraday'] = dataOut.dphi[:dataOut.NSHTS]
673 data['den_Faraday'] = dataOut.dphi[:dataOut.NSHTS]
674 data['den_error'] = dataOut.sdp2[:dataOut.NSHTS]
674 data['den_error'] = dataOut.sdp2[:dataOut.NSHTS]
675 #data['err_Faraday'] = dataOut.sdn1[:dataOut.NSHTS]
675 #data['err_Faraday'] = dataOut.sdn1[:dataOut.NSHTS]
676 #print(numpy.shape(data['den_power']))
676 #print(numpy.shape(data['den_power']))
677 #print(numpy.shape(data['den_Faraday']))
677 #print(numpy.shape(data['den_Faraday']))
678 #print(numpy.shape(data['den_error']))
678 #print(numpy.shape(data['den_error']))
679
679
680 data['NSHTS'] = dataOut.NSHTS
680 data['NSHTS'] = dataOut.NSHTS
681
681
682 meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS]
682 meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS]
683
683
684 return data, meta
684 return data, meta
685
685
686 def plot(self):
686 def plot(self):
687
687
688 y = self.data.yrange
688 y = self.data.yrange
689
689
690 #self.xmin = 1e3
690 #self.xmin = 1e3
691 #self.xmax = 1e7
691 #self.xmax = 1e7
692
692
693 ax = self.axes[0]
693 ax = self.axes[0]
694
694
695 data = self.data[-1]
695 data = self.data[-1]
696
696
697 DenPow = data['den_power']
697 DenPow = data['den_power']
698 DenFar = data['den_Faraday']
698 DenFar = data['den_Faraday']
699 errDenPow = data['den_error']
699 errDenPow = data['den_error']
700 #errFaraday = data['err_Faraday']
700 #errFaraday = data['err_Faraday']
701
701
702 NSHTS = data['NSHTS']
702 NSHTS = data['NSHTS']
703
703
704 if self.CODE == 'denLP':
704 if self.CODE == 'denLP':
705 DenPowLP = data['den_LP']
705 DenPowLP = data['den_LP']
706 errDenPowLP = data['den_LP_error']
706 errDenPowLP = data['den_LP_error']
707 cut = data['cut']
707 cut = data['cut']
708
708
709 if ax.firsttime:
709 if ax.firsttime:
710 self.autoxticks=False
710 self.autoxticks=False
711 #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2)
711 #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2)
712 ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2,linestyle='-')
712 ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2,linestyle='-')
713 #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2)
713 #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2)
714 ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-')
714 ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-')
715
715
716 if self.CODE=='denLP':
716 if self.CODE=='denLP':
717 ax.errorbar(DenPowLP[cut:], y[cut:], xerr=errDenPowLP[cut:], fmt='r^-',elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2)
717 ax.errorbar(DenPowLP[cut:], y[cut:], xerr=errDenPowLP[cut:], fmt='r^-',elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2)
718
718
719 plt.legend(loc='upper left',fontsize=8.5)
719 plt.legend(loc='upper left',fontsize=8.5)
720 #plt.legend(loc='lower left',fontsize=8.5)
720 #plt.legend(loc='lower left',fontsize=8.5)
721 ax.set_xscale("log", nonposx='clip')
721 ax.set_xscale("log", nonposx='clip')
722 grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50)
722 grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50)
723 self.ystep_given=100
723 self.ystep_given=100
724 if self.CODE=='denLP':
724 if self.CODE=='denLP':
725 self.ystep_given=200
725 self.ystep_given=200
726 ax.set_yticks(grid_y_ticks,minor=True)
726 ax.set_yticks(grid_y_ticks,minor=True)
727 locmaj = LogLocator(base=10,numticks=12)
727 locmaj = LogLocator(base=10,numticks=12)
728 ax.xaxis.set_major_locator(locmaj)
728 ax.xaxis.set_major_locator(locmaj)
729 locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12)
729 locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12)
730 ax.xaxis.set_minor_locator(locmin)
730 ax.xaxis.set_minor_locator(locmin)
731 ax.xaxis.set_minor_formatter(NullFormatter())
731 ax.xaxis.set_minor_formatter(NullFormatter())
732 ax.grid(which='minor')
732 ax.grid(which='minor')
733
733
734 else:
734 else:
735 dataBefore = self.data[-2]
735 dataBefore = self.data[-2]
736 DenPowBefore = dataBefore['den_power']
736 DenPowBefore = dataBefore['den_power']
737 self.clear_figures()
737 self.clear_figures()
738 #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2)
738 #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2)
739 ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2,linestyle='-')
739 ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2,linestyle='-')
740 #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2)
740 #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2)
741 ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-')
741 ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-')
742 ax.errorbar(DenPowBefore, y[:NSHTS], elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed")
742 ax.errorbar(DenPowBefore, y[:NSHTS], elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed")
743
743
744 if self.CODE=='denLP':
744 if self.CODE=='denLP':
745 ax.errorbar(DenPowLP[cut:], y[cut:], fmt='r^-', xerr=errDenPowLP[cut:],elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2)
745 ax.errorbar(DenPowLP[cut:], y[cut:], fmt='r^-', xerr=errDenPowLP[cut:],elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2)
746
746
747 ax.set_xscale("log", nonposx='clip')
747 ax.set_xscale("log", nonposx='clip')
748 grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50)
748 grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50)
749 ax.set_yticks(grid_y_ticks,minor=True)
749 ax.set_yticks(grid_y_ticks,minor=True)
750 locmaj = LogLocator(base=10,numticks=12)
750 locmaj = LogLocator(base=10,numticks=12)
751 ax.xaxis.set_major_locator(locmaj)
751 ax.xaxis.set_major_locator(locmaj)
752 locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12)
752 locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12)
753 ax.xaxis.set_minor_locator(locmin)
753 ax.xaxis.set_minor_locator(locmin)
754 ax.xaxis.set_minor_formatter(NullFormatter())
754 ax.xaxis.set_minor_formatter(NullFormatter())
755 ax.grid(which='minor')
755 ax.grid(which='minor')
756 plt.legend(loc='upper left',fontsize=8.5)
756 plt.legend(loc='upper left',fontsize=8.5)
757 #plt.legend(loc='lower left',fontsize=8.5)
757 #plt.legend(loc='lower left',fontsize=8.5)
758
758
759 class RelativeDenPlot(Plot):
759 class RelativeDenPlot(Plot):
760 '''
760 '''
761 Written by R. Flores
761 Written by R. Flores
762 '''
762 '''
763 '''
763 '''
764 Plot for electron density
764 Plot for electron density
765 '''
765 '''
766
766
767 CODE = 'den'
767 CODE = 'den'
768 #plot_name = 'Electron Density'
768 #plot_name = 'Electron Density'
769 plot_type = 'scatterbuffer'
769 plot_type = 'scatterbuffer'
770
770
771 def setup(self):
771 def setup(self):
772
772
773 self.ncols = 1
773 self.ncols = 1
774 self.nrows = 1
774 self.nrows = 1
775 self.nplots = 1
775 self.nplots = 1
776 self.ylabel = 'Range [km]'
776 self.ylabel = 'Range [km]'
777 self.xlabel = r'$\mathrm{N_e}$ Relative Electron Density ($\mathrm{1/cm^3}$)'
777 self.xlabel = r'$\mathrm{N_e}$ Relative Electron Density ($\mathrm{1/cm^3}$)'
778 self.titles = ['Electron Density']
778 self.titles = ['Electron Density']
779 self.width = 3.5
779 self.width = 3.5
780 self.height = 5.5
780 self.height = 5.5
781 self.colorbar = False
781 self.colorbar = False
782 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
782 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
783
783
784 def update(self, dataOut):
784 def update(self, dataOut):
785 data = {}
785 data = {}
786 meta = {}
786 meta = {}
787
787
788 data['den_power'] = dataOut.ph2
788 data['den_power'] = dataOut.ph2
789 data['den_error'] = dataOut.sdp2
789 data['den_error'] = dataOut.sdp2
790
790
791 meta['yrange'] = dataOut.heightList
791 meta['yrange'] = dataOut.heightList
792
792
793 return data, meta
793 return data, meta
794
794
795 def plot(self):
795 def plot(self):
796
796
797 y = self.data.yrange
797 y = self.data.yrange
798
798
799 ax = self.axes[0]
799 ax = self.axes[0]
800
800
801 data = self.data[-1]
801 data = self.data[-1]
802
802
803 DenPow = data['den_power']
803 DenPow = data['den_power']
804 errDenPow = data['den_error']
804 errDenPow = data['den_error']
805
805
806 if ax.firsttime:
806 if ax.firsttime:
807 self.autoxticks=False
807 self.autoxticks=False
808 ax.errorbar(DenPow, y, fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-')
808 ax.errorbar(DenPow, y, fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-')
809
809
810 plt.legend(loc='upper left',fontsize=8.5)
810 plt.legend(loc='upper left',fontsize=8.5)
811 #plt.legend(loc='lower left',fontsize=8.5)
811 #plt.legend(loc='lower left',fontsize=8.5)
812 ax.set_xscale("log", nonposx='clip')
812 ax.set_xscale("log", nonposx='clip')
813 grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50)
813 grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50)
814 self.ystep_given=100
814 self.ystep_given=100
815 ax.set_yticks(grid_y_ticks,minor=True)
815 ax.set_yticks(grid_y_ticks,minor=True)
816 locmaj = LogLocator(base=10,numticks=12)
816 locmaj = LogLocator(base=10,numticks=12)
817 ax.xaxis.set_major_locator(locmaj)
817 ax.xaxis.set_major_locator(locmaj)
818 locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12)
818 locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12)
819 ax.xaxis.set_minor_locator(locmin)
819 ax.xaxis.set_minor_locator(locmin)
820 ax.xaxis.set_minor_formatter(NullFormatter())
820 ax.xaxis.set_minor_formatter(NullFormatter())
821 ax.grid(which='minor')
821 ax.grid(which='minor')
822
822
823 else:
823 else:
824 dataBefore = self.data[-2]
824 dataBefore = self.data[-2]
825 DenPowBefore = dataBefore['den_power']
825 DenPowBefore = dataBefore['den_power']
826 self.clear_figures()
826 self.clear_figures()
827 ax.errorbar(DenPow, y, fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-')
827 ax.errorbar(DenPow, y, fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-')
828 ax.errorbar(DenPowBefore, y, elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed")
828 ax.errorbar(DenPowBefore, y, elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed")
829
829
830 ax.set_xscale("log", nonposx='clip')
830 ax.set_xscale("log", nonposx='clip')
831 grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50)
831 grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50)
832 ax.set_yticks(grid_y_ticks,minor=True)
832 ax.set_yticks(grid_y_ticks,minor=True)
833 locmaj = LogLocator(base=10,numticks=12)
833 locmaj = LogLocator(base=10,numticks=12)
834 ax.xaxis.set_major_locator(locmaj)
834 ax.xaxis.set_major_locator(locmaj)
835 locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12)
835 locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12)
836 ax.xaxis.set_minor_locator(locmin)
836 ax.xaxis.set_minor_locator(locmin)
837 ax.xaxis.set_minor_formatter(NullFormatter())
837 ax.xaxis.set_minor_formatter(NullFormatter())
838 ax.grid(which='minor')
838 ax.grid(which='minor')
839 plt.legend(loc='upper left',fontsize=8.5)
839 plt.legend(loc='upper left',fontsize=8.5)
840 #plt.legend(loc='lower left',fontsize=8.5)
840 #plt.legend(loc='lower left',fontsize=8.5)
841
841
842 class FaradayAnglePlot(Plot):
842 class FaradayAnglePlot(Plot):
843 '''
843 '''
844 Written by R. Flores
844 Written by R. Flores
845 '''
845 '''
846 '''
846 '''
847 Plot for electron density
847 Plot for electron density
848 '''
848 '''
849
849
850 CODE = 'angle'
850 CODE = 'angle'
851 plot_name = 'Faraday Angle'
851 plot_name = 'Faraday Angle'
852 plot_type = 'scatterbuffer'
852 plot_type = 'scatterbuffer'
853
853
854 def setup(self):
854 def setup(self):
855
855
856 self.ncols = 1
856 self.ncols = 1
857 self.nrows = 1
857 self.nrows = 1
858 self.nplots = 1
858 self.nplots = 1
859 self.ylabel = 'Range [km]'
859 self.ylabel = 'Range [km]'
860 self.xlabel = 'Faraday Angle (ΒΊ)'
860 self.xlabel = 'Faraday Angle (ΒΊ)'
861 self.titles = ['Electron Density']
861 self.titles = ['Electron Density']
862 self.width = 3.5
862 self.width = 3.5
863 self.height = 5.5
863 self.height = 5.5
864 self.colorbar = False
864 self.colorbar = False
865 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
865 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
866
866
867 def update(self, dataOut):
867 def update(self, dataOut):
868 data = {}
868 data = {}
869 meta = {}
869 meta = {}
870
870
871 data['angle'] = numpy.degrees(dataOut.phi)
871 data['angle'] = numpy.degrees(dataOut.phi)
872 #'''
872 #'''
873 #print(dataOut.phi_uwrp)
873 #print(dataOut.phi_uwrp)
874 #print(data['angle'])
874 #print(data['angle'])
875 #exit(1)
875 #exit(1)
876 #'''
876 #'''
877 data['dphi'] = dataOut.dphi_uc*10
877 data['dphi'] = dataOut.dphi_uc*10
878 #print(dataOut.dphi)
878 #print(dataOut.dphi)
879
879
880 #data['NSHTS'] = dataOut.NSHTS
880 #data['NSHTS'] = dataOut.NSHTS
881
881
882 #meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS]
882 #meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS]
883
883
884 return data, meta
884 return data, meta
885
885
886 def plot(self):
886 def plot(self):
887
887
888 data = self.data[-1]
888 data = self.data[-1]
889 self.x = data[self.CODE]
889 self.x = data[self.CODE]
890 dphi = data['dphi']
890 dphi = data['dphi']
891 self.y = self.data.yrange
891 self.y = self.data.yrange
892 self.xmin = -360#-180
892 self.xmin = -360#-180
893 self.xmax = 360#180
893 self.xmax = 360#180
894 ax = self.axes[0]
894 ax = self.axes[0]
895
895
896 if ax.firsttime:
896 if ax.firsttime:
897 self.autoxticks=False
897 self.autoxticks=False
898 #if self.CODE=='den':
898 #if self.CODE=='den':
899 ax.plot(self.x, self.y,marker='o',color='g',linewidth=1.0,markersize=2)
899 ax.plot(self.x, self.y,marker='o',color='g',linewidth=1.0,markersize=2)
900 ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2)
900 ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2)
901
901
902 grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50)
902 grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50)
903 self.ystep_given=100
903 self.ystep_given=100
904 if self.CODE=='denLP':
904 if self.CODE=='denLP':
905 self.ystep_given=200
905 self.ystep_given=200
906 ax.set_yticks(grid_y_ticks,minor=True)
906 ax.set_yticks(grid_y_ticks,minor=True)
907 ax.grid(which='minor')
907 ax.grid(which='minor')
908 #plt.tight_layout()
908 #plt.tight_layout()
909 else:
909 else:
910
910
911 self.clear_figures()
911 self.clear_figures()
912 #if self.CODE=='den':
912 #if self.CODE=='den':
913 #print(numpy.shape(self.x))
913 #print(numpy.shape(self.x))
914 ax.plot(self.x, self.y, marker='o',color='g',linewidth=1.0, markersize=2)
914 ax.plot(self.x, self.y, marker='o',color='g',linewidth=1.0, markersize=2)
915 ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2)
915 ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2)
916
916
917 grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50)
917 grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50)
918 ax.set_yticks(grid_y_ticks,minor=True)
918 ax.set_yticks(grid_y_ticks,minor=True)
919 ax.grid(which='minor')
919 ax.grid(which='minor')
920
920
921 class EDensityHPPlot(EDensityPlot):
921 class EDensityHPPlot(EDensityPlot):
922 '''
922 '''
923 Written by R. Flores
923 Written by R. Flores
924 '''
924 '''
925 '''
925 '''
926 Plot for Electron Density Hybrid Experiment
926 Plot for Electron Density Hybrid Experiment
927 '''
927 '''
928
928
929 CODE = 'denLP'
929 CODE = 'denLP'
930 plot_name = 'Electron Density'
930 plot_name = 'Electron Density'
931 plot_type = 'scatterbuffer'
931 plot_type = 'scatterbuffer'
932
932
933 def update(self, dataOut):
933 def update(self, dataOut):
934 data = {}
934 data = {}
935 meta = {}
935 meta = {}
936
936
937 data['den_power'] = dataOut.ph2[:dataOut.NSHTS]
937 data['den_power'] = dataOut.ph2[:dataOut.NSHTS]
938 data['den_Faraday']=dataOut.dphi[:dataOut.NSHTS]
938 data['den_Faraday']=dataOut.dphi[:dataOut.NSHTS]
939 data['den_error']=dataOut.sdp2[:dataOut.NSHTS]
939 data['den_error']=dataOut.sdp2[:dataOut.NSHTS]
940 data['den_LP']=dataOut.ne[:dataOut.NACF]
940 data['den_LP']=dataOut.ne[:dataOut.NACF]
941 data['den_LP_error']=dataOut.ene[:dataOut.NACF]*dataOut.ne[:dataOut.NACF]*0.434
941 data['den_LP_error']=dataOut.ene[:dataOut.NACF]*dataOut.ne[:dataOut.NACF]*0.434
942 #self.ene=10**dataOut.ene[:dataOut.NACF]
942 #self.ene=10**dataOut.ene[:dataOut.NACF]
943 data['NSHTS']=dataOut.NSHTS
943 data['NSHTS']=dataOut.NSHTS
944 data['cut']=dataOut.cut
944 data['cut']=dataOut.cut
945
945
946 return data, meta
946 return data, meta
947
947
948
948
949 class ACFsPlot(Plot):
949 class ACFsPlot(Plot):
950 '''
950 '''
951 Written by R. Flores
951 Written by R. Flores
952 '''
952 '''
953 '''
953 '''
954 Plot for ACFs Double Pulse Experiment
954 Plot for ACFs Double Pulse Experiment
955 '''
955 '''
956
956
957 CODE = 'acfs'
957 CODE = 'acfs'
958 #plot_name = 'ACF'
958 #plot_name = 'ACF'
959 plot_type = 'scatterbuffer'
959 plot_type = 'scatterbuffer'
960
960
961
961
962 def setup(self):
962 def setup(self):
963 self.ncols = 1
963 self.ncols = 1
964 self.nrows = 1
964 self.nrows = 1
965 self.nplots = 1
965 self.nplots = 1
966 self.ylabel = 'Range [km]'
966 self.ylabel = 'Range [km]'
967 self.xlabel = 'Lag (ms)'
967 self.xlabel = 'Lag (ms)'
968 self.titles = ['ACFs']
968 self.titles = ['ACFs']
969 self.width = 3.5
969 self.width = 3.5
970 self.height = 5.5
970 self.height = 5.5
971 self.colorbar = False
971 self.colorbar = False
972 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
972 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
973
973
974 def update(self, dataOut):
974 def update(self, dataOut):
975 data = {}
975 data = {}
976 meta = {}
976 meta = {}
977
977
978 data['ACFs'] = dataOut.acfs_to_plot
978 data['ACFs'] = dataOut.acfs_to_plot
979 data['ACFs_error'] = dataOut.acfs_error_to_plot
979 data['ACFs_error'] = dataOut.acfs_error_to_plot
980 data['lags'] = dataOut.lags_to_plot
980 data['lags'] = dataOut.lags_to_plot
981 data['Lag_contaminated_1'] = dataOut.x_igcej_to_plot
981 data['Lag_contaminated_1'] = dataOut.x_igcej_to_plot
982 data['Lag_contaminated_2'] = dataOut.x_ibad_to_plot
982 data['Lag_contaminated_2'] = dataOut.x_ibad_to_plot
983 data['Height_contaminated_1'] = dataOut.y_igcej_to_plot
983 data['Height_contaminated_1'] = dataOut.y_igcej_to_plot
984 data['Height_contaminated_2'] = dataOut.y_ibad_to_plot
984 data['Height_contaminated_2'] = dataOut.y_ibad_to_plot
985
985
986 meta['yrange'] = numpy.array([])
986 meta['yrange'] = numpy.array([])
987 #meta['NSHTS'] = dataOut.NSHTS
987 #meta['NSHTS'] = dataOut.NSHTS
988 #meta['DPL'] = dataOut.DPL
988 #meta['DPL'] = dataOut.DPL
989 data['NSHTS'] = dataOut.NSHTS #This is metadata
989 data['NSHTS'] = dataOut.NSHTS #This is metadata
990 data['DPL'] = dataOut.DPL #This is metadata
990 data['DPL'] = dataOut.DPL #This is metadata
991
991
992 return data, meta
992 return data, meta
993
993
994 def plot(self):
994 def plot(self):
995
995
996 data = self.data[-1]
996 data = self.data[-1]
997 #NSHTS = self.meta['NSHTS']
997 #NSHTS = self.meta['NSHTS']
998 #DPL = self.meta['DPL']
998 #DPL = self.meta['DPL']
999 NSHTS = data['NSHTS'] #This is metadata
999 NSHTS = data['NSHTS'] #This is metadata
1000 DPL = data['DPL'] #This is metadata
1000 DPL = data['DPL'] #This is metadata
1001
1001
1002 lags = data['lags']
1002 lags = data['lags']
1003 ACFs = data['ACFs']
1003 ACFs = data['ACFs']
1004 errACFs = data['ACFs_error']
1004 errACFs = data['ACFs_error']
1005 BadLag1 = data['Lag_contaminated_1']
1005 BadLag1 = data['Lag_contaminated_1']
1006 BadLag2 = data['Lag_contaminated_2']
1006 BadLag2 = data['Lag_contaminated_2']
1007 BadHei1 = data['Height_contaminated_1']
1007 BadHei1 = data['Height_contaminated_1']
1008 BadHei2 = data['Height_contaminated_2']
1008 BadHei2 = data['Height_contaminated_2']
1009
1009
1010 self.xmin = 0.0
1010 self.xmin = 0.0
1011 self.xmax = 2.0
1011 self.xmax = 2.0
1012 self.y = ACFs
1012 self.y = ACFs
1013
1013
1014 ax = self.axes[0]
1014 ax = self.axes[0]
1015
1015
1016 if ax.firsttime:
1016 if ax.firsttime:
1017
1017
1018 for i in range(NSHTS):
1018 for i in range(NSHTS):
1019 x_aux = numpy.isfinite(lags[i,:])
1019 x_aux = numpy.isfinite(lags[i,:])
1020 y_aux = numpy.isfinite(ACFs[i,:])
1020 y_aux = numpy.isfinite(ACFs[i,:])
1021 yerr_aux = numpy.isfinite(errACFs[i,:])
1021 yerr_aux = numpy.isfinite(errACFs[i,:])
1022 x_igcej_aux = numpy.isfinite(BadLag1[i,:])
1022 x_igcej_aux = numpy.isfinite(BadLag1[i,:])
1023 y_igcej_aux = numpy.isfinite(BadHei1[i,:])
1023 y_igcej_aux = numpy.isfinite(BadHei1[i,:])
1024 x_ibad_aux = numpy.isfinite(BadLag2[i,:])
1024 x_ibad_aux = numpy.isfinite(BadLag2[i,:])
1025 y_ibad_aux = numpy.isfinite(BadHei2[i,:])
1025 y_ibad_aux = numpy.isfinite(BadHei2[i,:])
1026 if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2:
1026 if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2:
1027 ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',marker='o',linewidth=1.0,markersize=2)
1027 ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',marker='o',linewidth=1.0,markersize=2)
1028 ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2)
1028 ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2)
1029 ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2)
1029 ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2)
1030
1030
1031 self.xstep_given = (self.xmax-self.xmin)/(DPL-1)
1031 self.xstep_given = (self.xmax-self.xmin)/(DPL-1)
1032 self.ystep_given = 50
1032 self.ystep_given = 50
1033 ax.yaxis.set_minor_locator(MultipleLocator(15))
1033 ax.yaxis.set_minor_locator(MultipleLocator(15))
1034 ax.grid(which='minor')
1034 ax.grid(which='minor')
1035
1035
1036 else:
1036 else:
1037 self.clear_figures()
1037 self.clear_figures()
1038 for i in range(NSHTS):
1038 for i in range(NSHTS):
1039 x_aux = numpy.isfinite(lags[i,:])
1039 x_aux = numpy.isfinite(lags[i,:])
1040 y_aux = numpy.isfinite(ACFs[i,:])
1040 y_aux = numpy.isfinite(ACFs[i,:])
1041 yerr_aux = numpy.isfinite(errACFs[i,:])
1041 yerr_aux = numpy.isfinite(errACFs[i,:])
1042 x_igcej_aux = numpy.isfinite(BadLag1[i,:])
1042 x_igcej_aux = numpy.isfinite(BadLag1[i,:])
1043 y_igcej_aux = numpy.isfinite(BadHei1[i,:])
1043 y_igcej_aux = numpy.isfinite(BadHei1[i,:])
1044 x_ibad_aux = numpy.isfinite(BadLag2[i,:])
1044 x_ibad_aux = numpy.isfinite(BadLag2[i,:])
1045 y_ibad_aux = numpy.isfinite(BadHei2[i,:])
1045 y_ibad_aux = numpy.isfinite(BadHei2[i,:])
1046 if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2:
1046 if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2:
1047 ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],linewidth=1.0,markersize=2,color='b',marker='o')
1047 ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],linewidth=1.0,markersize=2,color='b',marker='o')
1048 ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2)
1048 ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2)
1049 ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2)
1049 ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2)
1050 ax.yaxis.set_minor_locator(MultipleLocator(15))
1050 ax.yaxis.set_minor_locator(MultipleLocator(15))
1051
1051
1052 class ACFsLPPlot(Plot):
1052 class ACFsLPPlot(Plot):
1053 '''
1053 '''
1054 Written by R. Flores
1054 Written by R. Flores
1055 '''
1055 '''
1056 '''
1056 '''
1057 Plot for ACFs Double Pulse Experiment
1057 Plot for ACFs Double Pulse Experiment
1058 '''
1058 '''
1059
1059
1060 CODE = 'acfs_LP'
1060 CODE = 'acfs_LP'
1061 #plot_name = 'ACF'
1061 #plot_name = 'ACF'
1062 plot_type = 'scatterbuffer'
1062 plot_type = 'scatterbuffer'
1063
1063
1064
1064
1065 def setup(self):
1065 def setup(self):
1066 self.ncols = 1
1066 self.ncols = 1
1067 self.nrows = 1
1067 self.nrows = 1
1068 self.nplots = 1
1068 self.nplots = 1
1069 self.ylabel = 'Range [km]'
1069 self.ylabel = 'Range [km]'
1070 self.xlabel = 'Lag (ms)'
1070 self.xlabel = 'Lag (ms)'
1071 self.titles = ['ACFs']
1071 self.titles = ['ACFs']
1072 self.width = 3.5
1072 self.width = 3.5
1073 self.height = 5.5
1073 self.height = 5.5
1074 self.colorbar = False
1074 self.colorbar = False
1075 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
1075 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
1076
1076
1077 def update(self, dataOut):
1077 def update(self, dataOut):
1078 data = {}
1078 data = {}
1079 meta = {}
1079 meta = {}
1080
1080
1081 aux=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32')
1081 aux=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32')
1082 errors=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32')
1082 errors=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32')
1083 lags_LP_to_plot=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32')
1083 lags_LP_to_plot=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32')
1084
1084
1085 for i in range(dataOut.NACF):
1085 for i in range(dataOut.NACF):
1086 for j in range(dataOut.IBITS):
1086 for j in range(dataOut.IBITS):
1087 if numpy.abs(dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0])<1.0:
1087 if numpy.abs(dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0])<1.0:
1088 aux[i,j]=dataOut.output_LP_integrated.real[j,i,0]/dataOut.output_LP_integrated.real[0,i,0]
1088 aux[i,j]=dataOut.output_LP_integrated.real[j,i,0]/dataOut.output_LP_integrated.real[0,i,0]
1089 aux[i,j]=max(min(aux[i,j],1.0),-1.0)*dataOut.DH+dataOut.heightList[i]
1089 aux[i,j]=max(min(aux[i,j],1.0),-1.0)*dataOut.DH+dataOut.heightList[i]
1090 lags_LP_to_plot[i,j]=dataOut.lags_LP[j]
1090 lags_LP_to_plot[i,j]=dataOut.lags_LP[j]
1091 errors[i,j]=dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0]*dataOut.DH
1091 errors[i,j]=dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0]*dataOut.DH
1092 else:
1092 else:
1093 aux[i,j]=numpy.nan
1093 aux[i,j]=numpy.nan
1094 lags_LP_to_plot[i,j]=numpy.nan
1094 lags_LP_to_plot[i,j]=numpy.nan
1095 errors[i,j]=numpy.nan
1095 errors[i,j]=numpy.nan
1096
1096
1097 data['ACFs'] = aux
1097 data['ACFs'] = aux
1098 data['ACFs_error'] = errors
1098 data['ACFs_error'] = errors
1099 data['lags'] = lags_LP_to_plot
1099 data['lags'] = lags_LP_to_plot
1100
1100
1101 meta['yrange'] = numpy.array([])
1101 meta['yrange'] = numpy.array([])
1102 #meta['NACF'] = dataOut.NACF
1102 #meta['NACF'] = dataOut.NACF
1103 #meta['NLAG'] = dataOut.NLAG
1103 #meta['NLAG'] = dataOut.NLAG
1104 data['NACF'] = dataOut.NACF #This is metadata
1104 data['NACF'] = dataOut.NACF #This is metadata
1105 data['NLAG'] = dataOut.NLAG #This is metadata
1105 data['NLAG'] = dataOut.NLAG #This is metadata
1106
1106
1107 return data, meta
1107 return data, meta
1108
1108
1109 def plot(self):
1109 def plot(self):
1110
1110
1111 data = self.data[-1]
1111 data = self.data[-1]
1112 #NACF = self.meta['NACF']
1112 #NACF = self.meta['NACF']
1113 #NLAG = self.meta['NLAG']
1113 #NLAG = self.meta['NLAG']
1114 NACF = data['NACF'] #This is metadata
1114 NACF = data['NACF'] #This is metadata
1115 NLAG = data['NLAG'] #This is metadata
1115 NLAG = data['NLAG'] #This is metadata
1116
1116
1117 lags = data['lags']
1117 lags = data['lags']
1118 ACFs = data['ACFs']
1118 ACFs = data['ACFs']
1119 errACFs = data['ACFs_error']
1119 errACFs = data['ACFs_error']
1120
1120
1121 self.xmin = 0.0
1121 self.xmin = 0.0
1122 self.xmax = 1.5
1122 self.xmax = 1.5
1123
1123
1124 self.y = ACFs
1124 self.y = ACFs
1125
1125
1126 ax = self.axes[0]
1126 ax = self.axes[0]
1127
1127
1128 if ax.firsttime:
1128 if ax.firsttime:
1129
1129
1130 for i in range(NACF):
1130 for i in range(NACF):
1131 x_aux = numpy.isfinite(lags[i,:])
1131 x_aux = numpy.isfinite(lags[i,:])
1132 y_aux = numpy.isfinite(ACFs[i,:])
1132 y_aux = numpy.isfinite(ACFs[i,:])
1133 yerr_aux = numpy.isfinite(errACFs[i,:])
1133 yerr_aux = numpy.isfinite(errACFs[i,:])
1134
1134
1135 if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2:
1135 if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2:
1136 ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r')
1136 ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r')
1137
1137
1138 #self.xstep_given = (self.xmax-self.xmin)/(self.data.NLAG-1)
1138 #self.xstep_given = (self.xmax-self.xmin)/(self.data.NLAG-1)
1139 self.xstep_given=0.3
1139 self.xstep_given=0.3
1140 self.ystep_given = 200
1140 self.ystep_given = 200
1141 ax.yaxis.set_minor_locator(MultipleLocator(15))
1141 ax.yaxis.set_minor_locator(MultipleLocator(15))
1142 ax.grid(which='minor')
1142 ax.grid(which='minor')
1143
1143
1144 else:
1144 else:
1145 self.clear_figures()
1145 self.clear_figures()
1146
1146
1147 for i in range(NACF):
1147 for i in range(NACF):
1148 x_aux = numpy.isfinite(lags[i,:])
1148 x_aux = numpy.isfinite(lags[i,:])
1149 y_aux = numpy.isfinite(ACFs[i,:])
1149 y_aux = numpy.isfinite(ACFs[i,:])
1150 yerr_aux = numpy.isfinite(errACFs[i,:])
1150 yerr_aux = numpy.isfinite(errACFs[i,:])
1151
1151
1152 if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2:
1152 if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2:
1153 ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r')
1153 ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r')
1154
1154
1155 ax.yaxis.set_minor_locator(MultipleLocator(15))
1155 ax.yaxis.set_minor_locator(MultipleLocator(15))
1156
1156
1157
1157
1158 class CrossProductsPlot(Plot):
1158 class CrossProductsPlot(Plot):
1159 '''
1159 '''
1160 Written by R. Flores
1160 Written by R. Flores
1161 '''
1161 '''
1162 '''
1162 '''
1163 Plot for cross products
1163 Plot for cross products
1164 '''
1164 '''
1165
1165
1166 CODE = 'crossprod'
1166 CODE = 'crossprod'
1167 plot_name = 'Cross Products'
1167 plot_name = 'Cross Products'
1168 plot_type = 'scatterbuffer'
1168 plot_type = 'scatterbuffer'
1169
1169
1170 def setup(self):
1170 def setup(self):
1171
1171
1172 self.ncols = 3
1172 self.ncols = 3
1173 self.nrows = 1
1173 self.nrows = 1
1174 self.nplots = 3
1174 self.nplots = 3
1175 self.ylabel = 'Range [km]'
1175 self.ylabel = 'Range [km]'
1176 self.width = 3.5*self.nplots
1176 self.width = 3.5*self.nplots
1177 self.height = 5.5
1177 self.height = 5.5
1178 self.colorbar = False
1178 self.colorbar = False
1179 self.titles = []
1179 self.titles = []
1180
1180
1181 def update(self, dataOut):
1181 def update(self, dataOut):
1182
1182
1183 data = {}
1183 data = {}
1184 meta = {}
1184 meta = {}
1185
1185
1186 data['crossprod'] = dataOut.crossprods
1186 data['crossprod'] = dataOut.crossprods
1187 data['NDP'] = dataOut.NDP
1187 data['NDP'] = dataOut.NDP
1188
1188
1189 return data, meta
1189 return data, meta
1190
1190
1191 def plot(self):
1191 def plot(self):
1192
1192
1193 self.x = self.data['crossprod'][:,-1,:,:,:,:]
1193 self.x = self.data['crossprod'][:,-1,:,:,:,:]
1194 self.y = self.data.heights[0:self.data['NDP']]
1194 self.y = self.data.heights[0:self.data['NDP']]
1195
1195
1196 for n, ax in enumerate(self.axes):
1196 for n, ax in enumerate(self.axes):
1197
1197
1198 self.xmin=numpy.min(numpy.concatenate((self.x[n][0,20:30,0,0],self.x[n][1,20:30,0,0],self.x[n][2,20:30,0,0],self.x[n][3,20:30,0,0])))
1198 self.xmin=numpy.min(numpy.concatenate((self.x[n][0,20:30,0,0],self.x[n][1,20:30,0,0],self.x[n][2,20:30,0,0],self.x[n][3,20:30,0,0])))
1199 self.xmax=numpy.max(numpy.concatenate((self.x[n][0,20:30,0,0],self.x[n][1,20:30,0,0],self.x[n][2,20:30,0,0],self.x[n][3,20:30,0,0])))
1199 self.xmax=numpy.max(numpy.concatenate((self.x[n][0,20:30,0,0],self.x[n][1,20:30,0,0],self.x[n][2,20:30,0,0],self.x[n][3,20:30,0,0])))
1200
1200
1201 if ax.firsttime:
1201 if ax.firsttime:
1202
1202
1203 self.autoxticks=False
1203 self.autoxticks=False
1204 if n==0:
1204 if n==0:
1205 label1='kax'
1205 label1='kax'
1206 label2='kay'
1206 label2='kay'
1207 label3='kbx'
1207 label3='kbx'
1208 label4='kby'
1208 label4='kby'
1209 self.xlimits=[(self.xmin,self.xmax)]
1209 self.xlimits=[(self.xmin,self.xmax)]
1210 elif n==1:
1210 elif n==1:
1211 label1='kax2'
1211 label1='kax2'
1212 label2='kay2'
1212 label2='kay2'
1213 label3='kbx2'
1213 label3='kbx2'
1214 label4='kby2'
1214 label4='kby2'
1215 self.xlimits.append((self.xmin,self.xmax))
1215 self.xlimits.append((self.xmin,self.xmax))
1216 elif n==2:
1216 elif n==2:
1217 label1='kaxay'
1217 label1='kaxay'
1218 label2='kbxby'
1218 label2='kbxby'
1219 label3='kaxbx'
1219 label3='kaxbx'
1220 label4='kaxby'
1220 label4='kaxby'
1221 self.xlimits.append((self.xmin,self.xmax))
1221 self.xlimits.append((self.xmin,self.xmax))
1222
1222
1223 ax.plotline1 = ax.plot(self.x[n][0,:,0,0], self.y, color='r',linewidth=2.0, label=label1)
1223 ax.plotline1 = ax.plot(self.x[n][0,:,0,0], self.y, color='r',linewidth=2.0, label=label1)
1224 ax.plotline2 = ax.plot(self.x[n][1,:,0,0], self.y, color='k',linewidth=2.0, label=label2)
1224 ax.plotline2 = ax.plot(self.x[n][1,:,0,0], self.y, color='k',linewidth=2.0, label=label2)
1225 ax.plotline3 = ax.plot(self.x[n][2,:,0,0], self.y, color='b',linewidth=2.0, label=label3)
1225 ax.plotline3 = ax.plot(self.x[n][2,:,0,0], self.y, color='b',linewidth=2.0, label=label3)
1226 ax.plotline4 = ax.plot(self.x[n][3,:,0,0], self.y, color='m',linewidth=2.0, label=label4)
1226 ax.plotline4 = ax.plot(self.x[n][3,:,0,0], self.y, color='m',linewidth=2.0, label=label4)
1227 ax.legend(loc='upper right')
1227 ax.legend(loc='upper right')
1228 ax.set_xlim(self.xmin, self.xmax)
1228 ax.set_xlim(self.xmin, self.xmax)
1229 self.titles.append('{}'.format(self.plot_name.upper()))
1229 self.titles.append('{}'.format(self.plot_name.upper()))
1230
1230
1231 else:
1231 else:
1232
1232
1233 if n==0:
1233 if n==0:
1234 self.xlimits=[(self.xmin,self.xmax)]
1234 self.xlimits=[(self.xmin,self.xmax)]
1235 else:
1235 else:
1236 self.xlimits.append((self.xmin,self.xmax))
1236 self.xlimits.append((self.xmin,self.xmax))
1237
1237
1238 ax.set_xlim(self.xmin, self.xmax)
1238 ax.set_xlim(self.xmin, self.xmax)
1239
1239
1240 ax.plotline1[0].set_data(self.x[n][0,:,0,0],self.y)
1240 ax.plotline1[0].set_data(self.x[n][0,:,0,0],self.y)
1241 ax.plotline2[0].set_data(self.x[n][1,:,0,0],self.y)
1241 ax.plotline2[0].set_data(self.x[n][1,:,0,0],self.y)
1242 ax.plotline3[0].set_data(self.x[n][2,:,0,0],self.y)
1242 ax.plotline3[0].set_data(self.x[n][2,:,0,0],self.y)
1243 ax.plotline4[0].set_data(self.x[n][3,:,0,0],self.y)
1243 ax.plotline4[0].set_data(self.x[n][3,:,0,0],self.y)
1244 self.titles.append('{}'.format(self.plot_name.upper()))
1244 self.titles.append('{}'.format(self.plot_name.upper()))
1245
1245
1246
1246
1247 class CrossProductsLPPlot(Plot):
1247 class CrossProductsLPPlot(Plot):
1248 '''
1248 '''
1249 Written by R. Flores
1249 Written by R. Flores
1250 '''
1250 '''
1251 '''
1251 '''
1252 Plot for cross products LP
1252 Plot for cross products LP
1253 '''
1253 '''
1254
1254
1255 CODE = 'crossprodslp'
1255 CODE = 'crossprodslp'
1256 plot_name = 'Cross Products LP'
1256 plot_name = 'Cross Products LP'
1257 plot_type = 'scatterbuffer'
1257 plot_type = 'scatterbuffer'
1258
1258
1259
1259
1260 def setup(self):
1260 def setup(self):
1261
1261
1262 self.ncols = 2
1262 self.ncols = 2
1263 self.nrows = 1
1263 self.nrows = 1
1264 self.nplots = 2
1264 self.nplots = 2
1265 self.ylabel = 'Range [km]'
1265 self.ylabel = 'Range [km]'
1266 self.xlabel = 'dB'
1266 self.xlabel = 'dB'
1267 self.width = 3.5*self.nplots
1267 self.width = 3.5*self.nplots
1268 self.height = 5.5
1268 self.height = 5.5
1269 self.colorbar = False
1269 self.colorbar = False
1270 self.titles = []
1270 self.titles = []
1271 self.plots_adjust.update({'wspace': .8 ,'left': 0.17, 'right': 0.88, 'bottom': 0.1})
1271 self.plots_adjust.update({'wspace': .8 ,'left': 0.17, 'right': 0.88, 'bottom': 0.1})
1272
1272
1273 def update(self, dataOut):
1273 def update(self, dataOut):
1274 data = {}
1274 data = {}
1275 meta = {}
1275 meta = {}
1276
1276
1277 data['crossprodslp'] = 10*numpy.log10(numpy.abs(dataOut.output_LP))
1277 data['crossprodslp'] = 10*numpy.log10(numpy.abs(dataOut.output_LP))
1278
1278
1279 data['NRANGE'] = dataOut.NRANGE #This is metadata
1279 data['NRANGE'] = dataOut.NRANGE #This is metadata
1280 data['NLAG'] = dataOut.NLAG #This is metadata
1280 data['NLAG'] = dataOut.NLAG #This is metadata
1281
1281
1282 return data, meta
1282 return data, meta
1283
1283
1284 def plot(self):
1284 def plot(self):
1285
1285
1286 NRANGE = self.data['NRANGE'][-1]
1286 NRANGE = self.data['NRANGE'][-1]
1287 NLAG = self.data['NLAG'][-1]
1287 NLAG = self.data['NLAG'][-1]
1288
1288
1289 x = self.data[self.CODE][:,-1,:,:]
1289 x = self.data[self.CODE][:,-1,:,:]
1290 self.y = self.data.yrange[0:NRANGE]
1290 self.y = self.data.yrange[0:NRANGE]
1291
1291
1292 label_array=numpy.array(['lag '+ str(x) for x in range(NLAG)])
1292 label_array=numpy.array(['lag '+ str(x) for x in range(NLAG)])
1293 color_array=['r','k','g','b','c','m','y','orange','steelblue','purple','peru','darksalmon','grey','limegreen','olive','midnightblue']
1293 color_array=['r','k','g','b','c','m','y','orange','steelblue','purple','peru','darksalmon','grey','limegreen','olive','midnightblue']
1294
1294
1295
1295
1296 for n, ax in enumerate(self.axes):
1296 for n, ax in enumerate(self.axes):
1297
1297
1298 self.xmin=28#30
1298 self.xmin=28#30
1299 self.xmax=70#70
1299 self.xmax=70#70
1300 #self.xmin=numpy.min(numpy.concatenate((self.x[0,:,n],self.x[1,:,n])))
1300 #self.xmin=numpy.min(numpy.concatenate((self.x[0,:,n],self.x[1,:,n])))
1301 #self.xmax=numpy.max(numpy.concatenate((self.x[0,:,n],self.x[1,:,n])))
1301 #self.xmax=numpy.max(numpy.concatenate((self.x[0,:,n],self.x[1,:,n])))
1302
1302
1303 if ax.firsttime:
1303 if ax.firsttime:
1304
1304
1305 self.autoxticks=False
1305 self.autoxticks=False
1306 if n == 0:
1306 if n == 0:
1307 self.plotline_array=numpy.zeros((2,NLAG),dtype=object)
1307 self.plotline_array=numpy.zeros((2,NLAG),dtype=object)
1308
1308
1309 for i in range(NLAG):
1309 for i in range(NLAG):
1310 self.plotline_array[n,i], = ax.plot(x[i,:,n], self.y, color=color_array[i],linewidth=1.0, label=label_array[i])
1310 self.plotline_array[n,i], = ax.plot(x[i,:,n], self.y, color=color_array[i],linewidth=1.0, label=label_array[i])
1311
1311
1312 ax.legend(loc='upper right')
1312 ax.legend(loc='upper right')
1313 ax.set_xlim(self.xmin, self.xmax)
1313 ax.set_xlim(self.xmin, self.xmax)
1314 if n==0:
1314 if n==0:
1315 self.titles.append('{} CH0'.format(self.plot_name.upper()))
1315 self.titles.append('{} CH0'.format(self.plot_name.upper()))
1316 if n==1:
1316 if n==1:
1317 self.titles.append('{} CH1'.format(self.plot_name.upper()))
1317 self.titles.append('{} CH1'.format(self.plot_name.upper()))
1318 else:
1318 else:
1319 for i in range(NLAG):
1319 for i in range(NLAG):
1320 self.plotline_array[n,i].set_data(x[i,:,n],self.y)
1320 self.plotline_array[n,i].set_data(x[i,:,n],self.y)
1321
1321
1322 if n==0:
1322 if n==0:
1323 self.titles.append('{} CH0'.format(self.plot_name.upper()))
1323 self.titles.append('{} CH0'.format(self.plot_name.upper()))
1324 if n==1:
1324 if n==1:
1325 self.titles.append('{} CH1'.format(self.plot_name.upper()))
1325 self.titles.append('{} CH1'.format(self.plot_name.upper()))
1326
1326
1327
1327
1328 class NoiseDPPlot(NoisePlot):
1328 class NoiseDPPlot(NoisePlot):
1329 '''
1329 '''
1330 Written by R. Flores
1330 Written by R. Flores
1331 '''
1331 '''
1332 '''
1332 '''
1333 Plot for noise Double Pulse
1333 Plot for noise Double Pulse
1334 '''
1334 '''
1335
1335
1336 CODE = 'noise'
1336 CODE = 'noise'
1337 #plot_name = 'Noise'
1337 #plot_name = 'Noise'
1338 #plot_type = 'scatterbuffer'
1338 #plot_type = 'scatterbuffer'
1339
1339
1340 def update(self, dataOut):
1340 def update(self, dataOut):
1341
1341
1342 data = {}
1342 data = {}
1343 meta = {}
1343 meta = {}
1344 data['noise'] = 10*numpy.log10(dataOut.noise_final)
1344 data['noise'] = 10*numpy.log10(dataOut.noise_final)
1345
1345
1346 return data, meta
1346 return data, meta
1347
1347
1348
1348
1349 class XmitWaveformPlot(Plot):
1349 class XmitWaveformPlot(Plot):
1350 '''
1350 '''
1351 Written by R. Flores
1351 Written by R. Flores
1352 '''
1352 '''
1353 '''
1353 '''
1354 Plot for xmit waveform
1354 Plot for xmit waveform
1355 '''
1355 '''
1356
1356
1357 CODE = 'xmit'
1357 CODE = 'xmit'
1358 plot_name = 'Xmit Waveform'
1358 plot_name = 'Xmit Waveform'
1359 plot_type = 'scatterbuffer'
1359 plot_type = 'scatterbuffer'
1360
1360
1361
1361
1362 def setup(self):
1362 def setup(self):
1363
1363
1364 self.ncols = 1
1364 self.ncols = 1
1365 self.nrows = 1
1365 self.nrows = 1
1366 self.nplots = 1
1366 self.nplots = 1
1367 self.ylabel = ''
1367 self.ylabel = ''
1368 self.xlabel = 'Number of Lag'
1368 self.xlabel = 'Number of Lag'
1369 self.width = 5.5
1369 self.width = 5.5
1370 self.height = 3.5
1370 self.height = 3.5
1371 self.colorbar = False
1371 self.colorbar = False
1372 self.plots_adjust.update({'right': 0.85 })
1372 self.plots_adjust.update({'right': 0.85 })
1373 self.titles = [self.plot_name]
1373 self.titles = [self.plot_name]
1374 #self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
1374 #self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
1375
1375
1376 #if not self.titles:
1376 #if not self.titles:
1377 #self.titles = self.data.parameters \
1377 #self.titles = self.data.parameters \
1378 #if self.data.parameters else ['{}'.format(self.plot_name.upper())]
1378 #if self.data.parameters else ['{}'.format(self.plot_name.upper())]
1379
1379
1380 def update(self, dataOut):
1380 def update(self, dataOut):
1381
1381
1382 data = {}
1382 data = {}
1383 meta = {}
1383 meta = {}
1384
1384
1385 y_1=numpy.arctan2(dataOut.output_LP[:,0,2].imag,dataOut.output_LP[:,0,2].real)* 180 / (numpy.pi*10)
1385 y_1=numpy.arctan2(dataOut.output_LP[:,0,2].imag,dataOut.output_LP[:,0,2].real)* 180 / (numpy.pi*10)
1386 y_2=numpy.abs(dataOut.output_LP[:,0,2])
1386 y_2=numpy.abs(dataOut.output_LP[:,0,2])
1387 norm=numpy.max(y_2)
1387 norm=numpy.max(y_2)
1388 norm=max(norm,0.1)
1388 norm=max(norm,0.1)
1389 y_2=y_2/norm
1389 y_2=y_2/norm
1390
1390
1391 meta['yrange'] = numpy.array([])
1391 meta['yrange'] = numpy.array([])
1392
1392
1393 data['xmit'] = numpy.vstack((y_1,y_2))
1393 data['xmit'] = numpy.vstack((y_1,y_2))
1394 data['NLAG'] = dataOut.NLAG
1394 data['NLAG'] = dataOut.NLAG
1395
1395
1396 return data, meta
1396 return data, meta
1397
1397
1398 def plot(self):
1398 def plot(self):
1399
1399
1400 data = self.data[-1]
1400 data = self.data[-1]
1401 NLAG = data['NLAG']
1401 NLAG = data['NLAG']
1402 x = numpy.arange(0,NLAG,1,'float32')
1402 x = numpy.arange(0,NLAG,1,'float32')
1403 y = data['xmit']
1403 y = data['xmit']
1404
1404
1405 self.xmin = 0
1405 self.xmin = 0
1406 self.xmax = NLAG-1
1406 self.xmax = NLAG-1
1407 self.ymin = -1.0
1407 self.ymin = -1.0
1408 self.ymax = 1.0
1408 self.ymax = 1.0
1409 ax = self.axes[0]
1409 ax = self.axes[0]
1410
1410
1411 if ax.firsttime:
1411 if ax.firsttime:
1412 ax.plotline0=ax.plot(x,y[0,:],color='blue')
1412 ax.plotline0=ax.plot(x,y[0,:],color='blue')
1413 ax.plotline1=ax.plot(x,y[1,:],color='red')
1413 ax.plotline1=ax.plot(x,y[1,:],color='red')
1414 secax=ax.secondary_xaxis(location=0.5)
1414 secax=ax.secondary_xaxis(location=0.5)
1415 secax.xaxis.tick_bottom()
1415 secax.xaxis.tick_bottom()
1416 secax.tick_params( labelleft=False, labeltop=False,
1416 secax.tick_params( labelleft=False, labeltop=False,
1417 labelright=False, labelbottom=False)
1417 labelright=False, labelbottom=False)
1418
1418
1419 self.xstep_given = 3
1419 self.xstep_given = 3
1420 self.ystep_given = .25
1420 self.ystep_given = .25
1421 secax.set_xticks(numpy.linspace(self.xmin, self.xmax, 6)) #only works on matplotlib.version>3.2
1421 secax.set_xticks(numpy.linspace(self.xmin, self.xmax, 6)) #only works on matplotlib.version>3.2
1422
1422
1423 else:
1423 else:
1424 ax.plotline0[0].set_data(x,y[0,:])
1424 ax.plotline0[0].set_data(x,y[0,:])
1425 ax.plotline1[0].set_data(x,y[1,:])
1425 ax.plotline1[0].set_data(x,y[1,:])
General Comments 0
You need to be logged in to leave comments. Login now