@@ -1216,7 +1216,10 class Parameters(Spectra): | |||||
1216 |
|
1216 | |||
1217 | def getTimeInterval(self): |
|
1217 | def getTimeInterval(self): | |
1218 |
|
1218 | |||
1219 |
|
|
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 |
@@ -95,13 +95,12 class PlotData(Operation, Process): | |||||
95 | print 'plotting...{}'.format(self.CODE) |
|
95 | print 'plotting...{}'.format(self.CODE) | |
96 |
|
96 | |||
97 | if self.show: |
|
97 | if self.show: | |
98 | print 'showing' |
|
|||
99 | self.figure.show() |
|
98 | self.figure.show() | |
100 |
|
99 | |||
101 | self.plot() |
|
100 | self.plot() | |
102 | plt.tight_layout() |
|
101 | plt.tight_layout() | |
103 |
self.figure.canvas.manager.set_window_title('{} {} - |
|
102 | self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(), | |
104 |
|
|
103 | datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d'))) | |
105 |
|
104 | |||
106 | if self.save: |
|
105 | if self.save: | |
107 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, |
|
106 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, | |
@@ -119,12 +118,19 class PlotData(Operation, Process): | |||||
119 | def run(self): |
|
118 | def run(self): | |
120 |
|
119 | |||
121 | print '[Starting] {}'.format(self.name) |
|
120 | print '[Starting] {}'.format(self.name) | |
|
121 | ||||
122 | context = zmq.Context() |
|
122 | context = zmq.Context() | |
123 | receiver = context.socket(zmq.SUB) |
|
123 | receiver = context.socket(zmq.SUB) | |
124 | receiver.setsockopt(zmq.SUBSCRIBE, '') |
|
124 | receiver.setsockopt(zmq.SUBSCRIBE, '') | |
125 | receiver.setsockopt(zmq.CONFLATE, self.CONFLATE) |
|
125 | receiver.setsockopt(zmq.CONFLATE, self.CONFLATE) | |
126 | receiver.connect("ipc:///tmp/zmq.plots") |
|
126 | ||
|
127 | if 'server' in self.kwargs['parent']: | |||
|
128 | receiver.connect('ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server'])) | |||
|
129 | else: | |||
|
130 | receiver.connect("ipc:///tmp/zmq.plots") | |||
|
131 | ||||
127 | seconds_passed = 0 |
|
132 | seconds_passed = 0 | |
|
133 | ||||
128 | while True: |
|
134 | while True: | |
129 | try: |
|
135 | try: | |
130 | self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK)#flags=zmq.NOBLOCK |
|
136 | self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK)#flags=zmq.NOBLOCK | |
@@ -610,6 +616,7 class PlotNoiseData(PlotData): | |||||
610 |
|
616 | |||
611 |
|
617 | |||
612 | class PlotWindProfilerData(PlotRTIData): |
|
618 | class PlotWindProfilerData(PlotRTIData): | |
|
619 | ||||
613 | CODE = 'wind' |
|
620 | CODE = 'wind' | |
614 | colormap = 'seismic' |
|
621 | colormap = 'seismic' | |
615 |
|
622 | |||
@@ -619,7 +626,7 class PlotWindProfilerData(PlotRTIData): | |||||
619 | self.width = 10 |
|
626 | self.width = 10 | |
620 | self.height = 2.2*self.nrows |
|
627 | self.height = 2.2*self.nrows | |
621 | self.ylabel = 'Height [Km]' |
|
628 | self.ylabel = 'Height [Km]' | |
622 | self.titles = ['Zonal' ,'Meridional', 'Vertical'] |
|
629 | self.titles = ['Zonal Wind' ,'Meridional Wind', 'Vertical Wind'] | |
623 | self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] |
|
630 | self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] | |
624 | self.windFactor = [1, 1, 100] |
|
631 | self.windFactor = [1, 1, 100] | |
625 |
|
632 | |||
@@ -643,13 +650,13 class PlotWindProfilerData(PlotRTIData): | |||||
643 | self.z = [] |
|
650 | self.z = [] | |
644 |
|
651 | |||
645 | for ch in range(self.nrows): |
|
652 | for ch in range(self.nrows): | |
646 |
self.z.append([self.data[ |
|
653 | self.z.append([self.data['output'][t][ch] for t in self.times]) | |
647 |
|
654 | |||
648 | self.z = np.array(self.z) |
|
655 | self.z = np.array(self.z) | |
649 | self.z = numpy.ma.masked_invalid(self.z) |
|
656 | self.z = numpy.ma.masked_invalid(self.z) | |
650 |
|
657 | |||
651 | cmap=plt.get_cmap(self.colormap) |
|
658 | cmap=plt.get_cmap(self.colormap) | |
652 |
cmap.set_bad(' |
|
659 | cmap.set_bad('black', 1.) | |
653 |
|
660 | |||
654 | for n, ax in enumerate(self.axes): |
|
661 | for n, ax in enumerate(self.axes): | |
655 | x, y, z = self.fill_gaps(*self.decimate()) |
|
662 | x, y, z = self.fill_gaps(*self.decimate()) | |
@@ -668,9 +675,9 class PlotWindProfilerData(PlotRTIData): | |||||
668 | ) |
|
675 | ) | |
669 | divider = make_axes_locatable(ax) |
|
676 | divider = make_axes_locatable(ax) | |
670 | cax = divider.new_horizontal(size='2%', pad=0.05) |
|
677 | cax = divider.new_horizontal(size='2%', pad=0.05) | |
671 | cax.set_ylabel(self.clabels[n]) |
|
|||
672 | self.figure.add_axes(cax) |
|
678 | self.figure.add_axes(cax) | |
673 | plt.colorbar(plot, cax) |
|
679 | cb = plt.colorbar(plot, cax) | |
|
680 | cb.set_label(self.clabels[n]) | |||
674 | ax.set_ylim(self.ymin, self.ymax) |
|
681 | ax.set_ylim(self.ymin, self.ymax) | |
675 |
|
682 | |||
676 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
683 | ax.xaxis.set_major_formatter(FuncFormatter(func)) | |
@@ -707,3 +714,62 class PlotDOPData(PlotRTIData): | |||||
707 | class PlotPHASEData(PlotCOHData): |
|
714 | class PlotPHASEData(PlotCOHData): | |
708 | CODE = 'phase' |
|
715 | CODE = 'phase' | |
709 | colormap = 'seismic' |
|
716 | colormap = 'seismic' | |
|
717 | ||||
|
718 | ||||
|
719 | class PlotSkyMapData(PlotData): | |||
|
720 | ||||
|
721 | CODE = 'met' | |||
|
722 | ||||
|
723 | def setup(self): | |||
|
724 | ||||
|
725 | self.ncols = 1 | |||
|
726 | self.nrows = 1 | |||
|
727 | self.width = 7.2 | |||
|
728 | self.height = 7.2 | |||
|
729 | ||||
|
730 | self.xlabel = 'Zonal Zenith Angle (deg)' | |||
|
731 | self.ylabel = 'Meridional Zenith Angle (deg)' | |||
|
732 | ||||
|
733 | if self.figure is None: | |||
|
734 | self.figure = plt.figure(figsize=(self.width, self.height), | |||
|
735 | edgecolor='k', | |||
|
736 | facecolor='w') | |||
|
737 | else: | |||
|
738 | self.figure.clf() | |||
|
739 | ||||
|
740 | self.ax = plt.subplot2grid((self.nrows, self.ncols), (0, 0), 1, 1, polar=True) | |||
|
741 | self.ax.firsttime = True | |||
|
742 | ||||
|
743 | ||||
|
744 | def plot(self): | |||
|
745 | ||||
|
746 | arrayParameters = np.concatenate([self.data['param'][t] for t in self.times]) | |||
|
747 | error = arrayParameters[:,-1] | |||
|
748 | indValid = numpy.where(error == 0)[0] | |||
|
749 | finalMeteor = arrayParameters[indValid,:] | |||
|
750 | finalAzimuth = finalMeteor[:,3] | |||
|
751 | finalZenith = finalMeteor[:,4] | |||
|
752 | ||||
|
753 | x = finalAzimuth*numpy.pi/180 | |||
|
754 | y = finalZenith | |||
|
755 | ||||
|
756 | if self.ax.firsttime: | |||
|
757 | self.ax.plot = self.ax.plot(x, y, 'bo', markersize=5)[0] | |||
|
758 | self.ax.set_ylim(0,90) | |||
|
759 | self.ax.set_yticks(numpy.arange(0,90,20)) | |||
|
760 | self.ax.set_xlabel(self.xlabel) | |||
|
761 | self.ax.set_ylabel(self.ylabel) | |||
|
762 | self.ax.yaxis.labelpad = 40 | |||
|
763 | self.ax.firsttime = False | |||
|
764 | else: | |||
|
765 | self.ax.plot.set_data(x, y) | |||
|
766 | ||||
|
767 | ||||
|
768 | dt1 = datetime.datetime.fromtimestamp(self.min_time).strftime('%y/%m/%d %H:%M:%S') | |||
|
769 | dt2 = datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S') | |||
|
770 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, | |||
|
771 | dt2, | |||
|
772 | len(x)) | |||
|
773 | self.ax.set_title(title, size=8) | |||
|
774 | ||||
|
775 | self.saveTime = self.max_time |
@@ -149,6 +149,7 class ProcessingUnit(object): | |||||
149 | self.mp = True |
|
149 | self.mp = True | |
150 | self.start() |
|
150 | self.start() | |
151 | else: |
|
151 | else: | |
|
152 | self.operationKwargs[opId]['parent'] = self.kwargs | |||
152 | methodToCall(**self.operationKwargs[opId]) |
|
153 | methodToCall(**self.operationKwargs[opId]) | |
153 | else: |
|
154 | else: | |
154 | if name=='run': |
|
155 | if name=='run': | |
@@ -187,6 +188,7 class ProcessingUnit(object): | |||||
187 |
|
188 | |||
188 | if hasattr(externalProcObj, 'mp'): |
|
189 | if hasattr(externalProcObj, 'mp'): | |
189 | if externalProcObj.mp is False: |
|
190 | if externalProcObj.mp is False: | |
|
191 | externalProcObj.kwargs['parent'] = self.kwargs | |||
190 | self.operationKwargs[objId] = externalProcObj.kwargs |
|
192 | self.operationKwargs[objId] = externalProcObj.kwargs | |
191 | externalProcObj.mp = True |
|
193 | externalProcObj.mp = True | |
192 | externalProcObj.start() |
|
194 | externalProcObj.start() | |
@@ -194,6 +196,7 class ProcessingUnit(object): | |||||
194 | externalProcObj.run(self.dataOut, **externalProcObj.kwargs) |
|
196 | externalProcObj.run(self.dataOut, **externalProcObj.kwargs) | |
195 | self.operationKwargs[objId] = externalProcObj.kwargs |
|
197 | self.operationKwargs[objId] = externalProcObj.kwargs | |
196 |
|
198 | |||
|
199 | ||||
197 | return True |
|
200 | return True | |
198 |
|
201 | |||
199 | def call(self, opType, opName=None, opId=None): |
|
202 | def call(self, opType, opName=None, opId=None): |
@@ -373,8 +373,10 class ReceiverData(ProcessingUnit, Process): | |||||
373 | self.data[plottype][t] = self.dataOut.getCoherence() |
|
373 | self.data[plottype][t] = self.dataOut.getCoherence() | |
374 | if plottype == 'phase': |
|
374 | if plottype == 'phase': | |
375 | self.data[plottype][t] = self.dataOut.getCoherence(phase=True) |
|
375 | self.data[plottype][t] = self.dataOut.getCoherence(phase=True) | |
376 |
if plottype == ' |
|
376 | if plottype == 'output': | |
377 | self.data[plottype][t] = self.dataOut.data_output |
|
377 | self.data[plottype][t] = self.dataOut.data_output | |
|
378 | if plottype == 'param': | |||
|
379 | self.data[plottype][t] = self.dataOut.data_param | |||
378 | if self.realtime: |
|
380 | if self.realtime: | |
379 | self.data_web['timestamp'] = t |
|
381 | self.data_web['timestamp'] = t | |
380 | if plottype == 'spc': |
|
382 | if plottype == 'spc': | |
@@ -402,8 +404,14 class ReceiverData(ProcessingUnit, Process): | |||||
402 | self.sender_web = self.context.socket(zmq.PUB) |
|
404 | self.sender_web = self.context.socket(zmq.PUB) | |
403 | self.sender_web.connect(self.plot_address) |
|
405 | self.sender_web.connect(self.plot_address) | |
404 | time.sleep(1) |
|
406 | time.sleep(1) | |
405 | self.sender.bind("ipc:///tmp/zmq.plots") |
|
407 | ||
|
408 | if 'server' in self.kwargs: | |||
|
409 | self.sender.bind("ipc:///tmp/{}.plots".format(self.kwargs['server'])) | |||
|
410 | else: | |||
|
411 | self.sender.bind("ipc:///tmp/zmq.plots") | |||
|
412 | ||||
406 | time.sleep(3) |
|
413 | time.sleep(3) | |
|
414 | ||||
407 | t = Thread(target=self.event_monitor, args=(monitor,)) |
|
415 | t = Thread(target=self.event_monitor, args=(monitor,)) | |
408 | t.start() |
|
416 | t.start() | |
409 |
|
417 |
General Comments 0
You need to be logged in to leave comments.
Login now