##// END OF EJS Templates
Update plots for realtime app
Juan C. Espinoza -
r1221:94b941a5310a
parent child
Show More
@@ -1105,6 +1105,7 class PlotterData(object):
1105 1105
1106 1106 def __init__(self, code, throttle_value, exp_code, buffering=True, snr=False):
1107 1107
1108 self.key = code
1108 1109 self.throttle = throttle_value
1109 1110 self.exp_code = exp_code
1110 1111 self.buffering = buffering
@@ -1202,10 +1203,8 class PlotterData(object):
1202 1203 self.tm = tm
1203 1204 self.type = dataOut.type
1204 1205 self.parameters = getattr(dataOut, 'parameters', [])
1205 if hasattr(dataOut, 'pairsList'):
1206 self.pairs = dataOut.pairsList
1207 1206 if hasattr(dataOut, 'meta'):
1208 self.meta = dataOut.meta
1207 self.meta.update(dataOut.meta)
1209 1208 self.channels = dataOut.channelList
1210 1209 self.interval = dataOut.getTimeInterval()
1211 1210 self.localtime = dataOut.useLocalTime
@@ -1288,40 +1287,40 class PlotterData(object):
1288 1287
1289 1288 self.__heights = [H for tm in self.__times]
1290 1289
1291 def jsonify(self, decimate=False):
1290 def jsonify(self, plot_name, plot_type, decimate=False):
1292 1291 '''
1293 1292 Convert data to json
1294 1293 '''
1295 1294
1296 data = {}
1297 1295 tm = self.times[-1]
1298 1296 dy = int(self.heights.size/self.MAXNUMY) + 1
1299 for key in self.data:
1300 if key in ('spc', 'cspc') or not self.buffering:
1301 dx = int(self.data[key].shape[1]/self.MAXNUMX) + 1
1302 data[key] = self.roundFloats(
1303 self.data[key][::, ::dx, ::dy].tolist())
1304 else:
1305 data[key] = self.roundFloats(self.data[key][tm].tolist())
1306
1307 ret = {'data': data}
1308 ret['exp_code'] = self.exp_code
1309 ret['time'] = float(tm)
1310 ret['interval'] = float(self.interval)
1311 ret['localtime'] = self.localtime
1312 ret['yrange'] = self.roundFloats(self.heights[::dy].tolist())
1313 if 'spc' in self.data or 'cspc' in self.data:
1314 ret['xrange'] = self.roundFloats(self.xrange[2][::dx].tolist())
1297 if self.key in ('spc', 'cspc') or not self.buffering:
1298 dx = int(self.data[self.key].shape[1]/self.MAXNUMX) + 1
1299 data = self.roundFloats(
1300 self.data[self.key][::, ::dx, ::dy].tolist())
1315 1301 else:
1316 ret['xrange'] = []
1317 if hasattr(self, 'pairs'):
1318 ret['pairs'] = [(int(p[0]), int(p[1])) for p in self.pairs]
1302 data = self.roundFloats(self.data[self.key][tm].tolist())
1303 if self.key is 'noise':
1304 data = [[x] for x in data]
1305
1306 meta = {}
1307 ret = {
1308 'plot': plot_name,
1309 'code': self.exp_code,
1310 'time': float(tm),
1311 'data': data,
1312 }
1313 meta['type'] = plot_type
1314 meta['interval'] = float(self.interval)
1315 meta['localtime'] = self.localtime
1316 meta['yrange'] = self.roundFloats(self.heights[::dy].tolist())
1317 if 'spc' in self.data or 'cspc' in self.data:
1318 meta['xrange'] = self.roundFloats(self.xrange[2][::dx].tolist())
1319 1319 else:
1320 ret['pairs'] = []
1321
1322 for key, value in list(self.meta.items()):
1323 ret[key] = value
1320 meta['xrange'] = []
1324 1321
1322 meta.update(self.meta)
1323 ret['metadata'] = meta
1325 1324 return json.dumps(ret)
1326 1325
1327 1326 @property
@@ -236,6 +236,8 class Plot(Operation):
236 236 'Sending to server: {}'.format(self.plot_server),
237 237 self.name
238 238 )
239 if 'plot_name' in kwargs:
240 self.plot_name = kwargs['plot_name']
239 241
240 242 def __setup_plot(self):
241 243 '''
@@ -672,10 +674,10 class Plot(Operation):
672 674 self.sender_counter += 1
673 675
674 676 self.sender_counter = 1
675
677 self.data.meta['titles'] = self.titles
676 678 retries = 2
677 679 while True:
678 self.socket.send_string(self.data.jsonify())
680 self.socket.send_string(self.data.jsonify(self.plot_name, self.plot_type))
679 681 socks = dict(self.poll.poll(5000))
680 682 if socks.get(self.socket) == zmq.POLLIN:
681 683 reply = self.socket.recv_string()
@@ -42,6 +42,8 class SpectraPlot(Plot):
42 42
43 43 CODE = 'spc'
44 44 colormap = 'jro'
45 plot_name = 'Spectra'
46 plot_type = 'pcolor'
45 47
46 48 def setup(self):
47 49 self.nplots = len(self.data.channels)
@@ -112,6 +114,8 class CrossSpectraPlot(Plot):
112 114
113 115 CODE = 'cspc'
114 116 colormap = 'jet'
117 plot_name = 'CrossSpectra'
118 plot_type = 'pcolor'
115 119 zmin_coh = None
116 120 zmax_coh = None
117 121 zmin_phase = None
@@ -211,6 +215,8 class SpectralMomentsPlot(SpectraPlot):
211 215 '''
212 216 CODE = 'spc_moments'
213 217 colormap = 'jro'
218 plot_name = 'SpectralMoments'
219 plot_type = 'pcolor'
214 220
215 221
216 222 class RTIPlot(Plot):
@@ -220,6 +226,8 class RTIPlot(Plot):
220 226
221 227 CODE = 'rti'
222 228 colormap = 'jro'
229 plot_name = 'RTI'
230 plot_type = 'pcolorbuffer'
223 231
224 232 def setup(self):
225 233 self.xaxis = 'time'
@@ -275,6 +283,7 class CoherencePlot(RTIPlot):
275 283 '''
276 284
277 285 CODE = 'coh'
286 plot_name = 'Coherence'
278 287
279 288 def setup(self):
280 289 self.xaxis = 'time'
@@ -299,6 +308,7 class PhasePlot(CoherencePlot):
299 308
300 309 CODE = 'phase'
301 310 colormap = 'seismic'
311 plot_name = 'Phase'
302 312
303 313
304 314 class NoisePlot(Plot):
@@ -307,6 +317,9 class NoisePlot(Plot):
307 317 '''
308 318
309 319 CODE = 'noise'
320 plot_name = 'Noise'
321 plot_type = 'scatterbuffer'
322
310 323
311 324 def setup(self):
312 325 self.xaxis = 'time'
@@ -345,6 +358,7 class SnrPlot(RTIPlot):
345 358
346 359 CODE = 'snr'
347 360 colormap = 'jet'
361 plot_name = 'SNR'
348 362
349 363
350 364 class DopplerPlot(RTIPlot):
@@ -354,6 +368,7 class DopplerPlot(RTIPlot):
354 368
355 369 CODE = 'dop'
356 370 colormap = 'jet'
371 plot_name = 'Doppler'
357 372
358 373
359 374 class SkyMapPlot(Plot):
@@ -411,6 +426,7 class ParametersPlot(RTIPlot):
411 426
412 427 CODE = 'param'
413 428 colormap = 'seismic'
429 plot_name = 'Parameters'
414 430
415 431 def setup(self):
416 432 self.xaxis = 'time'
@@ -480,6 +496,7 class OutputPlot(ParametersPlot):
480 496
481 497 CODE = 'output'
482 498 colormap = 'seismic'
499 plot_name = 'Output'
483 500
484 501
485 502 class PolarMapPlot(Plot):
@@ -621,6 +638,8 class ScopePlot(Plot):
621 638 '''
622 639
623 640 CODE = 'scope'
641 plot_name = 'Scope'
642 plot_type = 'scatter'
624 643
625 644 def setup(self):
626 645
@@ -720,11 +739,6 class ScopePlot(Plot):
720 739 thisDatetime,
721 740 wintitle1
722 741 )
723
724
725
726
727
728 742 else:
729 743 wintitle = " [Profile = %d] " %self.data.profileIndex
730 744
@@ -743,6 +757,3 class ScopePlot(Plot):
743 757 thisDatetime,
744 758 wintitle
745 759 )
746
747
748 No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now