From bc327b6a5c2c068ad80bf1d72f88dcf4fe84413f Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Tue, 7 Feb 2017 22:03:51 -0700
Subject: [PATCH 1/7] sadigh cleanup

---
 src/org/opensha2/gmm/SadighEtAl_1997.java | 28 +++++++++++------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/org/opensha2/gmm/SadighEtAl_1997.java b/src/org/opensha2/gmm/SadighEtAl_1997.java
index a614fba53..3cc972694 100644
--- a/src/org/opensha2/gmm/SadighEtAl_1997.java
+++ b/src/org/opensha2/gmm/SadighEtAl_1997.java
@@ -41,16 +41,13 @@ import java.util.Map;
  */
 public class SadighEtAl_1997 implements GroundMotionModel {
 
-  // TODO this needs better site type identification by vs30 value
-
   /*
    * The Sadigh model provides different functional forms for soil and rock site
    * classes, has numerous magnitude and style-of-faulting coefficient variants.
    * This implementation nests style-of-faulting specific coefficents in the
    * coeff tables and keeps four uniform tables for the two site classes
    * supported with a low and high magnitude flavor of each. This yields some
-   * redundancy in the coefficent tables but reduces the need for conditional
-   * expressions.
+   * redundancy in the coefficent tables but reduces the need for conditionals.
    */
 
   static final String NAME = "Sadigh et al. (1997)";
@@ -113,12 +110,12 @@ public class SadighEtAl_1997 implements GroundMotionModel {
     double μ, σ;
 
     if (in.vs30 > VS30_CUT) {
-      // rock
+      /* Rock */
       Coefficients c = in.Mw <= 6.5 ? coeffs_bc_lo : coeffs_bc_hi;
       μ = calcRockMean(c, in.Mw, in.rRup, faultStyle);
       σ = calcStdDev(c, in.Mw);
     } else {
-      // soil
+      /* Soil */
       Coefficients c = in.Mw <= 6.5 ? coeffs_d_lo : coeffs_d_hi;
       μ = calcSoilMean(c, in.Mw, in.rRup, faultStyle);
       σ = calcStdDev(c, in.Mw);
@@ -129,33 +126,36 @@ public class SadighEtAl_1997 implements GroundMotionModel {
 
   private static final double calcRockMean(final Coefficients c, final double Mw,
       final double rRup, final FaultStyle style) {
-    // modified to saturate above Mw=8.5
 
-    // rock site coeffs are not dependent on style-of-faulting
-    // so we just use the rock flavor (c1r == c1ss)
+    /*
+     * Rock site coeffs are not dependent on style-of-faulting so we just use
+     * the rock flavor (c1r == c1ss)
+     */
 
+    /* Modified to saturate above Mw=8.5 */
     double lnY = c.c1r + c.c2 * Mw + c.c3 * pow(max(8.5 - Mw, 0.0), 2.5) + c.c4 *
         log(rRup + exp(c.c5 + c.c6r * Mw)) + c.c7 * log(rRup + 2);
 
-    // scale reverse amplitudes by 1.2; 0.18232 = ln(1.2)
+    /* Scale reverse amplitudes by 1.2; 0.18232 = ln(1.2) */
     return (style == REVERSE) ? lnY + 0.18232 : lnY;
   }
 
   private static final double calcSoilMean(final Coefficients c, final double Mw,
       final double rRup, final FaultStyle style) {
-    // modified to saturate above Mw=8.5
 
     double c1 = (style == REVERSE) ? c.c1r : c.c1ss;
     double c6 = (style == REVERSE) ? c.c6r : c.c6ss;
 
+    /* Modified to saturate above Mw=8.5 */
     return c1 + c.c2 * Mw - c.c3 * log(rRup + c.c4 * exp(c.c5 * Mw)) + c6 + c.c7 *
         pow(max(8.5 - Mw, 0.0), 2.5);
   }
 
   private static final double calcStdDev(final Coefficients c, final double Mw) {
-    // mMax_bc = 7.21, mMax_d = 7.0, coeff tables were populated
-    // with maxSigma for soil sites, maxSigma for rock were
-    // included in publication
+    /*
+     * mMax_bc = 7.21, mMax_d = 7.0, coeff tables were populated with maxSigma
+     * for soil sites, maxSigma for rock were included in publication
+     */
     return max(c.σ0 + c.cM * Mw, c.σMax);
   }
 
-- 
GitLab


From 3e632167b12f1b9b53f60ace877177c97424836b Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Tue, 7 Feb 2017 22:05:25 -0700
Subject: [PATCH 2/7] added AK map bounds

---
 src/org/opensha2/internal/NshmpPolygon.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/org/opensha2/internal/NshmpPolygon.java b/src/org/opensha2/internal/NshmpPolygon.java
index 2c788136e..d85602ca1 100644
--- a/src/org/opensha2/internal/NshmpPolygon.java
+++ b/src/org/opensha2/internal/NshmpPolygon.java
@@ -12,7 +12,8 @@ public enum NshmpPolygon {
 
   CEUS_CLIP(Data.CEUS_CLIP, "Central & Eastern US Map Extents"),
   WUS_CLIP(Data.WUS_CLIP, "Western US Map Extents"),
-
+  AK_CLIP(Data.AK_CLIP, "Alaska Map Extents"),
+  
   CONTERMINOUS_US(Data.CONTERMINOUS, "Conterminous US"),
 
   LA_BASIN(Data.WG_07_LA, "Los Angeles Basin – WGCEP 2007"),
@@ -67,6 +68,11 @@ public enum NshmpPolygon {
         { -100.0, 50.0 }
     };
 
+    private static final double[][] AK_CLIP = {
+        { -200.0, 48.0 },
+        { -125.0, 72.0 }
+    };
+
     private static final double[][] CONTERMINOUS = {
         { -97.7, 25.6 },
         { -96.9, 25.6 },
-- 
GitLab


From 610830131e1a5fef0f14e67d3c91a7fd652a2276 Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Tue, 7 Feb 2017 22:06:00 -0700
Subject: [PATCH 3/7] decreased allowed lon bounds to -360

---
 src/org/opensha2/geo/GeoTools.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/org/opensha2/geo/GeoTools.java b/src/org/opensha2/geo/GeoTools.java
index 742d88a3f..c169a13c9 100644
--- a/src/org/opensha2/geo/GeoTools.java
+++ b/src/org/opensha2/geo/GeoTools.java
@@ -44,8 +44,8 @@ public class GeoTools {
   /** Maximum latitude value (90°). */
   public static final double MAX_LAT = 90.0;
 
-  /** Minimum longitude value (-180°). */
-  public static final double MIN_LON = -180.0;
+  /** Minimum longitude value (-360°). */
+  public static final double MIN_LON = -360.0;
 
   // TODO test if and which distance calcs can handle
   // this higher MAX_LON
-- 
GitLab


From 3bf4af12ed628016b33b2c0fc5a1b4ef84f8d033 Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Tue, 7 Feb 2017 22:06:34 -0700
Subject: [PATCH 4/7] comments and cleanup

---
 src/org/opensha2/eq/Magnitudes.java | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/src/org/opensha2/eq/Magnitudes.java b/src/org/opensha2/eq/Magnitudes.java
index 982f7839b..12f9c0e70 100644
--- a/src/org/opensha2/eq/Magnitudes.java
+++ b/src/org/opensha2/eq/Magnitudes.java
@@ -90,8 +90,8 @@ public final class Magnitudes {
    * supplied, moment <em>rate</em> is returned.
    *
    * @param area in m<sup>2</sup>
-   * @param slip in m
-   * @return moment in N·m
+   * @param slip in m (or slip rate in m·t<sup>-1</sup>)
+   * @return moment in N·m (or moment rate in N·m·t<sup>-1</sup>)
    */
   public static double moment(double area, double slip) {
     return MU * area * slip;
@@ -110,16 +110,4 @@ public final class Magnitudes {
     return moment / (area * MU);
   }
 
-  // TODO finish this, check conversion for slip in m instead of mm/yr for
-  // rate
-  // /**
-  // * @param area in km<sup>2</sup>
-  // * @param slip
-  // * @return
-  // */
-  // public static double moment(double area, double slip) {
-  // return area *
-  // }
-  // public static double recurrence(double Mw, double area, double slip)
-
 }
-- 
GitLab


From 85a1cf1050840aa408d83a4c3263a4e44d2ea989 Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Tue, 7 Feb 2017 22:07:38 -0700
Subject: [PATCH 5/7] added parition()

---
 src/org/opensha2/geo/LocationList.java | 82 +++++++++++++++++++++++---
 1 file changed, 75 insertions(+), 7 deletions(-)

diff --git a/src/org/opensha2/geo/LocationList.java b/src/org/opensha2/geo/LocationList.java
index 9b452cc6e..f143e3f64 100644
--- a/src/org/opensha2/geo/LocationList.java
+++ b/src/org/opensha2/geo/LocationList.java
@@ -192,30 +192,32 @@ public abstract class LocationList implements Iterable<Location> {
   }
 
   /**
-   * Return a new {@code LocationList} created by resampling this list with the
-   * desired maximum spacing. The actual spacing of the returned list will
+   * Return a new {@code LocationList} created by resampling {@code this} with
+   * the desired maximum spacing. The actual spacing of the returned list will
    * likely differ, as spacing is adjusted down to maintain uniform divisions.
    * The original vertices are also not preserved such that some corners might
    * be adversely clipped if {@code spacing} is large. Buyer beware.
    *
-   * <p>For a singleton list, this method immediately returns this list.
+   * <p>If the length of this list is less than the desired spacing, this list
+   * is returned.
    *
    * @param spacing resample interval
    */
   public LocationList resample(double spacing) {
-    if (size() == 1) {
-      return this;
-    }
     checkArgument(
         Doubles.isFinite(spacing) && spacing > 0.0,
         "Spacing must be positive, real number");
 
+    double length = this.length();
+    if (length <= spacing) {
+      return this;
+    }
+
     /*
      * TODO Consider using rint() which will keep the actual spacing closer to
      * the target spacing, albeit sometimes larger.
      */
 
-    double length = this.length();
     spacing = length / Math.ceil(length / spacing);
     List<Location> resampled = Lists.newArrayList();
     Location start = this.first();
@@ -236,6 +238,72 @@ public abstract class LocationList implements Iterable<Location> {
     return LocationList.create(resampled);
   }
 
+  /**
+   * Partition this {@code LocationList} into sub-lists of desired
+   * {@code length}. The actual length of the returned lists will likely differ,
+   * as the lengths of the sub-lists are adjusted up or down to a value closest
+   * to the target length that yields sub-lists of equal length.
+   *
+   * <p>If this list is shorter than the sub-list target length, the method will
+   * return {@code this}.
+   *
+   * @param length target length of sub-lists
+   */
+  public List<LocationList> partition(double length) {
+    checkArgument(
+        Doubles.isFinite(length) && length > 0.0,
+        "Length must be positive, real number");
+
+    double totalLength = this.length();
+    if (totalLength <= length) {
+      return ImmutableList.of(this);
+    }
+
+    ImmutableList.Builder<LocationList> partitions = ImmutableList.builder();
+    double partitionLength = totalLength / Math.rint(totalLength / length);
+
+    double[] distances = distances();
+    LocationList.Builder partition = LocationList.builder();
+    double residual = 0.0;
+    for (int i = 0; i < distances.length; i++) {
+      Location start = get(i);
+      partition.add(start);
+      double distance = distances[i] + residual;
+      while (partitionLength < distance) {
+        /*
+         * Catch the edge case where, on the last segment of a trace that needs
+         * to be partitioned we just undershoot the last point. In the absence
+         * of this we can end up with a final section of length ≈ 0.
+         * 
+         */
+        if (i == distances.length - 1 && distance < 1.5 * partitionLength) {
+          break;
+        }
+        LocationVector v = LocationVector.create(start, get(i + 1));
+        Location end = Locations.location(start, v.azimuth(), partitionLength - residual);
+        partition.add(end);
+        partitions.add(partition.build());
+        partition = LocationList.builder();
+        partition.add(end);
+        start = end;
+        distance -= partitionLength;
+        residual = 0.0;
+      }
+      residual = distance;
+    }
+    partition.add(last());
+    partitions.add(partition.build());
+    return partitions.build();
+  }
+
+  private double[] distances() {
+    double[] distances = new double[size() - 1];
+    for (int i = 0; i < size() - 1; i++) {
+      distances[i] = Locations.horzDistanceFast(get(i), get(i + 1));
+    }
+    return distances;
+  }
+
   /**
    * Return a new {@code LocationList} with {@code Location}s in reverse order.
    */
-- 
GitLab


From c81371a845e5e82678a4dcd611de265a0465451f Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Tue, 7 Feb 2017 22:09:02 -0700
Subject: [PATCH 6/7] docs update

---
 src/org/opensha2/mfd/Mfds.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/org/opensha2/mfd/Mfds.java b/src/org/opensha2/mfd/Mfds.java
index f80851fbc..0190097e4 100644
--- a/src/org/opensha2/mfd/Mfds.java
+++ b/src/org/opensha2/mfd/Mfds.java
@@ -365,7 +365,7 @@ public final class Mfds {
   }
 
   /**
-   * Convert an {@code IncrementalMfd} to an {@code XySequence}.
+   * Convert an {@code IncrementalMfd} to an immutable {@code XySequence}.
    *
    * @param mfd to convert
    * @return a sequence populated with the values of the supplied
@@ -377,6 +377,13 @@ public final class Mfds {
         Doubles.toArray(mfd.yValues()));
   }
 
+  /**
+   * Convert an {@code IncrementalMfd} to a mutable {@code XySequence}.
+   *
+   * @param mfd to convert
+   * @return a sequence populated with the values of the supplied
+   *         {@code IncrementalMfd}.
+   */
   public static XySequence toMutableSequence(IncrementalMfd mfd) {
     return XySequence.create(mfd.xValues(), mfd.yValues());
   }
-- 
GitLab


From 2229efee72c7ab0bda32726fc198564d2b08be26 Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Tue, 7 Feb 2017 22:14:13 -0700
Subject: [PATCH 7/7] AK sites and polys

---
 etc/nshm/map-alaska.geojson                   |  19 ++
 etc/nshm/sites-alaska.csv                     |  27 ++
 etc/nshm/sites-alaska.geojson                 | 291 ++++++++++++++++++
 etc/nshm/sites-nshmp.csv                      |  26 ++
 etc/nshm/sites-nshmp.geojson                  | 286 +++++++++++++++++
 src/org/opensha2/internal/NshmpSite.java      |  53 +++-
 src/org/opensha2/internal/NshmpSiteFiles.java |  15 +-
 7 files changed, 712 insertions(+), 5 deletions(-)
 create mode 100644 etc/nshm/map-alaska.geojson
 create mode 100644 etc/nshm/sites-alaska.csv
 create mode 100644 etc/nshm/sites-alaska.geojson

diff --git a/etc/nshm/map-alaska.geojson b/etc/nshm/map-alaska.geojson
new file mode 100644
index 000000000..cdbf3df6c
--- /dev/null
+++ b/etc/nshm/map-alaska.geojson
@@ -0,0 +1,19 @@
+{
+  "type": "FeatureCollection",
+  "features": [
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Polygon",
+        "coordinates": [[
+            [ -200.0, 48.0 ],
+            [ -125.0, 72.0 ]
+          ]]
+      },
+      "properties": {
+        "spacing": 0.1,
+        "title": "Alaska"
+      }
+    }
+  ]
+}
diff --git a/etc/nshm/sites-alaska.csv b/etc/nshm/sites-alaska.csv
new file mode 100644
index 000000000..7f1b85d75
--- /dev/null
+++ b/etc/nshm/sites-alaska.csv
@@ -0,0 +1,27 @@
+name,                            lon,    lat
+Adak AK,                     -176.65,  51.90
+Anchorage AK,                -149.90,  61.20
+Barrow AK,                   -156.75,  71.30
+Bethel AK,                   -161.80,  60.80
+Delta Junction AK,           -145.70,  64.00
+Dillingham AK,               -158.45,  59.05
+Dutch Harbor AK,             -166.55,  53.90
+Evansville AK,               -151.50,  66.90
+Fairbanks AK,                -147.70,  64.85
+Glennallen AK,               -145.55,  62.10
+Haines AK,                   -135.45,  59.25
+Homer AK,                    -151.50,  59.65
+Juneau AK,                   -134.40,  58.30
+Kenai AK,                    -151.25,  60.55
+Ketchikan AK,                -131.65,  55.35
+Kodiak AK,                   -152.40,  57.80
+Kotzebue AK,                 -162.60,  66.90
+McGrath AK,                  -155.60,  62.95
+Nome AK,                     -165.40,  64.50
+Paxson AK,                   -145.50,  63.05
+Prudhoe Bay AK,              -148.35,  70.25
+Sitka AK,                    -135.35,  57.05
+Tok AK,                      -143.00,  63.30
+Valdez AK,                   -146.35,  61.15
+Wasilla AK,                  -149.45,  61.60
+Yakutat AK,                  -139.70,  59.55
diff --git a/etc/nshm/sites-alaska.geojson b/etc/nshm/sites-alaska.geojson
new file mode 100644
index 000000000..28b96440e
--- /dev/null
+++ b/etc/nshm/sites-alaska.geojson
@@ -0,0 +1,291 @@
+{
+  "type": "FeatureCollection",
+  "features": [
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-176.65, 51.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Adak AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-149.9, 61.2]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Anchorage AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-156.75, 71.3]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Barrow AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-161.8, 60.8]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Bethel AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-145.7, 64.0]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Delta Junction AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-158.45, 59.05]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Dillingham AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-166.55, 53.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Dutch Harbor AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-151.5, 66.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Evansville AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-147.7, 64.85]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Fairbanks AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-145.55, 62.1]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Glennallen AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-135.45, 59.25]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Haines AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-151.5, 59.65]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Homer AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-134.4, 58.3]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Juneau AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-151.25, 60.55]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Kenai AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-131.65, 55.35]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Ketchikan AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-152.4, 57.8]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Kodiak AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-162.6, 66.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Kotzebue AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-155.6, 62.95]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "McGrath AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-165.4, 64.5]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Nome AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-145.5, 63.05]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Paxson AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-148.35, 70.25]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Prudhoe Bay AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-135.35, 57.05]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Sitka AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-143.0, 63.3]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Tok AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-146.35, 61.15]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Valdez AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-149.45, 61.6]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Wasilla AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-139.7, 59.55]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Yakutat AK"
+      }
+    }
+  ]
+}
diff --git a/etc/nshm/sites-nshmp.csv b/etc/nshm/sites-nshmp.csv
index 1bc6a43f1..78fcb66d7 100644
--- a/etc/nshm/sites-nshmp.csv
+++ b/etc/nshm/sites-nshmp.csv
@@ -1,4 +1,30 @@
 name,                            lon,    lat
