diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/ModelLoader.java b/src/main/java/gov/usgs/earthquake/nshmp/model/ModelLoader.java index 256962ed86a183387e5c13850990edfc6bd524bb..ad1ee10d39410083bcfa97c3fc5839f9f1585aec 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/ModelLoader.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/ModelLoader.java @@ -9,6 +9,7 @@ import static gov.usgs.earthquake.nshmp.model.ModelFiles.TREE_INFO; import static gov.usgs.earthquake.nshmp.model.ModelFiles.checkGridDataDirectory; import static gov.usgs.earthquake.nshmp.model.ModelFiles.checkSourceTree; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readCalcConfig; +import static gov.usgs.earthquake.nshmp.model.ModelFiles.readCrustalSystemRuptureSet; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readDecollementConfig; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readFaultClusterSet; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readFaultConfig; @@ -23,6 +24,7 @@ import static gov.usgs.earthquake.nshmp.model.ModelFiles.readInterfaceClusterSet import static gov.usgs.earthquake.nshmp.model.ModelFiles.readInterfaceConfig; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readInterfaceFeatures; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readInterfaceRuptureSet; +import static gov.usgs.earthquake.nshmp.model.ModelFiles.readInterfaceSystemRuptureSet; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readMfdConfig; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readMfdMap; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readModelInfo; @@ -33,7 +35,6 @@ import static gov.usgs.earthquake.nshmp.model.ModelFiles.readSiteData; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readSlabConfig; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readSlabRuptureSets; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readSourceTree; -import static gov.usgs.earthquake.nshmp.model.ModelFiles.readSystemRuptureSet; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readTreeInfo; import static gov.usgs.earthquake.nshmp.model.ModelFiles.readZoneConfig; import static gov.usgs.earthquake.nshmp.model.SourceType.DECOLLEMENT; @@ -103,7 +104,8 @@ abstract class ModelLoader { public static void main(String[] args) throws IOException { - Path testModel = Paths.get("../nshm-conus-2018-5.2.x-maint"); + Path testModel = Paths.get("../nshm-prvi"); + // Path testModel = Paths.get("../nshm-conus-2018-5.2.x-maint"); // Path testModel = Paths.get("../nshm-conus"); // Path testModel = Paths.get("../nshm-alaska"); // Path testModel = Paths.get("../nshm-alaska-2007-2.2.x-maint"); @@ -728,7 +730,7 @@ abstract class ModelLoader { processSystemBranch(child, treeBuilder, data); } } else { - SystemRuptureSet srs = readSystemRuptureSet(dir, data).orElseThrow(); + SystemRuptureSet srs = readCrustalSystemRuptureSet(dir, data).orElseThrow(); treeBuilder.addLeaf(branch, srs); // add features to 'data' // TODO: revisit, do we want parent sections?? @@ -913,10 +915,15 @@ abstract class ModelLoader { System.out.println(" tree: [" + info.id + "] " + root.relativize(dir)); - data.interfaceFeatureMap(readInterfaceFeatures(dir).orElseThrow()); + /* Load features if 'classic' subduction model */ + var interfaceSections = readInterfaceFeatures(dir); + interfaceSections.ifPresent(data::interfaceFeatureMap); - List<Feature> features = ModelData.featureMapToList( - data.interfaceFeatureMap().orElseThrow().values()); + /* Set flag to process a logic-tree of fault-system solutions. */ + boolean interfaceSystemTree = interfaceSections.isEmpty(); + + // List<Feature> features = ModelData.featureMapToList( + // data.interfaceFeatureMap().orElseThrow().values()); SourceTree.Builder treeBuilder = SourceTree.builder() .path(dir) @@ -925,11 +932,23 @@ abstract class ModelLoader { .setting(data.tectonicSetting()) .type(INTERFACE) .gmms(data.gmms()) - .features(features) + // .features(features) .root(tree); for (Branch<Path> branch : tree) { - processBranch(branch, treeBuilder, ModelData.copyOf(data)); + if (interfaceSystemTree) { + processSystemBranch(branch, treeBuilder, data); + } else { + processBranch(branch, treeBuilder, data); + } + } + + if (data.systemFeatureMap().isPresent()) { + treeBuilder.features(ModelData.featureMapToList( + data.systemFeatureMap().orElseThrow().values())); + } else { + treeBuilder.features(ModelData.featureMapToList( + data.interfaceFeatureMap().orElseThrow().values())); } return treeBuilder.build(); @@ -1036,6 +1055,35 @@ abstract class ModelLoader { treeBuilder.addLeaf(pathTree.get(i), crsList.get(i)); } } + + /* Process fault system source tree branches. */ + private void processSystemBranch( + Branch<Path> branch, + SourceTree.Builder treeBuilder, + ModelData data) { + + /* + * No configuration overrides are currently expected for + * fault-system-solutions so this is simpler than above. + */ + Path dir = branch.value(); + System.out.println(" branch: " + root.relativize(dir)); + Optional<LogicTree<Path>> tree = readSourceTree(dir); + if (tree.isPresent()) { + LogicTree<Path> children = tree.orElseThrow(); + treeBuilder.addBranches(branch, children); + for (Branch<Path> child : children) { + processSystemBranch(child, treeBuilder, data); + } + } else { + SystemRuptureSet srs = readInterfaceSystemRuptureSet(dir, data).orElseThrow(); + treeBuilder.addLeaf(branch, srs); + // add features to 'data' + // TODO: revisit, do we want parent sections?? + data.systemFeatureMap(srs.sectionMap); + } + } + } static List<SourceTree> gridSources(