Skip to content

Commit

Permalink
Update to fix a bug when using the measure-mw REST endpoint with pers…
Browse files Browse the repository at this point in the history
…istResults=false.
  • Loading branch information
justinbarno committed Jul 27, 2022
1 parent bb9fc89 commit 2c76231
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 17 deletions.
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.18.1</version>
<version>1.0.18.2</version>
</parent>

<artifactId>calibration-gui</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion calibration-service/calibration-application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>gov.llnl.gnem.apps.coda.calibration</groupId>
<artifactId>calibration-service</artifactId>
<version>1.0.18.1</version>
<version>1.0.18.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion calibration-service/calibration-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>gov.llnl.gnem.apps.coda.calibration</groupId>
<artifactId>calibration-service</artifactId>
<version>1.0.18.1</version>
<version>1.0.18.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion calibration-service/calibration-repository/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>gov.llnl.gnem.apps.coda.calibration</groupId>
<artifactId>calibration-service</artifactId>
<version>1.0.18.1</version>
<version>1.0.18.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion calibration-service/calibration-service-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>gov.llnl.gnem.apps.coda.calibration</groupId>
<artifactId>calibration-service</artifactId>
<version>1.0.18.1</version>
<version>1.0.18.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public interface PeakVelocityMeasurementService extends BaseService<PeakVelocity

public List<PeakVelocityMeasurement> measureVelocities(List<Waveform> allStacks, VelocityConfiguration velocityConfig);

public List<PeakVelocityMeasurement> measureVelocities(List<Waveform> allStacks, VelocityConfiguration velocityConfig, boolean persistResults);

public List<PeakVelocityMeasurementMetadata> findAllMetadataOnly();

