-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasdf_rf_calc.py
89 lines (54 loc) · 2.42 KB
/
asdf_rf_calc.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
import pyasdf
from os.path import join
from obspy.core import Stream, Trace
from obspy.signal.rotate import rotate_ne_rt
import sys
from operator import itemgetter, attrgetter
from obspy.core import AttribDict
from obspy.geodetics.base import gps2dist_azimuth
from matplotlib.pyplot import plot
from rf import RFStream, rfstats, get_profile_boxes
import time
code_start_time = time.time()
# =========================== User Input Required =========================== #
#Path to the data
data_path = '/media/obsuser/GA-ANU_TRAN/'
#IRIS Virtual Ntework name
virt_net = '_ANU'
# FDSN network identifier (2 Characters)
FDSNnetwork = 'S1'
station = 'AQ3A1'
# =========================================================================== #
# ASDF file (High Performance Dataset) one file per network
ASDF_in = join(data_path, virt_net, FDSNnetwork, 'ASDF', FDSNnetwork + '.h5')
# Open the ASDF file
ds = pyasdf.ASDFDataSet(ASDF_in)
event_cat = ds.events
all_rf_stream = RFStream()
for _j, event in enumerate(event_cat):
print '\r Calculating Receiver Functions for {0} of {1} Earthquakes'.format(_j + 1, event_cat.count()),
sys.stdout.flush()
# Get quake origin info
origin_info = event.preferred_origin() or event.origins[0]
for filtered_waveforms in ds.ifilter(ds.q.event == event, ds.q.station == station):
st = filtered_waveforms.extracted_unproc_quakes
inv = filtered_waveforms.StationXML
if st.__nonzero__():
rf_stream = RFStream(st)
stats = rfstats(station=inv[0][0], event=event, phase='P', dist_range=(30,90))
# Stats might be none if epicentral distance of earthquake is outside dist_range
if not stats == None:
for tr in rf_stream:
tr.stats.update(stats)
rf_stream.filter('bandpass', freqmin=0.05, freqmax=1.)
rf_stream.rf(method='P', trim=(-10,30), downsample=50, deconvolve='time')
rf_stream.moveout()
rf_stream.ppoints(pp_depth=30)
all_rf_stream.extend(rf_stream)
all_rf_stream.sort(keys=['distance'])
all_rf_stream.select(station=station, channel='BHL').plot_rf(fillcolors=(None, 'k'))
#all_rf_stream.profile(boxes=get_profile_boxes(latlon0=(-35.344265, 149.159866), azimuth=10, bins=(0,10,20,30)))
#all_rf_stream.plot_profile()
del ds
print '\n'
print("--- Execution time: %s seconds ---" % (time.time() - code_start_time))