@@ -205,6 +205,7 class Plot(Operation): | |||
|
205 | 205 | self.ymax = kwargs.get('ymax', None) |
|
206 | 206 | self.yscale = kwargs.get('yscale', None) |
|
207 | 207 | self.xlabel = kwargs.get('xlabel', None) |
|
208 | self.attr_time = kwargs.get('attr_time', 'utctime') | |
|
208 | 209 | self.decimation = kwargs.get('decimation', None) |
|
209 | 210 | self.showSNR = kwargs.get('showSNR', False) |
|
210 | 211 | self.oneFigure = kwargs.get('oneFigure', True) |
@@ -304,8 +305,8 class Plot(Operation): | |||
|
304 | 305 | else: |
|
305 | 306 | cmap = plt.get_cmap(self.colormap) |
|
306 | 307 | cmap.set_bad(self.bgcolor, 1.) |
|
307 | self.cmaps.append(cmap) | |
|
308 | ||
|
308 | self.cmaps.append(cmap) | |
|
309 | ||
|
309 | 310 | for fig in self.figures: |
|
310 | 311 | fig.canvas.mpl_connect('key_press_event', self.OnKeyPress) |
|
311 | 312 | fig.canvas.mpl_connect('scroll_event', self.OnBtnScroll) |
@@ -468,7 +469,8 class Plot(Operation): | |||
|
468 | 469 | else: |
|
469 | 470 | if self.xaxis is 'time': |
|
470 | 471 | dt = self.getDateTime(self.data.max_time) |
|
471 | xmax = (dt.replace(hour=int(self.xmax), minute=59, second=59) - | |
|
472 | xmax = self.xmax - 1 | |
|
473 | xmax = (dt.replace(hour=int(xmax), minute=59, second=59) - | |
|
472 | 474 | datetime.datetime(1970, 1, 1) + datetime.timedelta(seconds=1)).total_seconds() |
|
473 | 475 | if self.data.localtime: |
|
474 | 476 | xmax += time.timezone |
@@ -477,44 +479,41 class Plot(Operation): | |||
|
477 | 479 | |
|
478 | 480 | ymin = self.ymin if self.ymin else numpy.nanmin(self.y) |
|
479 | 481 | ymax = self.ymax if self.ymax else numpy.nanmax(self.y) |
|
480 | #Y = numpy.array([1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000]) | |
|
481 | ||
|
482 | #i = 1 if numpy.where( | |
|
483 | # abs(ymax-ymin) <= Y)[0][0] < 0 else numpy.where(abs(ymax-ymin) <= Y)[0][0] | |
|
484 | #ystep = Y[i] / 10. | |
|
485 | dig = int(numpy.log10(ymax)) | |
|
486 | if dig == 0: | |
|
487 | digD = len(str(ymax)) - 2 | |
|
488 | ydec = ymax*(10**digD) | |
|
489 | ||
|
490 | dig = int(numpy.log10(ydec)) | |
|
491 | ystep = ((ydec + (10**(dig)))//10**(dig))*(10**(dig)) | |
|
492 | ystep = ystep/5 | |
|
493 | ystep = ystep/(10**digD) | |
|
494 | ||
|
495 | else: | |
|
496 | ystep = ((ymax + (10**(dig)))//10**(dig))*(10**(dig)) | |
|
497 | ystep = ystep/5 | |
|
498 | ||
|
499 | if self.xaxis is not 'time': | |
|
500 | ||
|
501 | dig = int(numpy.log10(xmax)) | |
|
502 | ||
|
503 | if dig <= 0: | |
|
504 | digD = len(str(xmax)) - 2 | |
|
505 | xdec = xmax*(10**digD) | |
|
506 | ||
|
507 | dig = int(numpy.log10(xdec)) | |
|
508 | xstep = ((xdec + (10**(dig)))//10**(dig))*(10**(dig)) | |
|
509 | xstep = xstep*0.5 | |
|
510 | xstep = xstep/(10**digD) | |
|
511 | ||
|
512 | else: | |
|
513 | xstep = ((xmax + (10**(dig)))//10**(dig))*(10**(dig)) | |
|
514 | xstep = xstep/5 | |
|
515 | 482 | |
|
516 | 483 | for n, ax in enumerate(self.axes): |
|
517 | 484 | if ax.firsttime: |
|
485 | ||
|
486 | dig = int(numpy.log10(ymax)) | |
|
487 | if dig == 0: | |
|
488 | digD = len(str(ymax)) - 2 | |
|
489 | ydec = ymax*(10**digD) | |
|
490 | ||
|
491 | dig = int(numpy.log10(ydec)) | |
|
492 | ystep = ((ydec + (10**(dig)))//10**(dig))*(10**(dig)) | |
|
493 | ystep = ystep/5 | |
|
494 | ystep = ystep/(10**digD) | |
|
495 | ||
|
496 | else: | |
|
497 | ystep = ((ymax + (10**(dig)))//10**(dig))*(10**(dig)) | |
|
498 | ystep = ystep/5 | |
|
499 | ||
|
500 | if self.xaxis is not 'time': | |
|
501 | ||
|
502 | dig = int(numpy.log10(xmax)) | |
|
503 | ||
|
504 | if dig <= 0: | |
|
505 | digD = len(str(xmax)) - 2 | |
|
506 | xdec = xmax*(10**digD) | |
|
507 | ||
|
508 | dig = int(numpy.log10(xdec)) | |
|
509 | xstep = ((xdec + (10**(dig)))//10**(dig))*(10**(dig)) | |
|
510 | xstep = xstep*0.5 | |
|
511 | xstep = xstep/(10**digD) | |
|
512 | ||
|
513 | else: | |
|
514 | xstep = ((xmax + (10**(dig)))//10**(dig))*(10**(dig)) | |
|
515 | xstep = xstep/5 | |
|
516 | ||
|
518 | 517 | ax.set_facecolor(self.bgcolor) |
|
519 | 518 | ax.yaxis.set_major_locator(MultipleLocator(ystep)) |
|
520 | 519 | if self.xscale: |
@@ -606,15 +605,13 class Plot(Operation): | |||
|
606 | 605 | fig.canvas.draw() |
|
607 | 606 | if self.show: |
|
608 | 607 | fig.show() |
|
609 | figpause(0.1) | |
|
608 | # figpause(0.1) | |
|
610 | 609 | |
|
611 | 610 | if self.save: |
|
612 | 611 | self.save_figure(n) |
|
613 | 612 | |
|
614 | 613 | if self.plot_server: |
|
615 | 614 | self.send_to_server() |
|
616 | # t = Thread(target=self.send_to_server) | |
|
617 | # t.start() | |
|
618 | 615 | |
|
619 | 616 | def save_figure(self, n): |
|
620 | 617 | ''' |
@@ -736,10 +733,8 class Plot(Operation): | |||
|
736 | 733 | |
|
737 | 734 | if self.isConfig is False: |
|
738 | 735 | self.__setup(**kwargs) |
|
739 | if dataOut.type == 'Parameters': | |
|
740 |
|
|
|
741 | else: | |
|
742 | t = dataOut.utctime | |
|
736 | ||
|
737 | t = getattr(dataOut, self.attr_time) | |
|
743 | 738 | |
|
744 | 739 | if dataOut.useLocalTime: |
|
745 | 740 | self.getDateTime = datetime.datetime.fromtimestamp |
@@ -753,10 +748,11 class Plot(Operation): | |||
|
753 | 748 | if 'buffer' in self.plot_type: |
|
754 | 749 | if self.xmin is None: |
|
755 | 750 | self.tmin = t |
|
751 | self.xmin = self.getDateTime(t).hour | |
|
756 | 752 | else: |
|
757 | 753 | self.tmin = ( |
|
758 | 754 | self.getDateTime(t).replace( |
|
759 | hour=self.xmin, | |
|
755 | hour=int(self.xmin), | |
|
760 | 756 | minute=0, |
|
761 | 757 | second=0) - self.getDateTime(0)).total_seconds() |
|
762 | 758 | |
@@ -769,16 +765,13 class Plot(Operation): | |||
|
769 | 765 | self.poll = zmq.Poller() |
|
770 | 766 | self.poll.register(self.socket, zmq.POLLIN) |
|
771 | 767 | |
|
772 | if dataOut.type == 'Parameters': | |
|
773 | tm = dataOut.utctimeInit | |
|
774 | else: | |
|
775 | tm = dataOut.utctime | |
|
768 | tm = getattr(dataOut, self.attr_time) | |
|
776 | 769 | |
|
777 | 770 | if not dataOut.useLocalTime and self.localtime: |
|
778 | 771 | tm -= time.timezone |
|
779 | 772 | if dataOut.useLocalTime and not self.localtime: |
|
780 | 773 | tm += time.timezone |
|
781 | ||
|
774 | ||
|
782 | 775 | if self.xaxis is 'time' and self.data and (tm - self.tmin) >= self.xrange*60*60: |
|
783 | 776 | self.save_counter = self.save_period |
|
784 | 777 | self.__plot() |
General Comments 0
You need to be logged in to leave comments.
Login now