Skip to content

Commit

Permalink
extending read_sem_cartesian test to check for evdp related to #132
Browse files Browse the repository at this point in the history
adding warning messages to sac header append when evdp or mag not
present
  • Loading branch information
bch0w committed Feb 29, 2024
1 parent 73462a2 commit 831b102
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pysep/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ def test_append_sac_headers(test_st, test_inv, test_event):
assert(st[0].stats.sac["evla"] == test_event.preferred_origin().latitude)


def test_append_sac_headers_cartesian(test_st, test_inv, test_event):
"""
Make sure we can write SAC headers correctly
"""
st = append_sac_headers(st=test_st, inv=test_inv, event=test_event)
assert(not hasattr(test_st[0].stats, "sac"))
assert(hasattr(st[0].stats, "sac"))
assert(st[0].stats.sac["evla"] == test_event.preferred_origin().latitude)


def test_event_tag_and_event_tag_legacy(test_event):
"""
Check that event tagging works as expected
Expand Down Expand Up @@ -183,6 +193,7 @@ def test_read_sem_cartesian():
stations=test_stations)
assert(st)
assert(st[0].stats.sac.stla == 67000.0)
assert("evdp" in st[0].stats.sac)

def test_estimate_prefilter_corners(test_st):
"""
Expand Down
2 changes: 2 additions & 0 deletions pysep/utils/cap_sac.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,14 @@ def _append_sac_headers_trace(tr, event, inv):
evdp = event.preferred_origin().depth / 1E3 # units: km
sac_header["evdp"] = evdp
except Exception: # NOQA
logger.warning("no event depth available for SAC header")
pass

try:
mag = event.preferred_magnitude().mag
sac_header["mag"] = mag
except Exception: # NOQA
logger.warning("no event magnitude available for SAC header")
pass

# Append SAC header and include back azimuth for rotation
Expand Down

0 comments on commit 831b102

Please sign in to comment.