From a84ca192252863eea27a751fbfa8a9efa3374108 2019-05-20 01:02:25 From: Juan C. Espinoza Date: 2019-05-20 01:02:25 Subject: [PATCH] Fix LT issue in plots add snr option in jrodata --- diff --git a/schainpy/model/data/jrodata.py b/schainpy/model/data/jrodata.py index 6ca9ad3..3f66067 100644 --- a/schainpy/model/data/jrodata.py +++ b/schainpy/model/data/jrodata.py @@ -1103,7 +1103,7 @@ class PlotterData(object): MAXNUMX = 100 MAXNUMY = 100 - def __init__(self, code, throttle_value, exp_code, buffering=True): + def __init__(self, code, throttle_value, exp_code, buffering=True, snr=False): self.throttle = throttle_value self.exp_code = exp_code @@ -1123,7 +1123,10 @@ class PlotterData(object): self.plottypes = ['noise', 'rti'] else: self.plottypes = [code] - + + if 'snr' not in self.plottypes and snr: + self.plottypes.append('snr') + for plot in self.plottypes: self.data[plot] = {} diff --git a/schainpy/model/graphics/jroplot_base.py b/schainpy/model/graphics/jroplot_base.py index 50eb44f..6c1b8c0 100644 --- a/schainpy/model/graphics/jroplot_base.py +++ b/schainpy/model/graphics/jroplot_base.py @@ -227,7 +227,7 @@ class Plot(Operation): self.sender_period = kwargs.get('sender_period', 2) self.__throttle_plot = apply_throttle(self.throttle) self.data = PlotterData( - self.CODE, self.throttle, self.exp_code, self.buffering) + self.CODE, self.throttle, self.exp_code, self.buffering, snr=self.showSNR) if self.plot_server: if not self.plot_server.startswith('tcp://'): @@ -303,15 +303,13 @@ class Plot(Operation): cmap = plt.get_cmap(self.colormap) cmap.set_bad(self.bgcolor, 1.) self.cmaps.append(cmap) - + for fig in self.figures: fig.canvas.mpl_connect('key_press_event', self.OnKeyPress) fig.canvas.mpl_connect('scroll_event', self.OnBtnScroll) fig.canvas.mpl_connect('button_press_event', self.onBtnPress) fig.canvas.mpl_connect('motion_notify_event', self.onMotion) fig.canvas.mpl_connect('button_release_event', self.onBtnRelease) - if self.show: - fig.show() def OnKeyPress(self, event): ''' @@ -604,6 +602,9 @@ class Plot(Operation): fig.canvas.manager.set_window_title('{} - {}'.format(self.title, self.getDateTime(self.data.max_time).strftime('%Y/%m/%d'))) fig.canvas.draw() + if self.show: + fig.show() + figpause(0.1) if self.save: self.save_figure(n) @@ -739,13 +740,21 @@ class Plot(Operation): if dataOut.useLocalTime: self.getDateTime = datetime.datetime.fromtimestamp + if not self.localtime: + t += time.timezone else: self.getDateTime = datetime.datetime.utcfromtimestamp + if self.localtime: + t -= time.timezone if self.xmin is None: self.tmin = t else: - self.tmin = (self.getDateTime(t).replace(hour=self.xmin, minute=0, second=0) - datetime.datetime(1970, 1, 1)).total_seconds() + self.tmin = ( + self.getDateTime(t).replace( + hour=self.xmin, + minute=0, + second=0) - self.getDateTime(0)).total_seconds() self.data.setup() self.isConfig = True @@ -765,7 +774,7 @@ class Plot(Operation): tm -= time.timezone if dataOut.useLocalTime and not self.localtime: tm += time.timezone - + if self.xaxis is 'time' and self.data and (tm - self.tmin) >= self.xrange*60*60: self.save_counter = self.save_period self.__plot() @@ -787,8 +796,6 @@ class Plot(Operation): else: self.__throttle_plot(self.__plot)#, coerce=coerce) - figpause(0.01) - def close(self): if self.data: diff --git a/schainpy/model/io/bltrIO_param.py b/schainpy/model/io/bltrIO_param.py index b04ab94..cd839ce 100644 --- a/schainpy/model/io/bltrIO_param.py +++ b/schainpy/model/io/bltrIO_param.py @@ -144,12 +144,13 @@ class BLTRParamReader(JRODataReader, ProcessingUnit): Get last file and add it to the list ''' - for n in range(self.nTries): - log.warning( - "Waiting %0.2f seconds for the next file, try %03d ..." % (self.delay, n+1), - self.name - ) - time.sleep(self.delay) + for n in range(self.nTries+1): + if n>0: + log.warning( + "Waiting %0.2f seconds for the next file, try %03d ..." % (self.delay, n+1), + self.name + ) + time.sleep(self.delay) file_list = os.listdir(self.path) file_list.sort() if file_list: @@ -230,6 +231,7 @@ class BLTRParamReader(JRODataReader, ProcessingUnit): self.counter_records = 0 self.flagIsNewFile = 0 self.fileIndex += 1 + time.sleep(2) return 1 @@ -245,7 +247,7 @@ class BLTRParamReader(JRODataReader, ProcessingUnit): pointer = self.fp.tell() self.readBlock() except: - if self.waitDataBlock(pointer, 38512) == 1: + if self.online and self.waitDataBlock(pointer, 38512) == 1: continue else: if not self.setNextFile():