diff --git a/build.gradle b/build.gradle index c62395b3..91dfaae6 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ apply from: '../opensha/build-common.gradle' dependencies { - api "ghsc:nshmp-lib:1.4.10" + api "ghsc:nshmp-lib:1.4.11" implementation 'org.apache.pdfbox:pdfbox:2.0.6' implementation 'org.apache.commons:commons-collections4:4.1' diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/NshmErf.java b/src/main/java/gov/usgs/earthquake/nshmp/model/NshmErf.java index 51ce9c71..453ec449 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/NshmErf.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/NshmErf.java @@ -45,12 +45,12 @@ public class NshmErf extends AbstractERF { private final boolean faults; public NshmErf(Path path, Set trts, - IncludeBackgroundOption gridOption) { + IncludeBackgroundOption gridOption) { this(HazardModel.load(path), trts, gridOption); } public NshmErf(HazardModel model, Set trts, - IncludeBackgroundOption gridOption) { + IncludeBackgroundOption gridOption) { this.model = model; allSources = new ArrayList<>(); sourceMap = MultimapBuilder @@ -63,8 +63,8 @@ public NshmErf(HazardModel model, Set trts, subInterface = trts.contains(SUBDUCTION_INTERFACE) || trts.isEmpty(); subSlab = trts.contains(SUBDUCTION_SLAB) || trts.isEmpty(); volcanic = trts.contains(VOLCANIC) || trts.isEmpty(); - this.grid = gridOption == IncludeBackgroundOption.INCLUDE - || gridOption == IncludeBackgroundOption.ONLY; + this.grid = gridOption == IncludeBackgroundOption.INCLUDE || + gridOption == IncludeBackgroundOption.ONLY; this.faults = gridOption != IncludeBackgroundOption.ONLY; init(); @@ -80,13 +80,13 @@ private void init() { // nshmp-haz initializers Multimap trees = model.trees(); for (Entry entry : trees.entries()) { - + TectonicSetting setting = entry.getKey(); SourceTree tree = entry.getValue(); SourceType type = tree.type(); - + if (setting == TectonicSetting.SUBDUCTION) { - if (type == SourceType.INTERFACE && !subInterface ) { + if (type == SourceType.INTERFACE && !subInterface) { continue; } if (type == SourceType.SLAB && !subSlab) { @@ -125,29 +125,29 @@ private List initTree(SourceTree tree) { tree.stream() .map(branch -> sourcesFromBranch(branch, duration)) .forEach(sources::addAll); - -// tree.stream() -// .map(branch -> { -// List brSrcs = sourcesFromBranch(branch, duration); -// if (brSrcs.size() > 0) { -// System.out.println("type: " + branch.value().type()); -// } -// return brSrcs; -// }) -// .forEach(list -> { -//// if (list.size() > 0) { -//// System.out.println("br: " + list.get(0).getTectonicRegionType()); -//// } -// sources.addAll(list); -// }); - + + // tree.stream() + // .map(branch -> { + // List brSrcs = sourcesFromBranch(branch, duration); + // if (brSrcs.size() > 0) { + // System.out.println("type: " + branch.value().type()); + // } + // return brSrcs; + // }) + // .forEach(list -> { + //// if (list.size() > 0) { + //// System.out.println("br: " + list.get(0).getTectonicRegionType()); + //// } + // sources.addAll(list); + // }); + sources.sort(new Comparator() { - @Override - public int compare(NshmSource o1, NshmSource o2) { - return Integer.compare(o1.getNSHM_ID(), o2.getNSHM_ID()); - } + @Override + public int compare(NshmSource o1, NshmSource o2) { + return Integer.compare(o1.getNSHM_ID(), o2.getNSHM_ID()); + } }); - + return sources; } @@ -166,11 +166,18 @@ private List sourcesFromBranch( ? pointRuptureSetToSources(grs, weight, duration) : List.of(); + case ZONE: + ZoneRuptureSet zrs = (ZoneRuptureSet) ruptureSet; + return (grid) + ? pointRuptureSetToSources(zrs, weight, duration) + : List.of(); + case FAULT_CLUSTER: ClusterRuptureSet crs = (ClusterRuptureSet) ruptureSet; return (faults) ? clusterRuptureSetToSources(crs, weight, duration) : List.of(); + case FAULT_SYSTEM: SystemRuptureSet srs = (SystemRuptureSet) ruptureSet; return (faults) @@ -195,7 +202,7 @@ private List sourcesFromBranch( } private static List pointRuptureSetToSources( - GridRuptureSet ruptureSet, + RuptureSet ruptureSet, double weight, double duration) { diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/NshmSource.java b/src/main/java/gov/usgs/earthquake/nshmp/model/NshmSource.java index 132b1b68..51ee59cd 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/NshmSource.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/NshmSource.java @@ -25,13 +25,13 @@ public abstract class NshmSource extends ProbEqkSource { } public abstract void setDuration(double duration); - + public void setName(String name) { - this.name = name; + this.name = name; } - + public int getNSHM_ID() { - return delegate.id(); + return delegate.id(); } public Source delegate() { @@ -57,9 +57,9 @@ public LocationList getAllSourceLocs() { public RuptureSurface getSourceSurface() { throw new UnsupportedOperationException(); } - + public Source getDelegate() { - return delegate; + return delegate; } static class Fault extends NshmSource {