From 2e93458e5074ba997038bcdbd4fc8e531bddb647 Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Wed, 9 Feb 2022 08:46:39 -0700
Subject: [PATCH] hazard model size cleanup

---
 .../earthquake/nshmp/calc/HazardCalcs.java    |  4 ++--
 .../earthquake/nshmp/model/HazardModel.java   | 21 ++++++++++---------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/main/java/gov/usgs/earthquake/nshmp/calc/HazardCalcs.java b/src/main/java/gov/usgs/earthquake/nshmp/calc/HazardCalcs.java
index 11ad060b..3ad3434d 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/calc/HazardCalcs.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/calc/HazardCalcs.java
@@ -141,7 +141,7 @@ public class HazardCalcs {
       Site site,
       Executor ex) throws InterruptedException, ExecutionException {
 
-    AsyncList<HazardCurveSet> curveSets = AsyncList.createWithCapacity(model.size());
+    AsyncList<HazardCurveSet> curveSets = AsyncList.create();
     AsyncList<RuptureSet<? extends Source>> gridTables = AsyncList.create();
     var settingFilter = model.settingFilter(config, site.location());
     var typeFilter = new SourceTypeFilter(config);
@@ -209,7 +209,7 @@ public class HazardCalcs {
       Site site,
       Logger log) {
 
-    List<HazardCurveSet> curveSets = new ArrayList<>(model.size());
+    List<HazardCurveSet> curveSets = new ArrayList<>();
     var settingsFilter = model.settingFilter(config, site.location());
     var typeFilter = new SourceTypeFilter(config);
 
diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/HazardModel.java b/src/main/java/gov/usgs/earthquake/nshmp/model/HazardModel.java
index 98f2003d..c89c991b 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/model/HazardModel.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/model/HazardModel.java
@@ -43,12 +43,13 @@ import gov.usgs.earthquake.nshmp.gmm.NehrpSiteClass;
 
 /**
  * A {@code HazardModel} is the top-level wrapper for earthquake {@link Source}
- * definitions and attendant {@link GroundMotionModel}s used in probabilisitic
+ * definitions and attendant {@link GroundMotionModel}s used in probabilistic
  * seismic hazard analyses (PSHAs) and related calculations. A
- * {@code HazardModel} contains of a number of {@link RuptureSet}s that define
- * logical groupings of sources by {@link SourceType}. Each {@code RuptureSet}
- * carries with it references to the {@code GroundMotionModel}s and associated
- * weights to be used when evaluating hazard.
+ * {@code HazardModel} is a List of {@link SourceTree}s that define logical
+ * trees of sources. The tips of the source logic tree branches are
+ * {@code RuptureSet}s that carry the necessary information to carries with it
+ * references to the {@code GroundMotionModel}s and associated weights to be
+ * used when evaluating hazard.
  *
  * @author U.S. Geological Survey
  * @see Source
@@ -87,8 +88,8 @@ public final class HazardModel implements Iterable<SourceTree> {
    *
    * <p>For more information on a HazardModel directory and file structure, see
    * the <a
-   * href="https://github.com/usgs/nshmp-haz/wiki/Earthquake-Source-Models">
-   * nshmp-haz wiki</a>.
+   * href="https://code.usgs.gov/ghsc/nshmp/nshmp-haz/-/blob/main/docs/pages/Hazard-Model.md">
+   * nshmp-haz documentation</a>.
    *
    * <p><b>Notes:</b> HazardModel loading is not thread safe. There are also a
    * wide variety of exceptions that may be encountered when loading a model.
@@ -103,10 +104,10 @@ public final class HazardModel implements Iterable<SourceTree> {
   }
 
   /**
-   * The number of {@code RuptureSet}s in this {@code HazardModel}.
+   * The number of {@code SourceTree}s in this model.
    */
-  public int size() { // TODO this should be the number of trees
-    return ruptureSetMap.size();
+  public int size() {
+    return idMap.size();
   }
 
   @Override
-- 
GitLab