Skip to content
Snippets Groups Projects
Commit cf2e66ba authored by Powers, Peter M.'s avatar Powers, Peter M.
Browse files

updated lib and other dependencies

parent 502c8802
No related branches found
No related tags found
2 merge requests!128Production Release | nshmp-ws,!127Updated lib and other dependencies
plugins {
id "application"
id "com.diffplug.gradle.spotless" version "${spotlessVersion}"
id "com.diffplug.spotless" version "${spotlessVersion}"
id "com.github.johnrengelman.shadow" version "${shadowVersion}"
id "com.github.node-gradle.node" version "${nodeVersion}"
id "com.github.spotbugs" version "${spotbugsVersion}"
......
githooksVersion = 1.2.0
jacksonVersion = 2.9.0
junitVersion = 5.5.2
junitVersion = 5.8.2
logbackVersion = 1.2.3
micronautVersion = 2.4.1
mnPluginVersion = 1.4.2
nodeVersion = 3.0.1
nshmFaultSectionsTag = v0.1
nshmpLibVersion = 0.4.2
nshmpLibVersion = 0.8.0
nshmpWsUtilsVersion = 0.1.2
shadowVersion = 6.1.0
spotbugsVersion = 4.2.4
spotlessVersion = 4.1.0
spotbugsVersion = 4.7.0
spotlessVersion = 6.0.4
swaggerVersion = 2.1.7
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
......@@ -18,11 +18,14 @@ import java.util.stream.Collectors;
import com.google.common.primitives.Doubles;
import gov.usgs.earthquake.nshmp.Maths;
import gov.usgs.earthquake.nshmp.data.DoubleData;
import gov.usgs.earthquake.nshmp.gmm.Gmm;
import gov.usgs.earthquake.nshmp.gmm.GmmInput;
import gov.usgs.earthquake.nshmp.gmm.GroundMotion;
import gov.usgs.earthquake.nshmp.gmm.GroundMotionModel;
import gov.usgs.earthquake.nshmp.gmm.Imt;
import gov.usgs.earthquake.nshmp.gmm.ScalarGroundMotion;
import gov.usgs.earthquake.nshmp.tree.Branch;
import gov.usgs.earthquake.nshmp.tree.LogicTree;
public class GroundMotions {
......@@ -115,7 +118,7 @@ public class GroundMotions {
GroundMotionModel model = gmm.instance(imt);
for (GmmInput gmmInput : gmmInputs) {
ScalarGroundMotion gm = model.calc(gmmInput);
GroundMotion gm = combine(model.calc(gmmInput));
means.add(gm.mean());
sigmas.add(gm.sigma());
}
......@@ -131,6 +134,30 @@ public class GroundMotions {
xsMap);
}
@Deprecated
static GroundMotion combine(LogicTree<GroundMotion> tree) {
// once GroundMotions in lib is exposed remove this
if (tree.size() == 1) {
return tree.get(0).value();
}
double[] means = tree.stream()
.map(Branch::value)
.mapToDouble(GroundMotion::mean)
.toArray();
double[] sigmas = tree.stream()
.map(Branch::value)
.mapToDouble(GroundMotion::sigma)
.toArray();
double[] weights = tree.stream()
.mapToDouble(Branch::weight)
.toArray();
double mean = DoubleData.weightedSumLn(means, weights);
double sigma = DoubleData.weightedSum(sigmas, weights);
// TODO update NGA-East test results
// double sigma = Maths.srssWeighted(sigmas, weights);
return GroundMotion.create(mean, sigma);
}
/*
* Compute distance metrics for a fault.
*/
......
......@@ -12,9 +12,9 @@ import com.google.common.collect.Maps;
import gov.usgs.earthquake.nshmp.gmm.Gmm;
import gov.usgs.earthquake.nshmp.gmm.GmmInput;
import gov.usgs.earthquake.nshmp.gmm.GroundMotion;
import gov.usgs.earthquake.nshmp.gmm.GroundMotionModel;
import gov.usgs.earthquake.nshmp.gmm.Imt;
import gov.usgs.earthquake.nshmp.gmm.ScalarGroundMotion;
/**
* Entry point for computing deterministic response spectra.
......@@ -46,8 +46,9 @@ public class ResponseSpectra {
* @return a two-element double[] containing the natural log of the median
* ground motion and its standard deviation
*/
@Deprecated
public static double[] groundMotion(Gmm model, Imt imt, GmmInput source) {
ScalarGroundMotion sgm = model.instance(imt).calc(source);
GroundMotion sgm = GroundMotions.combine(model.instance(imt).calc(source));
return new double[] { sgm.mean(), sgm.sigma() };
}
......@@ -71,7 +72,7 @@ public class ResponseSpectra {
Result spectrum = new Result(imts.size());
int i = 0;
for (Imt imt : imts) {
ScalarGroundMotion sgm = model.instance(imt).calc(input);
GroundMotion sgm = GroundMotions.combine(model.instance(imt).calc(input));
spectrum.periods[i] = imt.period();
spectrum.means[i] = sgm.mean();
spectrum.sigmas[i] = sgm.sigma();
......@@ -145,12 +146,12 @@ public class ResponseSpectra {
ImmutableList.Builder<Double> means = ImmutableList.builder();
ImmutableList.Builder<Double> sigmas = ImmutableList.builder();
ScalarGroundMotion pgaGm = gmm.instance(Imt.PGA).calc(input);
GroundMotion pgaGm = GroundMotions.combine(gmm.instance(Imt.PGA).calc(input));
means.add(pgaGm.mean());
sigmas.add(pgaGm.sigma());
for (Imt imt : saImts) {
ScalarGroundMotion sgm = gmm.instance(imt).calc(input);
GroundMotion sgm = GroundMotions.combine(gmm.instance(imt).calc(input));
means.add(sgm.mean());
sigmas.add(sgm.sigma());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment