-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup_gf_arctic.py
109 lines (77 loc) · 2.97 KB
/
setup_gf_arctic.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env python
#coding=utf-8
#----------------------------------------------------------------------
# version 1.03 - 24.02.10 - LK -
#----------------------------------------------------------------------
#
#
# Tool for setting up a database of Green's functions for a
# - circular shaped configuration of receivers
# - rectangular setup of source-grid
# around a given center (point, given in (lat,lon)-coordinates
#
# Function for setting up synthetic data-set for arbitrarily chosen source-point from source-grid
#
# USES FUNCTIONS FROM "setup_gf_functions.py" !!!!!
#
#----------------------------------------------------------------------
import sys
import os
import os.path as op
sys.path.append('/net/scratch2/gp/u25400/lasse/arctic/')
import setup_gf_tools_arctic
reload(setup_gf_tools_arctic)
from setup_gf_tools_arctic import *
#----------------------------------------------------------------------
_debug = 1
#----------------------------------------------------------------------
def setup_gf(configfilename,qs=True, data=False):
if not _debug:
saveout = sys.stdout
fsock = file('log_setup_arctic_current_run.log', 'w')
sys.stdout = fsock
print '\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n'
cfg = read_in_config_file(configfilename)
print '...done!\n'
cfg['datetime'] = cfg['event_id']
if not set_GF_parameters(cfg):
print 'ERROR in setting the Greens functions database parameters'
raise SystemExit
print '...done!\n'
#if _debug:
# for i in cfg:
# print i,cfg[i]
if qs==False and data==False:
sys.exit('\n NOTHING DONE !! \n')
#read in QSEIS database and prepare for given grid-receiver-configuration. create NetCDF GF database, ordered by station
#-------------------------
if qs:
setup_db_qseis(cfg)
#-------------------------
# if no real model available, take random GF made from white noise:
#setup_db_white_noise(cfg)
#-------------------------
if data:
#set artificial data
setup_synth_data(cfg)
#-------------------------
print '\n\n database ready !!!!!!!\n\n'
if cfg['number_of_gf'] == 8:
print '\n\n !!!!!!!!!!! ATTENTION!! Far field approximation applied !!!!!!!\n\n'
print '\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n'
if not _debug:
sys.stdout = saveout
fsock.close()
#----------------------------------------------------------------------
if not len(sys.argv)> 1:
sys.exit('\n NO input - provide config file !! \n')
cfg_file = op.realpath(op.abspath(op.join(os.curdir,sys.argv[1])))
qs_key=False
data_key=False
if len(sys.argv)> 2:
for aa in sys.argv[2:]:
if 'qs' in aa.lower():
qs_key = True
if 'data' in aa.lower():
data_key = True
setup_gf(cfg_file, qs=qs_key, data=data_key)