Skip to content

Commit

Permalink
* This release adds two significant features including the addition o…
Browse files Browse the repository at this point in the history
…f energy calculations and a new data table filter feature

* Energy calculation feature is based on Mayeda, K., and Walter, W. R. (1996), with updates made for CCT
  * Converted the energy calculation algorithm to MKS units
  * Utilized a numerically derived term for the k constant, analytical form derivation in progress
  * Reformulated the p-Wave contribution from a constant of 7%, as in Mayeda, K., and Walter, W. R. (1996), to a derived formula using the MDAC paramaterization based on Walter and Taylor, 2001
* Implementation of energy calculation feature includes the addition of new data columns containing calculation results
* Added total energy calculation values to be displayed in the area directly above spectral plots
* Renamed plot FIT as Mw_coda
* Added a data filter feature that allows users to filter the results displayed in a data table by event id, station etc.
* Updated data tables to show a filter icon in the column headers, which will open the filter dialog
* Included auto-completion and search of filter terms within the filter dialog feature
  • Loading branch information
downiec committed Sep 13, 2021
1 parent 8f6e4b2 commit cde0e0e
Show file tree
Hide file tree
Showing 46 changed files with 17,923 additions and 16,304 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ We don't presently deploy versioned artifacts into a public repository like the
#### **As a single runnable JAR**

```shell
java -jar coda-calibration/calibration-standalone/target/calibration-standalone-1.0.11-runnable.jar
java -jar coda-calibration/calibration-standalone/target/calibration-standalone-1.0.13-runnable.jar
```

#### **GUI alone**

```shell
java -jar coda-calibration/calibration-gui/target/calibration-gui-1.0.11-runnable.jar
java -jar coda-calibration/calibration-gui/target/calibration-gui-1.0.13-runnable.jar
```
#### **Calibration REST service alone**

```shell
java -jar coda-calibration/calibration-service/application/target/application-1.0.11-runnable.jar
java -jar coda-calibration/calibration-service/application/target/application-1.0.13-runnable.jar
```

#### A note about HTTPS
Expand Down
2 changes: 1 addition & 1 deletion calibration-gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>gov.llnl.gnem.apps.coda.calibration</groupId>
<artifactId>coda-calibration</artifactId>
<version>1.0.12</version>
<version>1.0.13</version>
</parent>

<artifactId>calibration-gui</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,21 @@ public abstract class AbstractMeasurementController implements MapListeningContr
@FXML
protected TableColumn<MeasuredMwDetails, String> mwCol;

@FXML
protected TableColumn<MeasuredMwDetails, String> obsEnergyCol;

@FXML
protected TableColumn<MeasuredMwDetails, String> totalEnergyCol;

@FXML
protected TableColumn<MeasuredMwDetails, String> totalEnergyMDACCol;

@FXML
protected TableColumn<MeasuredMwDetails, String> energyRatioCol;

@FXML
protected TableColumn<MeasuredMwDetails, String> energyStressCol;

@FXML
protected TableColumn<MeasuredMwDetails, String> stressCol;

Expand Down Expand Up @@ -196,6 +211,12 @@ public abstract class AbstractMeasurementController implements MapListeningContr
@FXML
protected TextField eventLoc;

@FXML
protected TextField obsTotalEnergy;

@FXML
protected TextField obsEnergy;

protected List<SpectraMeasurement> spectralMeasurements = new ArrayList<>();
private final ObservableList<String> evids = FXCollections.observableArrayList();

