diff --git a/src/main/java/gov/usgs/earthquake/nshmp/gmm/NehrpSiteClass.java b/src/main/java/gov/usgs/earthquake/nshmp/gmm/NehrpSiteClass.java index 43b5e36cfaaf48b2b08c732edb6a4265c19851d4..fb79b5083ea078d9eb6c311be8f65bced4d132aa 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/gmm/NehrpSiteClass.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/gmm/NehrpSiteClass.java @@ -8,7 +8,7 @@ package gov.usgs.earthquake.nshmp.gmm; * * @author U.S. Geological Survey */ -enum NehrpSiteClass { +public enum NehrpSiteClass { /** Site class A, very hard rock. */ A("very hard rock"), diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/Deserialize.java b/src/main/java/gov/usgs/earthquake/nshmp/model/Deserialize.java index da667ad2167df8658bc39c5eb506c4ab4199a0d3..8b02f6ed822f98c443fad6dab0efa3c147f6cc32 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/Deserialize.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/Deserialize.java @@ -98,7 +98,8 @@ class Deserialize { /* Read model info. */ static HazardModel.Info modelInfo(Path json) { var info = fromJson(json, HazardModel.Info.class); - checkState(info.name != null, "Missing 'name' in %s", json.getFileName()); + checkNotNull(info.name, "Missing 'name' in %s", json.getFileName()); + checkNotNull(info.siteClassMap, "Missing 'site-class-vs30' in %s", json.getFileName()); return info; } 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 f0b1368df8e00254f45ed731306438b0a5b53cd3..ba1757cb61fcb3441e925cdbdce9a7de38c78ff9 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/HazardModel.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/HazardModel.java @@ -9,18 +9,22 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import com.google.common.base.Strings; import com.google.common.collect.ImmutableSetMultimap; +import com.google.common.collect.Maps; import com.google.common.collect.SetMultimap; import com.google.common.collect.Sets; import com.google.common.collect.Streams; +import com.google.gson.annotations.SerializedName; import gov.usgs.earthquake.nshmp.Maths; import gov.usgs.earthquake.nshmp.calc.CalcConfig; import gov.usgs.earthquake.nshmp.gmm.Gmm; import gov.usgs.earthquake.nshmp.gmm.GroundMotionModel; +import gov.usgs.earthquake.nshmp.gmm.NehrpSiteClass; import gov.usgs.earthquake.nshmp.model.SourceTree.Leaf; import gov.usgs.earthquake.nshmp.tree.Branch; import gov.usgs.earthquake.nshmp.tree.LogicTree; @@ -61,12 +65,14 @@ public final class HazardModel implements Iterable<SourceSet<? extends Source>> // TODO need to revisit the application of uncertainty when minM < 6.5 // e.g. 809a Pine Valley graben in orwa.c.in - private final Info info; + private final String name; + private final Map<NehrpSiteClass, Double> siteClassMap; private final SetMultimap<SourceType, SourceSet<? extends Source>> sourceSetMap; private final CalcConfig config; private HazardModel(Builder builder) { - this.info = builder.info; + this.name = builder.info.name; + this.siteClassMap = Maps.immutableEnumMap(builder.info.siteClassMap); this.config = builder.config; this.sourceSetMap = builder.sourceSetMap; } @@ -108,7 +114,14 @@ public final class HazardModel implements Iterable<SourceSet<? extends Source>> * The name of the model. */ public String name() { - return info.name; + return name; + } + + /** + * Return the default calculation configuration. This may be overridden. + */ + public CalcConfig config() { + return config; } /** @@ -127,17 +140,14 @@ public final class HazardModel implements Iterable<SourceSet<? extends Source>> return sourceSetMap.keySet(); } - /** - * Return the default calculation configuration. This may be overridden. - */ - public CalcConfig config() { - return config; + public Map<NehrpSiteClass, Double> siteClasses() { + return siteClassMap; } @Override public String toString() { StringBuilder sb = new StringBuilder("HazardModel: "); - sb.append(info.name).append(NEWLINE); + sb.append(name).append(NEWLINE); for (SourceSet<? extends Source> sourceSet : this) { String typeStr = " " + sourceSet.type() + " Source Set"; sb.append(Strings.padEnd(typeStr, 26, ' ')); @@ -432,9 +442,12 @@ public final class HazardModel implements Iterable<SourceSet<? extends Source>> static class Info { final String name; + @SerializedName("site-class-vs30") + final Map<NehrpSiteClass, Double> siteClassMap; - Info(String name) { + Info(String name, Map<NehrpSiteClass, Double> siteClassMap) { this.name = name; + this.siteClassMap = siteClassMap; } }