+Adak AK,                     -176.65,  51.90
+Anchorage AK,                -149.90,  61.20
+Barrow AK,                   -156.75,  71.30
+Bethel AK,                   -161.80,  60.80
+Delta Junction AK,           -145.70,  64.00
+Dillingham AK,               -158.45,  59.05
+Dutch Harbor AK,             -166.55,  53.90
+Evansville AK,               -151.50,  66.90
+Fairbanks AK,                -147.70,  64.85
+Glennallen AK,               -145.55,  62.10
+Haines AK,                   -135.45,  59.25
+Homer AK,                    -151.50,  59.65
+Juneau AK,                   -134.40,  58.30
+Kenai AK,                    -151.25,  60.55
+Ketchikan AK,                -131.65,  55.35
+Kodiak AK,                   -152.40,  57.80
+Kotzebue AK,                 -162.60,  66.90
+McGrath AK,                  -155.60,  62.95
+Nome AK,                     -165.40,  64.50
+Paxson AK,                   -145.50,  63.05
+Prudhoe Bay AK,              -148.35,  70.25
+Sitka AK,                    -135.35,  57.05
+Tok AK,                      -143.00,  63.30
+Valdez AK,                   -146.35,  61.15
+Wasilla AK,                  -149.45,  61.60
+Yakutat AK,                  -139.70,  59.55
 Atmore AL,                    -87.50,  31.00
 Birmingham AL,                -86.80,  33.50
 El Dorado AR,                 -92.70,  33.20
