From 7bee06e1063852e3bc011b1123e5dbfc81ff974a Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Mon, 9 Dec 2024 11:56:26 -0700
Subject: [PATCH] added prvi coeff ref; simplified coeff constructor

---
 .../nshmp/gmm/AbrahamsonEtAl_2014.java        |  9 ++--
 .../nshmp/gmm/AbrahamsonGulerce_2020.java     | 13 +++---
 .../earthquake/nshmp/gmm/BooreEtAl_2014.java  | 11 +++--
 .../nshmp/gmm/CampbellBozorgnia_2014.java     | 11 +++--
 .../nshmp/gmm/ChiouYoungs_2014.java           |  9 ++--
 .../earthquake/nshmp/gmm/KuehnEtAl_2020.java  | 21 +++++----
 .../earthquake/nshmp/gmm/ParkerEtAl_2020.java | 45 ++++++++++++++++---
 7 files changed, 83 insertions(+), 36 deletions(-)

diff --git a/src/main/java/gov/usgs/earthquake/nshmp/gmm/AbrahamsonEtAl_2014.java b/src/main/java/gov/usgs/earthquake/nshmp/gmm/AbrahamsonEtAl_2014.java
index 45a5e060..3d159789 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/gmm/AbrahamsonEtAl_2014.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/gmm/AbrahamsonEtAl_2014.java
@@ -73,6 +73,7 @@ public class AbrahamsonEtAl_2014 implements GroundMotionModel {
       .build();
 
   static final CoefficientContainer COEFFS = new CoefficientContainer("ASK14.csv");
+  static final CoefficientContainer COEFFS_PRVI = new CoefficientContainer("ASK14_PRVI.csv");
 
   private static final double A3 = 0.275;
   private static final double A4 = -0.1;
@@ -114,9 +115,11 @@ public class AbrahamsonEtAl_2014 implements GroundMotionModel {
     // Japan model
     // final double a25, a28, a29, a31, a36, a37, a38, a39, a40, a41, a42;
 
-    Coefficients(Imt imt, CoefficientContainer cc) {
+    Coefficients(Imt imt) {
+
       this.imt = imt;
-      Map<String, Double> coeffs = cc.get(imt);
+      Map<String, Double> coeffs = COEFFS.get(imt);
+
       a1 = coeffs.get("a1");
       a2 = coeffs.get("a2");
       a6 = coeffs.get("a6");
@@ -150,7 +153,7 @@ public class AbrahamsonEtAl_2014 implements GroundMotionModel {
   private final Coefficients coeffs;
 
   AbrahamsonEtAl_2014(Imt imt) {
-    coeffs = new Coefficients(imt, COEFFS);
+    coeffs = new Coefficients(imt);
   }
 
   @Override
diff --git a/src/main/java/gov/usgs/earthquake/nshmp/gmm/AbrahamsonGulerce_2020.java b/src/main/java/gov/usgs/earthquake/nshmp/gmm/AbrahamsonGulerce_2020.java
index f64f389c..f8ad6f86 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/gmm/AbrahamsonGulerce_2020.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/gmm/AbrahamsonGulerce_2020.java
@@ -123,6 +123,7 @@ public abstract class AbrahamsonGulerce_2020 implements GroundMotionModel {
       .build();
 
   static final CoefficientContainer COEFFS = new CoefficientContainer("AG20.csv");
+  static final CoefficientContainer COEFFS_PRVI = new CoefficientContainer("AG20_PRVI.csv");
   static final CoefficientContainer COEFFS_AK_BIAS =
       new CoefficientContainer("nga-sub-ak-interface-bias-corr.csv");
 
@@ -151,11 +152,10 @@ public abstract class AbrahamsonGulerce_2020 implements GroundMotionModel {
 
     Coefficients(
         Imt imt,
-        CoefficientContainer cc,
-        CoefficientContainer ccBias,
         SubductionZone zone) {
+
       this.imt = imt;
-      Map<String, Double> coeffs = cc.get(imt);
+      Map<String, Double> coeffs = COEFFS.get(imt);
 
       /* Regional adjustments (Global) */
       double a1r = coeffs.get("a1");
@@ -219,8 +219,7 @@ public abstract class AbrahamsonGulerce_2020 implements GroundMotionModel {
        * Average bias-correction for NGA-Subduction global interface models in
        * Alaska NSHM.
        */
-      Map<String, Double> coeffsBias = ccBias.get(imt);
-      correctionAK = coeffsBias.get("bias_ak");
+      correctionAK = COEFFS_AK_BIAS.get(imt).get("bias_ak");
     }
   }
 
@@ -230,8 +229,8 @@ public abstract class AbrahamsonGulerce_2020 implements GroundMotionModel {
 
   AbrahamsonGulerce_2020(Imt imt, Gmm subtype, SubductionZone zone) {
     this.subtype = subtype;
-    coeffs = new Coefficients(imt, COEFFS, COEFFS_AK_BIAS, zone);
-    coeffsPGA = new Coefficients(PGA, COEFFS, COEFFS_AK_BIAS, zone);
+    coeffs = new Coefficients(imt, zone);
+    coeffsPGA = new Coefficients(PGA, zone);
   }
 
   @Override
diff --git a/src/main/java/gov/usgs/earthquake/nshmp/gmm/BooreEtAl_2014.java b/src/main/java/gov/usgs/earthquake/nshmp/gmm/BooreEtAl_2014.java
index ace03643..8a656896 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/gmm/BooreEtAl_2014.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/gmm/BooreEtAl_2014.java
@@ -67,6 +67,7 @@ public class BooreEtAl_2014 implements GroundMotionModel {
       .build();
 
   static final CoefficientContainer COEFFS = new CoefficientContainer("BSSA14.csv");
+  static final CoefficientContainer COEFFS_PRVI = new CoefficientContainer("BSSA14_PRVI.csv");
 
   private static final double A = pow(570.94, 4);
   private static final double B = pow(1360, 4) + A;
@@ -94,9 +95,11 @@ public class BooreEtAl_2014 implements GroundMotionModel {
     // unused regional coeffs
     // double Dc3CnTr, Dc3ItJp;
 
-    Coefficients(Imt imt, CoefficientContainer cc) {
+    Coefficients(Imt imt) {
+
       this.imt = imt;
-      Map<String, Double> coeffs = cc.get(imt);
+      Map<String, Double> coeffs = COEFFS.get(imt);
+
       e0 = coeffs.get("e0");
       e1 = coeffs.get("e1");
       e2 = coeffs.get("e2");
@@ -133,8 +136,8 @@ public class BooreEtAl_2014 implements GroundMotionModel {
   private final Coefficients coeffsPGA;
 
   BooreEtAl_2014(Imt imt) {
-    coeffs = new Coefficients(imt, COEFFS);
-    coeffsPGA = new Coefficients(PGA, COEFFS);
+    coeffs = new Coefficients(imt);
+    coeffsPGA = new Coefficients(PGA);
   }
 
   @Override
diff --git a/src/main/java/gov/usgs/earthquake/nshmp/gmm/CampbellBozorgnia_2014.java b/src/main/java/gov/usgs/earthquake/nshmp/gmm/CampbellBozorgnia_2014.java
index 67b5f314..c927084a 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/gmm/CampbellBozorgnia_2014.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/gmm/CampbellBozorgnia_2014.java
@@ -68,6 +68,7 @@ public class CampbellBozorgnia_2014 implements GroundMotionModel {
   static final String NAME = "Campbell & Bozorgnia (2014)";
 
   static final CoefficientContainer COEFFS = new CoefficientContainer("CB14.csv");
+  static final CoefficientContainer COEFFS_PRVI = new CoefficientContainer("CB14_PRVI.csv");
 
   /*
    * Developer notes:
@@ -113,9 +114,11 @@ public class CampbellBozorgnia_2014 implements GroundMotionModel {
     // unused regional and other coeffs
     // double c15, Dc20_CA, Dc20_JP, Dc20_CH, phiC;
 
-    Coefficients(Imt imt, CoefficientContainer cc) {
+    Coefficients(Imt imt) {
+
       this.imt = imt;
-      Map<String, Double> coeffs = cc.get(imt);
+      Map<String, Double> coeffs = COEFFS.get(imt);
+
       c0 = coeffs.get("c0");
       c1 = coeffs.get("c1");
       c2 = coeffs.get("c2");
@@ -155,8 +158,8 @@ public class CampbellBozorgnia_2014 implements GroundMotionModel {
   private final Coefficients coeffsPGA;
 
   CampbellBozorgnia_2014(Imt imt) {
-    coeffs = new Coefficients(imt, COEFFS);
-    coeffsPGA = new Coefficients(PGA, COEFFS);
+    coeffs = new Coefficients(imt);
+    coeffsPGA = new Coefficients(PGA);
   }
 
   @Override
diff --git a/src/main/java/gov/usgs/earthquake/nshmp/gmm/ChiouYoungs_2014.java b/src/main/java/gov/usgs/earthquake/nshmp/gmm/ChiouYoungs_2014.java
index fbb1ae41..e4751a83 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/gmm/ChiouYoungs_2014.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/gmm/ChiouYoungs_2014.java
@@ -80,6 +80,7 @@ public class ChiouYoungs_2014 implements GroundMotionModel {
       .build();
 
   static final CoefficientContainer COEFFS = new CoefficientContainer("CY14.csv");
+  static final CoefficientContainer COEFFS_PRVI = new CoefficientContainer("CY14_PRVI.csv");
 
   private static final double C2 = 1.06;
   private static final double C4 = -2.1;
@@ -111,9 +112,11 @@ public class ChiouYoungs_2014 implements GroundMotionModel {
     // double c8, c8a, c8b, sigma2_JP, gamma_JP_IT, gamma_WN, phi1_JP,
     // phi5_JP, phi6_JP;
 
-    Coefficients(Imt imt, CoefficientContainer cc) {
+    Coefficients(Imt imt) {
+
       this.imt = imt;
-      Map<String, Double> coeffs = cc.get(imt);
+      Map<String, Double> coeffs = COEFFS.get(imt);
+
       c1 = coeffs.get("c1");
       c1a = coeffs.get("c1a");
       c1b = coeffs.get("c1b");
@@ -152,7 +155,7 @@ public class ChiouYoungs_2014 implements GroundMotionModel {
   private final Coefficients coeffs;
 
   ChiouYoungs_2014(Imt imt) {
-    coeffs = new Coefficients(imt, COEFFS);
+    coeffs = new Coefficients(imt);
   }
 
   @Override
diff --git a/src/main/java/gov/usgs/earthquake/nshmp/gmm/KuehnEtAl_2020.java b/src/main/java/gov/usgs/earthquake/nshmp/gmm/KuehnEtAl_2020.java
index 825adffd..33832fe6 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/gmm/KuehnEtAl_2020.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/gmm/KuehnEtAl_2020.java
@@ -8,6 +8,7 @@ import static gov.usgs.earthquake.nshmp.gmm.Imt.PGA;
 import static gov.usgs.earthquake.nshmp.gmm.SubductionZone.ALASKA;
 import static gov.usgs.earthquake.nshmp.gmm.SubductionZone.CASCADIA;
 import static gov.usgs.earthquake.nshmp.gmm.SubductionZone.GLOBAL;
+import static gov.usgs.earthquake.nshmp.gmm.SubductionZone.PRVI;
 import static gov.usgs.earthquake.nshmp.gmm.SubductionZone.Type.INTERFACE;
 import static gov.usgs.earthquake.nshmp.gmm.SubductionZone.Type.SLAB;
 import static java.lang.Math.exp;
@@ -145,6 +146,7 @@ public abstract class KuehnEtAl_2020 implements GroundMotionModel {
       .build();
 
   static final CoefficientContainer COEFFS = new CoefficientContainer("KBCG20.csv");
+  static final CoefficientContainer COEFFS_PRVI = new CoefficientContainer("KBCG20_PRVI.csv");
   static final CoefficientContainer COEFFS_AK_BIAS =
       new CoefficientContainer("nga-sub-ak-interface-bias-corr.csv");
 
@@ -191,13 +193,11 @@ public abstract class KuehnEtAl_2020 implements GroundMotionModel {
 
     Coefficients(
         Imt imt,
-        CoefficientContainer cc,
-        CoefficientContainer ccBias,
         SubductionZone zone,
         boolean slab) {
 
       this.imt = imt;
-      Map<String, Double> coeffs = cc.get(imt);
+      Map<String, Double> coeffs = COEFFS.get(imt);
 
       θ3 = coeffs.get("theta_3");
       θ5 = coeffs.get("theta_5");
@@ -260,8 +260,7 @@ public abstract class KuehnEtAl_2020 implements GroundMotionModel {
        * Average bias-correction for NGA-Subduction global interface models in
        * Alaska NSHM.
        */
-      Map<String, Double> coeffsBias = ccBias.get(imt);
-      correctionAK = coeffsBias.get("bias_ak");
+      correctionAK = COEFFS_AK_BIAS.get(imt).get("bias_ak");
     }
   }
 
@@ -270,10 +269,16 @@ public abstract class KuehnEtAl_2020 implements GroundMotionModel {
   private final GroundMotionTable epistemicTable;
 
   KuehnEtAl_2020(Imt imt, SubductionZone zone) {
-    coeffs = new Coefficients(imt, COEFFS, COEFFS_AK_BIAS, zone, slab());
-    coeffsPGA = new Coefficients(PGA, COEFFS, COEFFS_AK_BIAS, zone, slab());
+    coeffs = new Coefficients(imt, zone, slab());
+    coeffsPGA = new Coefficients(PGA, zone, slab());
+
+    /*
+     * At present, PRVI is only used in backbone median models and we therefore
+     * point to the global epistemic uncertainty model.
+     */
+    SubductionZone epiZone = (zone == PRVI) ? GLOBAL : zone;
     SubductionZone.Type szType = slab() ? SLAB : INTERFACE;
-    epistemicTable = GroundMotionTables.getKbcg20(zone, szType, imt);
+    epistemicTable = GroundMotionTables.getKbcg20(epiZone, szType, imt);
   }
 
   @Override
diff --git a/src/main/java/gov/usgs/earthquake/nshmp/gmm/ParkerEtAl_2020.java b/src/main/java/gov/usgs/earthquake/nshmp/gmm/ParkerEtAl_2020.java
index bd2bfe91..db5b4f48 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/gmm/ParkerEtAl_2020.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/gmm/ParkerEtAl_2020.java
@@ -8,6 +8,7 @@ import static gov.usgs.earthquake.nshmp.gmm.Imt.PGA;
 import static gov.usgs.earthquake.nshmp.gmm.SubductionZone.ALASKA;
 import static gov.usgs.earthquake.nshmp.gmm.SubductionZone.CASCADIA;
 import static gov.usgs.earthquake.nshmp.gmm.SubductionZone.GLOBAL;
+import static gov.usgs.earthquake.nshmp.gmm.SubductionZone.PRVI;
 import static gov.usgs.earthquake.nshmp.gmm.SubductionZone.Type.INTERFACE;
 import static gov.usgs.earthquake.nshmp.gmm.SubductionZone.Type.SLAB;
 import static java.lang.Math.exp;
@@ -117,6 +118,7 @@ public abstract class ParkerEtAl_2020 implements GroundMotionModel {
   static final CoefficientContainer COEFFS_INTERFACE;
   static final CoefficientContainer COEFFS_SLAB;
   static final CoefficientContainer COEFFS_AK_BIAS;
+  static final CoefficientContainer COEFFS_PRVI;
 
   static {
     /*
@@ -127,6 +129,7 @@ public abstract class ParkerEtAl_2020 implements GroundMotionModel {
     COEFFS_INTERFACE = new CoefficientContainer("PSBAH20_interface.csv");
     COEFFS_SLAB = new CoefficientContainer("PSBAH20_slab.csv");
     COEFFS_AK_BIAS = new CoefficientContainer("nga-sub-ak-interface-bias-corr.csv");
+    COEFFS_PRVI = new CoefficientContainer("PSBAH20_PRVI.csv");
   }
 
   private static final double B4 = 0.1;
@@ -172,13 +175,12 @@ public abstract class ParkerEtAl_2020 implements GroundMotionModel {
 
     Coefficients(
         Imt imt,
-        CoefficientContainer cc,
-        CoefficientContainer ccBias,
         SubductionZone zone,
         boolean slab) {
 
       this.imt = imt; // Required for σε
 
+      CoefficientContainer cc = slab ? COEFFS_SLAB : COEFFS_INTERFACE;
       Map<String, Double> coeffs = cc.get(imt);
 
       // Model constant
@@ -261,8 +263,7 @@ public abstract class ParkerEtAl_2020 implements GroundMotionModel {
        * Average bias-correction for NGA-Subduction global interface models in
        * Alaska NSHM.
        */
-      Map<String, Double> coeffsBias = ccBias.get(imt);
-      correctionAK = coeffsBias.get("bias_ak");
+      correctionAK = COEFFS_AK_BIAS.get(imt).get("bias_ak");
     }
   }
 
@@ -270,9 +271,8 @@ public abstract class ParkerEtAl_2020 implements GroundMotionModel {
   private final Coefficients coeffsPGA;
 
   ParkerEtAl_2020(Imt imt, SubductionZone zone) {
-    CoefficientContainer cc = slab() ? COEFFS_SLAB : COEFFS_INTERFACE;
-    coeffs = new Coefficients(imt, cc, COEFFS_AK_BIAS, zone, slab());
-    coeffsPGA = new Coefficients(PGA, cc, COEFFS_AK_BIAS, zone, slab());
+    coeffs = new Coefficients(imt, zone, slab());
+    coeffsPGA = new Coefficients(PGA, zone, slab());
   }
 
   @Override
@@ -559,6 +559,15 @@ public abstract class ParkerEtAl_2020 implements GroundMotionModel {
     }
   }
 
+  private static abstract class Prvi extends ParkerEtAl_2020 {
+    static final SubductionZone ZONE = PRVI;
+    static final String NAME = ParkerEtAl_2020.NAME + " : " + ZONE;
+
+    Prvi(Imt imt) {
+      super(imt, ZONE);
+    }
+  }
+
   static class GlobalInterface extends Global {
     static final String NAME = Global.NAME + " : " + INTERFACE;
 
@@ -705,4 +714,26 @@ public abstract class ParkerEtAl_2020 implements GroundMotionModel {
       return true;
     }
   }
+
+  static final class PrviInterface extends Prvi {
+    static final String NAME = Alaska.NAME + " : " + INTERFACE;
+
+    PrviInterface(Imt imt) {
+      super(imt);
+    }
+  }
+
+  static final class PrviSlab extends Prvi {
+    static final String NAME = Alaska.NAME + " : " + SLAB;
+
+    PrviSlab(Imt imt) {
+      super(imt);
+    }
+
+    @Override
+    boolean slab() {
+      return true;
+    }
+  }
+
 }
-- 
GitLab