Skip to content

Commit

Permalink
Merge branch 'master' of [email protected]:opensha/opensha-dev.git
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmilner committed Feb 9, 2024
2 parents d3aa846 + 7cd8fae commit 423b1a7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 36 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
65 changes: 36 additions & 29 deletions src/main/java/gov/usgs/earthquake/nshmp/model/NshmErf.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public class NshmErf extends AbstractERF {
private final boolean faults;

public NshmErf(Path path, Set<TectonicRegionType> trts,
IncludeBackgroundOption gridOption) {
IncludeBackgroundOption gridOption) {
this(HazardModel.load(path), trts, gridOption);
}

public NshmErf(HazardModel model, Set<TectonicRegionType> trts,
IncludeBackgroundOption gridOption) {
IncludeBackgroundOption gridOption) {
this.model = model;
allSources = new ArrayList<>();
sourceMap = MultimapBuilder
Expand All @@ -63,8 +63,8 @@ public NshmErf(HazardModel model, Set<TectonicRegionType> 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();
Expand All @@ -80,13 +80,13 @@ private void init() {
// nshmp-haz initializers
Multimap<TectonicSetting, SourceTree> trees = model.trees();
for (Entry<TectonicSetting, SourceTree> 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) {
Expand Down Expand Up @@ -125,29 +125,29 @@ private List<NshmSource> initTree(SourceTree tree) {
tree.stream()
.map(branch -> sourcesFromBranch(branch, duration))
.forEach(sources::addAll);
// tree.stream()
// .map(branch -> {
// List<NshmSource> 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<NshmSource> 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<NshmSource>() {
@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;
}

Expand All @@ -166,11 +166,18 @@ private List<NshmSource> 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)
Expand All @@ -195,7 +202,7 @@ private List<NshmSource> sourcesFromBranch(
}

private static List<NshmSource> pointRuptureSetToSources(
GridRuptureSet ruptureSet,
RuptureSet<PointSource> ruptureSet,
double weight,
double duration) {

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/gov/usgs/earthquake/nshmp/model/NshmSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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 {
Expand Down

0 comments on commit 423b1a7

Please sign in to comment.