@@ -1148,6 +1148,8 class PlotterData(object): | |||||
1148 | raise KeyError(log.error('Missing key: {}'.format(key))) |
|
1148 | raise KeyError(log.error('Missing key: {}'.format(key))) | |
1149 | if 'spc' in key or not self.buffering: |
|
1149 | if 'spc' in key or not self.buffering: | |
1150 | ret = self.data[key] |
|
1150 | ret = self.data[key] | |
|
1151 | elif 'scope' in key: | |||
|
1152 | ret = numpy.array(self.data[key][float(self.tm)]) | |||
1151 | else: |
|
1153 | else: | |
1152 | ret = numpy.array([self.data[key][x] for x in self.times]) |
|
1154 | ret = numpy.array([self.data[key][x] for x in self.times]) | |
1153 | if ret.ndim > 1: |
|
1155 | if ret.ndim > 1: | |
@@ -1196,7 +1198,8 class PlotterData(object): | |||||
1196 |
|
1198 | |||
1197 | if tm in self.__times: |
|
1199 | if tm in self.__times: | |
1198 | return |
|
1200 | return | |
1199 |
|
1201 | self.profileIndex = dataOut.profileIndex | ||
|
1202 | self.tm = tm | |||
1200 | self.type = dataOut.type |
|
1203 | self.type = dataOut.type | |
1201 | self.parameters = getattr(dataOut, 'parameters', []) |
|
1204 | self.parameters = getattr(dataOut, 'parameters', []) | |
1202 | if hasattr(dataOut, 'pairsList'): |
|
1205 | if hasattr(dataOut, 'pairsList'): | |
@@ -1243,6 +1246,10 class PlotterData(object): | |||||
1243 | buffer = dataOut.data_output |
|
1246 | buffer = dataOut.data_output | |
1244 | if plot == 'param': |
|
1247 | if plot == 'param': | |
1245 | buffer = dataOut.data_param |
|
1248 | buffer = dataOut.data_param | |
|
1249 | if plot == 'scope': | |||
|
1250 | buffer = dataOut.data | |||
|
1251 | self.flagDataAsBlock = dataOut.flagDataAsBlock | |||
|
1252 | self.nProfiles = dataOut.nProfiles | |||
1246 |
|
1253 | |||
1247 | if plot == 'spc': |
|
1254 | if plot == 'spc': | |
1248 | self.data[plot] = buffer |
|
1255 | self.data[plot] = buffer |
@@ -345,6 +345,7 class Plot(Operation): | |||||
345 | self.channels = kwargs.get('channels', None) |
|
345 | self.channels = kwargs.get('channels', None) | |
346 | self.titles = kwargs.get('titles', []) |
|
346 | self.titles = kwargs.get('titles', []) | |
347 | self.polar = False |
|
347 | self.polar = False | |
|
348 | self.type = kwargs.get('type', 'iq') | |||
348 | self.grid = kwargs.get('grid', False) |
|
349 | self.grid = kwargs.get('grid', False) | |
349 | self.pause = kwargs.get('pause', False) |
|
350 | self.pause = kwargs.get('pause', False) | |
350 | self.save_labels = kwargs.get('save_labels', None) |
|
351 | self.save_labels = kwargs.get('save_labels', None) | |
@@ -614,14 +615,15 class Plot(Operation): | |||||
614 |
|
615 | |||
615 | ymin = self.ymin if self.ymin else numpy.nanmin(self.y) |
|
616 | ymin = self.ymin if self.ymin else numpy.nanmin(self.y) | |
616 | ymax = self.ymax if self.ymax else numpy.nanmax(self.y) |
|
617 | ymax = self.ymax if self.ymax else numpy.nanmax(self.y) | |
617 | Y = numpy.array([1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000]) |
|
618 | Y = numpy.array([1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000]) | |
618 | i = 1 if numpy.where( |
|
619 | #i = 1 if numpy.where( | |
619 | abs(ymax-ymin) <= Y)[0][0] < 0 else numpy.where(abs(ymax-ymin) <= Y)[0][0] |
|
620 | # abs(ymax-ymin) <= Y)[0][0] < 0 else numpy.where(abs(ymax-ymin) <= Y)[0][0] | |
620 | ystep = Y[i] / 10. |
|
621 | #ystep = Y[i] / 10. | |
621 |
|
622 | ystep = round(ymax,-1)//5 | ||
622 | if self.xaxis is not 'time': |
|
623 | if self.xaxis is not 'time': | |
623 | X = numpy.array([0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100, |
|
624 | X = numpy.array([0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100, | |
624 | 200, 500, 1000, 2000, 5000])/2. |
|
625 | 200, 500, 1000, 2000, 5000, 10000, 20000, 50000])/2. | |
|
626 | ||||
625 | i = 1 if numpy.where( |
|
627 | i = 1 if numpy.where( | |
626 | abs(xmax-xmin) <= X)[0][0] < 0 else numpy.where(abs(xmax-xmin) <= X)[0][0] |
|
628 | abs(xmax-xmin) <= X)[0][0] < 0 else numpy.where(abs(xmax-xmin) <= X)[0][0] | |
627 | xstep = X[i] / 5. |
|
629 | xstep = X[i] / 5. |
@@ -614,3 +614,135 class PolarMapPlot(Plot): | |||||
614 | self.titles = ['{} {}'.format( |
|
614 | self.titles = ['{} {}'.format( | |
615 | self.data.parameters[x], title) for x in self.channels] |
|
615 | self.data.parameters[x], title) for x in self.channels] | |
616 |
|
616 | |||
|
617 | class ScopePlot(Plot): | |||
|
618 | ||||
|
619 | ''' | |||
|
620 | Plot for Scope | |||
|
621 | ''' | |||
|
622 | ||||
|
623 | CODE = 'scope' | |||
|
624 | ||||
|
625 | def setup(self): | |||
|
626 | ||||
|
627 | self.xaxis = 'Range (Km)' | |||
|
628 | self.ncols = 1 | |||
|
629 | self.nrows = 1 | |||
|
630 | self.nplots = 1 | |||
|
631 | self.ylabel = 'Intensity [dB]' | |||
|
632 | self.titles = ['Scope'] | |||
|
633 | self.colorbar = False | |||
|
634 | colspan = 3 | |||
|
635 | rowspan = 1 | |||
|
636 | ||||
|
637 | def plot_iq(self, x, y, channelIndexList, thisDatetime, wintitle): | |||
|
638 | ||||
|
639 | yreal = y[channelIndexList,:].real | |||
|
640 | yimag = y[channelIndexList,:].imag | |||
|
641 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |||
|
642 | self.xlabel = "Range (Km)" | |||
|
643 | self.ylabel = "Intensity - IQ" | |||
|
644 | ||||
|
645 | self.y = yreal | |||
|
646 | self.x = x | |||
|
647 | self.xmin = min(x) | |||
|
648 | self.xmax = max(x) | |||
|
649 | ||||
|
650 | ||||
|
651 | self.titles[0] = title | |||
|
652 | ||||
|
653 | for i,ax in enumerate(self.axes): | |||
|
654 | title = "Channel %d" %(i) | |||
|
655 | if ax.firsttime: | |||
|
656 | ax.plt_r = ax.plot(x, yreal[i,:], color='b')[0] | |||
|
657 | ax.plt_i = ax.plot(x, yimag[i,:], color='r')[0] | |||
|
658 | else: | |||
|
659 | #pass | |||
|
660 | ax.plt_r.set_data(x, yreal[i,:]) | |||
|
661 | ax.plt_i.set_data(x, yimag[i,:]) | |||
|
662 | ||||
|
663 | def plot_power(self, x, y, channelIndexList, thisDatetime, wintitle): | |||
|
664 | y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:]) | |||
|
665 | yreal = y.real | |||
|
666 | self.y = yreal | |||
|
667 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |||
|
668 | self.xlabel = "Range (Km)" | |||
|
669 | self.ylabel = "Intensity" | |||
|
670 | self.xmin = min(x) | |||
|
671 | self.xmax = max(x) | |||
|
672 | ||||
|
673 | ||||
|
674 | self.titles[0] = title | |||
|
675 | ||||
|
676 | for i,ax in enumerate(self.axes): | |||
|
677 | title = "Channel %d" %(i) | |||
|
678 | ||||
|
679 | ychannel = yreal[i,:] | |||
|
680 | ||||
|
681 | if ax.firsttime: | |||
|
682 | ax.plt_r = ax.plot(x, ychannel)[0] | |||
|
683 | else: | |||
|
684 | #pass | |||
|
685 | ax.plt_r.set_data(x, ychannel) | |||
|
686 | ||||
|
687 | ||||
|
688 | def plot(self): | |||
|
689 | ||||
|
690 | if self.channels: | |||
|
691 | channels = self.channels | |||
|
692 | else: | |||
|
693 | channels = self.data.channels | |||
|
694 | ||||
|
695 | ||||
|
696 | ||||
|
697 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) | |||
|
698 | ||||
|
699 | scope = self.data['scope'] | |||
|
700 | ||||
|
701 | ||||
|
702 | if self.data.flagDataAsBlock: | |||
|
703 | ||||
|
704 | for i in range(self.data.nProfiles): | |||
|
705 | ||||
|
706 | wintitle1 = " [Profile = %d] " %i | |||
|
707 | ||||
|
708 | if self.type == "power": | |||
|
709 | self.plot_power(self.data.heights, | |||
|
710 | scope[:,i,:], | |||
|
711 | channels, | |||
|
712 | thisDatetime, | |||
|
713 | wintitle1 | |||
|
714 | ) | |||
|
715 | ||||
|
716 | if self.type == "iq": | |||
|
717 | self.plot_iq(self.data.heights, | |||
|
718 | scope[:,i,:], | |||
|
719 | channels, | |||
|
720 | thisDatetime, | |||
|
721 | wintitle1 | |||
|
722 | ) | |||
|
723 | ||||
|
724 | ||||
|
725 | ||||
|
726 | ||||
|
727 | ||||
|
728 | else: | |||
|
729 | wintitle = " [Profile = %d] " %self.data.profileIndex | |||
|
730 | ||||
|
731 | if self.type == "power": | |||
|
732 | self.plot_power(self.data.heights, | |||
|
733 | scope, | |||
|
734 | channels, | |||
|
735 | thisDatetime, | |||
|
736 | wintitle | |||
|
737 | ) | |||
|
738 | ||||
|
739 | if self.type == "iq": | |||
|
740 | self.plot_iq(self.data.heights, | |||
|
741 | scope, | |||
|
742 | channels, | |||
|
743 | thisDatetime, | |||
|
744 | wintitle | |||
|
745 | ) | |||
|
746 | ||||
|
747 | ||||
|
748 | No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now