AutoPickParamter class modified; not working at the moment (!)
This commit is contained in:
parent
34c1f9111b
commit
5a093ed736
@ -7,7 +7,7 @@ Created on Thu Feb 13 09:58:45 2014
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class AutoPickParameters(object):
|
class AutoPickParameter(object):
|
||||||
'''
|
'''
|
||||||
AutoPickParameters is a parameter type object capable to read and/or write
|
AutoPickParameters is a parameter type object capable to read and/or write
|
||||||
parameter ASCII and binary files. Parameters are given by example:
|
parameter ASCII and binary files. Parameters are given by example:
|
||||||
@ -19,7 +19,7 @@ class AutoPickParameters(object):
|
|||||||
order 4 # order_of_ar
|
order 4 # order_of_ar
|
||||||
fnoise 0 # noise_level_for_ar
|
fnoise 0 # noise_level_for_ar
|
||||||
suppp 7 # envelopecoeff
|
suppp 7 # envelopecoeff
|
||||||
tolt 300 #(s)time_int_around_the_arrival_time_of_the_phase_to_analyze
|
tolt 300 # (s)time around arrival time
|
||||||
f1tpwt 4 # propfact_minfreq_secondtaper
|
f1tpwt 4 # propfact_minfreq_secondtaper
|
||||||
pickwindow 9 # length_of_pick_window
|
pickwindow 9 # length_of_pick_window
|
||||||
w1 1 # length_of_smoothing_window
|
w1 1 # length_of_smoothing_window
|
||||||
@ -38,10 +38,10 @@ class AutoPickParameters(object):
|
|||||||
read content of an ASCII file an form a type consistent dictionary
|
read content of an ASCII file an form a type consistent dictionary
|
||||||
contain all parameters.
|
contain all parameters.
|
||||||
'''
|
'''
|
||||||
|
self.filename = fn
|
||||||
parFileCont = {}
|
parFileCont = {}
|
||||||
try:
|
try:
|
||||||
inputFile = open(fn, 'r')
|
inputFile = open(self.filename, 'r')
|
||||||
lines = inputFile.readlines()
|
lines = inputFile.readlines()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
parspl = line.split('\t')[:2]
|
parspl = line.split('\t')[:2]
|
||||||
@ -62,20 +62,50 @@ class AutoPickParameters(object):
|
|||||||
else:
|
else:
|
||||||
val = str(value.strip())
|
val = str(value.strip())
|
||||||
parFileCont[key] = val
|
parFileCont[key] = val
|
||||||
except e:
|
except Exception, e:
|
||||||
raise 'ParameterError:\n %s' % e
|
raise 'ParameterError:\n %s' % e
|
||||||
finally:
|
finally:
|
||||||
parFileCont = None
|
parFileCont = None
|
||||||
self.__parameter = parFileCont
|
self.__parameter = parFileCont
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
pass
|
string = ''
|
||||||
|
string += 'Automated picking parameter:\n\n'
|
||||||
def __repr__(self):
|
|
||||||
reprString = ''
|
|
||||||
reprString += 'Automated picking parameter:\n\n'
|
|
||||||
if self.__parameter is not None:
|
if self.__parameter is not None:
|
||||||
for key, value in self.__parameter.iteritems():
|
for key, value in self.__parameter.iteritems():
|
||||||
reprString += '%s:\t\t%s' % (key, value)
|
string += '%s:\t\t%s' % (key, value)
|
||||||
else:
|
else:
|
||||||
reprString += 'Empty parameter dictionary.'
|
string += 'Empty parameter dictionary.'
|
||||||
|
return string
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return 'AutoPickParameter(%s)' % self.filename
|
||||||
|
|
||||||
|
def __nonzero__(self):
|
||||||
|
return self.__parameter
|
||||||
|
|
||||||
|
def getParam(self, *args):
|
||||||
|
try:
|
||||||
|
for param in args:
|
||||||
|
try:
|
||||||
|
return self.__parameter[param]
|
||||||
|
except KeyError, e:
|
||||||
|
raise 'ParameterError:\n %s' % e
|
||||||
|
except TypeError:
|
||||||
|
try:
|
||||||
|
return self.__parameter[param]
|
||||||
|
except KeyError, e:
|
||||||
|
raise 'ParameterError:\n %s' % e
|
||||||
|
|
||||||
|
def setParam(self, **kwargs):
|
||||||
|
for param, value in kwargs:
|
||||||
|
try:
|
||||||
|
self.__parameter[param] = value
|
||||||
|
except KeyError, e:
|
||||||
|
raise 'ParameterError:\n %s' % e
|
||||||
|
finally:
|
||||||
|
self.__str__()
|
||||||
|
|
||||||
|
|
||||||
|
class ParameterError(Exception):
|
||||||
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user