From ab4970814fe17a9b1f52c39ba927281a8136b7ed Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Mon, 25 Apr 2022 15:38:56 -0600
Subject: [PATCH] added Hashash 2020 non-lin f4 coeff update

---
 .../usgs/earthquake/nshmp/gmm/NgaEast.java    | 46 +++++++++++++++----
 1 file changed, 37 insertions(+), 9 deletions(-)

diff --git a/src/main/java/gov/usgs/earthquake/nshmp/gmm/NgaEast.java b/src/main/java/gov/usgs/earthquake/nshmp/gmm/NgaEast.java
index ae96cbd6..7ea883f2 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/gmm/NgaEast.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/gmm/NgaEast.java
@@ -356,12 +356,15 @@ public abstract class NgaEast implements GroundMotionModel {
     final SiteAmp siteAmp;
     final double[] μWts;
 
-    /* Specifiy an array of models ids. */
     NgaEast_2018(Imt imt) {
+      this(imt, new SiteAmp(imt));
+    }
+
+    NgaEast_2018(Imt imt, SiteAmp siteAmp) {
       super(imt);
       this.tables = GroundMotionTables.getNgaEast(imt);
       this.pgaTables = GroundMotionTables.getNgaEast(Imt.PGA);
-      this.siteAmp = new SiteAmp(imt);
+      this.siteAmp = siteAmp;
       this.μWts = GroundMotionTables.getNgaEastWeights(imt);
     }
 
@@ -395,7 +398,7 @@ public abstract class NgaEast implements GroundMotionModel {
     static final String NAME = "NGA-East (2023)";
 
     NgaEast_2023(Imt imt) {
-      super(imt);
+      super(imt, new SiteAmp_2023(imt));
     }
 
     /*
@@ -494,13 +497,16 @@ public abstract class NgaEast implements GroundMotionModel {
     }
 
     UsgsSeeds_2018(Imt imt) {
+      this(imt, new SiteAmp(imt));
+    }
+
+    UsgsSeeds_2018(Imt imt, SiteAmp siteAmp) {
       super(imt);
       this.tables = getImtTables(imt);
       this.pgaTables = getImtTables(Imt.PGA);
       this.sp16 = (ShahjoueiPezeshk_2016) Gmm.NGA_EAST_SEED_SP16.instance(imt);
       this.sp16pga = (ShahjoueiPezeshk_2016) Gmm.NGA_EAST_SEED_SP16.instance(Imt.PGA);
-
-      this.siteAmp = new SiteAmp(imt);
+      this.siteAmp = siteAmp;
     }
 
     private static Map<Gmm, GroundMotionTable> getImtTables(Imt imt) {
@@ -542,6 +548,7 @@ public abstract class NgaEast implements GroundMotionModel {
   }
 
   public static void main(String[] args) {
+    // TODO clean
     // Gmm gmm = Gmm.NGA_EAST_SEED_SP16;
     Gmm gmm = Gmm.NGA_EAST_SEEDS_2018;
     // Gmm gmm = Gmm.NGA_EAST_SEED_SP16;
@@ -565,7 +572,7 @@ public abstract class NgaEast implements GroundMotionModel {
     static final String NAME = NgaEast.NAME + " Seed Tree (2023)";
 
     UsgsSeeds_2023(Imt imt) {
-      super(imt);
+      super(imt, new SiteAmp_2023(imt));
     }
 
     @Override
@@ -867,7 +874,7 @@ public abstract class NgaEast implements GroundMotionModel {
    * The model is applicable to 200 ≤ vs30 ≤ 2000 m/s and smoothly scales from
    * 200 m/s up to 3000 m;s and reasonably extrapolates down to 150 m/s.
    */
-  static final class SiteAmp {
+  static class SiteAmp {
 
     private static final CoefficientContainer COEFFS = new CoefficientContainer(
         "nga-east-usgs-siteamp.csv");
@@ -884,14 +891,14 @@ public abstract class NgaEast implements GroundMotionModel {
     private static final double WT2 = 0.1; // impedance model @ VW2
     private static final double WT_SCALE = (WT1 - WT2) / (log(VW1) - log(VW2)); // ≈1.65
 
-    private final Coefficients c;
+    final Coefficients c;
 
     private static final class Coefficients {
 
       final Imt imt;
       final double c, v1, v2, vf, σvc, σl, σu;
       final double f760i, f760g, f760iσ, f760gσ;
-      final double f3, f4, f5, vc, σc;
+      final double f3, f4, f4mod, f5, vc, σc;
 
       Coefficients(Imt imt, CoefficientContainer cc) {
         this.imt = imt;
@@ -909,6 +916,7 @@ public abstract class NgaEast implements GroundMotionModel {
         f760gσ = coeffs.get("f760gs");
         f3 = coeffs.get("f3");
         f4 = coeffs.get("f4");
+        f4mod = coeffs.get("f4mod");
         f5 = coeffs.get("f5");
         vc = coeffs.get("Vc");
         σc = coeffs.get("sig_c");
@@ -1039,6 +1047,10 @@ public abstract class NgaEast implements GroundMotionModel {
       return new Value(fT, σT);
     }
 
+    double calcF4() {
+      return c.f4;
+    }
+
     /**
      * Wrapper class for site amplification and associated epistemic
      * uncertainty.
@@ -1065,4 +1077,20 @@ public abstract class NgaEast implements GroundMotionModel {
     }
   }
 
+  /*
+   * Stewart et al. site amplification model, updated with alternate non-linear
+   * coefficient f4 per final Hashash et al. (2020) model.
+   */
+  static class SiteAmp_2023 extends SiteAmp {
+
+    SiteAmp_2023(Imt imt) {
+      super(imt);
+    }
+
+    @Override
+    double calcF4() {
+      return c.f4 * 0.5 + c.f4mod * 0.5;
+    }
+  }
+
 }
-- 
GitLab