Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify code to handle non-standard and time-varying component orientations #95

Merged
merged 13 commits into from
Jan 19, 2025
Merged
Prev Previous commit
Next Next commit
Make Z component have correct cmpaz and cmpinc headers
ShangqinHao committed Jan 17, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit b471d00ce6c2fa591bb7bc428c29971c300f5239
6 changes: 4 additions & 2 deletions seispy/eq.py
Original file line number Diff line number Diff line change
@@ -25,16 +25,18 @@ def __str__(self):
return '{}'.format(self.matchkey)

def rotateZNE(st):
"""Rotate non-traditional components (e.g., Z, 1, 2) to Z, N, E components
"""Rotate non-standard components (e.g., 1, 2, Z) to N, E, Z components
and reorder the components to ensure that the final *.BHZ.SAC files have correct cmpaz (=0) and cmpinc (=0) headers.
"""
try:
zne = rotate2zne(
st[0].data, st[0].stats.sac.cmpaz, st[0].stats.sac.cmpinc - 90,
st[1].data, st[1].stats.sac.cmpaz, st[1].stats.sac.cmpinc - 90,
st[2].data, st[2].stats.sac.cmpaz, st[2].stats.sac.cmpinc - 90)
nez = [zne[1], zne[2], zne[0]] # change order from ZNE to NEZ
except Exception as e:
raise ValueError('No specified cmpaz or cmpinc. {}'.format(e))
for tr, new_data, component in zip(st, zne, "ZNE"):
for tr, new_data, component in zip(st, nez, "NEZ"):
tr.data = new_data
tr.stats.channel = tr.stats.channel[:-1] + component