From cef48952e83af622cbe0ac9683738c5c495c3eb9 Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Tue, 1 Mar 2022 10:34:03 -0700
Subject: [PATCH] re-enabled damping sigma flag

---
 .../gov/usgs/earthquake/nshmp/calc/CalcConfig.java | 14 ++++++++++++++
 .../earthquake/nshmp/gmm/RezaeianDamping_2014.java |  2 +-
 src/main/resources/calc/calc-config-defaults.json  |  1 +
 .../earthquake/nshmp/calc/CalcConfigTests.java     |  3 +++
 src/test/resources/calc/calc-config-extends.json   |  1 +
 5 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/main/java/gov/usgs/earthquake/nshmp/calc/CalcConfig.java b/src/main/java/gov/usgs/earthquake/nshmp/calc/CalcConfig.java
index b1b08fab..214ac9b5 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/calc/CalcConfig.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/calc/CalcConfig.java
@@ -221,6 +221,13 @@ public final class CalcConfig {
      */
     public final double gmmDampingRatio;
 
+    /**
+     * Whether or not {@link GroundMotionModel} (GMM) sigmas are also modified
+     * according to the Rezaeian et al. (2014) model when applying damping
+     * scaling factors (DSF).
+     */
+    public final boolean gmmDampingSigma;
+
     /**
      * Factor by which the aleatory variability (sigma) for all GMMs should be
      * scaled.
@@ -251,6 +258,7 @@ public final class CalcConfig {
       this.sourceTypes = b.sourceTypes;
       this.vs30s = b.vs30s;
       this.gmmDampingRatio = b.gmmDampingRatio;
+      this.gmmDampingSigma = b.gmmDampingSigma;
       this.gmmSigmaScale = b.gmmSigmaScale;
       this.valueFormat = b.valueFormat;
 
@@ -293,6 +301,7 @@ public final class CalcConfig {
       Set<SourceType> sourceTypes;
       Set<Double> vs30s;
       Double gmmDampingRatio;
+      Boolean gmmDampingSigma;
       Double gmmSigmaScale;
       ValueFormat valueFormat;
       Map<Imt, double[]> customImls;
@@ -312,6 +321,7 @@ public final class CalcConfig {
             RezaeianDamping_2014.DAMPING_RATIO_RANGE,
             "gmmDampingRatio",
             gmmDampingRatio);
+        checkNotNull(gmmDampingSigma);
         checkNotNull(gmmSigmaScale);
         checkInRange(
             Range.closed(0.5, 1.0),
@@ -330,6 +340,7 @@ public final class CalcConfig {
         this.sourceTypes = that.sourceTypes;
         this.vs30s = that.vs30s;
         this.gmmDampingRatio = that.gmmDampingRatio;
+        this.gmmDampingSigma = that.gmmDampingSigma;
         this.gmmSigmaScale = that.gmmSigmaScale;
         this.valueFormat = that.valueFormat;
         this.customImls = that.customImls;
@@ -357,6 +368,9 @@ public final class CalcConfig {
         if (that.gmmDampingRatio != null) {
           this.gmmDampingRatio = that.gmmDampingRatio;
         }
+        if (that.gmmDampingSigma != null) {
+          this.gmmDampingSigma = that.gmmDampingSigma;
+        }
         if (that.gmmSigmaScale != null) {
           this.gmmSigmaScale = that.gmmSigmaScale;
         }
diff --git a/src/main/java/gov/usgs/earthquake/nshmp/gmm/RezaeianDamping_2014.java b/src/main/java/gov/usgs/earthquake/nshmp/gmm/RezaeianDamping_2014.java
index ef957225..212c4dfe 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/gmm/RezaeianDamping_2014.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/gmm/RezaeianDamping_2014.java
@@ -145,7 +145,7 @@ public class RezaeianDamping_2014 {
 
   RezaeianDamping_2014(CalcConfig config) {
     dampingRatio = config.hazard.gmmDampingRatio * 100.0;
-    updateSigma = false; // config.hazard.gmmDampingSigma;
+    updateSigma = config.hazard.gmmDampingSigma;
   }
 
   /**
diff --git a/src/main/resources/calc/calc-config-defaults.json b/src/main/resources/calc/calc-config-defaults.json
index 35ab5ca3..cdf19568 100644
--- a/src/main/resources/calc/calc-config-defaults.json
+++ b/src/main/resources/calc/calc-config-defaults.json
@@ -13,6 +13,7 @@
     "sourceTypes": [],
     "vs30s": [],
     "gmmDampingRatio": 0.05,
+	"gmmDampingSigma": false,
     "gmmSigmaScale": 1.0,
     "valueFormat": "ANNUAL_RATE",
     "customImls": {}
diff --git a/src/test/java/gov/usgs/earthquake/nshmp/calc/CalcConfigTests.java b/src/test/java/gov/usgs/earthquake/nshmp/calc/CalcConfigTests.java
index bc606ae9..d844e0a9 100644
--- a/src/test/java/gov/usgs/earthquake/nshmp/calc/CalcConfigTests.java
+++ b/src/test/java/gov/usgs/earthquake/nshmp/calc/CalcConfigTests.java
@@ -136,6 +136,7 @@ class CalcConfigTests {
     assertEquals(EnumSet.noneOf(TectonicSetting.class), def.tectonicSettings);
     assertEquals(EnumSet.noneOf(SourceType.class), def.tectonicSettings);
     assertEquals(0.05, def.gmmDampingRatio);
+    assertEquals(false, def.gmmDampingSigma);
     assertEquals(ValueFormat.ANNUAL_RATE, def.valueFormat);
 
     Map<Imt, XySequence> imlMap = def.modelCurves();
@@ -257,6 +258,7 @@ class CalcConfigTests {
     assertEquals(EnumSet.of(FAULT, ZONE, SLAB), def.sourceTypes);
     assertEquals(Set.of(260.0, 760.0), def.vs30s);
     assertEquals(0.03, def.gmmDampingRatio);
+    assertEquals(true, def.gmmDampingSigma);
     assertEquals(0.85, def.gmmSigmaScale);
     assertEquals(ValueFormat.POISSON_PROBABILITY, def.valueFormat);
 
@@ -272,6 +274,7 @@ class CalcConfigTests {
     assertEquals(EnumSet.noneOf(SourceType.class), def.tectonicSettings);
     assertEquals(Set.of(), def.vs30s);
     assertEquals(0.05, def.gmmDampingRatio);
+    assertEquals(false, def.gmmDampingSigma);
     assertEquals(1.0, def.gmmSigmaScale);
     assertEquals(ValueFormat.ANNUAL_RATE, def.valueFormat);
   }
diff --git a/src/test/resources/calc/calc-config-extends.json b/src/test/resources/calc/calc-config-extends.json
index 37f44268..e60f3e23 100644
--- a/src/test/resources/calc/calc-config-extends.json
+++ b/src/test/resources/calc/calc-config-extends.json
@@ -9,6 +9,7 @@
     "sourceTypes": [ "FAULT", "ZONE", "SLAB" ],
     "vs30s": [ 260, 760 ],
     "gmmDampingRatio": 0.03,
+    "gmmDampingSigma": true,
     "gmmSigmaScale": 0.85,
     "valueFormat": "POISSON_PROBABILITY",
     "customImls": {
-- 
GitLab