-
Notifications
You must be signed in to change notification settings - Fork 5
/
readlocal.py
84 lines (60 loc) · 2.02 KB
/
readlocal.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
# -*- coding: utf-8 -*-
"""
File with functions to read local data
A. Doran and G. Laske
"""
# import necessary functions
import obspy
from obspy import read as r
from obspy.core import UTCDateTime
from numpy import *
from scipy import signal
def getmsd1(t1,t2,dir1,sta):
# dir1='/data/irma6/gaherty/youngORCA/OBS/Mseed/'
t1=UTCDateTime(t1)
# d=r(dir1+'AKD.CH?.%i.%03d.*.msd'%(t1.year,t1.julday))
d=r(dir1+sta+'/'+sta+'*.CH?.%i.%03d.*.msd'%(t1.year,t1.julday))
# include next day of data if close to edge
if t1.hour>=20:
# d2=r(dir1+'AKD.CH?.%i.%03d.*.msd'%(t1.year,t1.julday+1))
d2=r(dir1+sta+'/'+sta+'*.CH?.%i.%03d.*.msd'%(t1.year,t1.julday+1))
d3=d+d2
d=d3.merge()
# rename channels
C1=d.select(channel='CH0')
C1[0].stats.channel='BH2'
C2=d.select(channel='CH1')
C2[0].stats.channel='BH1'
C3=d.select(channel='CH2')
C3[0].stats.channel='BHZ'
st1=C1+C2+C3
# set sampling rate
sps=20
# define four hours of data
# t2=60*60*4
return st1.slice(starttime=t1,endtime=t1+t2)
def getmsd2(t1,t2,dir1,sta):
# dir1='/data/irma6/gaherty/youngORCA/OBS/Mseed/'
t1=UTCDateTime(t1)
# d=r(dir1+'AKD.CH?.%i.%03d.*.msd'%(t1.year,t1.julday))
# d=r(dir1+sta+'/'+sta+'.CH?.%i.%03d.*.msd'%(t1.year,t1.julday))
d=r(dir1+sta+'/Mseed/'+sta+'*.CH?.%i.%03d.*.msd'%(t1.year,t1.julday))
# include next day of data if close to edge
if t1.hour>=20:
# d2=r(dir1+'AKD.CH?.%i.%03d.*.msd'%(t1.year,t1.julday+1))
d2=r(dir1+sta+'/Mseed/'+sta+'*.CH?.%i.%03d.*.msd'%(t1.year,t1.julday+1))
d3=d+d2
d=d3.merge()
# rename channels
C1=d.select(channel='CH0')
C1[0].stats.channel='BH2'
C2=d.select(channel='CH1')
C2[0].stats.channel='BH1'
C3=d.select(channel='CH2')
C3[0].stats.channel='BHZ'
st1=C1+C2+C3
# set sampling rate
sps=20
# define four hours of data
# t2=60*60*4
return st1.slice(starttime=t1,endtime=t1+t2)