forked from opensha/opensha-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kevin Milner
committed
Oct 28, 2024
1 parent
267d664
commit e6fc917
Showing
4 changed files
with
154 additions
and
2 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/java/scratch/kevin/nshm23/GriddedBranchMomentRatesFileWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/main/java/scratch/kevin/prvi25/RegionalMFD_Spider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: <results-dir>"); | ||
System.exit(1); | ||
} | ||
File dir = new File(args[0]); | ||
|
||
AveragingAccumulator<RegionsOfInterest> 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<OpenSHA_Module> archive = new ModuleArchive<>(solFile); | ||
RegionsOfInterest roi = archive.loadUnlistedModule(RegionsOfInterest.class, FaultSystemRupSet.NESTING_PREFIX); | ||
archive.getInput().close(); | ||
|
||
List<IncrementalMagFreqDist> 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<mfds.size(); i++) { | ||
IncrementalMagFreqDist mfd = mfds.get(i); | ||
System.out.println("\t\tMFD "+i+": "+(mfd == null ? "NULL" : | ||
mfd.getName()+" ("+ClassUtils.getClassNameWithoutPackage(mfd.getClass())+")")); | ||
} | ||
} | ||
List<TectonicRegionType> trts = roi.getTRTs(); | ||
System.out.println("\tTRTs: "+(trts == null ? "NULL" : trts.size()+"")); | ||
if (trts != null) { | ||
for (int i=0; i<trts.size(); i++) { | ||
TectonicRegionType trt = trts.get(i); | ||
System.out.println("\t\tTRT "+i+": "+(trt == null ? "NULL" : trt)); | ||
} | ||
} | ||
|
||
if (averager == null) | ||
averager = roi.averagingAccumulator(); | ||
averager.process(roi, 1d); | ||
} | ||
|
||
System.out.println("Building average"); | ||
RegionsOfInterest roi = averager.getAverage(); | ||
List<IncrementalMagFreqDist> 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<mfds.size(); i++) { | ||
IncrementalMagFreqDist mfd = mfds.get(i); | ||
System.out.println("\t\tMFD "+i+": "+(mfd == null ? "NULL" : | ||
mfd.getName()+" ("+ClassUtils.getClassNameWithoutPackage(mfd.getClass())+")")); | ||
} | ||
} | ||
List<TectonicRegionType> trts = roi.getTRTs(); | ||
System.out.println("\tTRTs: "+(trts == null ? "NULL" : trts.size()+"")); | ||
if (trts != null) { | ||
for (int i=0; i<trts.size(); i++) { | ||
TectonicRegionType trt = trts.get(i); | ||
System.out.println("\t\tTRT "+i+": "+(trt == null ? "NULL" : trt)); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters