Add converting fig_dict and iplot to the correct types

This commit is contained in:
Darius Arnold 2018-06-19 18:56:10 +02:00
parent 5b5da2e40d
commit d4033eca08
2 changed files with 23 additions and 3 deletions

View File

@ -17,7 +17,7 @@ from pylot.core.pick.picker import AICPicker, PragPicker
from pylot.core.pick.utils import checksignallength, checkZ4S, earllatepicker, \
getSNR, fmpicker, checkPonsets, wadaticheck, get_pickparams, get_quality_class
from pylot.core.util.utils import getPatternLine, gen_Pool,\
real_Bool, identifyPhaseID
real_Bool, identifyPhaseID, real_None, correct_iplot
from obspy.taup import TauPyModel
@ -211,8 +211,8 @@ class AutopickStation(object):
self.wfstream = wfstream
self.pickparam = pickparam
self.verbose = verbose
self.iplot = iplot
self.fig_dict = fig_dict
self.iplot = correct_iplot(iplot)
self.fig_dict = real_None(fig_dict)
self.metadata = metadata
self.origin = origin
@ -247,6 +247,7 @@ class AutopickStation(object):
self.taper_max_percentage = 0.05
self.taper_type = 'hann'
def vprint(self, s):
"""Only print statement if verbose picking is set to true."""
if self.verbose:

View File

@ -1260,6 +1260,25 @@ def check_event_folder(path):
return ev_type
def correct_iplot(iplot):
"""
iplot should be in range 0...2, but it can be given as True or 'True' as well, which should be converted
to an integer. Both will be converted to 2.
:type iplot: Bool or int
:return: iplot as an integer
:rtype: int
"""
# TODO this is a hack, there should never be the ability to pass anything else but an int
try:
iplot = int(iplot)
except ValueError:
if iplot is True or iplot == 'True':
iplot = 2
else:
iplot = 0
return iplot
if __name__ == "__main__":
import doctest