diff --git a/filter.in b/filter.in new file mode 100644 index 00000000..16aed0b7 --- /dev/null +++ b/filter.in @@ -0,0 +1,2 @@ +P +S bandpass 4 0.5 5.0 \ No newline at end of file diff --git a/pylot/core/util/defaults.py b/pylot/core/util/defaults.py index b2bf2a6d..c22ad865 100644 --- a/pylot/core/util/defaults.py +++ b/pylot/core/util/defaults.py @@ -6,12 +6,37 @@ Created on Wed Feb 26 12:31:25 2014 @author: sebastianw """ -FILTERDEFAULTS = {'P': {'filtertype': None, - 'order': None, - 'freq': None}, - 'S': {'filtertype': 'bandpass', - 'order': 4, - 'freq': [.5, 5]}} +import os + +def readFilterInformation(fname): + def convert2FreqRange(*args): + if len(args) > 1: + return [float(arg) for arg in args] + elif len(args) == 1: + return float(args[0]) + return None + filter_file = open(fname, 'r') + filter_information = dict() + for filter_line in filter_file.readlines(): + filter_line = filter_line.split(' ') + for n, pos in enumerate(filter_line): + if pos == '\n': + filter_line[n] = '' + filter_information[filter_line[0]] = {'filtertype': filter_line[1] + if filter_line[1] + else None, + 'order': int(filter_line[2]) + if filter_line[1] + else None, + 'freq': convert2FreqRange(*filter_line[3:]) + if filter_line[1] + else None} + return filter_information + + +FILTERDEFAULTS = readFilterInformation(os.path.join(os.path.expanduser('~'), + '.pylot', + 'filter.in')) OUTPUTFORMATS = {'.xml':'QUAKEML', '.cnv':'CNV',