diff --git a/etc/nshm/sites-nshmp.geojson b/etc/nshm/sites-nshmp.geojson
index 109f585d8..9a6865d0a 100644
--- a/etc/nshm/sites-nshmp.geojson
+++ b/etc/nshm/sites-nshmp.geojson
@@ -1,6 +1,292 @@
 {
   "type": "FeatureCollection",
   "features": [
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-176.65, 51.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Adak AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-149.9, 61.2]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Anchorage AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-156.75, 71.3]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Barrow AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-161.8, 60.8]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Bethel AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-145.7, 64.0]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Delta Junction AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-158.45, 59.05]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Dillingham AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-166.55, 53.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Dutch Harbor AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-151.5, 66.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Evansville AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-147.7, 64.85]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Fairbanks AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-145.55, 62.1]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Glennallen AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-135.45, 59.25]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Haines AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-151.5, 59.65]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Homer AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-134.4, 58.3]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Juneau AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-151.25, 60.55]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Kenai AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-131.65, 55.35]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Ketchikan AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-152.4, 57.8]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Kodiak AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-162.6, 66.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Kotzebue AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-155.6, 62.95]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "McGrath AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-165.4, 64.5]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Nome AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-145.5, 63.05]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Paxson AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-148.35, 70.25]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Prudhoe Bay AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-135.35, 57.05]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Sitka AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-143.0, 63.3]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Tok AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-146.35, 61.15]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Valdez AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-149.45, 61.6]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Wasilla AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-139.7, 59.55]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Yakutat AK"
+      }
+    },
     {
       "type": "Feature",
       "geometry": {
diff --git a/src/org/opensha2/internal/NshmpSite.java b/src/org/opensha2/internal/NshmpSite.java
index 6cdbf0226..6bedd5b81 100644
--- a/src/org/opensha2/internal/NshmpSite.java
+++ b/src/org/opensha2/internal/NshmpSite.java
@@ -201,7 +201,35 @@ public enum NshmpSite implements NamedLocation {
   BLACKSBURG_VA(-80.40, 37.25),
   RICHMOND_VA(-77.45, 37.55),
   CHARLESTON_WV(-81.65, 38.35),
-  MILWAUKEE_WI(-87.90, 43.05);
+  MILWAUKEE_WI(-87.90, 43.05),
+
+  /* Alaska */
+  ADAK_AK(-176.65, 51.9),
+  ANCHORAGE_AK(-149.90, 61.2),
+  BARROW_AK(-156.75, 71.3),
+  BETHEL_AK(-161.80, 60.8),
+  DELTA_JUNCTION_AK(-145.70, 64),
+  DILLINGHAM_AK(-158.45, 59.05),
+  DUTCH_HARBOR_AK(-166.55, 53.9),
+  EVANSVILLE_AK(-151.50, 66.9),
+  FAIRBANKS_AK(-147.70, 64.85),
+  GLENNALLEN_AK(-145.55, 62.1),
+  HAINES_AK(-135.45, 59.25),
+  HOMER_AK(-151.50, 59.65),
+  JUNEAU_AK(-134.40, 58.3),
+  KENAI_AK(-151.25, 60.55),
+  KETCHIKAN_AK(-131.65, 55.35),
+  KODIAK_AK(-152.40, 57.8),
+  KOTZEBUE_AK(-162.60, 66.9),
+  MCGRATH_AK(-155.60, 62.95),
+  NOME_AK(-165.40, 64.5),
+  PAXSON_AK(-145.50, 63.05),
+  PRUDHOE_BAY_AK(-148.35, 70.25),
+  SITKA_AK(-135.35, 57.05),
+  TOK_AK(-143.00, 63.3),
+  VALDEZ_AK(-146.35, 61.15),
+  WASILLA_AK(-149.45, 61.6),
+  YAKUTAT_AK(-139.70, 59.55);
 
   private final Location loc;
   private final UsRegion state;
@@ -228,6 +256,11 @@ public enum NshmpSite implements NamedLocation {
   @Override
   public String toString() {
     String label = Parsing.enumLabelWithSpaces(this, true);
+    if (label.startsWith("Mc")) {
+      StringBuilder sb = new StringBuilder(label);
+      sb.setCharAt(2, Character.toUpperCase(sb.charAt(2))); 
+      label = sb.toString();
+    }
     int stripIndex = label.lastIndexOf(' ');
     return label.substring(0, stripIndex) + " " + state.name();
   }
@@ -257,7 +290,21 @@ public enum NshmpSite implements NamedLocation {
         new Predicate<NshmpSite>() {
           @Override
           public boolean apply(NshmpSite site) {
-            return site.loc.lon() <= -100.0;
+            return site.loc.lon() <= -100.0 && site.loc.lon() >= -125.0;
+          }
+        }), NshmpSite.class);
+  }
+
+  /**
+   * The set of sites used to test the Alaska NSHM.
+   */
+  public static EnumSet<NshmpSite> alaska() {
+    return Sets.newEnumSet(Iterables.filter(
+        EnumSet.allOf(NshmpSite.class),
+        new Predicate<NshmpSite>() {
+          @Override
+          public boolean apply(NshmpSite site) {
+            return site.loc.lon() <= -125.0;
           }
         }), NshmpSite.class);
   }
@@ -340,7 +387,7 @@ public enum NshmpSite implements NamedLocation {
         CHICAGO_IL,
         NEW_YORK_NY);
   }
-  
+
   static class StateComparator implements Comparator<NshmpSite> {
     @Override
     public int compare(NshmpSite s1, NshmpSite s2) {
diff --git a/src/org/opensha2/internal/NshmpSiteFiles.java b/src/org/opensha2/internal/NshmpSiteFiles.java
index 2581fd2cc..aaf970f01 100644
--- a/src/org/opensha2/internal/NshmpSiteFiles.java
+++ b/src/org/opensha2/internal/NshmpSiteFiles.java
@@ -3,6 +3,7 @@ package org.opensha2.internal;
 import static com.google.common.base.Strings.padEnd;
 import static com.google.common.base.Strings.padStart;
 
+import static org.opensha2.internal.NshmpPolygon.AK_CLIP;
 import static org.opensha2.internal.NshmpPolygon.CEUS_CLIP;
 import static org.opensha2.internal.NshmpPolygon.CONTERMINOUS_US;
 import static org.opensha2.internal.NshmpPolygon.CYBERSHAKE;
@@ -67,7 +68,7 @@ final class NshmpSiteFiles {
     writeSites("nureg", EnumSet.allOf(NuregSite.class), DEC3_FMT);
     writeCybershakeSites("cybershake", EnumSet.allOf(CybershakeSite.class));
 
-    // writeNshmpPolys();
+     writeNshmpPolys();
     // writeNshmpSummaryPoly();
     // writeNshmpSites_0p1();
   }
@@ -88,7 +89,16 @@ final class NshmpSiteFiles {
     Path wusOut = EXPORT_DIR.resolve("map-wus.geojson");
     LocationList wusBounds = WUS_CLIP.coordinates();
     writePolyJson(wusOut, "NSHMP Western US", usCoords, 0.1, wusBounds);
-
+    
+    // TODO AK needs to be updated with proper clipping region as above
+    // currently just mercator rectangle
+    writePolyJson(
+        EXPORT_DIR.resolve("map-alaska.geojson"),
+        "Alaska",
+        AK_CLIP.coordinates(),
+        0.1,
+        null);
+    
     writePolyJson(
         EXPORT_DIR.resolve("map-la-basin.geojson"),
         LA_BASIN.toString(),
@@ -227,6 +237,7 @@ final class NshmpSiteFiles {
     writeNshmpSites("ceus", NshmpSite.ceus());
     writeNshmpSites("wus", NshmpSite.wus());
     writeNshmpSites("nrc", NshmpSite.nrc());
+    writeNshmpSites("alaska", NshmpSite.alaska());
     writeSites("nehrp", NshmpSite.nehrp(), DEC2_FMT);
   }
 
-- 
GitLab