From 87b617b9243130283b4438906a14d3376bc22a35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Wed, 9 Aug 2017 13:17:54 +0200 Subject: [PATCH] [Bugfix] Control figure output of autoPyLoT via optional input argument iplot. --- pylot/core/pick/autopick.py | 10 +++++++++- pylot/core/pick/picker.py | 26 +++++++++++++++++++++----- pylot/core/pick/utils.py | 30 +++++++++++++++++++++++++++--- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/pylot/core/pick/autopick.py b/pylot/core/pick/autopick.py index 1d1f9feb..f1c18284 100644 --- a/pylot/core/pick/autopick.py +++ b/pylot/core/pick/autopick.py @@ -756,9 +756,17 @@ def autopickstation(wfstream, pickparam, verbose=False, 'bad P onset, skipping S picking!') ############################################################## + try: + iplot = int(iplot) + except: + if iplot == True or iplot == 'True': + iplot = 2 + else: + iplot = 0 + if iplot > 0: # plot vertical trace - if not fig_dict: + if fig_dict == None or fig_dict == 'None': fig = plt.figure() plt_flag = 1 else: diff --git a/pylot/core/pick/picker.py b/pylot/core/pick/picker.py index ba96e650..c72f1f60 100644 --- a/pylot/core/pick/picker.py +++ b/pylot/core/pick/picker.py @@ -155,6 +155,14 @@ class AICPicker(AutoPicker): self.slope = None self.SNR = None plt_flag = 0 + try: + iplot = int(self.iplot) + except: + if self.iplot == True or self.iplot == 'True': + iplot = 2 + else: + iplot = 0 + # find NaN's nn = np.isnan(self.cf) if len(nn) > 1: @@ -243,7 +251,7 @@ class AICPicker(AutoPicker): print("AICPicker: Maximum for slope determination right at the beginning of the window!") print("Choose longer slope determination window!") if self.iplot > 1: - if not self.fig: + if self.fig == None or self.fig == 'None': fig = plt.figure() # self.iplot) ### WHY? MP MP plt_flag = 1 else: @@ -276,8 +284,8 @@ class AICPicker(AutoPicker): self.SNR = None self.slope = None - if self.iplot > 1: - if not self.fig: + if iplot > 1: + if self.fig == None or self.fig == 'None': fig = plt.figure() # self.iplot) plt_flag = 1 else: @@ -338,6 +346,14 @@ class PragPicker(AutoPicker): def calcPick(self): + try: + iplot = int(self.getiplot()) + except: + if self.getiplot() == True or self.getiplot() == 'True': + iplot = 2 + else: + iplot = 0 + if self.getpick1() is not None: print('PragPicker: Get most likely pick from HOS- or AR-CF using pragmatic picking algorithm ...') @@ -421,8 +437,8 @@ class PragPicker(AutoPicker): self.Pick = None pickflag = 0 - if self.getiplot() > 1: - if not self.fig: + if iplot > 1: + if self.fig == None or self.fig == 'None': fig = plt.figure() # self.getiplot()) plt_flag = 1 else: diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index a6625fcd..3fbb119c 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -51,6 +51,14 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=0, verbosity=1, fig=None): EPick = None PickError = None plt_flag = 0 + try: + iplot = int(iplot) + except: + if iplot == True or iplot == 'True': + iplot = 2 + else: + iplot = 0 + if verbosity: print('earllatepicker: Get earliest and latest possible pick' ' relative to most likely pick ...') @@ -119,7 +127,7 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=0, verbosity=1, fig=None): PickError = symmetrize_error(diffti_te, diffti_tl) if iplot > 1: - if not fig: + if fig == None or fig == 'None': fig = plt.figure() # iplot) plt_flag = 1 ax = fig.add_subplot(111) @@ -174,6 +182,14 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=0, fig=None): ''' plt_flag = 0 + try: + iplot = int(iplot) + except: + if iplot == True or iplot == 'True': + iplot = 2 + else: + iplot = 0 + warnings.simplefilter('ignore', np.RankWarning) assert isinstance(Xraw, Stream), "%s is not a stream object" % str(Xraw) @@ -297,7 +313,7 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=0, fig=None): print("fmpicker: Found polarity %s" % FM) if iplot > 1: - if not fig: + if fig == None or fig == 'None': fig = plt.figure() # iplot) plt_flag = 1 ax1 = fig.add_subplot(211) @@ -698,6 +714,14 @@ def checksignallength(X, pick, TSNR, minsiglength, nfac, minpercent, iplot=0, fi ''' plt_flag = 0 + try: + iplot = int(self.iplot) + except: + if iplot == True or iplot == 'True': + iplot = 2 + else: + iplot = 0 + assert isinstance(X, Stream), "%s is not a stream object" % str(X) print("Checking signal length ...") @@ -740,7 +764,7 @@ def checksignallength(X, pick, TSNR, minsiglength, nfac, minpercent, iplot=0, fi returnflag = 0 if iplot > 1: - if not fig: + if fig == None or fig == 'None': fig = plt.figure() # iplot) plt_flag = 1 ax = fig.add_subplot(111)