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

updated combined gmm to return tree

parent 58f500b4
No related branches found
No related tags found
1 merge request!231Gmm cleaning
......@@ -5,6 +5,7 @@ import static gov.usgs.earthquake.nshmp.gmm.Gmm.ASK_14;
import static gov.usgs.earthquake.nshmp.gmm.Gmm.ASK_14_BASIN;
import static gov.usgs.earthquake.nshmp.gmm.Gmm.ATKINSON_08_PRIME;
import static gov.usgs.earthquake.nshmp.gmm.Gmm.ATKINSON_10;
import static gov.usgs.earthquake.nshmp.gmm.Gmm.BCHYDRO_12_SLAB;
import static gov.usgs.earthquake.nshmp.gmm.Gmm.BSSA_14;
import static gov.usgs.earthquake.nshmp.gmm.Gmm.BSSA_14_BASIN;
import static gov.usgs.earthquake.nshmp.gmm.Gmm.CAMPBELL_03;
......@@ -23,12 +24,12 @@ import static gov.usgs.earthquake.nshmp.gmm.Gmm.SILVA_02;
import static gov.usgs.earthquake.nshmp.gmm.Gmm.SOMERVILLE_01;
import static gov.usgs.earthquake.nshmp.gmm.Gmm.TORO_97_MW;
import static gov.usgs.earthquake.nshmp.gmm.Gmm.TP_05;
import static gov.usgs.earthquake.nshmp.gmm.Gmm.WONG_15;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import com.google.common.collect.ImmutableMap;
import gov.usgs.earthquake.nshmp.gmm.GmmInput.Constraints;
import gov.usgs.earthquake.nshmp.tree.LogicTree;
......@@ -41,44 +42,34 @@ import gov.usgs.earthquake.nshmp.tree.LogicTree;
class CombinedGmm implements GroundMotionModel {
private static final String NAME = "Combined: ";
private final Map<GroundMotionModel, Double> gmms;
private final Map<Gmm, Double> gmms;
private final Imt imt;
/* Supply map of ground motion models initialized to the required IMT. */
private CombinedGmm(Imt imt, Map<Gmm, Double> gmms) {
this.gmms = instancesForImt(imt, gmms);
this.gmms = gmms;
this.imt = imt;
}
@Override
public LogicTree<GroundMotion> calc(GmmInput in) {
Map<GroundMotion, Double> sgms = gmms.entrySet().stream()
.collect(Collectors.toMap(
entry -> GroundMotions.combine(entry.getKey().calc(in)),
Map.Entry::getValue));
/*
* Mean values are converted to linear space for combining and returned to
* natural log space upon return.
*/
double μ = sgms.entrySet().stream()
.collect(Collectors.summingDouble(
entry -> Math.exp(entry.getKey().mean()) * entry.getValue()));
double σ = sgms.entrySet().stream()
.collect(Collectors.summingDouble(
entry -> entry.getKey().sigma() * entry.getValue()));
return GroundMotions.createTree(Math.log(μ), σ);
LogicTree.Builder<GroundMotion> builder = LogicTree.builder(NAME);
gmms.keySet().forEach(key -> builder.addBranch(
key.name(),
GroundMotions.combine(key.instance(imt).calc(in)),
gmms.get(key)));
return builder.build();
}
static Map<GroundMotionModel, Double> instancesForImt(
static Map<Gmm, GroundMotionModel> instancesForImt(
Imt imt,
Map<Gmm, Double> gmms) {
return gmms.entrySet().stream()
.collect(Collectors.toMap(
entry -> entry.getKey().instance(imt),
Map.Entry::getValue));
Entry::getKey,
entry -> entry.getKey().instance(imt)));
}
/*
......@@ -87,11 +78,10 @@ class CombinedGmm implements GroundMotionModel {
* intersection of all support IMTs.
*/
private static final Map<Gmm, Double> HI_DEEP_2021 = ImmutableMap.<Gmm, Double> builder()
.put(ATKINSON_10, 0.4)
.put(Gmm.BCHYDRO_12_SLAB, 0.4)
.put(Gmm.WONG_15, 0.2)
.build();
private static final Map<Gmm, Double> HI_DEEP_2021 = Map.of(
ATKINSON_10, 0.4,
BCHYDRO_12_SLAB, 0.4,
WONG_15, 0.2);
static final class HawaiiDeep2021 extends CombinedGmm {
......@@ -104,13 +94,12 @@ class CombinedGmm implements GroundMotionModel {
}
}
private static final Map<Gmm, Double> HI_SHALLOW_2021 = ImmutableMap.<Gmm, Double> builder()
.put(ATKINSON_10, 0.2)
.put(ASK_14, 0.2)
.put(BSSA_14, 0.2)
.put(CB_14, 0.2)
.put(CY_14, 0.2)
.build();
private static final Map<Gmm, Double> HI_SHALLOW_2021 = Map.of(
ATKINSON_10, 0.2,
ASK_14, 0.2,
BSSA_14, 0.2,
CB_14, 0.2,
CY_14, 0.2);
static final class HawaiiShallow2021 extends CombinedGmm {
......@@ -123,17 +112,16 @@ class CombinedGmm implements GroundMotionModel {
}
}
static final Map<Gmm, Double> CEUS_2014_FAULT = ImmutableMap.<Gmm, Double> builder()
.put(AB_06_PRIME, 0.22)
.put(ATKINSON_08_PRIME, 0.08)
.put(CAMPBELL_03, 0.11)
.put(FRANKEL_96, 0.06)
.put(PEZESHK_11, 0.15)
.put(SILVA_02, 0.06)
.put(SOMERVILLE_01, 0.1)
.put(TP_05, 0.11)
.put(TORO_97_MW, 0.11)
.build();
static final Map<Gmm, Double> CEUS_2014_FAULT = Map.of(
AB_06_PRIME, 0.22,
ATKINSON_08_PRIME, 0.08,
CAMPBELL_03, 0.11,
FRANKEL_96, 0.06,
PEZESHK_11, 0.15,
SILVA_02, 0.06,
SOMERVILLE_01, 0.1,
TP_05, 0.11,
TORO_97_MW, 0.11);
/* Need to allow Vs30=3000 through for comparison plots. */
private static final Constraints CEUS_2014_CONSTRAINTS = Constraints.builder()
......@@ -160,10 +148,9 @@ class CombinedGmm implements GroundMotionModel {
}
/* 5.0 */
private static final Map<Gmm, Double> CEUS_2018 = ImmutableMap.<Gmm, Double> builder()
.put(NGA_EAST_USGS, 0.667)
.put(NGA_EAST_USGS_SEEDS, 0.333)
.build();
private static final Map<Gmm, Double> CEUS_2018 = Map.of(
NGA_EAST_USGS, 0.667,
NGA_EAST_USGS_SEEDS, 0.333);
static final class Ceus2018 extends CombinedGmm {
......@@ -177,10 +164,9 @@ class CombinedGmm implements GroundMotionModel {
}
/* 5.0 Gulf Coast */
private static final Map<Gmm, Double> CEUS_2018_CPA = ImmutableMap.<Gmm, Double> builder()
.put(NGA_EAST_USGS_CPA, 0.667)
.put(NGA_EAST_USGS_SEEDS_CPA, 0.333)
.build();
private static final Map<Gmm, Double> CEUS_2018_CPA = Map.of(
NGA_EAST_USGS_CPA, 0.667,
NGA_EAST_USGS_SEEDS_CPA, 0.333);
static final class Ceus2018Cpa extends CombinedGmm {
......@@ -193,13 +179,12 @@ class CombinedGmm implements GroundMotionModel {
}
}
private static final Map<Gmm, Double> WUS_2014_4P1 = ImmutableMap.<Gmm, Double> builder()
.put(ASK_14, 0.22)
.put(BSSA_14, 0.22)
.put(CB_14, 0.22)
.put(CY_14, 0.22)
.put(IDRISS_14, 0.12)
.build();
private static final Map<Gmm, Double> WUS_2014_4P1 = Map.of(
ASK_14, 0.22,
BSSA_14, 0.22,
CB_14, 0.22,
CY_14, 0.22,
IDRISS_14, 0.12);
/* 4.1 */
static final class Wus2014_4p1 extends CombinedGmm {
......@@ -213,12 +198,11 @@ class CombinedGmm implements GroundMotionModel {
}
}
private static final Map<Gmm, Double> WUS_2014_4P2 = ImmutableMap.<Gmm, Double> builder()
.put(ASK_14, 0.25)
.put(BSSA_14, 0.25)
.put(CB_14, 0.25)
.put(CY_14, 0.25)
.build();
private static final Map<Gmm, Double> WUS_2014_4P2 = Map.of(
ASK_14, 0.25,
BSSA_14, 0.25,
CB_14, 0.25,
CY_14, 0.25);
/* 4.2 */
static final class Wus2014_4p2 extends CombinedGmm {
......@@ -232,12 +216,11 @@ class CombinedGmm implements GroundMotionModel {
}
}
private static final Map<Gmm, Double> WUS_2018 = ImmutableMap.<Gmm, Double> builder()
.put(ASK_14_BASIN, 0.25)
.put(BSSA_14_BASIN, 0.25)
.put(CB_14_BASIN, 0.25)
.put(CY_14_BASIN, 0.25)
.build();
private static final Map<Gmm, Double> WUS_2018 = Map.of(
ASK_14_BASIN, 0.25,
BSSA_14_BASIN, 0.25,
CB_14_BASIN, 0.25,
CY_14_BASIN, 0.25);
/* No Idriss. */
static final class Wus2018 extends CombinedGmm {
......
......@@ -49,7 +49,6 @@ class GroundMotions {
.mapToDouble(Branch::weight)
.toArray();
double mean = DoubleData.weightedSumLn(means, weights);
// double sigma = DoubleData.weightedSum(sigmas, weights);
double sigma = Maths.srssWeighted(sigmas, weights);
return GroundMotion.create(mean, 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