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

fault and cluster handling improvements

parent e127ccf0
No related branches found
No related tags found
1 merge request!146Lib updates
Pipeline #32243 failed
......@@ -20,7 +20,6 @@ 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;
......@@ -268,19 +267,42 @@ public final class HazardModel implements Iterable<SourceSet<? extends Source>>
return;
}
/* FAULT: each leaf is a FaultSource in a FaultSourceSet */
// System.out.println(tree.singleType());
if (tree.singleType()) {
/* Check if mixed fault/cluster types */
// boolean mixed = tree.branchMap().keySet().stream()
// .map(Leaf::ruptureSet)
// .map(RuptureSet::type)
// .forEach(System.out::println);
// TODO want to get rid of this but currently needed
// to distinguish trees made up of CLUSTER and FAULT
// TODO what should this return for mixed fault/cluster ??
// @Deprecated
// public boolean singleType() {
// // leafBranches.keySet().forEach(System.out::println);
// return leafBranches.keySet().stream()
// .map(Leaf::ruptureSet)
// .map(RuptureSet::type)
// .distinct()
// .count() == 1;
// }
/*
* FAULT/CLUSTER: each FAULT leaf is a FaultSource in a FaultSourceSet,
* each CLUSTER leaf is an individual clusterSourceSet
*/
FaultSourceSet.Builder fss = new FaultSourceSet.Builder();
fss.name(tree.name());
fss.weight(1.0);
fss.gmms(tree.gmms());
FaultSourceSet.Builder fss = new FaultSourceSet.Builder();
fss.name(tree.name());
fss.weight(1.0);
fss.gmms(tree.gmms());
for (Leaf leaf : tree.branchMap().keySet()) {
for (Leaf leaf : tree.branchMap().keySet()) {
RuptureSet rs = leaf.ruptureSet;
// System.out.println("Flt to FaultSrcSet: " + rs.type() + " " +
// rs.name());
RuptureSet rs = leaf.ruptureSet;
double branchWeight = tree.branchWeights().get(leaf);
if (leaf.ruptureSet.type() == SourceType.FAULT) {
double leafWeight = tree.branchWeights().get(leaf);
FaultRuptureSet frs = (FaultRuptureSet) rs;
......@@ -302,29 +324,12 @@ public final class HazardModel implements Iterable<SourceSet<? extends Source>>
} else {
System.out.println(" No source ruptures: " + faultSource.name());
}
}
if (fss.sources.size() > 0) {
addSourceSet(fss.buildFaultSet());
} else {
System.out.println(" Empty Source Set: " + fss.name);
}
return;
}
/* Otherwise types are mixed, e.g. New Madrid, Wasatch */
for (Leaf leaf : tree.branchMap().keySet()) {
RuptureSet rs = leaf.ruptureSet;
double branchWeight = tree.branchWeights().get(leaf);
if (leaf.ruptureSet.type() == SourceType.FAULT_CLUSTER) {
// System.out.println("Flt to ClusterSrcSet: " + rs.type() + " " +
// rs.name());
ClusterRuptureSet crs = (ClusterRuptureSet) rs;
ClusterSourceSet.Builder css = new ClusterSourceSet.Builder();
css.name(crs.name);
css.id(crs.id);
......@@ -336,38 +341,39 @@ public final class HazardModel implements Iterable<SourceSet<? extends Source>>
for (Branch<Double> rateBranch : rateTree) {
double returnPeriod = rateBranch.value();
double rate = (returnPeriod <= 0.0)
? 0.0
: Maths.roundToDigits(1.0 / returnPeriod, 4);
String clusterLabel = crs.name + " : " + ((int) returnPeriod) + "-yr";
double rate = (rateBranch.value() <= 0.0) ? 0.0 : rateBranch.value();
String rateLabel = (rate == 0.0) ? "0" : String.valueOf((int) (1.0 / rate));
String clusterLabel = crs.name + " : " + rateLabel + "-yr";
ClusterSource.Builder csBuilder = new ClusterSource.Builder()
.name(clusterLabel)
.id(crs.id)
.rate(rate); // cluster rate
FaultSourceSet.Builder fss = new FaultSourceSet.Builder();
fss.name(clusterLabel);
fss.id(crs.id);
fss.gmms(tree.gmms());
FaultSourceSet.Builder cfss = new FaultSourceSet.Builder();
cfss.name(clusterLabel);
cfss.id(crs.id);
cfss.gmms(tree.gmms());
// The weight of the fss gets called by ClusterSource.weight()
// The weight of the cfss gets called by ClusterSource.weight()
// and is used in HazardCurveSet.Builder.addCurves()
fss.weight(rateBranch.weight());
cfss.weight(rateBranch.weight());
for (FaultRuptureSet frs : crs.faultRuptureSets) {
fss.source(faultRuptureSetToSource(frs, 1.0), 1.0);
cfss.source(faultRuptureSetToSource(frs, 1.0), 1.0);
}
csBuilder.faults(fss.buildFaultSet());
csBuilder.faults(cfss.buildFaultSet());
css.source(csBuilder.buildClusterSource());
}
addSourceSet(css.buildClusterSet());
}
}
if (fss.sources.size() > 0) {
addSourceSet(fss.buildFaultSet());
} else {
System.out.println(" Empty Source Set: " + fss.name);
}
}
private FaultSource faultRuptureSetToSource(
......
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