Expand Down Expand Up @@ -334,8 +355,14 @@ public void initialize() {

CellBindingUtils.attachTextCellFactories(valMwCol, MeasuredMwDetails::getValMw, dfmt4);
CellBindingUtils.attachTextCellFactories(valStressCol, MeasuredMwDetails::getValApparentStressInMpa, dfmt4);

CellBindingUtils.attachTextCellFactories(measuredMwCol, MeasuredMwDetails::getMw, dfmt4);

CellBindingUtils.attachTextCellFactories(obsEnergyCol, MeasuredMwDetails::getObsEnergy, dfmt4);
CellBindingUtils.attachTextCellFactories(totalEnergyCol, MeasuredMwDetails::getTotalEnergy, dfmt4);
CellBindingUtils.attachTextCellFactories(totalEnergyMDACCol, MeasuredMwDetails::getTotalEnergyMDAC, dfmt4);
CellBindingUtils.attachTextCellFactories(energyRatioCol, MeasuredMwDetails::getEnergyRatio, dfmt4);
CellBindingUtils.attachTextCellFactories(energyStressCol, MeasuredMwDetails::getEnergyStress, dfmt4);

CellBindingUtils.attachTextCellFactories(measuredStressCol, MeasuredMwDetails::getApparentStressInMpa, dfmt4);
CellBindingUtils.attachTextCellFactories(measuredCornerFreqCol, MeasuredMwDetails::getCornerFreq, dfmt4);

Expand Down Expand Up @@ -401,20 +428,27 @@ private void plotSpectra() {
fittingSpectra.add(validationSpectra);
if (filteredMeasurements != null && !filteredMeasurements.isEmpty() && filteredMeasurements.get(0).getWaveform() != null) {
final Event event = filteredMeasurements.get(0).getWaveform().getEvent();
final Spectra fitSpectra = fittingSpectra.get(0);
eventTime.setText(
"Date: "
+ DateTimeFormatter.ISO_INSTANT.format(event.getOriginTime().toInstant())
+ " Julian Day: "
+ TimeT.jdateToTimeT(TimeT.EpochToJdate(event.getOriginTime().toInstant().getEpochSecond())).getJDay());
eventLoc.setText("Lat: " + dfmt4.format(event.getLatitude()) + " Lon: " + dfmt4.format(event.getLongitude()) + " Depth: " + dfmt2.format(event.getDepth()));
obsEnergy.setText("Observed Energy: " + dfmt4.format(fitSpectra.getObsEnergy()) + " J MDAC Energy: " + dfmt4.format(fitSpectra.getlogTotalEnergyMDAC()) + " J");
obsTotalEnergy.setText("Observed Total Energy: " + dfmt4.format(fitSpectra.getLogTotalEnergy()) + " J @ " + dfmt4.format(fitSpectra.getObsAppStress()) + " MPa");
eventTime.setVisible(true);
eventLoc.setVisible(true);
obsEnergy.setVisible(true);
obsTotalEnergy.setVisible(true);
} else {
filteredMeasurements = Collections.emptyList();
}
} else {
eventTime.setVisible(false);
eventLoc.setVisible(false);
obsEnergy.setVisible(false);
obsTotalEnergy.setVisible(false);
filteredMeasurements = spectralMeasurements;
fittingSpectra = null;
}
Expand Down Expand Up @@ -911,7 +945,8 @@ protected void handlePlotObjectClicked(final PlotObjectClick poc, final Function
List<Point2D> points = poc.getPlotPoints();
Set<Waveform> waveforms = new HashSet<>();

//FIXME: This entire scheme is tremendously inefficient and needs a rework at some point.
// FIXME: This entire scheme is tremendously inefficient and needs a rework at
// some point.
for (SpectraPlotController spc : spectraControllers) {
spc.getSpectralPlot().deselectAllPoints();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2021, Lawrence Livermore National Security, LLC. Produced at the Lawrence Livermore National Laboratory
* CODE-743439.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the “Licensee”); you may not use this file except in compliance with the License. You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the license.
*
* This work was performed under the auspices of the U.S. Department of Energy
* by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.
*/
package gov.llnl.gnem.apps.coda.calibration.gui.controllers;

import org.apache.commons.lang3.StringUtils;

import javafx.collections.ObservableList;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseButton;

public class AutoCompleteCombo<T> extends ComboBox<T> {

private ObservableList<T> originalItems;

public AutoCompleteCombo(ObservableList<T> items) {
this.originalItems = items;
this.setEditable(true);
this.getEditor().setOnKeyTyped(e -> handle(e));
this.getEditor().setOnMouseClicked(event -> {
if (event.getButton().equals(MouseButton.PRIMARY) && (event.getClickCount() == 2)) {
return;
}
this.show();
});
this.setItems(originalItems);
};

public void setOriginalItems(ObservableList<T> items) {
originalItems = items;
}

private void handle(KeyEvent event) {
TextField field = this.getEditor();
if (field == null) {
return;
}

final String text = field.getText();
ObservableList<T> filtered = filteredItems(text);

if (this.getSelectionModel().getSelectedItem() != null) {
this.getSelectionModel().clearSelection();
field.setText(text.trim());
field.end();
}

this.setItems(filtered);
this.show();
}

private ObservableList<T> filteredItems(String text) {
if (StringUtils.isBlank(text)) {
return originalItems;
}
ObservableList<T> dropDownItems = originalItems;
if (!originalItems.isEmpty()) {
dropDownItems = originalItems.filtered(data -> {
if (data != null && !StringUtils.isBlank(data.toString())) {
return data.toString().toLowerCase().contains(text.toLowerCase());
}
return false;
});
}

return dropDownItems;
}
}
Loading

0 comments on commit cde0e0e

Please sign in to comment.