##// END OF EJS Templates
First faraday ops review #TODO: fix plots
jespinoza -
r1381:3afd912ddcce
parent child
Show More

The requested changes are too big and content was truncated. Show full diff

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