From 2628e9d568cfbcc64df25221f47e2106ec53adf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Wed, 3 May 2017 16:19:08 +0200 Subject: [PATCH] Partly fixed bug when plotting corrupted trace, formerly killed by ValueError. --- pylot/RELEASE-VERSION | 2 +- pylot/core/util/utils.py | 9 ++++++--- pylot/core/util/widgets.py | 19 ++++++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index af9fbbb6..a9034cda 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -50ee3-dirty +e966-dirty diff --git a/pylot/core/util/utils.py b/pylot/core/util/utils.py index aab1cee2..905073e1 100644 --- a/pylot/core/util/utils.py +++ b/pylot/core/util/utils.py @@ -7,6 +7,7 @@ from scipy.interpolate import splrep, splev import os import pwd import re +import warnings import subprocess from obspy import UTCDateTime, read from pylot.core.io.inputs import AutoPickParameter @@ -381,9 +382,11 @@ def prepTimeAxis(stime, trace): print('shorten time axes by one datum') time_ax = np.arange(stime, etime - tincr, tincr) if len(time_ax) != nsamp: - raise ValueError('{0} samples of data \n ' - '{1} length of time vector \n' - 'delta: {2}'.format(nsamp, len(time_ax), tincr)) + print('Station {0}, {1} samples of data \n ' + '{2} length of time vector \n' + 'delta: {3}'.format(trace.stats.station, + nsamp, len(time_ax), tincr)) + time_ax = None return time_ax diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 028d70bc..80e34e53 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -445,15 +445,16 @@ class WaveformWidget(FigureCanvas): print(msg) stime = trace.stats.starttime - wfstart time_ax = prepTimeAxis(stime, trace) - if not scaleddata: - trace.detrend('constant') - trace.normalize(np.max(np.abs(trace.data)) * 2) - self.getAxes().plot(time_ax, trace.data + n, 'k') - if noiselevel is not None: - for level in noiselevel: - self.getAxes().plot([time_ax[0], time_ax[-1]], - [level, level], '--k') - self.setPlotDict(n, (station, channel)) + if time_ax is not None: + if not scaleddata: + trace.detrend('constant') + trace.normalize(np.max(np.abs(trace.data)) * 2) + self.getAxes().plot(time_ax, trace.data + n, 'k') + if noiselevel is not None: + for level in noiselevel: + self.getAxes().plot([time_ax[0], time_ax[-1]], + [level, level], '--k') + self.setPlotDict(n, (station, channel)) xlabel = 'seconds since {0}'.format(wfstart) ylabel = '' self.updateWidget(xlabel, ylabel, title)