From d3a38526d6c4384a3957da91a79dad2897a6e2bd Mon Sep 17 00:00:00 2001 From: Philip Crotwell Date: Thu, 24 Oct 2024 16:44:33 -0400 Subject: [PATCH] set extra header markers using seisFile methods --- .../sc/seis/TauP/cmdline/TauP_SetMSeed3.java | 21 ++++++++++++------- .../edu/sc/seis/TauP/cmdline/TauP_Spikes.java | 8 ++++++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/sc/seis/TauP/cmdline/TauP_SetMSeed3.java b/src/main/java/edu/sc/seis/TauP/cmdline/TauP_SetMSeed3.java index dbcf3d1e..9c778987 100644 --- a/src/main/java/edu/sc/seis/TauP/cmdline/TauP_SetMSeed3.java +++ b/src/main/java/edu/sc/seis/TauP/cmdline/TauP_SetMSeed3.java @@ -15,6 +15,7 @@ import java.io.*; +import edu.sc.seis.seisFile.mseed3.ehbag.Marker; import org.json.JSONArray; import org.json.JSONObject; import picocli.CommandLine; @@ -192,6 +193,11 @@ public void processRecord(MSeed3Record dr3) throws TauPException { if (evTime == null) { System.err.println("Unable to extract event origin time, skipping record"); } + + List mList = new ArrayList<>(); + for (Arrival arrival : arrivals) { + mList.add(createEHMarker(arrival, evTime)); + } insertMarkers(bag, arrivals, evTime); } } @@ -208,12 +214,10 @@ public static void insertMarkers(JSONObject bag, List arrivals, Instant bag.put("mark", markers); } - public static JSONObject createEHMarker(Arrival arrival, Instant evTime) { - JSONObject mark = new JSONObject(); - mark.put("n", arrival.getName()); - mark.put("tm", TimeUtils.toISOString(evTime.plusMillis(Math.round(arrival.getTime()*1000)))); - mark.put("mtype", "md"); - return mark; + public static Marker createEHMarker(Arrival arrival, Instant evTime) { + Marker m = new Marker(arrival.getName(), evTime.plusMillis(Math.round(arrival.getTime()*1000)).atZone(TimeUtils.TZ_UTC)); + m.setType(MSeed3EHKeys.MARKER_MODELED); + return m; } Event findQuakeInTime(Instant time, Duration tol) { @@ -244,7 +248,10 @@ public String getEhKey() { } @CommandLine.Option(names = "--taupeh", - description = "key to store full TauP JSON output within extra headers within, otherwise use abbreviated 'bag' style markers.") + arity = "0..1", + fallbackValue = "taup", + description = "key to store full TauP JSON output within extra headers within, otherwise use abbreviated 'bag' style markers."+ + "If specified without parameter, extra header key of ${FALLBACK-VALUE} will be used.") public void setEhKey(String ehKey) { this.ehKey = ehKey; } diff --git a/src/main/java/edu/sc/seis/TauP/cmdline/TauP_Spikes.java b/src/main/java/edu/sc/seis/TauP/cmdline/TauP_Spikes.java index f761d92b..73a26d82 100644 --- a/src/main/java/edu/sc/seis/TauP/cmdline/TauP_Spikes.java +++ b/src/main/java/edu/sc/seis/TauP/cmdline/TauP_Spikes.java @@ -33,6 +33,7 @@ import edu.sc.seis.seisFile.fdsnws.quakeml.*; import edu.sc.seis.seisFile.mseed3.FDSNSourceId; import edu.sc.seis.seisFile.mseed3.MSeed3EH; +import edu.sc.seis.seisFile.mseed3.MSeed3EHKeys; import edu.sc.seis.seisFile.mseed3.MSeed3Record; import edu.sc.seis.seisFile.mseed3.ehbag.Marker; import edu.sc.seis.seisFile.mseed3.ehbag.Path; @@ -96,6 +97,11 @@ public void validateArguments() throws TauPException { } } + @Override + public void init() throws TauPException { + super.init(); + } + @Override public void start() throws IOException, TauPException { try { @@ -220,7 +226,7 @@ public MSeed3EH createEH(double degrees, ZonedDateTime startDateTime, List