From e6fc917d1ec1b23d7aa99ced032b93a1e15780d3 Mon Sep 17 00:00:00 2001 From: Kevin Milner Date: Mon, 28 Oct 2024 10:04:13 -0700 Subject: [PATCH] updates for new PRVI runs --- .../GriddedBranchMomentRatesFileWriter.java | 32 +++++++ ..._LogicTreeInversionRunnerScriptWriter.java | 8 +- .../kevin/prvi25/RegionalMFD_Spider.java | 86 +++++++++++++++++++ .../scratch/kevin/ucerf3/PureScratch.java | 30 ++++++- 4 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 src/main/java/scratch/kevin/nshm23/GriddedBranchMomentRatesFileWriter.java create mode 100644 src/main/java/scratch/kevin/prvi25/RegionalMFD_Spider.java diff --git a/src/main/java/scratch/kevin/nshm23/GriddedBranchMomentRatesFileWriter.java b/src/main/java/scratch/kevin/nshm23/GriddedBranchMomentRatesFileWriter.java new file mode 100644 index 00000000..d69d9dbe --- /dev/null +++ b/src/main/java/scratch/kevin/nshm23/GriddedBranchMomentRatesFileWriter.java @@ -0,0 +1,32 @@ +package scratch.kevin.nshm23; + +import java.io.File; +import java.io.IOException; + +import org.opensha.commons.data.xyz.GriddedGeoDataSet; +import org.opensha.commons.logicTree.LogicTreeBranch; +import org.opensha.sha.earthquake.faultSysSolution.modules.GridSourceProvider; +import org.opensha.sha.earthquake.faultSysSolution.modules.SolutionLogicTree; +import org.opensha.sha.earthquake.faultSysSolution.reports.plots.NucleationRatePlot; + +import com.google.common.base.Preconditions; + +public class GriddedBranchMomentRatesFileWriter { + + public static void main(String[] args) throws IOException { + File sltFile = new File("/home/kevin/OpenSHA/nshm23/batch_inversions/" + + "2024_02_02-nshm23_branches-WUS_FM_v3/results_gridded_branches_simplified.zip"); + SolutionLogicTree slt = SolutionLogicTree.load(sltFile); + + File outputDir = new File("/tmp/gridded_moment_rate_branches"); + Preconditions.checkState(outputDir.exists() || outputDir.mkdir()); + + for (LogicTreeBranch branch : slt.getLogicTree()) { + System.out.println("Branch: "+branch); + GridSourceProvider gridProv = slt.loadGridProvForBranch(branch); + GriddedGeoDataSet xyz = NucleationRatePlot.calcGriddedNucleationMomentRates(gridProv); + GriddedGeoDataSet.writeXYZFile(xyz, new File(outputDir, branch.buildFileName()+".xyz")); + } + } + +} diff --git a/src/main/java/scratch/kevin/nshm23/MPJ_LogicTreeInversionRunnerScriptWriter.java b/src/main/java/scratch/kevin/nshm23/MPJ_LogicTreeInversionRunnerScriptWriter.java index 640da5f7..f45aa7c0 100644 --- a/src/main/java/scratch/kevin/nshm23/MPJ_LogicTreeInversionRunnerScriptWriter.java +++ b/src/main/java/scratch/kevin/nshm23/MPJ_LogicTreeInversionRunnerScriptWriter.java @@ -630,7 +630,13 @@ public static void main(String[] args) throws IOException { // dirName += "-proxyGriddedTests"; - Class factoryClass = PRVI25_InvConfigFactory.class; +// Class factoryClass = PRVI25_InvConfigFactory.class; + + Class factoryClass = PRVI25_InvConfigFactory.GriddedUseM1Bounds.class; + dirName += "-grid_bounds_m1"; + +// Class factoryClass = PRVI25_InvConfigFactory.GriddedUseM1toMmaxBounds.class; +// dirName += "-grid_bounds_m1_to_mmax"; if (!factoryClass.equals(PRVI25_InvConfigFactory.class)) { // try instantiate it to make sure we get any static modifiers that might change branch weights diff --git a/src/main/java/scratch/kevin/prvi25/RegionalMFD_Spider.java b/src/main/java/scratch/kevin/prvi25/RegionalMFD_Spider.java new file mode 100644 index 00000000..a1aec543 --- /dev/null +++ b/src/main/java/scratch/kevin/prvi25/RegionalMFD_Spider.java @@ -0,0 +1,86 @@ +package scratch.kevin.prvi25; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import org.opensha.commons.util.ClassUtils; +import org.opensha.commons.util.modules.AverageableModule.AveragingAccumulator; +import org.opensha.commons.util.modules.ModuleArchive; +import org.opensha.commons.util.modules.OpenSHA_Module; +import org.opensha.sha.earthquake.faultSysSolution.FaultSystemRupSet; +import org.opensha.sha.earthquake.faultSysSolution.modules.RegionsOfInterest; +import org.opensha.sha.magdist.IncrementalMagFreqDist; +import org.opensha.sha.util.TectonicRegionType; + +public class RegionalMFD_Spider { + + public static void main(String[] args) throws IOException { + if (args.length != 1) { + System.err.println("USAGE: "); + System.exit(1); + } + File dir = new File(args[0]); + + AveragingAccumulator averager = null; + + ModuleArchive.VERBOSE_DEFAULT = false; + + for (File subdir : dir.listFiles()) { + if (!subdir.isDirectory()) + continue; + File solFile = new File(subdir, "solution.zip"); + if (!solFile.exists()) + continue; + System.out.println(subdir.getName()); + ModuleArchive archive = new ModuleArchive<>(solFile); + RegionsOfInterest roi = archive.loadUnlistedModule(RegionsOfInterest.class, FaultSystemRupSet.NESTING_PREFIX); + archive.getInput().close(); + + List mfds = roi.getMFDs(); + System.out.println("\tRegion count: "+roi.getRegions().size()); + System.out.println("\tMFDs: "+(mfds == null ? "NULL" : mfds.size()+"")); + if (mfds != null) { + for (int i=0; i trts = roi.getTRTs(); + System.out.println("\tTRTs: "+(trts == null ? "NULL" : trts.size()+"")); + if (trts != null) { + for (int i=0; i mfds = roi.getMFDs(); + System.out.println("\tRegion count: "+roi.getRegions().size()); + System.out.println("\tMFDs: "+(mfds == null ? "NULL" : mfds.size()+"")); + if (mfds != null) { + for (int i=0; i trts = roi.getTRTs(); + System.out.println("\tTRTs: "+(trts == null ? "NULL" : trts.size()+"")); + if (trts != null) { + for (int i=0; i