Skip to content
Snippets Groups Projects
Commit b20525a8 authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

Merge branch 'total-mfd' into 'main'

Resolves - Add total MFD for source tree to Models serialization classes

Closes #161

See merge request !288
parents 66a535cf e006046f
No related branches found
No related tags found
1 merge request!288Resolves - Add total MFD for source tree to Models serialization classes
Pipeline #159584 passed
......@@ -15,7 +15,9 @@ import java.util.stream.Collectors;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import gov.usgs.earthquake.nshmp.data.XySequence;
import gov.usgs.earthquake.nshmp.mfd.Mfd;
import gov.usgs.earthquake.nshmp.mfd.Mfds;
import gov.usgs.earthquake.nshmp.model.SourceTree.Leaf;
import gov.usgs.earthquake.nshmp.tree.Branch;
......@@ -70,7 +72,6 @@ public class Models {
// System.out.println(GSON.toJson(tree(model, 2591))); // Stonewall Ant.
System.out.println(GSON.toJson(tree(model, 2535))); // Steens
}
/**
......@@ -156,6 +157,7 @@ public class Models {
final String path;
final TectonicSetting setting;
final SourceType type;
final XySequence totalMfd;
final List<SourceBranch> branches;
Tree(SourceTree tree, Path modelRoot) {
......@@ -164,6 +166,8 @@ public class Models {
this.path = modelRoot.relativize(tree.path()).toString();
this.setting = tree.setting();
this.type = tree.type();
this.totalMfd = Mfds.combine(tree.stream().map(branch -> branch.value().totalMfd())
.collect(Collectors.toList())).data();
List<SourceBranch> branches = new ArrayList<>();
......
......@@ -16,6 +16,13 @@ import gov.usgs.earthquake.nshmp.tree.LogicTree;
*/
public interface RuptureSet<T extends Source> extends Iterable<T> {
/**
* Return the total Mfd.
*/
default Mfd totalMfd() {
return ModelTrees.reduceMfdTree(mfdTree());
};
/**
* The display name of the rupture set.
*/
......@@ -97,12 +104,6 @@ public interface RuptureSet<T extends Source> extends Iterable<T> {
*/
Predicate<T> distanceFilter(Location loc, double distance);
/**
* Return the total
* @return
*/
// Mfd mfd();
// instead of Source
// interface .Model
......
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