diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/SystemRuptureSet.java b/src/main/java/gov/usgs/earthquake/nshmp/model/SystemRuptureSet.java index 5f176c65e6823766150a4d457fca01a29e3c4e4d..a61cae86c7b7204526f825fbee97be987dd12aaa 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/SystemRuptureSet.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/SystemRuptureSet.java @@ -8,6 +8,7 @@ import static gov.usgs.earthquake.nshmp.Earthquakes.checkMagnitude; import static gov.usgs.earthquake.nshmp.Faults.checkDip; import static gov.usgs.earthquake.nshmp.Faults.checkRake; import static gov.usgs.earthquake.nshmp.geo.Locations.horzDistanceFast; +import static gov.usgs.earthquake.nshmp.model.Deserialize.MFD_TREE; import static gov.usgs.earthquake.nshmp.model.SourceFeature.Key.DEPTH; import static gov.usgs.earthquake.nshmp.model.SourceFeature.Key.DIP; import static gov.usgs.earthquake.nshmp.model.SourceFeature.Key.INDICES; @@ -18,6 +19,7 @@ import static gov.usgs.earthquake.nshmp.model.SourceFeature.Key.WIDTH; import static java.lang.Math.min; import static java.util.stream.Collectors.toList; +import java.math.RoundingMode; import java.nio.file.Path; import java.util.BitSet; import java.util.Comparator; @@ -34,6 +36,7 @@ import com.google.common.collect.Iterables; import com.google.common.primitives.Doubles; import gov.usgs.earthquake.nshmp.Faults; +import gov.usgs.earthquake.nshmp.Maths; import gov.usgs.earthquake.nshmp.calc.HazardInput; import gov.usgs.earthquake.nshmp.calc.InputList; import gov.usgs.earthquake.nshmp.calc.Site; @@ -90,6 +93,8 @@ public class SystemRuptureSet extends AbstractRuptureSet<SystemRuptureSet.System private final double[] widths; private final double[] rakes; + private final LogicTree<Mfd> mfdTree; + public final Statistics stats; /* @@ -159,6 +164,17 @@ public class SystemRuptureSet extends AbstractRuptureSet<SystemRuptureSet.System this.rakes[i] = checkRake(r.getDouble(RAKE)); } this.stats = new Statistics(mMin, mMax); + + // build total MFD for fault system + IntervalArray.Builder mfdBuilder = IntervalArray.Builder.withRows( + Maths.round(stats.mMin, 1, RoundingMode.FLOOR), + Maths.round(stats.mMax, 1, RoundingMode.CEILING), + 0.1); + for (int i = 0; i < mags.length; i++) { + mfdBuilder.add(mags[i], rates[i]); + } + Mfd mfd = Mfd.create(mfdBuilder.build().values()); + this.mfdTree = LogicTree.singleton(MFD_TREE, name(), mfd); } private static int[] indexStringToIndices(String s) { @@ -209,7 +225,7 @@ public class SystemRuptureSet extends AbstractRuptureSet<SystemRuptureSet.System @Override public LogicTree<Mfd> mfdTree() { - throw new UnsupportedOperationException(); + return mfdTree; } @Override