Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
voj committed Dec 4, 2024
1 parent 90445b4 commit cc8d604
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ public class NZSHM22_CoulombRuptureSetBuilder_IntegrationTest {

/**
* Turns all ruptures into sets of parent ids
*
* @param rupSet
* @return
*/
public static List<Set<Integer>> toParentIds(FaultSystemRupSet rupSet) {
List<Set<Integer>> parentIds = new ArrayList<>();
for(List<Integer> rupture:rupSet.getSectionIndicesForAllRups()) {
for (List<Integer> rupture : rupSet.getSectionIndicesForAllRups()) {
Set<Integer> parents = new HashSet<>();
for(Integer sectionId: rupture) {
for (Integer sectionId : rupture) {
parents.add(rupSet.getFaultSectionData(sectionId).getParentSectionId());
}
parentIds.add(parents);
Expand All @@ -30,10 +31,10 @@ public static List<Set<Integer>> toParentIds(FaultSystemRupSet rupSet) {
return parentIds;
}

public Set<Integer> getMostParents(FaultSystemRupSet rupSet){
public Set<Integer> getMostParents(FaultSystemRupSet rupSet) {
List<Set<Integer>> parents = toParentIds(rupSet);
parents.sort(Comparator.comparing(Set::size));
return parents.get(parents.size()-1);
return parents.get(parents.size() - 1);
}

@Test
Expand All @@ -56,7 +57,7 @@ public void testAlpineVernon() throws IOException, DocumentException {

assertEquals("Fowlers", ruptureSet.getFaultSectionData(11).getParentSectionName());
assertEquals(5.0E-4, ruptureSet.getSlipRateForSection(11), 0.0000001);
assertEquals(0.35,ruptureSet.getFaultSectionData(11).getOrigSlipRateStdDev(), 0.0000001);
assertEquals(3.5E-4, ruptureSet.getSlipRateStdDevForSection(11),0.0000001);
assertEquals(0.35, ruptureSet.getFaultSectionData(11).getOrigSlipRateStdDev(), 0.0000001);
assertEquals(3.5E-4, ruptureSet.getSlipRateStdDevForSection(11), 0.0000001);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.nio.file.Files;

import nz.cri.gns.NZSHM22.opensha.enumTreeBranches.NZSHM22_FaultModels;
import nz.cri.gns.NZSHM22.opensha.util.Parameters;
import org.dom4j.DocumentException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -47,17 +46,8 @@ public static void tearDown() throws IOException {

@Test
public void testRunReportForInversionSolution() throws IOException, DocumentException {
System.out.println("hello");
try {
Parameters param = Parameters.NZSHM22.INVERSION_CRUSTAL.getParameters();
}catch(Exception x) {
assertTrue(x.getMessage(), false);
}

FaultSystemSolution solution = null;

solution = TestHelpers.createCrustalSolution(
TestHelpers.makeRupSet(NZSHM22_FaultModels.CFM_1_0A_DOM_SANSTVZ, ScalingRelationships.SHAW_2009_MOD));
FaultSystemSolution solution = TestHelpers.createCrustalSolution(
TestHelpers.makeRupSet(NZSHM22_FaultModels.CFM_1_0A_DOM_SANSTVZ, ScalingRelationships.SHAW_2009_MOD));
new NZSHM22_ReportPageGen().setOutputPath(tempFolder.toString())
.setName("test")
.setSolution(solution)
Expand Down
24 changes: 13 additions & 11 deletions src/integration/java/nz/cri/gns/NZSHM22/util/TestHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static FileBackedModule serialiseDeserialise(FileBackedModule module) thr

/**
* Creates a rupture set for tests that are concerned with fault sections rather than ruptures.
*
* @param faultModel
* @return
*/
Expand Down Expand Up @@ -74,23 +75,24 @@ public static FaultSystemRupSet createRupSet(NZSHM22_FaultModels faultModel, Rup

/**
* Creates a solution similar to NZSHM22, but repeatable and without averaging
*
* @param rupSet
* @return
* @throws IOException
* @throws DocumentException
*/
public static FaultSystemSolution createCrustalSolution(FaultSystemRupSet rupSet) throws IOException, DocumentException {
ArchiveOutput.InMemoryZipOutput output = new ArchiveOutput.InMemoryZipOutput(true);
rupSet.getArchive().write(output);
ParameterRunner parameterRunner = new ParameterRunner(Parameters.NZSHM22.INVERSION_CRUSTAL);
NZSHM22_CrustalInversionRunner runner = new NZSHM22_CrustalInversionRunner();
parameterRunner.setUpCrustalInversionRunner(runner);
runner.setRuptureSetArchiveInput(output.getCompletedInput());
runner.setIterationCompletionCriteria(1);
runner.setSelectionIterations(2);
runner.setRepeatable(true);
runner.setInversionAveraging(false);
return runner.runInversion();
ArchiveOutput.InMemoryZipOutput output = new ArchiveOutput.InMemoryZipOutput(true);
rupSet.getArchive().write(output);
ParameterRunner parameterRunner = new ParameterRunner(Parameters.NZSHM22.INVERSION_CRUSTAL);
NZSHM22_CrustalInversionRunner runner = new NZSHM22_CrustalInversionRunner();
parameterRunner.setUpCrustalInversionRunner(runner);
runner.setRuptureSetArchiveInput(output.getCompletedInput());
runner.setIterationCompletionCriteria(1);
runner.setSelectionIterations(2);
runner.setRepeatable(true);
runner.setInversionAveraging(false);
return runner.runInversion();
}

public static ArchiveInput archiveInput(FaultSystemRupSet rupSet) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static FileBackedModule serialiseDeserialise(FileBackedModule module) thr

/**
* Creates a rupture set for tests that are concerned with fault sections rather than ruptures.
*
* @param faultModel
* @return
*/
Expand Down

0 comments on commit cc8d604

Please sign in to comment.