Skip to content
GitLab
菜单
项目
群组
代码片段
/
帮助
帮助
支持
社区论坛
快捷键
?
提交反馈
登录/注册
切换导航
菜单
打开侧边栏
NJU Geophy
seispy
提交
2a8572e8
提交
2a8572e8
编辑于
10月 28, 2021
作者:
Mijian Xu
😷
浏览文件
Raise error log when number of sacfiles is not 3.
上级
0512c2fd
变更
2
Hide whitespace changes
Inline
Side-by-side
seispy/eq.py
浏览文件 @
2a8572e8
...
...
@@ -29,8 +29,13 @@ class eq(object):
def
__init__
(
self
,
pathname
,
datestr
,
suffix
):
self
.
datestr
=
datestr
self
.
st
=
obspy
.
read
(
join
(
pathname
,
'*'
+
datestr
+
'*'
+
suffix
))
if
len
(
self
.
st
)
!=
3
:
raise
ValueError
(
'Sismogram must be in 3 components, but there are {} of {}'
.
format
(
len
(
self
.
st
),
datestr
))
if
len
(
self
.
st
)
<
3
:
channel
=
' '
.
join
([
tr
.
stats
.
channel
for
tr
in
self
.
st
])
raise
ValueError
(
'Sismogram must be in 3 components, but there are only channel {} of {}'
.
format
(
channel
,
datestr
))
elif
len
(
self
.
st
)
>
3
:
raise
ValueError
(
'{} has more than 3 components, please select to delete redundant seismic components'
.
format
(
datestr
))
else
:
pass
# if not (self.st[0].stats.npts == self.st[1].stats.npts == self.st[2].stats.npts):
# raise ValueError('Samples are different in 3 components')
self
.
st
.
sort
()
...
...
seispy/rf.py
浏览文件 @
2a8572e8
...
...
@@ -81,7 +81,7 @@ def load_station_info(pathname, ref_comp, suffix):
return
ex_tr
.
knetwk
,
ex_tr
.
kstnm
,
ex_tr
.
stla
,
ex_tr
.
stlo
,
ex_tr
.
stel
def
match_eq
(
eq_lst
,
pathname
,
stla
,
stlo
,
ref_comp
=
'Z'
,
suffix
=
'SAC'
,
offset
=
None
,
def
match_eq
(
eq_lst
,
pathname
,
stla
,
stlo
,
logger
,
ref_comp
=
'Z'
,
suffix
=
'SAC'
,
offset
=
None
,
tolerance
=
210
,
dateformat
=
'%Y.%j.%H.%M.%S'
):
pattern
=
datestr2regex
(
dateformat
)
ref_eqs
=
glob
.
glob
(
join
(
pathname
,
'*{0}*{1}'
.
format
(
ref_comp
,
suffix
)))
...
...
@@ -114,7 +114,7 @@ def match_eq(eq_lst, pathname, stla, stlo, ref_comp='Z', suffix='SAC', offset=No
try
:
this_eq
=
eq
(
pathname
,
datestr
,
suffix
)
except
Exception
as
e
:
continue
logger
.
RF
.
error
(
''
.
format
(
e
))
this_eq
.
get_time_offset
(
results
.
iloc
[
0
][
'date'
])
daz
=
distaz
(
stla
,
stlo
,
results
.
iloc
[
0
][
'evla'
],
results
.
iloc
[
0
][
'evlo'
])
this_df
=
pd
.
DataFrame
([[
daz
.
delta
,
daz
.
baz
,
this_eq
,
datestr
]],
columns
=
new_col
,
index
=
results
.
index
.
values
)
...
...
@@ -272,10 +272,10 @@ class RF(object):
raise
e
self
.
logger
.
RFlog
.
info
(
'Found {} earthquakes'
.
format
(
self
.
eq_lst
.
shape
[
0
]))
def
match_eq
(
self
,
switchEN
=
False
,
reverseE
=
False
,
reverseN
=
False
):
def
match_eq
(
self
):
try
:
self
.
logger
.
RFlog
.
info
(
'Match SAC files'
)
self
.
eqs
=
match_eq
(
self
.
eq_lst
,
self
.
para
.
datapath
,
self
.
stainfo
.
stla
,
self
.
stainfo
.
stlo
,
self
.
eqs
=
match_eq
(
self
.
eq_lst
,
self
.
para
.
datapath
,
self
.
stainfo
.
stla
,
self
.
stainfo
.
stlo
,
self
.
logger
,
ref_comp
=
self
.
para
.
ref_comp
,
suffix
=
self
.
para
.
suffix
,
offset
=
self
.
para
.
offset
,
tolerance
=
self
.
para
.
tolerance
,
dateformat
=
self
.
para
.
dateformat
)
...
...
编辑
预览
支持
Markdown
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录