Skip to content

Commit

Permalink
set extra header markers using seisFile methods
Browse files Browse the repository at this point in the history
  • Loading branch information
crotwell committed Oct 24, 2024
1 parent 9c13f28 commit d3a3852
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
21 changes: 14 additions & 7 deletions src/main/java/edu/sc/seis/TauP/cmdline/TauP_SetMSeed3.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Marker> mList = new ArrayList<>();
for (Arrival arrival : arrivals) {
mList.add(createEHMarker(arrival, evTime));
}
insertMarkers(bag, arrivals, evTime);
}
}
Expand All @@ -208,12 +214,10 @@ public static void insertMarkers(JSONObject bag, List<Arrival> 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) {
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/edu/sc/seis/TauP/cmdline/TauP_Spikes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -220,7 +226,7 @@ public MSeed3EH createEH(double degrees, ZonedDateTime startDateTime, List<Arriv
for (Arrival a : allArrivals) {
ZonedDateTime arrTime = startDateTime.plusNanos(Math.round(a.getTime() * 1e9));
String desc = "";
Marker m = new Marker(a.getName(), arrTime, Marker.MARKER_PREDIC_MODEL, desc);
Marker m = new Marker(a.getName(), arrTime, MSeed3EHKeys.MARKER_MODELED, desc);
eh.addToBag(m);
}
return eh;
Expand Down

0 comments on commit d3a3852

Please sign in to comment.