[closes #157] filter defaults are now read from text file like the sample filter.in coming with this commit simply copy to .pylot folder in your home directory (this is preliminary because the filter parameters should be settable project wide by one responsible person)

This commit is contained in:
Sebastian Wehling-Benatelli 2015-07-21 07:41:41 +02:00
parent 0b02e8c213
commit 0e3576d193
2 changed files with 33 additions and 6 deletions

2
filter.in Normal file
View File

@ -0,0 +1,2 @@
P
S bandpass 4 0.5 5.0

View File

@ -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',