@@ -1216,7 +1216,10 class Parameters(Spectra): | |||
|
1216 | 1216 | |
|
1217 | 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 | 1224 | def getNoise(self): |
|
1222 | 1225 |
@@ -92,13 +92,12 class PlotData(Operation, Process): | |||
|
92 | 92 | print 'plotting...{}'.format(self.CODE) |
|
93 | 93 | |
|
94 | 94 | if self.show: |
|
95 | print 'showing' | |
|
96 | 95 | self.figure.show() |
|
97 | 96 | |
|
98 | 97 | self.plot() |
|
99 | 98 | plt.tight_layout() |
|
100 |
self.figure.canvas.manager.set_window_title('{} {} - |
|
|
101 |
|
|
|
99 | self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(), | |
|
100 | datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d'))) | |
|
102 | 101 | |
|
103 | 102 | if self.save: |
|
104 | 103 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, |
@@ -116,11 +115,15 class PlotData(Operation, Process): | |||
|
116 | 115 | def run(self): |
|
117 | 116 | |
|
118 | 117 | print '[Starting] {}'.format(self.name) |
|
118 | ||
|
119 | 119 | context = zmq.Context() |
|
120 | 120 | receiver = context.socket(zmq.SUB) |
|
121 | 121 | receiver.setsockopt(zmq.SUBSCRIBE, '') |
|
122 | 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 | 128 | while True: |
|
126 | 129 | try: |
@@ -594,6 +597,7 class PlotNoiseData(PlotData): | |||
|
594 | 597 | |
|
595 | 598 | |
|
596 | 599 | class PlotWindProfilerData(PlotRTIData): |
|
600 | ||
|
597 | 601 | CODE = 'wind' |
|
598 | 602 | colormap = 'seismic' |
|
599 | 603 | |
@@ -603,7 +607,7 class PlotWindProfilerData(PlotRTIData): | |||
|
603 | 607 | self.width = 10 |
|
604 | 608 | self.height = 2.2*self.nrows |
|
605 | 609 | self.ylabel = 'Height [Km]' |
|
606 | self.titles = ['Zonal' ,'Meridional', 'Vertical'] | |
|
610 | self.titles = ['Zonal Wind' ,'Meridional Wind', 'Vertical Wind'] | |
|
607 | 611 | self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] |
|
608 | 612 | self.windFactor = [1, 1, 100] |
|
609 | 613 | |
@@ -627,13 +631,13 class PlotWindProfilerData(PlotRTIData): | |||
|
627 | 631 | self.z = [] |
|
628 | 632 | |
|
629 | 633 | for ch in range(self.nrows): |
|
630 |
self.z.append([self.data[ |
|
|
634 | self.z.append([self.data['output'][t][ch] for t in self.times]) | |
|
631 | 635 | |
|
632 | 636 | self.z = np.array(self.z) |
|
633 | 637 | self.z = numpy.ma.masked_invalid(self.z) |
|
634 | 638 | |
|
635 | 639 | cmap=plt.get_cmap(self.colormap) |
|
636 |
cmap.set_bad(' |
|
|
640 | cmap.set_bad('black', 1.) | |
|
637 | 641 | |
|
638 | 642 | for n, ax in enumerate(self.axes): |
|
639 | 643 | x, y, z = self.fill_gaps(*self.decimate()) |
@@ -652,9 +656,9 class PlotWindProfilerData(PlotRTIData): | |||
|
652 | 656 | ) |
|
653 | 657 | divider = make_axes_locatable(ax) |
|
654 | 658 | cax = divider.new_horizontal(size='2%', pad=0.05) |
|
655 | cax.set_ylabel(self.clabels[n]) | |
|
656 | 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 | 662 | ax.set_ylim(self.ymin, self.ymax) |
|
659 | 663 | |
|
660 | 664 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
@@ -691,3 +695,62 class PlotDOPData(PlotRTIData): | |||
|
691 | 695 | class PlotPHASEData(PlotCOHData): |
|
692 | 696 | CODE = 'phase' |
|
693 | 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 | 121 | if self.mp is False: |
|
122 | 122 | self.mp = True |
|
123 | 123 | self.start() |
|
124 |
else: |
|
|
124 | else: | |
|
125 | self.operationKwargs[opId]['parent'] = self.kwargs | |
|
125 | 126 | methodToCall(**self.operationKwargs[opId]) |
|
126 | 127 | else: |
|
127 | 128 | if name=='run': |
|
128 | 129 | methodToCall(**self.kwargs) |
|
129 |
else: |
|
|
130 | else: | |
|
130 | 131 | methodToCall(**self.operationKwargs[opId]) |
|
131 | 132 | |
|
132 | 133 | if self.dataOut is None: |
@@ -160,12 +161,14 class ProcessingUnit(object): | |||
|
160 | 161 | |
|
161 | 162 | if hasattr(externalProcObj, 'mp'): |
|
162 | 163 | if externalProcObj.mp is False: |
|
164 | externalProcObj.kwargs['parent'] = self.kwargs | |
|
163 | 165 | self.operationKwargs[objId] = externalProcObj.kwargs |
|
164 | 166 | externalProcObj.mp = True |
|
165 | 167 | externalProcObj.start() |
|
166 | 168 | else: |
|
167 | 169 | externalProcObj.run(self.dataOut, **externalProcObj.kwargs) |
|
168 | 170 | self.operationKwargs[objId] = externalProcObj.kwargs |
|
171 | ||
|
169 | 172 | |
|
170 | 173 | return True |
|
171 | 174 |
@@ -367,8 +367,10 class ReceiverData(ProcessingUnit, Process): | |||
|
367 | 367 | self.data[plottype][t] = self.dataOut.getCoherence() |
|
368 | 368 | if plottype == 'phase': |
|
369 | 369 | self.data[plottype][t] = self.dataOut.getCoherence(phase=True) |
|
370 |
if plottype == ' |
|
|
370 | if plottype == 'output': | |
|
371 | 371 | self.data[plottype][t] = self.dataOut.data_output |
|
372 | if plottype == 'param': | |
|
373 | self.data[plottype][t] = self.dataOut.data_param | |
|
372 | 374 | if self.realtime: |
|
373 | 375 | self.data_web['timestamp'] = t |
|
374 | 376 | if plottype == 'spc': |
@@ -396,7 +398,10 class ReceiverData(ProcessingUnit, Process): | |||
|
396 | 398 | self.sender_web = self.context.socket(zmq.PUB) |
|
397 | 399 | self.sender_web.connect(self.plot_address) |
|
398 | 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 | 406 | t = Thread(target=self.event_monitor, args=(monitor,)) |
|
402 | 407 | t.start() |
General Comments 0
You need to be logged in to leave comments.
Login now