public PeakVelocityMeasurementMetadata findByWaveformIdMetadataOnly(Long id);

}
2 changes: 1 addition & 1 deletion calibration-service/calibration-service-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>gov.llnl.gnem.apps.coda.calibration</groupId>
<artifactId>calibration-service</artifactId>
<version>1.0.18.1</version>
<version>1.0.18.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ private MeasuredMwReportByEvent makeMwMeasurements(Long id, boolean autoPickingE
Map<FrequencyBand, SharedFrequencyBandParameters> frequencyBandParameterMap = MetadataUtils.mapSharedParamsToFrequencyBands(sharedParametersService.findAll());

List<Waveform> measStacks = stacks;
List<PeakVelocityMeasurement> velocityMeasured = Optional.ofNullable(peakVelocityMeasurementsService.measureVelocities(measStacks, velocityConfig)).orElseGet(ArrayList::new);
List<PeakVelocityMeasurement> velocityMeasured = Optional.ofNullable(peakVelocityMeasurementsService.measureVelocities(measStacks, velocityConfig, persistResults)).orElseGet(ArrayList::new);

//Offset the coda start picks to the model velocity from the individual peak velocity estimate
velocityMeasured = offsetCodaStarts(velocityMeasured, frequencyBandParameterMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ public List<PeakVelocityMeasurement> findAll(Iterable<Long> ids) {

@Override
public List<PeakVelocityMeasurement> measureVelocities(List<Waveform> allStacks, VelocityConfiguration velocityConfiguration) {
return velocityCalc.computeMaximumVelocity(allStacks, velocityConfiguration);
return measureVelocities(allStacks, velocityConfiguration, true);
}

@Override
public List<PeakVelocityMeasurement> measureVelocities(List<Waveform> allStacks, VelocityConfiguration velocityConfiguration, boolean persistResults) {
return velocityCalc.computeMaximumVelocity(allStacks, velocityConfiguration, persistResults);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ public MaxVelocityCalculator(VelocityConfiguration velConf, WaveformToTimeSeries
this.pickService = pickService;
}

public List<PeakVelocityMeasurement> computeMaximumVelocity(List<Waveform> waveforms, VelocityConfiguration velocityConfiguration, boolean persistResults) {
return computeMaximumVelocity(
waveforms,
getFrequencyBandMap(),
velocityConfiguration.getGroupVelocity1InKmsGtDistance(),
velocityConfiguration.getGroupVelocity2InKmsGtDistance(),
velocityConfiguration.getGroupVelocity1InKmsLtDistance(),
velocityConfiguration.getGroupVelocity2InKmsLtDistance(),
velocityConfiguration.getDistanceThresholdInKm(),
persistResults);
}

public List<PeakVelocityMeasurement> computeMaximumVelocity(List<Waveform> waveforms) {
return computeMaximumVelocity(
waveforms,
Expand All @@ -65,7 +77,8 @@ public List<PeakVelocityMeasurement> computeMaximumVelocity(List<Waveform> wavef
velConf.getGroupVelocity2InKmsGtDistance(),
velConf.getGroupVelocity1InKmsLtDistance(),
velConf.getGroupVelocity2InKmsLtDistance(),
velConf.getDistanceThresholdInKm());
velConf.getDistanceThresholdInKm(),
true);
}

public List<PeakVelocityMeasurement> computeMaximumVelocity(List<Waveform> waveforms, VelocityConfiguration velocityConfiguration) {
Expand All @@ -77,7 +90,8 @@ public List<PeakVelocityMeasurement> computeMaximumVelocity(List<Waveform> wavef
velocityConfiguration.getGroupVelocity2InKmsGtDistance(),
velocityConfiguration.getGroupVelocity1InKmsLtDistance(),
velocityConfiguration.getGroupVelocity2InKmsLtDistance(),
velocityConfiguration.getDistanceThresholdInKm());
velocityConfiguration.getDistanceThresholdInKm(),
true);
} else {
return computeMaximumVelocity(waveforms);
}
Expand All @@ -88,7 +102,7 @@ private Map<FrequencyBand, SharedFrequencyBandParameters> getFrequencyBandMap()
}

private List<PeakVelocityMeasurement> computeMaximumVelocity(List<Waveform> waveforms, Map<FrequencyBand, SharedFrequencyBandParameters> frequencyBands, double gv1GtDistanceThreshold,
double gv2GtDistanceThreshold, double gv1LtDistanceThreshold, double gv2LtDistanceThreshold, double thresholdInKm) {
double gv2GtDistanceThreshold, double gv1LtDistanceThreshold, double gv2LtDistanceThreshold, double thresholdInKm, boolean savePicks) {
return waveforms.stream().parallel().map(rawWaveform -> {
if (Thread.currentThread().isInterrupted()) {
return null;
Expand Down Expand Up @@ -156,7 +170,7 @@ private List<PeakVelocityMeasurement> computeMaximumVelocity(List<Waveform> wave
//Drop old CS picks if there are any
rawWaveform.setAssociatedPicks(rawWaveform.getAssociatedPicks().stream().filter(p -> !PICK_TYPES.CS.getPhase().equals(p.getPickName())).collect(Collectors.toList()));

if (!hasUserStartPick) {
if (savePicks && !hasUserStartPick) {
WaveformPick startPick = new WaveformPick().setPickType(PICK_TYPES.CS.name())
.setPickName(PICK_TYPES.CS.getPhase())
.setWaveform(rawWaveform)
Expand Down
2 changes: 1 addition & 1 deletion calibration-service/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.18.1</version>
<version>1.0.18.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion calibration-standalone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>gov.llnl.gnem.apps.coda.calibration</groupId>
<artifactId>coda-calibration</artifactId>
<version>1.0.18.1</version>
<version>1.0.18.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion externals/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>gov.llnl.gnem.apps.coda.calibration</groupId>
<artifactId>coda-calibration</artifactId>
<version>1.0.18.1</version>
<version>1.0.18.2</version>
</parent>

<artifactId>externals</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion mapping/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>gov.llnl.gnem.apps.coda.calibration</groupId>
<artifactId>coda-calibration</artifactId>
<version>1.0.18.1</version>
<version>1.0.18.2</version>
</parent>

<groupId>gov.llnl.gnem.apps.coda.common</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>gov.llnl.gnem.apps.coda.calibration</groupId>
<artifactId>coda-calibration</artifactId>
<version>1.0.18.1</version>
<version>1.0.18.2</version>
<name>coda-calibration</name>

<packaging>pom</packaging>
Expand Down

0 comments on commit 2c76231

Please sign in to comment.