Skip to content

Commit 2665022

Browse files
committed
Bugfix release for CCT 1.0.24
Fix backwards event id label on specta ratio plot summary table Correct calculation for hypocentral distance in spectra ratio plot summary table to use event-event instead of (erroneous) event-station function Corrects several null pointer errors when missing information in spectra ratio report exports Add uncertainty quantification for apparent stress estimates in spectra ratio report Fix error when plots were shrunk to 0px causing plots to not re-plot afterwards Fix issue where SVG outout was not generated for spectra ratio plots under some circumstances
1 parent 298f07c commit 2665022

File tree

16 files changed

+501
-152
lines changed

16 files changed

+501
-152
lines changed

calibration-gui/src/main/java/gov/llnl/gnem/apps/coda/calibration/gui/CodaGuiController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@ private void openManual(ActionEvent e) {
397397
}
398398

399399
manualWebview = new WebView();
400+
manualWebview.setMinHeight(5);
401+
manualWebview.setMinWidth(5);
400402

401403
manualWebview.getEngine().setJavaScriptEnabled(true);
402404
manualWebview.getEngine().getLoadWorker().stateProperty().addListener((o, ov, nv) -> {

calibration-gui/src/main/java/gov/llnl/gnem/apps/coda/calibration/gui/controllers/AbstractMeasurementController.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,13 @@ private void plotSpectra() {
414414
filteredMeasurements = filterToEvent(evidCombo.getSelectionModel().getSelectedItem(), spectralMeasurements);
415415
fittingSpectra = getFitSpectra();
416416
final Spectra referenceSpectra = spectraClient.getReferenceSpectra(evidCombo.getSelectionModel().getSelectedItem()).block(Duration.ofSeconds(2));
417-
fittingSpectra.add(referenceSpectra);
417+
if (!referenceSpectra.getSpectraXY().isEmpty()) {
418+
fittingSpectra.add(referenceSpectra);
419+
}
418420
final Spectra validationSpectra = spectraClient.getValidationSpectra(evidCombo.getSelectionModel().getSelectedItem()).block(Duration.ofSeconds(2));
419-
fittingSpectra.add(validationSpectra);
421+
if (!validationSpectra.getSpectraXY().isEmpty()) {
422+
fittingSpectra.add(validationSpectra);
423+
}
420424

421425
if (filteredMeasurements != null && !filteredMeasurements.isEmpty() && filteredMeasurements.get(0).getWaveform() != null) {
422426
final Event event = filteredMeasurements.get(0).getWaveform().getEvent();

calibration-gui/src/main/java/gov/llnl/gnem/apps/coda/calibration/gui/controllers/MeasuredMwsController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.time.temporal.ChronoUnit;
2222
import java.util.ArrayList;
2323
import java.util.Collection;
24+
import java.util.Collections;
2425
import java.util.HashMap;
2526
import java.util.List;
2627
import java.util.Map;
@@ -144,7 +145,11 @@ protected String getDisplayName() {
144145

145146
@Override
146147
protected List<Spectra> getFitSpectra() {
147-
return new ArrayList<>(fitSpectra.get(evidCombo.getSelectionModel().getSelectedItem()));
148+
List<Spectra> spectra = fitSpectra.get(evidCombo.getSelectionModel().getSelectedItem());
149+
if (spectra == null) {
150+
spectra = Collections.emptyList();
151+
}
152+
return spectra;
148153
}
149154

150155
@Override

calibration-gui/src/main/java/gov/llnl/gnem/apps/coda/calibration/gui/plotting/LeafletMap.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ public LeafletMap() {
119119

120120
Platform.runLater(() -> {
121121
webView = new WebView();
122+
webView.setMinHeight(5);
123+
webView.setMinWidth(5);
124+
122125
webView.getEngine().setJavaScriptEnabled(true);
123126
webView.setContextMenuEnabled(false);
124127
contextMenu = new ContextMenu();

calibration-gui/src/main/java/gov/llnl/gnem/apps/coda/calibration/gui/plotting/RatioDetailPlot.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public void plotRatio() {
259259
PLOT_ORDERING.DIFF_WAVEFORM.getZOrder(),
260260
numeratorCutColor,
261261
true,
262-
!this.alignPeaks,
262+
true,
263263
false);
264264
plotTimeSeries(
265265
denomSegment,
@@ -270,7 +270,7 @@ public void plotRatio() {
270270
PLOT_ORDERING.DIFF_WAVEFORM.getZOrder(),
271271
denominatorCutColor,
272272
false,
273-
!this.alignPeaks,
273+
false,
274274
false);
275275
plotTimeSeries(diffSegment, numeratorWave.getSampleRate(), numerOriginTime, numerStartCutTime, "Diff Wave", PLOT_ORDERING.DIFF_WAVEFORM.getZOrder(), diffColor, true, false, true);
276276
replot();

calibration-gui/src/main/java/gov/llnl/gnem/apps/coda/calibration/gui/plotting/RatioMeasurementSpectraPlotManager.java

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
package gov.llnl.gnem.apps.coda.calibration.gui.plotting;
1616

1717
import java.beans.PropertyChangeListener;
18-
import java.io.BufferedWriter;
1918
import java.io.File;
20-
import java.io.FileWriter;
2119
import java.io.IOException;
2220
import java.lang.reflect.InvocationTargetException;
2321
import java.nio.file.Files;
@@ -552,8 +550,6 @@ public void downloadPlots(final ActionEvent e) {
552550
tmpFolder.toFile().deleteOnExit();
553551

554552
exportScreenshots(tmpFolder.toFile());
555-
exportReportData(tmpFolder.toFile());
556-
557553
exportArchive = spectraRatioExporter.createExportArchive(ratioMeasurementReport, getEventPair(), tmpFolder);
558554

559555
if (exportArchive != null) {
@@ -677,7 +673,7 @@ private void plotJointInversionData(Map<EventPair, SpectraRatioPairInversionResu
677673
private void addEventDataToTable(String dataHeader, EventPair eventPair) {
678674
Double epicentralEventDistance = getEventPairEpicentralDistanceKm();
679675
Double hypocentralEventDistance = getHypocentralEventPairDistanceKm();
680-
Double eventDepth = getEventPairDepthKm();
676+
Double eventDepth = getEventPairDepthDiffKm();
681677

682678
ratioSummaryValues.add(new Pair<>(dataHeader, ""));
683679
ratioSummaryValues.add(new Pair<>("Numerator Event [A]", eventPair.getY().getEventId()));
@@ -1074,8 +1070,8 @@ private void updateInversionReferenceLines(SpectraRatioPairInversionResult pairI
10741070

10751071
getRatioSpectraPlot().getSubplot().addPlotObject(refRatioShape);
10761072

1077-
createFrequencyLine("Pair", false, PAIR_COLOR, LineStyles.DASH, true, pairMomentRatio, false);
1078-
createFrequencyLine("Pair", true, PAIR_COLOR, LineStyles.DASH, true, refRatio, false);
1073+
createFrequencyLine("Pair", true, PAIR_COLOR, LineStyles.DASH, true, pairMomentRatio, false);
1074+
createFrequencyLine("Pair", false, PAIR_COLOR, LineStyles.DASH, true, refRatio, false);
10791075
}
10801076
}
10811077

@@ -1092,8 +1088,8 @@ private void updateInversionReferenceLines(SpectraRatioPairInversionResult pairI
10921088

10931089
getRatioSpectraPlot().getSubplot().addPlotObject(refRatioShape);
10941090

1095-
createFrequencyLine("Joint", false, JOINT_COLOR, LineStyles.LONG_DASH, true, jointMomentRatio, false);
1096-
createFrequencyLine("Joint", true, JOINT_COLOR, LineStyles.LONG_DASH, true, refRatio, false);
1091+
createFrequencyLine("Joint", true, JOINT_COLOR, LineStyles.LONG_DASH, true, jointMomentRatio, false);
1092+
createFrequencyLine("Joint", false, JOINT_COLOR, LineStyles.LONG_DASH, true, refRatio, false);
10971093
}
10981094
}
10991095
}
@@ -1160,8 +1156,8 @@ private void updateMomentRatioLines() {
11601156

11611157
getRatioSpectraPlot().getSubplot().addPlotObject(refRatioShape);
11621158

1163-
createFrequencyLine("CCT", false, Color.BLACK, LineStyles.DOT, true, momentRatio, false);
1164-
createFrequencyLine("CCT", true, Color.BLACK, LineStyles.DOT, true, refRatio, false);
1159+
createFrequencyLine("CCT", true, Color.BLACK, LineStyles.DOT, true, momentRatio, false);
1160+
createFrequencyLine("CCT", false, Color.BLACK, LineStyles.DOT, true, refRatio, false);
11651161
}
11661162
}
11671163
}
@@ -1311,7 +1307,7 @@ public Double getHypocentralEventPairDistanceKm() {
13111307
}
13121308

13131309
// Gets the depth difference between event pair
1314-
public Double getEventPairDepthKm() {
1310+
public Double getEventPairDepthDiffKm() {
13151311
SpectraRatioPairDetails ratioDetails = getCurrentFirstRatio();
13161312
if (ratioDetails != null) {
13171313
double numerDepth = ratioDetails.getNumerWaveform().getEvent().getDepth();
@@ -1514,35 +1510,6 @@ public void exportScreenshots(final File folder) {
15141510
exportSVG(ratioSpectralPlotController.getSpectralPlot().getSubplot(), folder + File.separator + SPECTRA_RATIO_PREFIX + plotExportSuffix);
15151511
}
15161512

1517-
public void exportReportData(final File folder) {
1518-
String reportFilename = "EventPairTableData.txt";
1519-
StringBuilder reportStr = new StringBuilder();
1520-
1521-
String timestamp = SnapshotUtils.getTimestampWithLeadingSeparator();
1522-
reportStr.append("SPECTRA RATIO DATA REPORT\nTimestamp: " + timestamp + "\n");
1523-
reportStr.append("=".repeat(100) + "\n");
1524-
1525-
ratioSummaryValues.forEach(keyValuePair -> {
1526-
reportStr.append(keyValuePair.getX() + ": " + keyValuePair.getY() + "\n");
1527-
});
1528-
1529-
reportStr.append("=".repeat(100) + "\nSPECTRA RATIO DATA POINTS\n");
1530-
ratioMeasurementReport.getRatiosList(getEventPair()).forEach(pairDetails -> {
1531-
String centerFreq = dfmt4.format(centerFreq(pairDetails.getNumerWaveform().getLowFrequency(), pairDetails.getNumerWaveform().getHighFrequency()));
1532-
reportStr.append("{station: " + pairDetails.getNumerWaveform().getStream().getStation().getStationName());
1533-
reportStr.append(" , center_freq: " + centerFreq);
1534-
reportStr.append(" , ratio: " + dfmt4.format(pairDetails.getDiffAvg()) + "}\n");
1535-
});
1536-
1537-
try {
1538-
BufferedWriter writer = new BufferedWriter(new FileWriter(folder + File.separator + reportFilename));
1539-
writer.write(reportStr.toString());
1540-
writer.close();
1541-
} catch (IOException e) {
1542-
log.error("Error attempting to write report data text file : {}", e.getLocalizedMessage(), e);
1543-
}
1544-
}
1545-
15461513
private void exportSVG(BasicPlot plot, String path) {
15471514
try {
15481515
Files.write(Paths.get(path), plot.getSVG().getBytes());

calibration-gui/src/main/java/gov/llnl/gnem/apps/coda/calibration/gui/plotting/SpectraPlotManager.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ public SpectralPlot plotSpectra(List<PlotPoint> plotPoints, String plotTitle, Pa
151151
public void plotSpectraPlots() {
152152
if (eventPair != null) {
153153
if (!getCombinedPlotPoints().isEmpty()) {
154-
combinedPlot = plotSpectra(getCombinedPlotPoints(), String.format("Event_Pair_%s_%s", eventPair.getX().getEventId(), eventPair.getY().getEventId()), combinedPlotPane);
154+
combinedPlot = plotSpectra(getCombinedPlotPoints(), String.format("Event_Pair_%s_%s", eventPair.getY().getEventId(), eventPair.getX().getEventId()), combinedPlotPane);
155155
}
156156
if (!getNumeratorPlotPoints().isEmpty() && !getDenominatorPlotPoints().isEmpty()) {
157-
numerPlot = plotSpectra(getNumeratorPlotPoints(), String.format("Numerator Event %s", eventPair.getX().getEventId()), numerPane);
158-
denomPlot = plotSpectra(getDenominatorPlotPoints(), String.format("Denominator Event %s", eventPair.getY().getEventId()), denomPane);
157+
numerPlot = plotSpectra(getNumeratorPlotPoints(), String.format("Numerator Event %s", eventPair.getY().getEventId()), numerPane);
158+
denomPlot = plotSpectra(getDenominatorPlotPoints(), String.format("Denominator Event %s", eventPair.getX().getEventId()), denomPane);
159159
}
160160
}
161161
}
@@ -180,10 +180,10 @@ public void exportScreenshots(final File folder) {
180180
plotPane = combinedPlotPane;
181181
}
182182

183-
String combinedName = String.format("Combined_Plot_For_%s_%s", eventPair.getX().getEventId(), eventPair.getY().getEventId());
184-
String splitname = String.format("Spectra_Plots_%s_%s", eventPair.getX().getEventId(), eventPair.getY().getEventId());
185-
String numerName = String.format("Numerator_Spectra_Plot_%s", eventPair.getX().getEventId());
186-
String denomName = String.format("Denominator_Spectra_Plot_%s", eventPair.getY().getEventId());
183+
String combinedName = String.format("Combined_Plot_For_%s_%s", eventPair.getY().getEventId(), eventPair.getX().getEventId());
184+
String splitname = String.format("Spectra_Plots_%s_%s", eventPair.getY().getEventId(), eventPair.getX().getEventId());
185+
String numerName = String.format("Numerator_Spectra_Plot_%s", eventPair.getY().getEventId());
186+
String denomName = String.format("Denominator_Spectra_Plot_%s", eventPair.getX().getEventId());
187187

188188
if (isCombinedPlot && combinedPlot != null) {
189189
SnapshotUtils.writePng(folder, new Pair<>(combinedName + "_", plotPane), timestamp);

calibration-gui/src/main/java/gov/llnl/gnem/apps/coda/common/gui/data/client/DistanceCalculator.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,20 @@ public Double getEpicentralDistance(GeodeticCoordinate coordA, GeodeticCoordinat
6868

6969
public Double getHypocentralDistance(GeodeticCoordinate coordA, GeodeticCoordinate coordB) {
7070

71-
llnl.gnem.core.util.Geometry.GeodeticCoordinate convertedCoordA = new llnl.gnem.core.util.Geometry.GeodeticCoordinate(coordA.getLat(), coordA.getLon(), Math.copySign(coordA.getDepthKm(), -1d));
72-
llnl.gnem.core.util.Geometry.GeodeticCoordinate convertedCoordB = new llnl.gnem.core.util.Geometry.GeodeticCoordinate(coordB.getLat(), coordB.getLon(), coordB.getElevationKm());
71+
llnl.gnem.core.util.Geometry.GeodeticCoordinate convertedCoordA = new llnl.gnem.core.util.Geometry.GeodeticCoordinate(coordA.getLat(), coordA.getLon(), coordA.getDepthKm());
72+
llnl.gnem.core.util.Geometry.GeodeticCoordinate convertedCoordB = new llnl.gnem.core.util.Geometry.GeodeticCoordinate(coordB.getLat(), coordB.getLon(), coordB.getDepthKm());
7373

7474
return EModel.getSeparationMeters(convertedCoordA, convertedCoordB) / 1000.0;
7575
}
7676

7777
public static GeodeticCoordinate getEventCoord(Event event) {
78-
7978
// Note we are assuming event depth is in meters, and converting to km for distance calculations in km
8079
return new GeodeticCoordinate(event.getLatitude(), event.getLongitude(), event.getDepth() / 1000.0);
8180
}
8281

8382
public static GeodeticCoordinate getStationCoord(Station station) {
84-
8583
// Here, we are assuming a station elevation is in meters
86-
return new GeodeticCoordinate(station.getLatitude(), station.getLongitude(), station.getElevation() / 1000.0);
84+
// Geodetic coordinate lib expects depth positive is down
85+
return new GeodeticCoordinate(station.getLatitude(), station.getLongitude(), Math.copySign(station.getElevation() / 1000.0, -1d));
8786
}
8887
}

calibration-service/calibration-application/src/main/java/gov/llnl/gnem/apps/coda/common/application/web/WaveformsCollectionJsonController.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ public ResponseEntity<?> createBatch(@PathVariable Long sessionId, @Valid @Reque
144144
if (result.hasErrors()) {
145145
return ResponseEntity.status(HttpStatus.CONFLICT).body(result);
146146
}
147-
getWaveformService().update(sessionId, new ArrayList<>(waveforms));
147+
if (waveforms != null) {
148+
getWaveformService().update(sessionId, new ArrayList<>(waveforms));
149+
}
148150
return ResponseEntity.ok().build();
149151
}
150152

@@ -153,7 +155,9 @@ public ResponseEntity<?> updateBatch(@PathVariable Long sessionId, @Valid @Reque
153155
if (result.hasErrors()) {
154156
return ResponseEntity.status(HttpStatus.CONFLICT).body(result);
155157
}
156-
getWaveformService().update(sessionId, new ArrayList<>(waveforms));
158+
if (waveforms != null) {
159+
getWaveformService().update(sessionId, new ArrayList<>(waveforms));
160+
}
157161
return ResponseEntity.ok().build();
158162
}
159163

calibration-service/calibration-model/src/main/java/gov/llnl/gnem/apps/coda/common/model/util/GeodeticCoordinate.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ public class GeodeticCoordinate {
1919
private final double lat;
2020
private final double lon;
2121
private final double depthKm;
22-
private final double elevationKm;
2322

2423
public GeodeticCoordinate() {
2524
lat = 0;
2625
lon = 0;
2726
depthKm = 0;
28-
elevationKm = 0;
2927
}
3028

3129
/**
@@ -41,21 +39,13 @@ public GeodeticCoordinate(double lat, double lon, double depth) {
4139
this.lat = lat;
4240
this.lon = lon;
4341
this.depthKm = depth;
44-
elevationKm = 0;
4542
}
4643

47-
public GeodeticCoordinate(double lat, double lon, double depth, double elevKm) {
48-
this.lat = lat;
49-
this.lon = lon;
50-
this.depthKm = depth;
51-
elevationKm = elevKm;
52-
}
5344

5445
public GeodeticCoordinate(GeodeticCoordinate old) {
5546
lat = old.getLat();
5647
lon = old.getLon();
5748
depthKm = old.getDepthKm();
58-
this.elevationKm = old.elevationKm;
5949
}
6050

6151
public double getLat() {
@@ -70,17 +60,12 @@ public double getDepthKm() {
7060
return depthKm;
7161
}
7262

73-
public double getElevationKm() {
74-
return elevationKm;
75-
}
76-
7763
@Override
7864
public int hashCode() {
7965
int hash = 3;
8066
hash = 29 * hash + (int) (Double.doubleToLongBits(this.lat) ^ (Double.doubleToLongBits(this.lat) >>> 32));
8167
hash = 29 * hash + (int) (Double.doubleToLongBits(this.lon) ^ (Double.doubleToLongBits(this.lon) >>> 32));
8268
hash = 29 * hash + (int) (Double.doubleToLongBits(this.depthKm) ^ (Double.doubleToLongBits(this.depthKm) >>> 32));
83-
hash = 29 * hash + (int) (Double.doubleToLongBits(this.elevationKm) ^ (Double.doubleToLongBits(this.elevationKm) >>> 32));
8469
return hash;
8570
}
8671

@@ -105,15 +90,12 @@ public boolean equals(Object obj) {
10590
if (Double.doubleToLongBits(this.depthKm) != Double.doubleToLongBits(other.depthKm)) {
10691
return false;
10792
}
108-
if (Double.doubleToLongBits(this.elevationKm) != Double.doubleToLongBits(other.elevationKm)) {
109-
return false;
110-
}
11193
return true;
11294
}
11395

11496
@Override
11597
public String toString() {
116-
return "GeodeticCoordinate{" + "lat=" + lat + ", lon=" + lon + ", depthKm=" + depthKm + ", elevationKm=" + elevationKm + '}';
98+
return "GeodeticCoordinate{" + "lat=" + lat + ", lon=" + lon + ", depthKm=" + depthKm + '}';
11799
}
118100

119101
}

0 commit comments

Comments
 (0)