##// END OF EJS Templates
Add SkyMapPlotData, operation can access parent kwargs, fix server plot for multiple ReceiverData
Juan C. Espinoza -
r937:6cdcc42f2694
parent child
Show More
@@ -1216,7 +1216,10 class Parameters(Spectra):
1216
1216
1217 def getTimeInterval(self):
1217 def getTimeInterval(self):
1218
1218
1219 return self.timeInterval1
1219 if hasattr(self, 'timeInterval1'):
1220 return self.timeInterval1
1221 else:
1222 return self.paramInterval
1220
1223
1221 def getNoise(self):
1224 def getNoise(self):
1222
1225
@@ -92,13 +92,12 class PlotData(Operation, Process):
92 print 'plotting...{}'.format(self.CODE)
92 print 'plotting...{}'.format(self.CODE)
93
93
94 if self.show:
94 if self.show:
95 print 'showing'
96 self.figure.show()
95 self.figure.show()
97
96
98 self.plot()
97 self.plot()
99 plt.tight_layout()
98 plt.tight_layout()
100 self.figure.canvas.manager.set_window_title('{} {} - Date:{}'.format(self.title, self.CODE.upper(),
99 self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(),
101 datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')))
100 datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d')))
102
101
103 if self.save:
102 if self.save:
104 figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,
103 figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,
@@ -116,11 +115,15 class PlotData(Operation, Process):
116 def run(self):
115 def run(self):
117
116
118 print '[Starting] {}'.format(self.name)
117 print '[Starting] {}'.format(self.name)
118
119 context = zmq.Context()
119 context = zmq.Context()
120 receiver = context.socket(zmq.SUB)
120 receiver = context.socket(zmq.SUB)
121 receiver.setsockopt(zmq.SUBSCRIBE, '')
121 receiver.setsockopt(zmq.SUBSCRIBE, '')
122 receiver.setsockopt(zmq.CONFLATE, self.CONFLATE)
122 receiver.setsockopt(zmq.CONFLATE, self.CONFLATE)
123 receiver.connect("ipc:///tmp/zmq.plots")
123 if 'server' in self.kwargs['parent']:
124 receiver.connect('ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server']))
125 else:
126 receiver.connect("ipc:///tmp/zmq.plots")
124
127
125 while True:
128 while True:
126 try:
129 try:
@@ -594,6 +597,7 class PlotNoiseData(PlotData):
594
597
595
598
596 class PlotWindProfilerData(PlotRTIData):
599 class PlotWindProfilerData(PlotRTIData):
600
597 CODE = 'wind'
601 CODE = 'wind'
598 colormap = 'seismic'
602 colormap = 'seismic'
599
603
@@ -603,7 +607,7 class PlotWindProfilerData(PlotRTIData):
603 self.width = 10
607 self.width = 10
604 self.height = 2.2*self.nrows
608 self.height = 2.2*self.nrows
605 self.ylabel = 'Height [Km]'
609 self.ylabel = 'Height [Km]'
606 self.titles = ['Zonal' ,'Meridional', 'Vertical']
610 self.titles = ['Zonal Wind' ,'Meridional Wind', 'Vertical Wind']
607 self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
611 self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
608 self.windFactor = [1, 1, 100]
612 self.windFactor = [1, 1, 100]
609
613
@@ -627,13 +631,13 class PlotWindProfilerData(PlotRTIData):
627 self.z = []
631 self.z = []
628
632
629 for ch in range(self.nrows):
633 for ch in range(self.nrows):
630 self.z.append([self.data[self.CODE][t][ch] for t in self.times])
634 self.z.append([self.data['output'][t][ch] for t in self.times])
631
635
632 self.z = np.array(self.z)
636 self.z = np.array(self.z)
633 self.z = numpy.ma.masked_invalid(self.z)
637 self.z = numpy.ma.masked_invalid(self.z)
634
638
635 cmap=plt.get_cmap(self.colormap)
639 cmap=plt.get_cmap(self.colormap)
636 cmap.set_bad('white', 1.)
640 cmap.set_bad('black', 1.)
637
641
638 for n, ax in enumerate(self.axes):
642 for n, ax in enumerate(self.axes):
639 x, y, z = self.fill_gaps(*self.decimate())
643 x, y, z = self.fill_gaps(*self.decimate())
@@ -652,9 +656,9 class PlotWindProfilerData(PlotRTIData):
652 )
656 )
653 divider = make_axes_locatable(ax)
657 divider = make_axes_locatable(ax)
654 cax = divider.new_horizontal(size='2%', pad=0.05)
658 cax = divider.new_horizontal(size='2%', pad=0.05)
655 cax.set_ylabel(self.clabels[n])
656 self.figure.add_axes(cax)
659 self.figure.add_axes(cax)
657 plt.colorbar(plot, cax)
660 cb = plt.colorbar(plot, cax)
661 cb.set_label(self.clabels[n])
658 ax.set_ylim(self.ymin, self.ymax)
662 ax.set_ylim(self.ymin, self.ymax)
659
663
660 ax.xaxis.set_major_formatter(FuncFormatter(func))
664 ax.xaxis.set_major_formatter(FuncFormatter(func))
@@ -691,3 +695,62 class PlotDOPData(PlotRTIData):
691 class PlotPHASEData(PlotCOHData):
695 class PlotPHASEData(PlotCOHData):
692 CODE = 'phase'
696 CODE = 'phase'
693 colormap = 'seismic'
697 colormap = 'seismic'
698
699
700 class PlotSkyMapData(PlotData):
701
702 CODE = 'met'
703
704 def setup(self):
705
706 self.ncols = 1
707 self.nrows = 1
708 self.width = 7.2
709 self.height = 7.2
710
711 self.xlabel = 'Zonal Zenith Angle (deg)'
712 self.ylabel = 'Meridional Zenith Angle (deg)'
713
714 if self.figure is None:
715 self.figure = plt.figure(figsize=(self.width, self.height),
716 edgecolor='k',
717 facecolor='w')
718 else:
719 self.figure.clf()
720
721 self.ax = plt.subplot2grid((self.nrows, self.ncols), (0, 0), 1, 1, polar=True)
722 self.ax.firsttime = True
723
724
725 def plot(self):
726
727 arrayParameters = np.concatenate([self.data['param'][t] for t in self.times])
728 error = arrayParameters[:,-1]
729 indValid = numpy.where(error == 0)[0]
730 finalMeteor = arrayParameters[indValid,:]
731 finalAzimuth = finalMeteor[:,3]
732 finalZenith = finalMeteor[:,4]
733
734 x = finalAzimuth*numpy.pi/180
735 y = finalZenith
736
737 if self.ax.firsttime:
738 self.ax.plot = self.ax.plot(x, y, 'bo', markersize=5)[0]
739 self.ax.set_ylim(0,90)
740 self.ax.set_yticks(numpy.arange(0,90,20))
741 self.ax.set_xlabel(self.xlabel)
742 self.ax.set_ylabel(self.ylabel)
743 self.ax.yaxis.labelpad = 40
744 self.ax.firsttime = False
745 else:
746 self.ax.plot.set_data(x, y)
747
748
749 dt1 = datetime.datetime.fromtimestamp(self.min_time).strftime('%y/%m/%d %H:%M:%S')
750 dt2 = datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')
751 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
752 dt2,
753 len(x))
754 self.ax.set_title(title, size=8)
755
756 self.saveTime = self.max_time
@@ -121,12 +121,13 class ProcessingUnit(object):
121 if self.mp is False:
121 if self.mp is False:
122 self.mp = True
122 self.mp = True
123 self.start()
123 self.start()
124 else:
124 else:
125 self.operationKwargs[opId]['parent'] = self.kwargs
125 methodToCall(**self.operationKwargs[opId])
126 methodToCall(**self.operationKwargs[opId])
126 else:
127 else:
127 if name=='run':
128 if name=='run':
128 methodToCall(**self.kwargs)
129 methodToCall(**self.kwargs)
129 else:
130 else:
130 methodToCall(**self.operationKwargs[opId])
131 methodToCall(**self.operationKwargs[opId])
131
132
132 if self.dataOut is None:
133 if self.dataOut is None:
@@ -160,12 +161,14 class ProcessingUnit(object):
160
161
161 if hasattr(externalProcObj, 'mp'):
162 if hasattr(externalProcObj, 'mp'):
162 if externalProcObj.mp is False:
163 if externalProcObj.mp is False:
164 externalProcObj.kwargs['parent'] = self.kwargs
163 self.operationKwargs[objId] = externalProcObj.kwargs
165 self.operationKwargs[objId] = externalProcObj.kwargs
164 externalProcObj.mp = True
166 externalProcObj.mp = True
165 externalProcObj.start()
167 externalProcObj.start()
166 else:
168 else:
167 externalProcObj.run(self.dataOut, **externalProcObj.kwargs)
169 externalProcObj.run(self.dataOut, **externalProcObj.kwargs)
168 self.operationKwargs[objId] = externalProcObj.kwargs
170 self.operationKwargs[objId] = externalProcObj.kwargs
171
169
172
170 return True
173 return True
171
174
@@ -367,8 +367,10 class ReceiverData(ProcessingUnit, Process):
367 self.data[plottype][t] = self.dataOut.getCoherence()
367 self.data[plottype][t] = self.dataOut.getCoherence()
368 if plottype == 'phase':
368 if plottype == 'phase':
369 self.data[plottype][t] = self.dataOut.getCoherence(phase=True)
369 self.data[plottype][t] = self.dataOut.getCoherence(phase=True)
370 if plottype == 'wind':
370 if plottype == 'output':
371 self.data[plottype][t] = self.dataOut.data_output
371 self.data[plottype][t] = self.dataOut.data_output
372 if plottype == 'param':
373 self.data[plottype][t] = self.dataOut.data_param
372 if self.realtime:
374 if self.realtime:
373 self.data_web['timestamp'] = t
375 self.data_web['timestamp'] = t
374 if plottype == 'spc':
376 if plottype == 'spc':
@@ -396,7 +398,10 class ReceiverData(ProcessingUnit, Process):
396 self.sender_web = self.context.socket(zmq.PUB)
398 self.sender_web = self.context.socket(zmq.PUB)
397 self.sender_web.connect(self.plot_address)
399 self.sender_web.connect(self.plot_address)
398 time.sleep(1)
400 time.sleep(1)
399 self.sender.bind("ipc:///tmp/zmq.plots")
401 if 'server' in self.kwargs:
402 self.sender.bind("ipc:///tmp/{}.plots".format(self.kwargs['server']))
403 else:
404 self.sender.bind("ipc:///tmp/zmq.plots")
400
405
401 t = Thread(target=self.event_monitor, args=(monitor,))
406 t = Thread(target=self.event_monitor, args=(monitor,))
402 t.start()
407 t.start()
General Comments 0
You need to be logged in to leave comments. Login now