Decrease indentation in pick_s_phase

Instead of checking if(condition){DoSomething()}; check if (!condition){ErrorOut()}; DoSomething();.
This allows to decrease the indentation of the potentially large codeblock DoSomething().
This commit is contained in:
Darius Arnold 2018-07-17 13:56:25 +02:00
parent 02873938cb
commit 6d26338f2e

View File

@ -920,7 +920,16 @@ class AutopickStation(object):
if not slope: if not slope:
slope = 0 slope = 0
if slope >= self.s_params.minAICSslope and aicarhpick.getSNR() >= self.s_params.minAICSSNR and aicarhpick.getpick() is not None: if slope < self.s_params.minAICSslope:
error_msg = error_msg = 'AIC S onset slope to small: got {}, min {}'.format(slope, self.s_params.minAICSslope)
raise PickingFailedException(error_msg)
if aicarhpick.getSNR() < self.s_params.minAICSSNR:
error_msg = 'AIC S onset SNR to small: got {}, min {}'.format(aicarhpick.getSNR(), self.s_params.minAICSSNR)
raise PickingFailedException(error_msg)
if aicarhpick.getpick() is None:
error_msg = 'Invalid AIC S pick!'
raise PickingFailedException(error_msg)
#if slope >= self.s_params.minAICSslope and aicarhpick.getSNR() >= self.s_params.minAICSSNR and aicarhpick.getpick() is not None:
self.s_results.aicSflag = 1 self.s_results.aicSflag = 1
msg = 'AIC S-pick passes quality control: Slope: {0} counts/s, ' \ msg = 'AIC S-pick passes quality control: Slope: {0} counts/s, ' \
'SNR: {1}\nGo on with refined picking ...\n' \ 'SNR: {1}\nGo on with refined picking ...\n' \
@ -1019,9 +1028,6 @@ class AutopickStation(object):
'##################################################' '##################################################'
''.format(self.s_results.Sweight, self.s_results.SNRS, self.s_results.SNRSdB)) ''.format(self.s_results.Sweight, self.s_results.SNRS, self.s_results.SNRSdB))
else:
print('autopickstation: No horizontal component data available or '
'bad P onset, skipping S picking!')
def get_fig_from_figdict(figdict, figkey): def get_fig_from_figdict(figdict, figkey):
""" """