From 4b6b3de547e16281cfbe5031e72fd4526111f9c5 Mon Sep 17 00:00:00 2001 From: marcel Date: Wed, 16 Aug 2017 11:19:25 +0200 Subject: [PATCH] [change] check for real bool --- pylot/core/pick/autopick.py | 19 ++++++++++++++----- pylot/core/util/utils.py | 9 +++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/pylot/core/pick/autopick.py b/pylot/core/pick/autopick.py index c5c9804c..0cf5e91c 100644 --- a/pylot/core/pick/autopick.py +++ b/pylot/core/pick/autopick.py @@ -19,7 +19,7 @@ from pylot.core.pick.picker import AICPicker, PragPicker from pylot.core.pick.utils import checksignallength, checkZ4S, earllatepicker, \ getSNR, fmpicker, checkPonsets, wadaticheck from pylot.core.util.utils import getPatternLine, gen_Pool, identifyPhase, loopIdentifyPhase, \ - full_range + real_Bool from obspy.taup import TauPyModel @@ -140,7 +140,7 @@ def autopickstation(wfstream, pickparam, verbose=False, algoS = pickparam.get('algoS') sstart = pickparam.get('sstart') sstop = pickparam.get('sstop') - use_taup = pickparam.get('use_taup') + use_taup = real_Bool(pickparam.get('use_taup')) taup_model = pickparam.get('taup_model') bph1 = pickparam.get('bph1') bph2 = pickparam.get('bph2') @@ -229,7 +229,7 @@ def autopickstation(wfstream, pickparam, verbose=False, # for global seismology: use tau-p method for estimating travel times (needs source and station coords.) # if not given: sets Lc to infinity to use full stream - if use_taup == True or use_taup == 'True': + if use_taup: Lc = np.inf print('autopickstation: use_taup flag active.') if not metadata[1]: @@ -262,14 +262,23 @@ def autopickstation(wfstream, pickparam, verbose=False, # modifiy pstart and pstop relative to estimated first P arrival (relative to station time axis) pstart += (source_origin.time + estFirstP) - zdat[0].stats.starttime pstop += (source_origin.time + estFirstP) - zdat[0].stats.starttime - Lc = pstop - pstart print('autopick: CF calculation times respectively:' ' pstart: {} s, pstop: {} s'.format(pstart, pstop)) elif not origin: print('No source origins given!') - else: + + # make sure pstart and pstop are inside zdat[0] + pstart = max(pstart, 0) + pstop = min(pstop, len(zdat[0])*zdat[0].stats.delta) + + if not use_taup or origin: Lc = pstop - pstart + Lwf = zdat[0].stats.endtime - zdat[0].stats.starttime + if not Lwf > 0: + print('autopickstation: empty trace! Return!') + return + Ldiff = Lwf - Lc if Ldiff < 0: msg = 'autopickstation: Cutting times are too large for actual ' \ diff --git a/pylot/core/util/utils.py b/pylot/core/util/utils.py index ffeb29c3..70c73f0c 100644 --- a/pylot/core/util/utils.py +++ b/pylot/core/util/utils.py @@ -221,6 +221,15 @@ def real_None(value): return value +def real_Bool(value): + if value == 'True': + return True + elif value == 'False': + return False + else: + return value + + def four_digits(year): """ takes a two digit year integer and returns the correct four digit equivalent