Skip to content
Snippets Groups Projects
Commit f9709d15 authored by Powers, Peter M.'s avatar Powers, Peter M.
Browse files

test mag curve sum equals total

parent e36b40f8
No related branches found
No related tags found
1 merge request!421Magnitude curves
......@@ -14,6 +14,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
......@@ -33,6 +34,7 @@ import gov.usgs.earthquake.nshmp.calc.HazardCalcs;
import gov.usgs.earthquake.nshmp.calc.HazardExport;
import gov.usgs.earthquake.nshmp.calc.Site;
import gov.usgs.earthquake.nshmp.calc.Sites;
import gov.usgs.earthquake.nshmp.data.MutableXySequence;
import gov.usgs.earthquake.nshmp.data.XySequence;
import gov.usgs.earthquake.nshmp.geo.Location;
import gov.usgs.earthquake.nshmp.gmm.Gmm;
......@@ -135,6 +137,12 @@ class LoaderTests {
}
assertCurveEquals(magExpecteds.get(m), magActuals.get(m), tol);
}
// Check that actual magnitude curves sum to expected total curve for IMT
XySequence magCombinedActual = combineMagCurves(
actuals.curves().get(imt),
actuals.magCurves().get(imt).values());
assertCurveEquals(totalExpected, magCombinedActual, tol);
}
}
......@@ -285,6 +293,20 @@ class LoaderTests {
.toArray();
}
/* --- mag hazard testing --- */
private static XySequence combineMagCurves(
XySequence model,
Collection<MutableXySequence> curves) {
MutableXySequence xyOut = MutableXySequence.emptyCopyOf(model);
for (XySequence curve : curves) {
if (curve != null) {
xyOut.add(curve);
}
}
return xyOut;
}
public static void main(String[] args) throws IOException {
model = ModelLoader.load(MODEL_PATH);
List<Site> sites = Sites.fromCsv(SITES_PATH, model.siteData(), OptionalDouble.empty());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment