Skip to content

Commit

Permalink
* Updated to Spring 6
Browse files Browse the repository at this point in the history
* Spectral inversion results in CERT are now plotted as misfit in mean absolute deviation
* CERT spectra now includes calculated HFL/LFL values for inversions and, if available, CCT magnitudes HFL/LFL reference lines
* Added function to set user-specified high and low frequency asymptotes to the spectral ratio plot and include them in the exported report if they are available. These buttons can be found in the modebar on the top-right of the spectra ratio plot.
* Updated the spectra download functions so that event report information, including the inversion results and user set frequency values will be exported in the .json file.
* Changes to validation events to remove them also from the site correction re-averaging during calibrations.
* Add path corrected plot back in to site tab, co-located with the raw amplitude plot.
* Plots for the CERT module have been updated and reworked in many cases to clean up and/or add additional information or interactivity.
  • Loading branch information
justinbarno committed Aug 6, 2024
1 parent 63a3585 commit d9ade7d
Show file tree
Hide file tree
Showing 1,621 changed files with 199,316 additions and 438,651 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ mvn clean install
#### **As a single runnable JAR**

```shell
java -jar coda-calibration/calibration-standalone/target/calibration-standalone-1.0.20-runnable.jar
java -jar coda-calibration/calibration-standalone/target/calibration-standalone-1.0.22-runnable.jar
```

#### **GUI alone**

```shell
java -jar coda-calibration/calibration-gui/target/calibration-gui-1.0.20-runnable.jar
java -jar coda-calibration/calibration-gui/target/calibration-gui-1.0.22-runnable.jar
```

#### **Calibration REST service alone**

```shell
java -jar coda-calibration/calibration-service/application/target/application-1.0.20-runnable.jar
java -jar coda-calibration/calibration-service/application/target/application-1.0.22-runnable.jar
```

#### A note about HTTPS
Expand Down
24 changes: 14 additions & 10 deletions calibration-gui/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="https://maven.apache.org/POM/4.0.0"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>gov.llnl.gnem.apps.coda.calibration</groupId>
<artifactId>coda-calibration</artifactId>
<version>1.0.21.1</version>
<version>1.0.22</version>
</parent>

<artifactId>calibration-gui</artifactId>
Expand Down Expand Up @@ -52,10 +54,6 @@
<groupId>gov.llnl.gnem.apps.coda.calibration</groupId>
<artifactId>calibration-model</artifactId>
<exclusions>
<exclusion>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
</exclusion>
<exclusion>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
Expand All @@ -69,8 +67,8 @@
<artifactId>spring-aspects</artifactId>
</exclusion>
<exclusion>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.data</groupId>
Expand All @@ -95,7 +93,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
Expand Down Expand Up @@ -177,6 +174,8 @@
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<!-- Tells Eclipses m2e adapter to only execute this when using the maven->update project button -->
<?m2eexecute onConfiguration?>
<goals>
<goal>unpack</goal>
</goals>
Expand Down Expand Up @@ -207,6 +206,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -221,7 +224,8 @@
<Implementation-Build>${buildNumber}</Implementation-Build>
<Build-Branch>${scmBranch}</Build-Branch>
<Build-Timestamp>${maven.build.timestamp}</Build-Timestamp>
<JavaFX-Preloader-Class>gov.llnl.gnem.apps.coda.calibration.gui.CodaGuiPreloader</JavaFX-Preloader-Class>
<JavaFX-Preloader-Class>
gov.llnl.gnem.apps.coda.calibration.gui.CodaGuiPreloader</JavaFX-Preloader-Class>
</manifestEntries>
</archive>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;

import javax.annotation.PreDestroy;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;

