Skip to content

Commit

Permalink
1.0.4-M2.1 Changelog:
Browse files Browse the repository at this point in the history
    Changes:
    Made optimization for Path correction significantly more aggressive
    Reweight GT spectra with stress drop values defined to be 1.0 across all frequencies
    Make noise floor display consistent across the board
    Show 'bad' autopicks so humans get more feedback on what the autopicker is doing
    Remove AP pick if a human moves them (consider as 'reviewed').

    Bugfixes:
    Bumped up the tolerences on YBB_MIN to let the model have a little more flex.
    Minor bugfixes across the board.
    Version updates to all dependencies to stay up-to-date.
    JdkSslContext changed behavior in 4.1 of Netty.
  • Loading branch information
justinbarno committed Mar 4, 2019
1 parent c11f0b0 commit a09d4b8
Show file tree
Hide file tree
Showing 58 changed files with 962 additions and 491 deletions.
24 changes: 24 additions & 0 deletions calibration-gui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
12 changes: 1 addition & 11 deletions calibration-gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,7 @@
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
import java.io.IOException;
import java.net.URL;
import java.util.TimeZone;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.jar.Attributes;
import java.util.jar.Manifest;

Expand Down Expand Up @@ -159,10 +162,13 @@ public void start(Stage primaryStage) throws Exception {

@Override
public void stop() throws Exception {
CompletableFuture.runAsync(() -> {
springContext.stop();
springContext.close();
}).get(1, TimeUnit.SECONDS);
try {
CompletableFuture.runAsync(() -> {
springContext.stop();
springContext.close();
}).get(1, TimeUnit.SECONDS);
} catch (TimeoutException | ExecutionException | CancellationException | InterruptedException e) {
}
Platform.exit();
System.exit(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,30 @@ private <T> void plot(final FrequencyBand selectedFrequency, Function<FrequencyB
selectedData.clear();
highlightedData.clear();

AtomicReference<Integer> min = new AtomicReference<Integer>(XAXIS_MIN);
AtomicReference<Integer> max = new AtomicReference<Integer>(XAXIS_MIN);
AtomicReference<Integer> minX = new AtomicReference<Integer>(0);
AtomicReference<Integer> maxX = new AtomicReference<Integer>(0);
AtomicReference<Double> minY = new AtomicReference<Double>(0d);
AtomicReference<Double> maxY = new AtomicReference<Double>(0d);

Optional.ofNullable(valueSupplier.apply(selectedFrequency)).ifPresent(values -> values.forEach(val -> {
Data<Number, Number> data = dataPointSupplier.apply(val);
pointData.add(data);
if (data.getXValue().doubleValue() > max.get()) {
max.set(data.getXValue().intValue());
if (data.getXValue().doubleValue() > maxX.get()) {
maxX.set(data.getXValue().intValue());
}
if (data.getXValue().doubleValue() < min.get()) {
min.set(data.getXValue().intValue());
if (data.getXValue().doubleValue() < minX.get()) {
minX.set(data.getXValue().intValue());
}

if (data.getXValue().doubleValue() > maxY.get()) {
maxY.set(data.getYValue().doubleValue());
}
if (data.getYValue().doubleValue() < minY.get()) {
minY.set(data.getYValue().doubleValue());
}

data.getNode().addEventHandler(MouseEvent.MOUSE_CLICKED, mouseClickedCallback.apply(val));
data.getNode().toBack();
Waveform w = mapFunc.apply(val);
boolean eventExists = w != null && w.getEvent() != null && w.getEvent().getEventId() != null;
boolean stationExists = w != null && w.getStream() != null && w.getStream().getStation() != null && w.getStream().getStation().getStationName() != null;
Expand All @@ -379,12 +390,20 @@ private <T> void plot(final FrequencyBand selectedFrequency, Function<FrequencyB
}
}));

if (max.get() > XAXIS_MAX || max.get() == XAXIS_MIN) {
max.set(XAXIS_MAX);
if (maxX.get() > XAXIS_MAX || maxX.get() == XAXIS_MIN) {
maxX.set(XAXIS_MAX);
}

if (yAxis.getLowerBound() > minY.get()) {
yAxis.setLowerBound(1.1 * minY.get());
}

if (yAxis.getUpperBound() < maxY.get()) {
yAxis.setUpperBound(1.1 * maxY.get());
}

if (curveProducer != null) {
for (double i = min.get(); i <= max.get(); i = i + ((max.get() - min.get()) / LINE_SEGMENTS)) {
for (double i = minX.get(); i <= maxX.get(); i = i + ((maxX.get() - minX.get()) / LINE_SEGMENTS)) {
Data<Number, Number> data = curveProducer.apply(i);
modelData.add(data);
data.getNode().setMouseTransparent(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -34,6 +35,7 @@
import gov.llnl.gnem.apps.coda.common.gui.util.NumberFormatFactory;
import gov.llnl.gnem.apps.coda.common.model.domain.Event;
import gov.llnl.gnem.apps.coda.common.model.domain.FrequencyBand;
import gov.llnl.gnem.apps.coda.common.model.domain.SharedFrequencyBandParameters;
import gov.llnl.gnem.apps.coda.common.model.domain.Station;
import gov.llnl.gnem.apps.coda.common.model.domain.SyntheticCoda;
import gov.llnl.gnem.apps.coda.common.model.domain.Waveform;
Expand Down Expand Up @@ -74,6 +76,8 @@ public class CodaWaveformPlot extends SeriesPlot {

private PeakVelocityClient velocityClient;

private SyntheticCoda synthetic;

private enum PLOT_ORDERING {
BACKGROUND(0), NOISE_BOX(1), WAVEFORM(2), NOISE_LINE(3), SHAPE_FIT(4), MODEL_FIT(5), PICKS(6);

Expand Down Expand Up @@ -156,6 +160,9 @@ public void setWaveform(Waveform waveform, SyntheticCoda synth) {
Collection<VPickLine> pickLines = this.addPick(pick.getPickName(), pickTime);
for (VPickLine pickLine : pickLines) {
pickLine.setDraggable(true);
if (!pickLine.getText().equalsIgnoreCase("f")) {
pickLine.setColor(Color.LIGHT_GRAY);
}
pickLineMap.put(pickLine, pick);
}
}
Expand Down Expand Up @@ -197,63 +204,18 @@ public void setWaveform(Waveform waveform, SyntheticCoda synth) {
// int timeStart = (int) (new TimeT(measurement.getNoiseStartSecondsFromOrigin()).subtractD(beginTime) - 0.5);
// int timeEnd = (int) (new TimeT(measurement.getNoiseEndSecondsFromOrigin()).subtractD(beginTime) - 0.5);
// subplot.AddPlotObject(createRectangle(timeStart, timeEnd, -FULL_LENGTH, FULL_LENGTH, PINK_HALF_TRANS), PLOT_ORDERING.NOISE_BOX.getZOrder());
subplot.AddPlotObject(createFixedLine(measurement.getNoiseLevel(), lineLength, LIGHT_RED, PenStyle.DASH), PLOT_ORDERING.NOISE_LINE.getZOrder());
subplot.AddPlotObject(createFixedLine(measurement.getNoiseLevel() + params.getMinSnr(), lineLength, LIGHT_RED, PenStyle.SOLID), PLOT_ORDERING.NOISE_LINE.getZOrder());
subplot.AddPlotObject(createFixedLine(measurement.getNoiseLevel(), lineLength, Color.BLACK, PenStyle.DASH), PLOT_ORDERING.NOISE_LINE.getZOrder());
subplot.AddPlotObject(createFixedLine(measurement.getNoiseLevel() + params.getMinSnr(), lineLength, Color.BLACK, PenStyle.SOLID), PLOT_ORDERING.NOISE_LINE.getZOrder());
repaint();
}
});

if (synth != null) {
TimeSeries interpolatedSeries = new TimeSeries(waveformSegment, waveform.getSampleRate(), beginTime);
float[] synthSegment = doublesToFloats(synth.getSegment());
TimeSeries synthSeries = new TimeSeries(synthSegment, synth.getSampleRate(), new TimeT(synth.getBeginTime()));
WaveformPick endPick = null;
for (WaveformPick p : waveform.getAssociatedPicks()) {
if (PICK_TYPES.F.name().equals(p.getPickType())) {
endPick = p;
break;
}
}
TimeT endTime;
if (endPick != null && endPick.getPickTimeSecFromOrigin() > 0 && waveform.getEvent() != null) {
endTime = new TimeT(waveform.getEvent().getOriginTime()).add(endPick.getPickTimeSecFromOrigin());
} else {
endTime = new TimeT(synth.getEndTime());
}

interpolatedSeries.interpolate(synthSeries.getSamprate());

double vr = params.getVelocity0() - params.getVelocity1() / (params.getVelocity2() + distance);
if (vr == 0.0) {
vr = 1.0;
}
TimeT originTime = new TimeT(event.getOriginTime());
TimeT startTime;
TimeT trimTime = originTime.add(distance / vr);
TimeSeries trimmedWaveform = new TimeSeries(waveformSegment, waveform.getSampleRate(), beginTime);
try {
trimmedWaveform.cutBefore(trimTime);
trimmedWaveform.cutAfter(trimTime.add(30.0));
startTime = new TimeT(trimTime.getEpochTime() + trimmedWaveform.getMaxTime()[0]);
} catch (IllegalArgumentException e) {
startTime = trimTime;
}

if (startTime.lt(endTime)) {
interpolatedSeries.cut(startTime, endTime);
synthSeries.cut(startTime, endTime);

TimeSeries diffSeis = interpolatedSeries.subtract(synthSeries);
int timeShift = (int) (startTime.subtractD(beginTime) - 0.5);
double median = diffSeis.getMedian();

subplot.DeletePlotObject(legendRef);
subplot.AddPlotObject(createLegend(labelText + "Shift: " + dfmt4.format(median)));
subplot.AddPlotObject(createLine(timeShift, median, synthSeries, Color.GREEN), PLOT_ORDERING.MODEL_FIT.getZOrder());
repaint();
}
plotSynthetic(waveform, synth, beginTime, waveformSegment, subplot, event, distance, labelText, legendRef, params);
this.synthetic = synth;
} else if (this.synthetic != null && synthetic.getSourceWaveform() != null && synthetic.getSourceWaveform().getId() == waveform.getId()) {
plotSynthetic(waveform, synthetic, beginTime, waveformSegment, subplot, event, distance, labelText, legendRef, params);
}

} catch (IllegalArgumentException e) {
log.warn(e.getMessage(), e);
}
Expand All @@ -264,6 +226,60 @@ public void setWaveform(Waveform waveform, SyntheticCoda synth) {
}
}

private void plotSynthetic(Waveform waveform, SyntheticCoda synth, final TimeT beginTime, final float[] waveformSegment, JSubplot subplot, Event event, double distance, String labelText,
PlotObject legendRef, SharedFrequencyBandParameters params) {
TimeSeries interpolatedSeries = new TimeSeries(waveformSegment, waveform.getSampleRate(), beginTime);
float[] synthSegment = doublesToFloats(synth.getSegment());
TimeSeries synthSeries = new TimeSeries(synthSegment, synth.getSampleRate(), new TimeT(synth.getBeginTime()));
WaveformPick endPick = null;
for (WaveformPick p : waveform.getAssociatedPicks()) {
if (p.getPickType() != null && PICK_TYPES.F.name().equalsIgnoreCase(p.getPickType().trim())) {
endPick = p;
break;
}
}
TimeT endTime;
if (endPick != null && event != null) {
endTime = new TimeT(event.getOriginTime()).add(endPick.getPickTimeSecFromOrigin());
} else {
endTime = new TimeT(synth.getEndTime());
}

interpolatedSeries.interpolate(synthSeries.getSamprate());

double vr = params.getVelocity0() - params.getVelocity1() / (params.getVelocity2() + distance);
if (vr == 0.0) {
vr = 1.0;
}
TimeT originTime = new TimeT(event.getOriginTime());
TimeT startTime;
TimeT trimTime = originTime.add(distance / vr);
if (trimTime.lt(endTime)) {
TimeSeries trimmedWaveform = new TimeSeries(waveformSegment, waveform.getSampleRate(), beginTime);
try {
trimmedWaveform.cutBefore(trimTime);
trimmedWaveform.cutAfter(trimTime.add(30.0));
startTime = new TimeT(trimTime.getEpochTime() + trimmedWaveform.getMaxTime()[0]);
} catch (IllegalArgumentException e) {
startTime = trimTime;
}

if (startTime.lt(endTime)) {
interpolatedSeries.cut(startTime, endTime);
synthSeries.cut(startTime, endTime);

TimeSeries diffSeis = interpolatedSeries.subtract(synthSeries);
int timeShift = (int) (startTime.subtractD(beginTime) + 0.5);
double median = diffSeis.getMedian();

subplot.DeletePlotObject(legendRef);
subplot.AddPlotObject(createLegend(labelText + "Shift: " + dfmt4.format(median)));
subplot.AddPlotObject(createLine(timeShift, median, synthSeries, Color.GREEN), PLOT_ORDERING.MODEL_FIT.getZOrder());
repaint();
}
}
}

private PinnedText createLegend(String text) {
return new PinnedText(5d, 5d, text, HorizPinEdge.RIGHT, VertPinEdge.TOP, getTitle().getFontName(), getTitle().getFontSize(), Color.black, HorizAlignment.RIGHT, VertAlignment.TOP);
}
Expand Down Expand Up @@ -322,8 +338,17 @@ protected void handlePickMovedState(Object obj) {
if (vpl != null) {
try {
WaveformPick pick = pickLineMap.get(vpl);
if (pick != null) {
if (pick != null && pick.getWaveform() != null) {
pick.setPickTimeSecFromOrigin((float) (vpl.getXval() - new TimeT(pick.getWaveform().getEvent().getOriginTime()).subtractD(new TimeT(pick.getWaveform().getBeginTime()))));
if (pick.getPickName() != null && PICK_TYPES.F.getPhase().equalsIgnoreCase(pick.getPickName().trim())) {
pick.getWaveform()
.setAssociatedPicks(
pick.getWaveform()
.getAssociatedPicks()
.stream()
.filter(p -> p.getPickName() != null && !PICK_TYPES.AP.getPhase().equalsIgnoreCase(p.getPickName().trim()))
.collect(Collectors.toList()));
}
waveformClient.postWaveform(pick.getWaveform()).subscribe(this::setWaveform);
}
} catch (ClassCastException | JsonProcessingException e) {
Expand Down
4 changes: 2 additions & 2 deletions calibration-gui/src/main/resources/fxml/FitPlot.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.default-color0.chart-series-line { -fx-stroke: transparent; }
.default-color1.chart-series-line { -fx-stroke: blue; -fx-stroke-width:5px;}
.default-color2.chart-series-line { -fx-stroke: black; }
.default-color1.chart-series-line { -fx-stroke: blue; -fx-stroke-width:5px; }
.default-color2.chart-series-line { -fx-stroke: transparent; }
.default-color3.chart-series-line { -fx-stroke: transparent; }

.default-color0.chart-line-symbol {
Expand Down
1 change: 1 addition & 0 deletions calibration-gui/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<configuration />
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,30 @@ public class MdacParametersFI {
@NumberFormat
private double rhor;

public MdacParametersFI() {
super();
}

public MdacParametersFI(MdacParametersFI mdacFI) {
super();
this.id = new Long(mdacFI.getId());
this.version = new Long(mdacFI.getVersion());
this.sigma = mdacFI.getSigma();
this.delSigma = mdacFI.getDelSigma();
this.psi = mdacFI.getPsi();
this.delPsi = mdacFI.getDelPsi();
this.zeta = mdacFI.getZeta();
this.m0ref = mdacFI.getM0ref();
this.alphas = mdacFI.getAlphas();
this.betas = mdacFI.getBetas();
this.rhos = mdacFI.getRhos();
this.radPatP = mdacFI.getRadPatP();
this.radPatS = mdacFI.getRadPatS();
this.alphaR = mdacFI.getAlphaR();
this.betaR = mdacFI.getBetaR();
this.rhor = mdacFI.getRhor();
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
package gov.llnl.gnem.apps.coda.calibration.service.api;

public interface EndTimePicker {
public double getEndTime(float[] waveform, double sampleRate, double startTimeEpochSeconds, int startOffset, double minLengthSec, double maxLengthSec, double minimumSnr);
public double getEndTime(float[] waveform, double sampleRate, double startTimeEpochSeconds, int startOffset, double minLengthSec, double maxLengthSec, double minimumSnr, double noise);
}
12 changes: 1 addition & 11 deletions calibration-service/calibration-service-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,7 @@
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Loading

0 comments on commit a09d4b8

Please sign in to comment.