From 831b1023eea0481c4982b94e2515921c683d7a40 Mon Sep 17 00:00:00 2001 From: bch0w Date: Thu, 29 Feb 2024 10:57:32 -0900 Subject: [PATCH] extending read_sem_cartesian test to check for evdp related to #132 adding warning messages to sac header append when evdp or mag not present --- pysep/tests/test_utils.py | 11 +++++++++++ pysep/utils/cap_sac.py | 2 ++ 2 files changed, 13 insertions(+) diff --git a/pysep/tests/test_utils.py b/pysep/tests/test_utils.py index d60c37a..e4ae2d3 100644 --- a/pysep/tests/test_utils.py +++ b/pysep/tests/test_utils.py @@ -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 @@ -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): """ diff --git a/pysep/utils/cap_sac.py b/pysep/utils/cap_sac.py index 9be09e2..615ea08 100644 --- a/pysep/utils/cap_sac.py +++ b/pysep/utils/cap_sac.py @@ -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