Expand Down Expand Up @@ -80,6 +79,7 @@
import gov.llnl.gnem.apps.coda.envelope.gui.LoadRatioEventsGuiController;
import gov.llnl.gnem.apps.coda.spectra.gui.RatioStatusProgressListener;
import gov.llnl.gnem.apps.coda.spectra.gui.SpectraRatioGuiController;
import jakarta.annotation.PreDestroy;
import javafx.application.Platform;
import javafx.concurrent.Worker;
import javafx.event.ActionEvent;
Expand Down Expand Up @@ -112,7 +112,7 @@ public class CodaGuiController {

private static final String SCREENSHOT_TITLE = "CERT_Screenshot";

private static final String ABOUT_TEXT = "Version 1.0.21";
private static final String ABOUT_TEXT = "Version 1.0.22";

@FXML
private Node rootElement;
Expand Down Expand Up @@ -313,17 +313,21 @@ private void changeAppMode() {
refreshButton.setGraphic(refreshLabel);
});
} else {
activeTabRefresh = data.getRefreshFunction();

spectraGui.loadEnvelopes();
siteTab.setOnSelectionChanged(e -> {
if (siteTab.isSelected()) {
activeTabRefresh = eventTableRefreshFunction;
activeTabRefresh.run();
activeTabScreenshot = basicPngScreenshot(siteTab);
} else {
siteTab.setGraphic(null);
}
});

Platform.runLater(() -> {
dataTab.setGraphic(activeMapIcon);
mainTabPane.getTabs().remove(shapeTab);
mainTabPane.getTabs().remove(pathTab);
mainTabPane.getTabs().remove(measuredMwsTab);
Expand Down Expand Up @@ -509,7 +513,7 @@ private void runCalibration() {

@FXML
private void measureMws() {
measuredMws.getRefreshFunction().run();
Platform.runLater(measuredMws::reload);
}

@FXML
Expand Down Expand Up @@ -550,12 +554,8 @@ public void initialize() {
snapshotButton.setGraphic(makeSnapshotLabel());
snapshotButton.setContentDisplay(ContentDisplay.CENTER);

addEnabledTabListeners(dataTab, data);

activeTabScreenshot = folder -> SnapshotUtils.writePng(folder, new Pair<>(dataTab.getText(), dataTab.getContent()));

data.setVisible(true);

paramTab.setOnSelectionChanged(e -> {
if (paramTab.isSelected()) {
cctMapController.clearIcons();
Expand All @@ -565,6 +565,9 @@ public void initialize() {
}
});

data.setVisible(true);
addEnabledTabListeners(dataTab, data);

if (GuiApplication.getStartupMode() == ApplicationMode.CCT) {
dataTab.setGraphic(activeMapIcon);
addEnabledTabListeners(shapeTab, shape);
Expand All @@ -575,12 +578,14 @@ public void initialize() {
siteTab.setOnSelectionChanged(e -> {
if (siteTab.isSelected()) {
activeTabRefresh = eventTableRefreshFunction;
activeTabRefresh.run();
activeTabScreenshot = basicPngScreenshot(siteTab);
} else {
siteTab.setGraphic(null);
}
});
Platform.runLater(() -> {
dataTab.setGraphic(activeMapIcon);
mainTabPane.getTabs().remove(shapeTab);
mainTabPane.getTabs().remove(pathTab);
mainTabPane.getTabs().remove(measuredMwsTab);
Expand Down Expand Up @@ -657,6 +662,9 @@ private Consumer<File> basicPngScreenshot(Tab tab) {
@FXML
private void refreshTab(ActionEvent e) {
activeTabRefresh.run();
if (rootElement.getParent() != null) {
rootElement.getParent().requestLayout();
}
}

@FXML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,13 @@

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Locale;
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;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -43,6 +38,7 @@
import gov.llnl.gnem.apps.coda.calibration.gui.events.CalibrationStageShownEvent;
import gov.llnl.gnem.apps.coda.common.gui.SimpleGuiPreloader;
import gov.llnl.gnem.apps.coda.common.gui.util.CommonGuiUtils;
import jakarta.annotation.PostConstruct;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
Expand Down Expand Up @@ -137,43 +133,14 @@ public void start(Stage primaryStage) throws Exception {
Hooks.onOperatorDebug();
}

try {
Class<GuiApplication> clazz = GuiApplication.class;
String className = clazz.getSimpleName() + ".class";
String classPath = clazz.getResource(className).toString();
String baseTitle = "";

if (GuiApplication.getStartupMode() == ApplicationMode.CCT) {
baseTitle = CCT_TITLE;
} else {
baseTitle = CERT_TITLE;
}

if (classPath.startsWith("jar")) {
String manifestPath = classPath.substring(0, classPath.indexOf('!') + 1) + "/META-INF/MANIFEST.MF";
Manifest mf = new Manifest(new URL(manifestPath).openStream());
Attributes atts = mf.getMainAttributes();
// Put this info in the log to help with analysis
log.debug(
"Version:{} Commit:{} Branch:{} By:{} at {}",
atts.getValue("Implementation-Version"),
atts.getValue("Implementation-Build"),
atts.getValue("Build-Branch"),
atts.getValue("Built-By"),
atts.getValue("Build-Timestamp"));
// Update the title bar
baseTitle += " Built at " + atts.getValue("Build-Timestamp");
} else {
// Class not from JAR
log.debug("{} not running from a jar.", baseTitle);
}
props.setBaseTitle(baseTitle);
} catch (IOException e) {
// should never happen...
log.error("Failed initializing!", e);
String baseTitle = "";
if (GuiApplication.getStartupMode() == ApplicationMode.CCT) {
baseTitle = CCT_TITLE;
} else {
baseTitle = CERT_TITLE;
}

Platform.setImplicitExit(true);
props.setBaseTitle(baseTitle);
FXMLLoader fxmlLoader = null;

if (startupMode == ApplicationMode.CERT) {
Expand All @@ -199,7 +166,6 @@ public void start(Stage primaryStage) throws Exception {
}

static public void changeApplicationMode() {

if (GuiApplication.getStartupMode() == ApplicationMode.CCT) {
GuiApplication.startupMode = ApplicationMode.CERT;
} else {
Expand All @@ -224,6 +190,7 @@ static public void changeApplicationMode() {
try {
Parent root = fxmlLoader.load();
Platform.runLater(() -> {
Font.loadFont(GuiApplication.class.getResource("/fxml/MaterialIcons-Regular.ttf").toExternalForm(), 18);
primaryStage.setTitle(props.getBaseTitle());
Scene scene = new Scene(root, props.getHeight(), props.getWidth());
primaryStage.setScene(scene);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;

import gov.llnl.gnem.apps.coda.calibration.model.domain.SiteFrequencyBandParameters;
import gov.llnl.gnem.apps.coda.calibration.model.domain.SpectraMeasurementMetadata;
Expand All @@ -43,6 +44,7 @@ public class WebfluxConfig {
@Autowired
public WebfluxConfig(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
this.objectMapper.registerModule(new Jdk8Module());
this.objectMapper.addMixIn(SharedFrequencyBandParameters.class, SharedFrequencyBandParametersJsonMixin.class);
this.objectMapper.addMixIn(SiteFrequencyBandParameters.class, SiteFrequencyBandParametersJsonMixin.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ protected void reloadData() {
for (final SpectraMeasurement meas : spectralMeasurements) {
final String evid = meas.getWaveform().getEvent().getEventId();
final Double freq = centerFreq(meas.getWaveform());
evidStats.computeIfAbsent(evid, key -> new HashMap<>()).computeIfAbsent(freq, key -> new SummaryStatistics()).addValue(meas.getPathAndSiteCorrected());
evidStats.computeIfAbsent(evid, key -> new HashMap<>()).computeIfAbsent(freq, key -> new SummaryStatistics()).addValue(meas.getPathAndSiteCorrected() - 7.0);
}

for (final Map<Double, SummaryStatistics> freqStats : evidStats.values()) {
Expand Down Expand Up @@ -1048,7 +1048,7 @@ private List<EventSpectraReport> getFormattedValues(String eventId, List<Spectra
if (!eventId.equalsIgnoreCase("All")) {
filteredMeasurements = filterToEvent(eventId, measurements);
}
Map<String, Map<Double, Double>> averageValues = new HashMap<>();
Map<String, Map<Double, SummaryStatistics>> averageValues = new HashMap<>();
for (SpectraMeasurement meas : filteredMeasurements) {
String key = meas.getWaveform().getEvent().getEventId()
+ "-"
Expand All @@ -1063,17 +1063,20 @@ private List<EventSpectraReport> getFormattedValues(String eventId, List<Spectra
new ArrayList<>()));

Double freq = centerFreq(meas.getWaveform());
valuesMap.get(key).add(new Pair<>(freq, meas.getPathAndSiteCorrected()));
averageValues.computeIfAbsent(meas.getWaveform().getEvent().getEventId(), k -> new TreeMap<>()).merge(freq, meas.getPathAndSiteCorrected(), (l, r) -> (l + r) / 2.0);
valuesMap.get(key).add(new Pair<>(freq, meas.getPathAndSiteCorrected() - 7.0));
averageValues.computeIfAbsent(meas.getWaveform().getEvent().getEventId(), k -> new TreeMap<>()).computeIfAbsent(freq, x -> {
SummaryStatistics sum = new SummaryStatistics();
return sum;
}).addValue(meas.getPathAndSiteCorrected() - 7.0);
}

for (Entry<String, Map<Double, Double>> average : averageValues.entrySet()) {
for (Entry<String, Map<Double, SummaryStatistics>> average : averageValues.entrySet()) {
valuesMap.put(
"Average-" + average.getKey(),
new EventSpectraReport(average.getKey(),
null,
"Average",
average.getValue().entrySet().stream().map(e -> new Pair<>(e.getKey(), e.getValue())).collect(Collectors.toList())));
average.getValue().entrySet().stream().map(e -> new Pair<>(e.getKey(), e.getValue().getMean())).collect(Collectors.toList())));
}
}
return new ArrayList<>(valuesMap.values());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.w3c.dom.events.Event;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.eventbus.EventBus;
Expand All @@ -46,6 +45,7 @@
import gov.llnl.gnem.apps.coda.calibration.model.domain.ValidationMwParameters;
import gov.llnl.gnem.apps.coda.calibration.model.domain.VelocityConfiguration;
import gov.llnl.gnem.apps.coda.common.gui.converters.api.FileToWaveformConverter;
import gov.llnl.gnem.apps.coda.common.model.domain.Event;
import gov.llnl.gnem.apps.coda.common.model.domain.SharedFrequencyBandParameters;
import reactor.core.publisher.Mono;

Expand Down
Loading

0 comments on commit d9ade7d

Please sign in to comment.