##// END OF EJS Templates
Se inclute SpectralMoments y DoubleGaussianPlot de tipo SpectraPlot
Danny Scipión -
r1358:fd32f6159d97
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -1,358 +1,371
1 import os
1 import os
2 import datetime
2 import datetime
3 import numpy
3 import numpy
4
4
5 from schainpy.model.graphics.jroplot_base import Plot, plt
5 from schainpy.model.graphics.jroplot_base import Plot, plt
6 from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot
6 from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot, SpectraCutPlot
7 from schainpy.utils import log
7 from schainpy.utils import log
8
8
9 EARTH_RADIUS = 6.3710e3
9 EARTH_RADIUS = 6.3710e3
10
10
11
11
12 def ll2xy(lat1, lon1, lat2, lon2):
12 def ll2xy(lat1, lon1, lat2, lon2):
13
13
14 p = 0.017453292519943295
14 p = 0.017453292519943295
15 a = 0.5 - numpy.cos((lat2 - lat1) * p)/2 + numpy.cos(lat1 * p) * \
15 a = 0.5 - numpy.cos((lat2 - lat1) * p)/2 + numpy.cos(lat1 * p) * \
16 numpy.cos(lat2 * p) * (1 - numpy.cos((lon2 - lon1) * p)) / 2
16 numpy.cos(lat2 * p) * (1 - numpy.cos((lon2 - lon1) * p)) / 2
17 r = 12742 * numpy.arcsin(numpy.sqrt(a))
17 r = 12742 * numpy.arcsin(numpy.sqrt(a))
18 theta = numpy.arctan2(numpy.sin((lon2-lon1)*p)*numpy.cos(lat2*p), numpy.cos(lat1*p)
18 theta = numpy.arctan2(numpy.sin((lon2-lon1)*p)*numpy.cos(lat2*p), numpy.cos(lat1*p)
19 * numpy.sin(lat2*p)-numpy.sin(lat1*p)*numpy.cos(lat2*p)*numpy.cos((lon2-lon1)*p))
19 * numpy.sin(lat2*p)-numpy.sin(lat1*p)*numpy.cos(lat2*p)*numpy.cos((lon2-lon1)*p))
20 theta = -theta + numpy.pi/2
20 theta = -theta + numpy.pi/2
21 return r*numpy.cos(theta), r*numpy.sin(theta)
21 return r*numpy.cos(theta), r*numpy.sin(theta)
22
22
23
23
24 def km2deg(km):
24 def km2deg(km):
25 '''
25 '''
26 Convert distance in km to degrees
26 Convert distance in km to degrees
27 '''
27 '''
28
28
29 return numpy.rad2deg(km/EARTH_RADIUS)
29 return numpy.rad2deg(km/EARTH_RADIUS)
30
30
31
31
32
32
33 class SpectralMomentsPlot(SpectraPlot):
33 class SpectralMomentsPlot(SpectraPlot):
34 '''
34 '''
35 Plot for Spectral Moments
35 Plot for Spectral Moments
36 '''
36 '''
37 CODE = 'spc_moments'
37 CODE = 'spc_moments'
38 colormap = 'jet'
38 # colormap = 'jet'
39 plot_type = 'pcolor'
39 # plot_type = 'pcolor'
40
41 class DobleGaussianPlot(SpectraPlot):
42 '''
43 Plot for Double Gaussian Plot
44 '''
45 CODE = 'gaussian_fit'
46 # colormap = 'jet'
47 # plot_type = 'pcolor'
40
48
49 class DoubleGaussianSpectraCutPlot(SpectraCutPlot):
50 '''
51 Plot SpectraCut with Double Gaussian Fit
52 '''
53 CODE = 'cut_gaussian_fit'
41
54
42 class SnrPlot(RTIPlot):
55 class SnrPlot(RTIPlot):
43 '''
56 '''
44 Plot for SNR Data
57 Plot for SNR Data
45 '''
58 '''
46
59
47 CODE = 'snr'
60 CODE = 'snr'
48 colormap = 'jet'
61 colormap = 'jet'
49
62
50 def update(self, dataOut):
63 def update(self, dataOut):
51
64
52 data = {
65 data = {
53 'snr': 10*numpy.log10(dataOut.data_snr)
66 'snr': 10*numpy.log10(dataOut.data_snr)
54 }
67 }
55
68
56 return data, {}
69 return data, {}
57
70
58 class DopplerPlot(RTIPlot):
71 class DopplerPlot(RTIPlot):
59 '''
72 '''
60 Plot for DOPPLER Data (1st moment)
73 Plot for DOPPLER Data (1st moment)
61 '''
74 '''
62
75
63 CODE = 'dop'
76 CODE = 'dop'
64 colormap = 'jet'
77 colormap = 'jet'
65
78
66 def update(self, dataOut):
79 def update(self, dataOut):
67
80
68 data = {
81 data = {
69 'dop': 10*numpy.log10(dataOut.data_dop)
82 'dop': 10*numpy.log10(dataOut.data_dop)
70 }
83 }
71
84
72 return data, {}
85 return data, {}
73
86
74 class PowerPlot(RTIPlot):
87 class PowerPlot(RTIPlot):
75 '''
88 '''
76 Plot for Power Data (0 moment)
89 Plot for Power Data (0 moment)
77 '''
90 '''
78
91
79 CODE = 'pow'
92 CODE = 'pow'
80 colormap = 'jet'
93 colormap = 'jet'
81
94
82 def update(self, dataOut):
95 def update(self, dataOut):
83
96
84 data = {
97 data = {
85 'pow': 10*numpy.log10(dataOut.data_pow)
98 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor)
86 }
99 }
87
100
88 return data, {}
101 return data, {}
89
102
90 class SpectralWidthPlot(RTIPlot):
103 class SpectralWidthPlot(RTIPlot):
91 '''
104 '''
92 Plot for Spectral Width Data (2nd moment)
105 Plot for Spectral Width Data (2nd moment)
93 '''
106 '''
94
107
95 CODE = 'width'
108 CODE = 'width'
96 colormap = 'jet'
109 colormap = 'jet'
97
110
98 def update(self, dataOut):
111 def update(self, dataOut):
99
112
100 data = {
113 data = {
101 'width': dataOut.data_width
114 'width': dataOut.data_width
102 }
115 }
103
116
104 return data, {}
117 return data, {}
105
118
106 class SkyMapPlot(Plot):
119 class SkyMapPlot(Plot):
107 '''
120 '''
108 Plot for meteors detection data
121 Plot for meteors detection data
109 '''
122 '''
110
123
111 CODE = 'param'
124 CODE = 'param'
112
125
113 def setup(self):
126 def setup(self):
114
127
115 self.ncols = 1
128 self.ncols = 1
116 self.nrows = 1
129 self.nrows = 1
117 self.width = 7.2
130 self.width = 7.2
118 self.height = 7.2
131 self.height = 7.2
119 self.nplots = 1
132 self.nplots = 1
120 self.xlabel = 'Zonal Zenith Angle (deg)'
133 self.xlabel = 'Zonal Zenith Angle (deg)'
121 self.ylabel = 'Meridional Zenith Angle (deg)'
134 self.ylabel = 'Meridional Zenith Angle (deg)'
122 self.polar = True
135 self.polar = True
123 self.ymin = -180
136 self.ymin = -180
124 self.ymax = 180
137 self.ymax = 180
125 self.colorbar = False
138 self.colorbar = False
126
139
127 def plot(self):
140 def plot(self):
128
141
129 arrayParameters = numpy.concatenate(self.data['param'])
142 arrayParameters = numpy.concatenate(self.data['param'])
130 error = arrayParameters[:, -1]
143 error = arrayParameters[:, -1]
131 indValid = numpy.where(error == 0)[0]
144 indValid = numpy.where(error == 0)[0]
132 finalMeteor = arrayParameters[indValid, :]
145 finalMeteor = arrayParameters[indValid, :]
133 finalAzimuth = finalMeteor[:, 3]
146 finalAzimuth = finalMeteor[:, 3]
134 finalZenith = finalMeteor[:, 4]
147 finalZenith = finalMeteor[:, 4]
135
148
136 x = finalAzimuth * numpy.pi / 180
149 x = finalAzimuth * numpy.pi / 180
137 y = finalZenith
150 y = finalZenith
138
151
139 ax = self.axes[0]
152 ax = self.axes[0]
140
153
141 if ax.firsttime:
154 if ax.firsttime:
142 ax.plot = ax.plot(x, y, 'bo', markersize=5)[0]
155 ax.plot = ax.plot(x, y, 'bo', markersize=5)[0]
143 else:
156 else:
144 ax.plot.set_data(x, y)
157 ax.plot.set_data(x, y)
145
158
146 dt1 = self.getDateTime(self.data.min_time).strftime('%y/%m/%d %H:%M:%S')
159 dt1 = self.getDateTime(self.data.min_time).strftime('%y/%m/%d %H:%M:%S')
147 dt2 = self.getDateTime(self.data.max_time).strftime('%y/%m/%d %H:%M:%S')
160 dt2 = self.getDateTime(self.data.max_time).strftime('%y/%m/%d %H:%M:%S')
148 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
161 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
149 dt2,
162 dt2,
150 len(x))
163 len(x))
151 self.titles[0] = title
164 self.titles[0] = title
152
165
153
166
154 class GenericRTIPlot(Plot):
167 class GenericRTIPlot(Plot):
155 '''
168 '''
156 Plot for data_xxxx object
169 Plot for data_xxxx object
157 '''
170 '''
158
171
159 CODE = 'param'
172 CODE = 'param'
160 colormap = 'viridis'
173 colormap = 'viridis'
161 plot_type = 'pcolorbuffer'
174 plot_type = 'pcolorbuffer'
162
175
163 def setup(self):
176 def setup(self):
164 self.xaxis = 'time'
177 self.xaxis = 'time'
165 self.ncols = 1
178 self.ncols = 1
166 self.nrows = self.data.shape(self.attr_data)[0]
179 self.nrows = self.data.shape(self.attr_data)[0]
167 self.nplots = self.nrows
180 self.nplots = self.nrows
168 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95})
181 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95})
169
182
170 if not self.xlabel:
183 if not self.xlabel:
171 self.xlabel = 'Time'
184 self.xlabel = 'Time'
172
185
173 self.ylabel = 'Height [km]'
186 self.ylabel = 'Range [km]'
174 if not self.titles:
187 if not self.titles:
175 self.titles = self.data.parameters \
188 self.titles = self.data.parameters \
176 if self.data.parameters else ['Param {}'.format(x) for x in range(self.nrows)]
189 if self.data.parameters else ['Param {}'.format(x) for x in range(self.nrows)]
177
190
178 def update(self, dataOut):
191 def update(self, dataOut):
179
192
180 data = {
193 data = {
181 self.attr_data : getattr(dataOut, self.attr_data)
194 self.attr_data : getattr(dataOut, self.attr_data)
182 }
195 }
183
196
184 meta = {}
197 meta = {}
185
198
186 return data, meta
199 return data, meta
187
200
188 def plot(self):
201 def plot(self):
189 # self.data.normalize_heights()
202 # self.data.normalize_heights()
190 self.x = self.data.times
203 self.x = self.data.times
191 self.y = self.data.yrange
204 self.y = self.data.yrange
192 self.z = self.data[self.attr_data]
205 self.z = self.data[self.attr_data]
193
206
194 self.z = numpy.ma.masked_invalid(self.z)
207 self.z = numpy.ma.masked_invalid(self.z)
195
208
196 if self.decimation is None:
209 if self.decimation is None:
197 x, y, z = self.fill_gaps(self.x, self.y, self.z)
210 x, y, z = self.fill_gaps(self.x, self.y, self.z)
198 else:
211 else:
199 x, y, z = self.fill_gaps(*self.decimate())
212 x, y, z = self.fill_gaps(*self.decimate())
200
213
201 for n, ax in enumerate(self.axes):
214 for n, ax in enumerate(self.axes):
202
215
203 self.zmax = self.zmax if self.zmax is not None else numpy.max(
216 self.zmax = self.zmax if self.zmax is not None else numpy.max(
204 self.z[n])
217 self.z[n])
205 self.zmin = self.zmin if self.zmin is not None else numpy.min(
218 self.zmin = self.zmin if self.zmin is not None else numpy.min(
206 self.z[n])
219 self.z[n])
207
220
208 if ax.firsttime:
221 if ax.firsttime:
209 if self.zlimits is not None:
222 if self.zlimits is not None:
210 self.zmin, self.zmax = self.zlimits[n]
223 self.zmin, self.zmax = self.zlimits[n]
211
224
212 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
225 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
213 vmin=self.zmin,
226 vmin=self.zmin,
214 vmax=self.zmax,
227 vmax=self.zmax,
215 cmap=self.cmaps[n]
228 cmap=self.cmaps[n]
216 )
229 )
217 else:
230 else:
218 if self.zlimits is not None:
231 if self.zlimits is not None:
219 self.zmin, self.zmax = self.zlimits[n]
232 self.zmin, self.zmax = self.zlimits[n]
220 ax.collections.remove(ax.collections[0])
233 ax.collections.remove(ax.collections[0])
221 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
234 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
222 vmin=self.zmin,
235 vmin=self.zmin,
223 vmax=self.zmax,
236 vmax=self.zmax,
224 cmap=self.cmaps[n]
237 cmap=self.cmaps[n]
225 )
238 )
226
239
227
240
228 class PolarMapPlot(Plot):
241 class PolarMapPlot(Plot):
229 '''
242 '''
230 Plot for weather radar
243 Plot for weather radar
231 '''
244 '''
232
245
233 CODE = 'param'
246 CODE = 'param'
234 colormap = 'seismic'
247 colormap = 'seismic'
235
248
236 def setup(self):
249 def setup(self):
237 self.ncols = 1
250 self.ncols = 1
238 self.nrows = 1
251 self.nrows = 1
239 self.width = 9
252 self.width = 9
240 self.height = 8
253 self.height = 8
241 self.mode = self.data.meta['mode']
254 self.mode = self.data.meta['mode']
242 if self.channels is not None:
255 if self.channels is not None:
243 self.nplots = len(self.channels)
256 self.nplots = len(self.channels)
244 self.nrows = len(self.channels)
257 self.nrows = len(self.channels)
245 else:
258 else:
246 self.nplots = self.data.shape(self.CODE)[0]
259 self.nplots = self.data.shape(self.CODE)[0]
247 self.nrows = self.nplots
260 self.nrows = self.nplots
248 self.channels = list(range(self.nplots))
261 self.channels = list(range(self.nplots))
249 if self.mode == 'E':
262 if self.mode == 'E':
250 self.xlabel = 'Longitude'
263 self.xlabel = 'Longitude'
251 self.ylabel = 'Latitude'
264 self.ylabel = 'Latitude'
252 else:
265 else:
253 self.xlabel = 'Range (km)'
266 self.xlabel = 'Range (km)'
254 self.ylabel = 'Height (km)'
267 self.ylabel = 'Height (km)'
255 self.bgcolor = 'white'
268 self.bgcolor = 'white'
256 self.cb_labels = self.data.meta['units']
269 self.cb_labels = self.data.meta['units']
257 self.lat = self.data.meta['latitude']
270 self.lat = self.data.meta['latitude']
258 self.lon = self.data.meta['longitude']
271 self.lon = self.data.meta['longitude']
259 self.xmin, self.xmax = float(
272 self.xmin, self.xmax = float(
260 km2deg(self.xmin) + self.lon), float(km2deg(self.xmax) + self.lon)
273 km2deg(self.xmin) + self.lon), float(km2deg(self.xmax) + self.lon)
261 self.ymin, self.ymax = float(
274 self.ymin, self.ymax = float(
262 km2deg(self.ymin) + self.lat), float(km2deg(self.ymax) + self.lat)
275 km2deg(self.ymin) + self.lat), float(km2deg(self.ymax) + self.lat)
263 # self.polar = True
276 # self.polar = True
264
277
265 def plot(self):
278 def plot(self):
266
279
267 for n, ax in enumerate(self.axes):
280 for n, ax in enumerate(self.axes):
268 data = self.data['param'][self.channels[n]]
281 data = self.data['param'][self.channels[n]]
269
282
270 zeniths = numpy.linspace(
283 zeniths = numpy.linspace(
271 0, self.data.meta['max_range'], data.shape[1])
284 0, self.data.meta['max_range'], data.shape[1])
272 if self.mode == 'E':
285 if self.mode == 'E':
273 azimuths = -numpy.radians(self.data.yrange)+numpy.pi/2
286 azimuths = -numpy.radians(self.data.yrange)+numpy.pi/2
274 r, theta = numpy.meshgrid(zeniths, azimuths)
287 r, theta = numpy.meshgrid(zeniths, azimuths)
275 x, y = r*numpy.cos(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])), r*numpy.sin(
288 x, y = r*numpy.cos(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])), r*numpy.sin(
276 theta)*numpy.cos(numpy.radians(self.data.meta['elevation']))
289 theta)*numpy.cos(numpy.radians(self.data.meta['elevation']))
277 x = km2deg(x) + self.lon
290 x = km2deg(x) + self.lon
278 y = km2deg(y) + self.lat
291 y = km2deg(y) + self.lat
279 else:
292 else:
280 azimuths = numpy.radians(self.data.yrange)
293 azimuths = numpy.radians(self.data.yrange)
281 r, theta = numpy.meshgrid(zeniths, azimuths)
294 r, theta = numpy.meshgrid(zeniths, azimuths)
282 x, y = r*numpy.cos(theta), r*numpy.sin(theta)
295 x, y = r*numpy.cos(theta), r*numpy.sin(theta)
283 self.y = zeniths
296 self.y = zeniths
284
297
285 if ax.firsttime:
298 if ax.firsttime:
286 if self.zlimits is not None:
299 if self.zlimits is not None:
287 self.zmin, self.zmax = self.zlimits[n]
300 self.zmin, self.zmax = self.zlimits[n]
288 ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)),
301 ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)),
289 x, y, numpy.ma.array(data, mask=numpy.isnan(data)),
302 x, y, numpy.ma.array(data, mask=numpy.isnan(data)),
290 vmin=self.zmin,
303 vmin=self.zmin,
291 vmax=self.zmax,
304 vmax=self.zmax,
292 cmap=self.cmaps[n])
305 cmap=self.cmaps[n])
293 else:
306 else:
294 if self.zlimits is not None:
307 if self.zlimits is not None:
295 self.zmin, self.zmax = self.zlimits[n]
308 self.zmin, self.zmax = self.zlimits[n]
296 ax.collections.remove(ax.collections[0])
309 ax.collections.remove(ax.collections[0])
297 ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)),
310 ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)),
298 x, y, numpy.ma.array(data, mask=numpy.isnan(data)),
311 x, y, numpy.ma.array(data, mask=numpy.isnan(data)),
299 vmin=self.zmin,
312 vmin=self.zmin,
300 vmax=self.zmax,
313 vmax=self.zmax,
301 cmap=self.cmaps[n])
314 cmap=self.cmaps[n])
302
315
303 if self.mode == 'A':
316 if self.mode == 'A':
304 continue
317 continue
305
318
306 # plot district names
319 # plot district names
307 f = open('/data/workspace/schain_scripts/distrito.csv')
320 f = open('/data/workspace/schain_scripts/distrito.csv')
308 for line in f:
321 for line in f:
309 label, lon, lat = [s.strip() for s in line.split(',') if s]
322 label, lon, lat = [s.strip() for s in line.split(',') if s]
310 lat = float(lat)
323 lat = float(lat)
311 lon = float(lon)
324 lon = float(lon)
312 # ax.plot(lon, lat, '.b', ms=2)
325 # ax.plot(lon, lat, '.b', ms=2)
313 ax.text(lon, lat, label.decode('utf8'), ha='center',
326 ax.text(lon, lat, label.decode('utf8'), ha='center',
314 va='bottom', size='8', color='black')
327 va='bottom', size='8', color='black')
315
328
316 # plot limites
329 # plot limites
317 limites = []
330 limites = []
318 tmp = []
331 tmp = []
319 for line in open('/data/workspace/schain_scripts/lima.csv'):
332 for line in open('/data/workspace/schain_scripts/lima.csv'):
320 if '#' in line:
333 if '#' in line:
321 if tmp:
334 if tmp:
322 limites.append(tmp)
335 limites.append(tmp)
323 tmp = []
336 tmp = []
324 continue
337 continue
325 values = line.strip().split(',')
338 values = line.strip().split(',')
326 tmp.append((float(values[0]), float(values[1])))
339 tmp.append((float(values[0]), float(values[1])))
327 for points in limites:
340 for points in limites:
328 ax.add_patch(
341 ax.add_patch(
329 Polygon(points, ec='k', fc='none', ls='--', lw=0.5))
342 Polygon(points, ec='k', fc='none', ls='--', lw=0.5))
330
343
331 # plot Cuencas
344 # plot Cuencas
332 for cuenca in ('rimac', 'lurin', 'mala', 'chillon', 'chilca', 'chancay-huaral'):
345 for cuenca in ('rimac', 'lurin', 'mala', 'chillon', 'chilca', 'chancay-huaral'):
333 f = open('/data/workspace/schain_scripts/{}.csv'.format(cuenca))
346 f = open('/data/workspace/schain_scripts/{}.csv'.format(cuenca))
334 values = [line.strip().split(',') for line in f]
347 values = [line.strip().split(',') for line in f]
335 points = [(float(s[0]), float(s[1])) for s in values]
348 points = [(float(s[0]), float(s[1])) for s in values]
336 ax.add_patch(Polygon(points, ec='b', fc='none'))
349 ax.add_patch(Polygon(points, ec='b', fc='none'))
337
350
338 # plot grid
351 # plot grid
339 for r in (15, 30, 45, 60):
352 for r in (15, 30, 45, 60):
340 ax.add_artist(plt.Circle((self.lon, self.lat),
353 ax.add_artist(plt.Circle((self.lon, self.lat),
341 km2deg(r), color='0.6', fill=False, lw=0.2))
354 km2deg(r), color='0.6', fill=False, lw=0.2))
342 ax.text(
355 ax.text(
343 self.lon + (km2deg(r))*numpy.cos(60*numpy.pi/180),
356 self.lon + (km2deg(r))*numpy.cos(60*numpy.pi/180),
344 self.lat + (km2deg(r))*numpy.sin(60*numpy.pi/180),
357 self.lat + (km2deg(r))*numpy.sin(60*numpy.pi/180),
345 '{}km'.format(r),
358 '{}km'.format(r),
346 ha='center', va='bottom', size='8', color='0.6', weight='heavy')
359 ha='center', va='bottom', size='8', color='0.6', weight='heavy')
347
360
348 if self.mode == 'E':
361 if self.mode == 'E':
349 title = 'El={}$^\circ$'.format(self.data.meta['elevation'])
362 title = 'El={}$^\circ$'.format(self.data.meta['elevation'])
350 label = 'E{:02d}'.format(int(self.data.meta['elevation']))
363 label = 'E{:02d}'.format(int(self.data.meta['elevation']))
351 else:
364 else:
352 title = 'Az={}$^\circ$'.format(self.data.meta['azimuth'])
365 title = 'Az={}$^\circ$'.format(self.data.meta['azimuth'])
353 label = 'A{:02d}'.format(int(self.data.meta['azimuth']))
366 label = 'A{:02d}'.format(int(self.data.meta['azimuth']))
354
367
355 self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels]
368 self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels]
356 self.titles = ['{} {}'.format(
369 self.titles = ['{} {}'.format(
357 self.data.parameters[x], title) for x in self.channels]
370 self.data.parameters[x], title) for x in self.channels]
358
371
@@ -1,702 +1,743
1 # Copyright (c) 2012-2020 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 self.nplots = len(self.data.channels)
26 self.nplots = len(self.data.channels)
27 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
27 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
28 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
28 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
29 self.height = 2.6 * self.nrows
29 self.height = 2.6 * self.nrows
30 self.cb_label = 'dB'
30 self.cb_label = 'dB'
31 if self.showprofile:
31 if self.showprofile:
32 self.width = 4 * self.ncols
32 self.width = 4 * self.ncols
33 else:
33 else:
34 self.width = 3.5 * self.ncols
34 self.width = 3.5 * self.ncols
35 self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08})
35 self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08})
36 self.ylabel = 'Range [km]'
36 self.ylabel = 'Range [km]'
37
37
38 def update(self, dataOut):
38 def update(self, dataOut):
39
39
40 data = {}
40 data = {}
41 meta = {}
41 meta = {}
42 spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor)
42 spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor)
43 data['spc'] = spc
43 data['spc'] = spc
44 data['rti'] = dataOut.getPower()
44 data['rti'] = dataOut.getPower()
45 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
45 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
46 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
46 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
47
47 if self.CODE == 'spc_moments':
48 if self.CODE == 'spc_moments':
48 data['moments'] = dataOut.moments
49 data['moments'] = dataOut.moments
50 # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor)
51 if self.CODE == 'gaussian_fit':
52 # data['moments'] = dataOut.moments
53 data['gaussfit'] = dataOut.DGauFitParams
54 # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor)
49
55
50 return data, meta
56 return data, meta
51
57
52 def plot(self):
58 def plot(self):
53 if self.xaxis == "frequency":
59 if self.xaxis == "frequency":
54 x = self.data.xrange[0]
60 x = self.data.xrange[0]
55 self.xlabel = "Frequency (kHz)"
61 self.xlabel = "Frequency (kHz)"
56 elif self.xaxis == "time":
62 elif self.xaxis == "time":
57 x = self.data.xrange[1]
63 x = self.data.xrange[1]
58 self.xlabel = "Time (ms)"
64 self.xlabel = "Time (ms)"
59 else:
65 else:
60 x = self.data.xrange[2]
66 x = self.data.xrange[2]
61 self.xlabel = "Velocity (m/s)"
67 self.xlabel = "Velocity (m/s)"
62
68
63 if self.CODE == 'spc_moments':
69 if (self.CODE == 'spc_moments') | (self.CODE == 'gaussian_fit'):
64 x = self.data.xrange[2]
70 x = self.data.xrange[2]
65 self.xlabel = "Velocity (m/s)"
71 self.xlabel = "Velocity (m/s)"
66
72
67 self.titles = []
73 self.titles = []
68
74
69 y = self.data.yrange
75 y = self.data.yrange
70 self.y = y
76 self.y = y
71
77
72 data = self.data[-1]
78 data = self.data[-1]
73 z = data['spc']
79 z = data['spc']
74
80
75 for n, ax in enumerate(self.axes):
81 for n, ax in enumerate(self.axes):
76 noise = data['noise'][n]
82 noise = data['noise'][n]
77 if self.CODE == 'spc_moments':
83 if self.CODE == 'spc_moments':
78 mean = data['moments'][n, 2]
84 mean = data['moments'][n, 1]
85 if self.CODE == 'gaussian_fit':
86 # mean = data['moments'][n, 1]
87 gau0 = data['gaussfit'][n][2,:,0]
88 gau1 = data['gaussfit'][n][2,:,1]
79 if ax.firsttime:
89 if ax.firsttime:
80 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
90 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
81 self.xmin = self.xmin if self.xmin else -self.xmax
91 self.xmin = self.xmin if self.xmin else -self.xmax
82 self.zmin = self.zmin if self.zmin else numpy.nanmin(z)
92 self.zmin = self.zmin if self.zmin else numpy.nanmin(z)
83 self.zmax = self.zmax if self.zmax else numpy.nanmax(z)
93 self.zmax = self.zmax if self.zmax else numpy.nanmax(z)
84 ax.plt = ax.pcolormesh(x, y, z[n].T,
94 ax.plt = ax.pcolormesh(x, y, z[n].T,
85 vmin=self.zmin,
95 vmin=self.zmin,
86 vmax=self.zmax,
96 vmax=self.zmax,
87 cmap=plt.get_cmap(self.colormap)
97 cmap=plt.get_cmap(self.colormap)
88 )
98 )
89
99
90 if self.showprofile:
100 if self.showprofile:
91 ax.plt_profile = self.pf_axes[n].plot(
101 ax.plt_profile = self.pf_axes[n].plot(
92 data['rti'][n], y)[0]
102 data['rti'][n], y)[0]
93 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
103 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
94 color="k", linestyle="dashed", lw=1)[0]
104 color="k", linestyle="dashed", lw=1)[0]
95 if self.CODE == 'spc_moments':
105 if self.CODE == 'spc_moments':
96 ax.plt_mean = ax.plot(mean, y, color='k')[0]
106 ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0]
107 if self.CODE == 'gaussian_fit':
108 # ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0]
109 ax.plt_gau0 = ax.plot(gau0, y, color='r', lw=1)[0]
110 ax.plt_gau1 = ax.plot(gau1, y, color='y', lw=1)[0]
97 else:
111 else:
98 ax.plt.set_array(z[n].T.ravel())
112 ax.plt.set_array(z[n].T.ravel())
99 if self.showprofile:
113 if self.showprofile:
100 ax.plt_profile.set_data(data['rti'][n], y)
114 ax.plt_profile.set_data(data['rti'][n], y)
101 ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y)
115 ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y)
102 if self.CODE == 'spc_moments':
116 if self.CODE == 'spc_moments':
103 ax.plt_mean.set_data(mean, y)
117 ax.plt_mean.set_data(mean, y)
118 if self.CODE == 'gaussian_fit':
119 # ax.plt_mean.set_data(mean, y)
120 ax.plt_gau0.set_data(gau0, y)
121 ax.plt_gau1.set_data(gau1, y)
104 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
122 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
105
123
106
124
107 class CrossSpectraPlot(Plot):
125 class CrossSpectraPlot(Plot):
108
126
109 CODE = 'cspc'
127 CODE = 'cspc'
110 colormap = 'jet'
128 colormap = 'jet'
111 plot_type = 'pcolor'
129 plot_type = 'pcolor'
112 zmin_coh = None
130 zmin_coh = None
113 zmax_coh = None
131 zmax_coh = None
114 zmin_phase = None
132 zmin_phase = None
115 zmax_phase = None
133 zmax_phase = None
116
134
117 def setup(self):
135 def setup(self):
118
136
119 self.ncols = 4
137 self.ncols = 4
120 self.nplots = len(self.data.pairs) * 2
138 self.nplots = len(self.data.pairs) * 2
121 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
139 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
122 self.width = 3.1 * self.ncols
140 self.width = 3.1 * self.ncols
123 self.height = 2.6 * self.nrows
141 self.height = 2.6 * self.nrows
124 self.ylabel = 'Range [km]'
142 self.ylabel = 'Range [km]'
125 self.showprofile = False
143 self.showprofile = False
126 self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08})
144 self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08})
127
145
128 def update(self, dataOut):
146 def update(self, dataOut):
129
147
130 data = {}
148 data = {}
131 meta = {}
149 meta = {}
132
150
133 spc = dataOut.data_spc
151 spc = dataOut.data_spc
134 cspc = dataOut.data_cspc
152 cspc = dataOut.data_cspc
135 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
153 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
136 meta['pairs'] = dataOut.pairsList
154 meta['pairs'] = dataOut.pairsList
137
155
138 tmp = []
156 tmp = []
139
157
140 for n, pair in enumerate(meta['pairs']):
158 for n, pair in enumerate(meta['pairs']):
141 out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
159 out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
142 coh = numpy.abs(out)
160 coh = numpy.abs(out)
143 phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
161 phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
144 tmp.append(coh)
162 tmp.append(coh)
145 tmp.append(phase)
163 tmp.append(phase)
146
164
147 data['cspc'] = numpy.array(tmp)
165 data['cspc'] = numpy.array(tmp)
148
166
149 return data, meta
167 return data, meta
150
168
151 def plot(self):
169 def plot(self):
152
170
153 if self.xaxis == "frequency":
171 if self.xaxis == "frequency":
154 x = self.data.xrange[0]
172 x = self.data.xrange[0]
155 self.xlabel = "Frequency (kHz)"
173 self.xlabel = "Frequency (kHz)"
156 elif self.xaxis == "time":
174 elif self.xaxis == "time":
157 x = self.data.xrange[1]
175 x = self.data.xrange[1]
158 self.xlabel = "Time (ms)"
176 self.xlabel = "Time (ms)"
159 else:
177 else:
160 x = self.data.xrange[2]
178 x = self.data.xrange[2]
161 self.xlabel = "Velocity (m/s)"
179 self.xlabel = "Velocity (m/s)"
162
180
163 self.titles = []
181 self.titles = []
164
182
165 y = self.data.yrange
183 y = self.data.yrange
166 self.y = y
184 self.y = y
167
185
168 data = self.data[-1]
186 data = self.data[-1]
169 cspc = data['cspc']
187 cspc = data['cspc']
170
188
171 for n in range(len(self.data.pairs)):
189 for n in range(len(self.data.pairs)):
172 pair = self.data.pairs[n]
190 pair = self.data.pairs[n]
173 coh = cspc[n*2]
191 coh = cspc[n*2]
174 phase = cspc[n*2+1]
192 phase = cspc[n*2+1]
175 ax = self.axes[2 * n]
193 ax = self.axes[2 * n]
176 if ax.firsttime:
194 if ax.firsttime:
177 ax.plt = ax.pcolormesh(x, y, coh.T,
195 ax.plt = ax.pcolormesh(x, y, coh.T,
178 vmin=0,
196 vmin=0,
179 vmax=1,
197 vmax=1,
180 cmap=plt.get_cmap(self.colormap_coh)
198 cmap=plt.get_cmap(self.colormap_coh)
181 )
199 )
182 else:
200 else:
183 ax.plt.set_array(coh.T.ravel())
201 ax.plt.set_array(coh.T.ravel())
184 self.titles.append(
202 self.titles.append(
185 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
203 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
186
204
187 ax = self.axes[2 * n + 1]
205 ax = self.axes[2 * n + 1]
188 if ax.firsttime:
206 if ax.firsttime:
189 ax.plt = ax.pcolormesh(x, y, phase.T,
207 ax.plt = ax.pcolormesh(x, y, phase.T,
190 vmin=-180,
208 vmin=-180,
191 vmax=180,
209 vmax=180,
192 cmap=plt.get_cmap(self.colormap_phase)
210 cmap=plt.get_cmap(self.colormap_phase)
193 )
211 )
194 else:
212 else:
195 ax.plt.set_array(phase.T.ravel())
213 ax.plt.set_array(phase.T.ravel())
196 self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1]))
214 self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1]))
197
215
198
216
199 class RTIPlot(Plot):
217 class RTIPlot(Plot):
200 '''
218 '''
201 Plot for RTI data
219 Plot for RTI data
202 '''
220 '''
203
221
204 CODE = 'rti'
222 CODE = 'rti'
205 colormap = 'jet'
223 colormap = 'jet'
206 plot_type = 'pcolorbuffer'
224 plot_type = 'pcolorbuffer'
207
225
208 def setup(self):
226 def setup(self):
209 self.xaxis = 'time'
227 self.xaxis = 'time'
210 self.ncols = 1
228 self.ncols = 1
211 self.nrows = len(self.data.channels)
229 self.nrows = len(self.data.channels)
212 self.nplots = len(self.data.channels)
230 self.nplots = len(self.data.channels)
213 self.ylabel = 'Range [km]'
231 self.ylabel = 'Range [km]'
214 self.xlabel = 'Time'
232 self.xlabel = 'Time'
215 self.cb_label = 'dB'
233 self.cb_label = 'dB'
216 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95})
234 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95})
217 self.titles = ['{} Channel {}'.format(
235 self.titles = ['{} Channel {}'.format(
218 self.CODE.upper(), x) for x in range(self.nrows)]
236 self.CODE.upper(), x) for x in range(self.nrows)]
219
237
220 def update(self, dataOut):
238 def update(self, dataOut):
221
239
222 data = {}
240 data = {}
223 meta = {}
241 meta = {}
224 data['rti'] = dataOut.getPower()
242 data['rti'] = dataOut.getPower()
225 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
243 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
226
244
227 return data, meta
245 return data, meta
228
246
229 def plot(self):
247 def plot(self):
230 self.x = self.data.times
248 self.x = self.data.times
231 self.y = self.data.yrange
249 self.y = self.data.yrange
232 self.z = self.data[self.CODE]
250 self.z = self.data[self.CODE]
233 self.z = numpy.ma.masked_invalid(self.z)
251 self.z = numpy.ma.masked_invalid(self.z)
234
252
235 if self.decimation is None:
253 if self.decimation is None:
236 x, y, z = self.fill_gaps(self.x, self.y, self.z)
254 x, y, z = self.fill_gaps(self.x, self.y, self.z)
237 else:
255 else:
238 x, y, z = self.fill_gaps(*self.decimate())
256 x, y, z = self.fill_gaps(*self.decimate())
239
257
240 for n, ax in enumerate(self.axes):
258 for n, ax in enumerate(self.axes):
241 self.zmin = self.zmin if self.zmin else numpy.min(self.z)
259 self.zmin = self.zmin if self.zmin else numpy.min(self.z)
242 self.zmax = self.zmax if self.zmax else numpy.max(self.z)
260 self.zmax = self.zmax if self.zmax else numpy.max(self.z)
243 data = self.data[-1]
261 data = self.data[-1]
244 if ax.firsttime:
262 if ax.firsttime:
245 ax.plt = ax.pcolormesh(x, y, z[n].T,
263 ax.plt = ax.pcolormesh(x, y, z[n].T,
246 vmin=self.zmin,
264 vmin=self.zmin,
247 vmax=self.zmax,
265 vmax=self.zmax,
248 cmap=plt.get_cmap(self.colormap)
266 cmap=plt.get_cmap(self.colormap)
249 )
267 )
250 if self.showprofile:
268 if self.showprofile:
251 ax.plot_profile = self.pf_axes[n].plot(
269 ax.plot_profile = self.pf_axes[n].plot(
252 data['rti'][n], self.y)[0]
270 data['rti'][n], self.y)[0]
253 ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(data['noise'][n], len(self.y)), self.y,
271 ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(data['noise'][n], len(self.y)), self.y,
254 color="k", linestyle="dashed", lw=1)[0]
272 color="k", linestyle="dashed", lw=1)[0]
255 else:
273 else:
256 ax.collections.remove(ax.collections[0])
274 ax.collections.remove(ax.collections[0])
257 ax.plt = ax.pcolormesh(x, y, z[n].T,
275 ax.plt = ax.pcolormesh(x, y, z[n].T,
258 vmin=self.zmin,
276 vmin=self.zmin,
259 vmax=self.zmax,
277 vmax=self.zmax,
260 cmap=plt.get_cmap(self.colormap)
278 cmap=plt.get_cmap(self.colormap)
261 )
279 )
262 if self.showprofile:
280 if self.showprofile:
263 ax.plot_profile.set_data(data['rti'][n], self.y)
281 ax.plot_profile.set_data(data['rti'][n], self.y)
264 ax.plot_noise.set_data(numpy.repeat(
282 ax.plot_noise.set_data(numpy.repeat(
265 data['noise'][n], len(self.y)), self.y)
283 data['noise'][n], len(self.y)), self.y)
266
284
267
285
268 class CoherencePlot(RTIPlot):
286 class CoherencePlot(RTIPlot):
269 '''
287 '''
270 Plot for Coherence data
288 Plot for Coherence data
271 '''
289 '''
272
290
273 CODE = 'coh'
291 CODE = 'coh'
274
292
275 def setup(self):
293 def setup(self):
276 self.xaxis = 'time'
294 self.xaxis = 'time'
277 self.ncols = 1
295 self.ncols = 1
278 self.nrows = len(self.data.pairs)
296 self.nrows = len(self.data.pairs)
279 self.nplots = len(self.data.pairs)
297 self.nplots = len(self.data.pairs)
280 self.ylabel = 'Range [km]'
298 self.ylabel = 'Range [km]'
281 self.xlabel = 'Time'
299 self.xlabel = 'Time'
282 self.plots_adjust.update({'hspace':0.6, 'left': 0.1, 'bottom': 0.1,'right':0.95})
300 self.plots_adjust.update({'hspace':0.6, 'left': 0.1, 'bottom': 0.1,'right':0.95})
283 if self.CODE == 'coh':
301 if self.CODE == 'coh':
284 self.cb_label = ''
302 self.cb_label = ''
285 self.titles = [
303 self.titles = [
286 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
304 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
287 else:
305 else:
288 self.cb_label = 'Degrees'
306 self.cb_label = 'Degrees'
289 self.titles = [
307 self.titles = [
290 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
308 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
291
309
292 def update(self, dataOut):
310 def update(self, dataOut):
293
311
294 data = {}
312 data = {}
295 meta = {}
313 meta = {}
296 data['coh'] = dataOut.getCoherence()
314 data['coh'] = dataOut.getCoherence()
297 meta['pairs'] = dataOut.pairsList
315 meta['pairs'] = dataOut.pairsList
298
316
299 return data, meta
317 return data, meta
300
318
301 class PhasePlot(CoherencePlot):
319 class PhasePlot(CoherencePlot):
302 '''
320 '''
303 Plot for Phase map data
321 Plot for Phase map data
304 '''
322 '''
305
323
306 CODE = 'phase'
324 CODE = 'phase'
307 colormap = 'seismic'
325 colormap = 'seismic'
308
326
309 def update(self, dataOut):
327 def update(self, dataOut):
310
328
311 data = {}
329 data = {}
312 meta = {}
330 meta = {}
313 data['phase'] = dataOut.getCoherence(phase=True)
331 data['phase'] = dataOut.getCoherence(phase=True)
314 meta['pairs'] = dataOut.pairsList
332 meta['pairs'] = dataOut.pairsList
315
333
316 return data, meta
334 return data, meta
317
335
318 class NoisePlot(Plot):
336 class NoisePlot(Plot):
319 '''
337 '''
320 Plot for noise
338 Plot for noise
321 '''
339 '''
322
340
323 CODE = 'noise'
341 CODE = 'noise'
324 plot_type = 'scatterbuffer'
342 plot_type = 'scatterbuffer'
325
343
326 def setup(self):
344 def setup(self):
327 self.xaxis = 'time'
345 self.xaxis = 'time'
328 self.ncols = 1
346 self.ncols = 1
329 self.nrows = 1
347 self.nrows = 1
330 self.nplots = 1
348 self.nplots = 1
331 self.ylabel = 'Intensity [dB]'
349 self.ylabel = 'Intensity [dB]'
332 self.xlabel = 'Time'
350 self.xlabel = 'Time'
333 self.titles = ['Noise']
351 self.titles = ['Noise']
334 self.colorbar = False
352 self.colorbar = False
335 self.plots_adjust.update({'right': 0.85 })
353 self.plots_adjust.update({'right': 0.85 })
336
354
337 def update(self, dataOut):
355 def update(self, dataOut):
338
356
339 data = {}
357 data = {}
340 meta = {}
358 meta = {}
341 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor).reshape(dataOut.nChannels, 1)
359 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor).reshape(dataOut.nChannels, 1)
342 meta['yrange'] = numpy.array([])
360 meta['yrange'] = numpy.array([])
343
361
344 return data, meta
362 return data, meta
345
363
346 def plot(self):
364 def plot(self):
347
365
348 x = self.data.times
366 x = self.data.times
349 xmin = self.data.min_time
367 xmin = self.data.min_time
350 xmax = xmin + self.xrange * 60 * 60
368 xmax = xmin + self.xrange * 60 * 60
351 Y = self.data['noise']
369 Y = self.data['noise']
352
370
353 if self.axes[0].firsttime:
371 if self.axes[0].firsttime:
354 self.ymin = numpy.nanmin(Y) - 5
372 self.ymin = numpy.nanmin(Y) - 5
355 self.ymax = numpy.nanmax(Y) + 5
373 self.ymax = numpy.nanmax(Y) + 5
356 for ch in self.data.channels:
374 for ch in self.data.channels:
357 y = Y[ch]
375 y = Y[ch]
358 self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch))
376 self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch))
359 plt.legend(bbox_to_anchor=(1.18, 1.0))
377 plt.legend(bbox_to_anchor=(1.18, 1.0))
360 else:
378 else:
361 for ch in self.data.channels:
379 for ch in self.data.channels:
362 y = Y[ch]
380 y = Y[ch]
363 self.axes[0].lines[ch].set_data(x, y)
381 self.axes[0].lines[ch].set_data(x, y)
364
382
365
383
366 class PowerProfilePlot(Plot):
384 class PowerProfilePlot(Plot):
367
385
368 CODE = 'pow_profile'
386 CODE = 'pow_profile'
369 plot_type = 'scatter'
387 plot_type = 'scatter'
370
388
371 def setup(self):
389 def setup(self):
372
390
373 self.ncols = 1
391 self.ncols = 1
374 self.nrows = 1
392 self.nrows = 1
375 self.nplots = 1
393 self.nplots = 1
376 self.height = 4
394 self.height = 4
377 self.width = 3
395 self.width = 3
378 self.ylabel = 'Range [km]'
396 self.ylabel = 'Range [km]'
379 self.xlabel = 'Intensity [dB]'
397 self.xlabel = 'Intensity [dB]'
380 self.titles = ['Power Profile']
398 self.titles = ['Power Profile']
381 self.colorbar = False
399 self.colorbar = False
382
400
383 def update(self, dataOut):
401 def update(self, dataOut):
384
402
385 data = {}
403 data = {}
386 meta = {}
404 meta = {}
387 data[self.CODE] = dataOut.getPower()
405 data[self.CODE] = dataOut.getPower()
388
406
389 return data, meta
407 return data, meta
390
408
391 def plot(self):
409 def plot(self):
392
410
393 y = self.data.yrange
411 y = self.data.yrange
394 self.y = y
412 self.y = y
395
413
396 x = self.data[-1][self.CODE]
414 x = self.data[-1][self.CODE]
397
415
398 if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9
416 if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9
399 if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1
417 if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1
400
418
401 if self.axes[0].firsttime:
419 if self.axes[0].firsttime:
402 for ch in self.data.channels:
420 for ch in self.data.channels:
403 self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch))
421 self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch))
404 plt.legend()
422 plt.legend()
405 else:
423 else:
406 for ch in self.data.channels:
424 for ch in self.data.channels:
407 self.axes[0].lines[ch].set_data(x[ch], y)
425 self.axes[0].lines[ch].set_data(x[ch], y)
408
426
409
427
410 class SpectraCutPlot(Plot):
428 class SpectraCutPlot(Plot):
411
429
412 CODE = 'spc_cut'
430 CODE = 'spc_cut'
413 plot_type = 'scatter'
431 plot_type = 'scatter'
414 buffering = False
432 buffering = False
415
433
416 def setup(self):
434 def setup(self):
417
435
418 self.nplots = len(self.data.channels)
436 self.nplots = len(self.data.channels)
419 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
437 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
420 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
438 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
421 self.width = 3.4 * self.ncols + 1.5
439 self.width = 3.4 * self.ncols + 1.5
422 self.height = 3 * self.nrows
440 self.height = 3 * self.nrows
423 self.ylabel = 'Power [dB]'
441 self.ylabel = 'Power [dB]'
424 self.colorbar = False
442 self.colorbar = False
425 self.plots_adjust.update({'left':0.1, 'hspace':0.3, 'right': 0.75, 'bottom':0.08})
443 self.plots_adjust.update({'left':0.1, 'hspace':0.3, 'right': 0.75, 'bottom':0.08})
426
444
427 def update(self, dataOut):
445 def update(self, dataOut):
428
446
429 data = {}
447 data = {}
430 meta = {}
448 meta = {}
431 spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor)
449 spc = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor)
432 data['spc'] = spc
450 data['spc'] = spc
433 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
451 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
434
452 if self.CODE == 'cut_gaussian_fit':
453 data['gauss_fit0'] = 10*numpy.log10(dataOut.GaussFit0/dataOut.normFactor)
454 data['gauss_fit1'] = 10*numpy.log10(dataOut.GaussFit1/dataOut.normFactor)
435 return data, meta
455 return data, meta
436
456
437 def plot(self):
457 def plot(self):
438 if self.xaxis == "frequency":
458 if self.xaxis == "frequency":
439 x = self.data.xrange[0][1:]
459 x = self.data.xrange[0][1:]
440 self.xlabel = "Frequency (kHz)"
460 self.xlabel = "Frequency (kHz)"
441 elif self.xaxis == "time":
461 elif self.xaxis == "time":
442 x = self.data.xrange[1]
462 x = self.data.xrange[1]
443 self.xlabel = "Time (ms)"
463 self.xlabel = "Time (ms)"
444 else:
464 else:
445 x = self.data.xrange[2]
465 x = self.data.xrange[2][:-1]
466 self.xlabel = "Velocity (m/s)"
467
468 if self.CODE == 'cut_gaussian_fit':
469 x = self.data.xrange[2][:-1]
446 self.xlabel = "Velocity (m/s)"
470 self.xlabel = "Velocity (m/s)"
447
471
448 self.titles = []
472 self.titles = []
449
473
450 y = self.data.yrange
474 y = self.data.yrange
451 z = self.data[-1]['spc']
475 data = self.data[-1]
476 z = data['spc']
452
477
453 if self.height_index:
478 if self.height_index:
454 index = numpy.array(self.height_index)
479 index = numpy.array(self.height_index)
455 else:
480 else:
456 index = numpy.arange(0, len(y), int((len(y))/9))
481 index = numpy.arange(0, len(y), int((len(y))/9))
457
482
458 for n, ax in enumerate(self.axes):
483 for n, ax in enumerate(self.axes):
484 if self.CODE == 'cut_gaussian_fit':
485 gau0 = data['gauss_fit0']
486 gau1 = data['gauss_fit1']
459 if ax.firsttime:
487 if ax.firsttime:
460 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
488 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
461 self.xmin = self.xmin if self.xmin else -self.xmax
489 self.xmin = self.xmin if self.xmin else -self.xmax
462 self.ymin = self.ymin if self.ymin else numpy.nanmin(z)
490 self.ymin = self.ymin if self.ymin else numpy.nanmin(z)
463 self.ymax = self.ymax if self.ymax else numpy.nanmax(z)
491 self.ymax = self.ymax if self.ymax else numpy.nanmax(z)
464 ax.plt = ax.plot(x, z[n, :, index].T)
492 ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25)
493 if self.CODE == 'cut_gaussian_fit':
494 ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.')
495 for i, line in enumerate(ax.plt_gau0):
496 line.set_color(ax.plt[i].get_color())
497 ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--')
498 for i, line in enumerate(ax.plt_gau1):
499 line.set_color(ax.plt[i].get_color())
465 labels = ['Range = {:2.1f}km'.format(y[i]) for i in index]
500 labels = ['Range = {:2.1f}km'.format(y[i]) for i in index]
466 self.figures[0].legend(ax.plt, labels, loc='center right')
501 self.figures[0].legend(ax.plt, labels, loc='center right')
467 else:
502 else:
468 for i, line in enumerate(ax.plt):
503 for i, line in enumerate(ax.plt):
469 line.set_data(x, z[n, :, i])
504 line.set_data(x, z[n, :, index[i]].T)
505 for i, line in enumerate(ax.plt_gau0):
506 line.set_data(x, gau0[n, :, index[i]].T)
507 line.set_color(ax.plt[i].get_color())
508 for i, line in enumerate(ax.plt_gau1):
509 line.set_data(x, gau1[n, :, index[i]].T)
510 line.set_color(ax.plt[i].get_color())
470 self.titles.append('CH {}'.format(n))
511 self.titles.append('CH {}'.format(n))
471
512
472
513
473 class BeaconPhase(Plot):
514 class BeaconPhase(Plot):
474
515
475 __isConfig = None
516 __isConfig = None
476 __nsubplots = None
517 __nsubplots = None
477
518
478 PREFIX = 'beacon_phase'
519 PREFIX = 'beacon_phase'
479
520
480 def __init__(self):
521 def __init__(self):
481 Plot.__init__(self)
522 Plot.__init__(self)
482 self.timerange = 24*60*60
523 self.timerange = 24*60*60
483 self.isConfig = False
524 self.isConfig = False
484 self.__nsubplots = 1
525 self.__nsubplots = 1
485 self.counter_imagwr = 0
526 self.counter_imagwr = 0
486 self.WIDTH = 800
527 self.WIDTH = 800
487 self.HEIGHT = 400
528 self.HEIGHT = 400
488 self.WIDTHPROF = 120
529 self.WIDTHPROF = 120
489 self.HEIGHTPROF = 0
530 self.HEIGHTPROF = 0
490 self.xdata = None
531 self.xdata = None
491 self.ydata = None
532 self.ydata = None
492
533
493 self.PLOT_CODE = BEACON_CODE
534 self.PLOT_CODE = BEACON_CODE
494
535
495 self.FTP_WEI = None
536 self.FTP_WEI = None
496 self.EXP_CODE = None
537 self.EXP_CODE = None
497 self.SUB_EXP_CODE = None
538 self.SUB_EXP_CODE = None
498 self.PLOT_POS = None
539 self.PLOT_POS = None
499
540
500 self.filename_phase = None
541 self.filename_phase = None
501
542
502 self.figfile = None
543 self.figfile = None
503
544
504 self.xmin = None
545 self.xmin = None
505 self.xmax = None
546 self.xmax = None
506
547
507 def getSubplots(self):
548 def getSubplots(self):
508
549
509 ncol = 1
550 ncol = 1
510 nrow = 1
551 nrow = 1
511
552
512 return nrow, ncol
553 return nrow, ncol
513
554
514 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
555 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
515
556
516 self.__showprofile = showprofile
557 self.__showprofile = showprofile
517 self.nplots = nplots
558 self.nplots = nplots
518
559
519 ncolspan = 7
560 ncolspan = 7
520 colspan = 6
561 colspan = 6
521 self.__nsubplots = 2
562 self.__nsubplots = 2
522
563
523 self.createFigure(id = id,
564 self.createFigure(id = id,
524 wintitle = wintitle,
565 wintitle = wintitle,
525 widthplot = self.WIDTH+self.WIDTHPROF,
566 widthplot = self.WIDTH+self.WIDTHPROF,
526 heightplot = self.HEIGHT+self.HEIGHTPROF,
567 heightplot = self.HEIGHT+self.HEIGHTPROF,
527 show=show)
568 show=show)
528
569
529 nrow, ncol = self.getSubplots()
570 nrow, ncol = self.getSubplots()
530
571
531 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
572 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
532
573
533 def save_phase(self, filename_phase):
574 def save_phase(self, filename_phase):
534 f = open(filename_phase,'w+')
575 f = open(filename_phase,'w+')
535 f.write('\n\n')
576 f.write('\n\n')
536 f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n')
577 f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n')
537 f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' )
578 f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' )
538 f.close()
579 f.close()
539
580
540 def save_data(self, filename_phase, data, data_datetime):
581 def save_data(self, filename_phase, data, data_datetime):
541 f=open(filename_phase,'a')
582 f=open(filename_phase,'a')
542 timetuple_data = data_datetime.timetuple()
583 timetuple_data = data_datetime.timetuple()
543 day = str(timetuple_data.tm_mday)
584 day = str(timetuple_data.tm_mday)
544 month = str(timetuple_data.tm_mon)
585 month = str(timetuple_data.tm_mon)
545 year = str(timetuple_data.tm_year)
586 year = str(timetuple_data.tm_year)
546 hour = str(timetuple_data.tm_hour)
587 hour = str(timetuple_data.tm_hour)
547 minute = str(timetuple_data.tm_min)
588 minute = str(timetuple_data.tm_min)
548 second = str(timetuple_data.tm_sec)
589 second = str(timetuple_data.tm_sec)
549 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n')
590 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n')
550 f.close()
591 f.close()
551
592
552 def plot(self):
593 def plot(self):
553 log.warning('TODO: Not yet implemented...')
594 log.warning('TODO: Not yet implemented...')
554
595
555 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
596 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
556 xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None,
597 xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None,
557 timerange=None,
598 timerange=None,
558 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
599 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
559 server=None, folder=None, username=None, password=None,
600 server=None, folder=None, username=None, password=None,
560 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
601 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
561
602
562 if dataOut.flagNoData:
603 if dataOut.flagNoData:
563 return dataOut
604 return dataOut
564
605
565 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
606 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
566 return
607 return
567
608
568 if pairsList == None:
609 if pairsList == None:
569 pairsIndexList = dataOut.pairsIndexList[:10]
610 pairsIndexList = dataOut.pairsIndexList[:10]
570 else:
611 else:
571 pairsIndexList = []
612 pairsIndexList = []
572 for pair in pairsList:
613 for pair in pairsList:
573 if pair not in dataOut.pairsList:
614 if pair not in dataOut.pairsList:
574 raise ValueError("Pair %s is not in dataOut.pairsList" %(pair))
615 raise ValueError("Pair %s is not in dataOut.pairsList" %(pair))
575 pairsIndexList.append(dataOut.pairsList.index(pair))
616 pairsIndexList.append(dataOut.pairsList.index(pair))
576
617
577 if pairsIndexList == []:
618 if pairsIndexList == []:
578 return
619 return
579
620
580 # if len(pairsIndexList) > 4:
621 # if len(pairsIndexList) > 4:
581 # pairsIndexList = pairsIndexList[0:4]
622 # pairsIndexList = pairsIndexList[0:4]
582
623
583 hmin_index = None
624 hmin_index = None
584 hmax_index = None
625 hmax_index = None
585
626
586 if hmin != None and hmax != None:
627 if hmin != None and hmax != None:
587 indexes = numpy.arange(dataOut.nHeights)
628 indexes = numpy.arange(dataOut.nHeights)
588 hmin_list = indexes[dataOut.heightList >= hmin]
629 hmin_list = indexes[dataOut.heightList >= hmin]
589 hmax_list = indexes[dataOut.heightList <= hmax]
630 hmax_list = indexes[dataOut.heightList <= hmax]
590
631
591 if hmin_list.any():
632 if hmin_list.any():
592 hmin_index = hmin_list[0]
633 hmin_index = hmin_list[0]
593
634
594 if hmax_list.any():
635 if hmax_list.any():
595 hmax_index = hmax_list[-1]+1
636 hmax_index = hmax_list[-1]+1
596
637
597 x = dataOut.getTimeRange()
638 x = dataOut.getTimeRange()
598
639
599 thisDatetime = dataOut.datatime
640 thisDatetime = dataOut.datatime
600
641
601 title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
642 title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
602 xlabel = "Local Time"
643 xlabel = "Local Time"
603 ylabel = "Phase (degrees)"
644 ylabel = "Phase (degrees)"
604
645
605 update_figfile = False
646 update_figfile = False
606
647
607 nplots = len(pairsIndexList)
648 nplots = len(pairsIndexList)
608 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
649 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
609 phase_beacon = numpy.zeros(len(pairsIndexList))
650 phase_beacon = numpy.zeros(len(pairsIndexList))
610 for i in range(nplots):
651 for i in range(nplots):
611 pair = dataOut.pairsList[pairsIndexList[i]]
652 pair = dataOut.pairsList[pairsIndexList[i]]
612 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0)
653 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0)
613 powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0)
654 powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0)
614 powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0)
655 powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0)
615 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
656 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
616 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
657 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
617
658
618 if dataOut.beacon_heiIndexList:
659 if dataOut.beacon_heiIndexList:
619 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
660 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
620 else:
661 else:
621 phase_beacon[i] = numpy.average(phase)
662 phase_beacon[i] = numpy.average(phase)
622
663
623 if not self.isConfig:
664 if not self.isConfig:
624
665
625 nplots = len(pairsIndexList)
666 nplots = len(pairsIndexList)
626
667
627 self.setup(id=id,
668 self.setup(id=id,
628 nplots=nplots,
669 nplots=nplots,
629 wintitle=wintitle,
670 wintitle=wintitle,
630 showprofile=showprofile,
671 showprofile=showprofile,
631 show=show)
672 show=show)
632
673
633 if timerange != None:
674 if timerange != None:
634 self.timerange = timerange
675 self.timerange = timerange
635
676
636 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
677 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
637
678
638 if ymin == None: ymin = 0
679 if ymin == None: ymin = 0
639 if ymax == None: ymax = 360
680 if ymax == None: ymax = 360
640
681
641 self.FTP_WEI = ftp_wei
682 self.FTP_WEI = ftp_wei
642 self.EXP_CODE = exp_code
683 self.EXP_CODE = exp_code
643 self.SUB_EXP_CODE = sub_exp_code
684 self.SUB_EXP_CODE = sub_exp_code
644 self.PLOT_POS = plot_pos
685 self.PLOT_POS = plot_pos
645
686
646 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
687 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
647 self.isConfig = True
688 self.isConfig = True
648 self.figfile = figfile
689 self.figfile = figfile
649 self.xdata = numpy.array([])
690 self.xdata = numpy.array([])
650 self.ydata = numpy.array([])
691 self.ydata = numpy.array([])
651
692
652 update_figfile = True
693 update_figfile = True
653
694
654 #open file beacon phase
695 #open file beacon phase
655 path = '%s%03d' %(self.PREFIX, self.id)
696 path = '%s%03d' %(self.PREFIX, self.id)
656 beacon_file = os.path.join(path,'%s.txt'%self.name)
697 beacon_file = os.path.join(path,'%s.txt'%self.name)
657 self.filename_phase = os.path.join(figpath,beacon_file)
698 self.filename_phase = os.path.join(figpath,beacon_file)
658 #self.save_phase(self.filename_phase)
699 #self.save_phase(self.filename_phase)
659
700
660
701
661 #store data beacon phase
702 #store data beacon phase
662 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
703 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
663
704
664 self.setWinTitle(title)
705 self.setWinTitle(title)
665
706
666
707
667 title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
708 title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
668
709
669 legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList]
710 legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList]
670
711
671 axes = self.axesList[0]
712 axes = self.axesList[0]
672
713
673 self.xdata = numpy.hstack((self.xdata, x[0:1]))
714 self.xdata = numpy.hstack((self.xdata, x[0:1]))
674
715
675 if len(self.ydata)==0:
716 if len(self.ydata)==0:
676 self.ydata = phase_beacon.reshape(-1,1)
717 self.ydata = phase_beacon.reshape(-1,1)
677 else:
718 else:
678 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
719 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
679
720
680
721
681 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
722 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
682 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
723 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
683 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
724 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
684 XAxisAsTime=True, grid='both'
725 XAxisAsTime=True, grid='both'
685 )
726 )
686
727
687 self.draw()
728 self.draw()
688
729
689 if dataOut.ltctime >= self.xmax:
730 if dataOut.ltctime >= self.xmax:
690 self.counter_imagwr = wr_period
731 self.counter_imagwr = wr_period
691 self.isConfig = False
732 self.isConfig = False
692 update_figfile = True
733 update_figfile = True
693
734
694 self.save(figpath=figpath,
735 self.save(figpath=figpath,
695 figfile=figfile,
736 figfile=figfile,
696 save=save,
737 save=save,
697 ftp=ftp,
738 ftp=ftp,
698 wr_period=wr_period,
739 wr_period=wr_period,
699 thisDatetime=thisDatetime,
740 thisDatetime=thisDatetime,
700 update_figfile=update_figfile)
741 update_figfile=update_figfile)
701
742
702 return dataOut No newline at end of file
743 return dataOut
General Comments 0
You need to be logged in to leave comments. Login now