-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen_config.py
71 lines (58 loc) · 2.12 KB
/
gen_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import configparser
import operator
import os
from functools import reduce
def main():
config = configparser.ConfigParser(allow_no_value=True)
config['GLOBAL'] = {
'MinutesPerImage': 10,
}
config.set('GLOBAL', '; Location to save spectrogram PNG files.')
config.set('GLOBAL', '; Will be relative to the specgen/generate.py script if '
'it does not start with /')
config.set('GLOBAL', 'PlotImgDir', './specweb/static/plots')
config['WINSTON'] = {
'; Currently waveform data is pulled from a winston.': None,
'; In the future, this may become configurable to any ObsPy data source': None,
'url': 'pubavo1.wr.usgs.gov',
'port': 16022,
}
config['MySQL'] = {
'; MySQL is used to pull latitude/longitude information for volcanos': None,
"; from geodiva so Cheryl Cameron doesn't have my head": None,
'DB_HOST': 'spurr.snap.uaf.edu',
'DB_USER': '<MY_USER>',
'DB_PASSWORD': '<MY_PASSWORD>',
'DB_NAME': 'geodiva',
}
config['IRIS'] = {'url': 'https://service.iris.edu/fdsnws/station/1/query', }
# Data filters to apply to the raw data
config['FILTER'] = {
'LowCut': .5,
'HighCut': 15,
'Order': 2,
}
# Parameters for generating the seismic spectrogram function
config['SPECTROGRAM'] = {
'WindowType': 'hamming',
'WindowSize': 1024,
'Overlap': 924,
'NFFT': 1024,
'MaxFreq': 10,
'MinFreq': 0,
'padding': 10,
}
# Get any enviroment variable overrides
for key in config:
for envkey, value in os.environ.items():
if envkey.startswith(key):
print("Override found for key", key, ":", envkey)
env_parts = envkey.split('__')
try:
reduce(operator.getitem, env_parts[:-1], config)[env_parts[-1]] = value
except:
print("Unable to get dest for override key", envkey)
with open('specgen/config/config.ini', 'w') as conffile:
config.write(conffile)
if __name__ == "__main__":
main()