Skip to content

Commit 563fd1c

Browse files
author
Kevin Milner
committed
CARC project2 path updates
1 parent b33c65c commit 563fd1c

12 files changed

+274
-59
lines changed

src/main/java/scratch/kevin/nshm23/BranchAveragedHazardScriptWriter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public static void main(String[] args) throws IOException {
157157
File localDir = new File(localMainDir, dirName);
158158
Preconditions.checkState(localDir.exists() || localDir.mkdir());
159159

160-
File remoteMainDir = new File("/project/scec_608/kmilner/nshm23/batch_inversions");
160+
File remoteMainDir = new File("/project2/scec_608/kmilner/fss_inversions");
161161
int remoteTotalThreads = 20;
162162
int remoteTotalMemGB = 50;
163163
String queue = "scec";
@@ -202,7 +202,7 @@ public static void main(String[] args) throws IOException {
202202
parallelMPJWrite.setClasspath(classpath);
203203

204204
List<File> singleClasspath = new ArrayList<>(classpath);
205-
singleClasspath.add(new File("/project/scec_608/kmilner/git/opensha/lib/mpj-0.38.jar"));
205+
singleClasspath.add(new File("/project2/scec_608/kmilner/git/opensha/lib/mpj-0.38.jar"));
206206
singleMPJWrite.setClasspath(singleClasspath);
207207

208208
// write the region

src/main/java/scratch/kevin/nshm23/MPJ_LogicTreeInversionRunnerScriptWriter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public static void main(String[] args) throws IOException {
131131
boolean supersample = false;
132132
double[] periods = null;
133133

134-
File remoteMainDir = new File("/project/scec_608/kmilner/nshm23/batch_inversions");
134+
File remoteMainDir = new File("/project2/scec_608/kmilner/fss_inversions");
135135
int remoteTotalThreads = 20;
136136
int remoteInversionsPerBundle = 1;
137137
int remoteTotalMemGB = 50;
@@ -661,7 +661,6 @@ public static void main(String[] args) throws IOException {
661661
// forceHazardReg = new GriddedRegion(PRVI25_RegionLoader.loadPRVI_MapExtents(), 0.05, GriddedRegion.ANCHOR_0_0);
662662
forceHazardReg = new GriddedRegion(PRVI25_RegionLoader.loadPRVI_MapExtents(), 0.025, GriddedRegion.ANCHOR_0_0); // this is what I use for the paper
663663
sigmaTrunc = 3d;
664-
supersample = false;
665664

666665
// levels = new ArrayList<>(levels);
667666
// levels.add(NSHM23_LogicTreeBranch.SUB_SECT_CONSTR);
@@ -947,7 +946,7 @@ else if (v2 == null)
947946
List<File> classpath = new ArrayList<>();
948947
classpath.add(new File(dirPath+"/opensha-dev-all.jar"));
949948
if (mpjWrite instanceof NoMPJSingleNodeShellScriptWriter)
950-
classpath.add(new File("/project/scec_608/kmilner/git/opensha/lib/mpj-0.38.jar"));
949+
classpath.add(new File("/project2/scec_608/kmilner/git/opensha/lib/mpj-0.38.jar"));
951950

952951
File localLogicTree = new File(localDir, "logic_tree.json");
953952
logicTree.write(localLogicTree);

src/main/java/scratch/kevin/nshm23/wrapper/MPJ_WrapperHazardCalcScriptWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ else if (griddedOp == IncludeBackgroundOption.ONLY)
120120
List<File> classpath = new ArrayList<>();
121121
classpath.add(new File(dirPath+"/opensha-dev-all.jar"));
122122
if (mpjWrite instanceof NoMPJSingleNodeShellScriptWriter)
123-
classpath.add(new File("/project/scec_608/kmilner/git/opensha/lib/mpj-0.38.jar"));
123+
classpath.add(new File("/project2/scec_608/kmilner/git/opensha/lib/mpj-0.38.jar"));
124124

125125
File localReg = new File(localDir, "gridded_region.json");
126126
Feature.write(gridReg.toFeature(), localReg);

src/main/java/scratch/kevin/prvi25/GMMLogicTreeWriter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public static void main(String[] args) throws IOException {
216216
String dirName = outputDir.getName();
217217
File localDir = outputDir;
218218

219-
File remoteMainDir = new File("/project/scec_608/kmilner/nshm23/batch_inversions");
219+
File remoteMainDir = new File("/project2/scec_608/kmilner/fss_inversions");
220220
int remoteTotalThreads = 20;
221221
int remoteTotalMemGB = 50;
222222
String queue = "scec";
@@ -239,7 +239,7 @@ public static void main(String[] args) throws IOException {
239239
List<File> classpath = new ArrayList<>();
240240
classpath.add(new File(dirPath+"/opensha-dev-all.jar"));
241241
if (mpjWrite instanceof NoMPJSingleNodeShellScriptWriter)
242-
classpath.add(new File("/project/scec_608/kmilner/git/opensha/lib/mpj-0.38.jar"));
242+
classpath.add(new File("/project2/scec_608/kmilner/git/opensha/lib/mpj-0.38.jar"));
243243

244244
mpjWrite.setClasspath(classpath);
245245
if (mpjWrite instanceof MPJExpressShellScriptWriter)

src/main/java/scratch/kevin/prvi25/GriddedRateDistributionSolutionWriter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ private static void writeHazardScripts(File outputDir, GriddedRegion gridReg) th
885885
String dirName = outputDir.getName();
886886
File localDir = outputDir;
887887

888-
File remoteMainDir = new File("/project/scec_608/kmilner/nshm23/batch_inversions");
888+
File remoteMainDir = new File("/project2/scec_608/kmilner/fss_inversions");
889889
int remoteTotalThreads = 20;
890890
int remoteTotalMemGB = 50;
891891
String queue = "scec";
@@ -906,7 +906,7 @@ private static void writeHazardScripts(File outputDir, GriddedRegion gridReg) th
906906
List<File> classpath = new ArrayList<>();
907907
classpath.add(new File(dirPath+"/opensha-dev-all.jar"));
908908
if (mpjWrite instanceof NoMPJSingleNodeShellScriptWriter)
909-
classpath.add(new File("/project/scec_608/kmilner/git/opensha/lib/mpj-0.38.jar"));
909+
classpath.add(new File("/project2/scec_608/kmilner/git/opensha/lib/mpj-0.38.jar"));
910910

911911
mpjWrite.setClasspath(classpath);
912912
if (mpjWrite instanceof MPJExpressShellScriptWriter)

src/main/java/scratch/kevin/prvi25/HazardComp2003PageGen.java

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ private CompType(String label, String texPrefix) {
5858
};
5959

6060
public static void main(String[] args) throws IOException {
61-
// String imtName = "PGA";
62-
// String imtDir = "PGA";
63-
// double period = 0d;
61+
String imtName = "PGA";
62+
String imtDir = "PGA";
63+
double period = 0d;
6464

6565
// String imtName = "0.2s SA";
6666
// String imtDir = "SA0P2";
@@ -70,9 +70,9 @@ public static void main(String[] args) throws IOException {
7070
// String imtDir = "SA1P0";
7171
// double period = 1d;
7272

73-
String imtName = "5s SA";
74-
String imtDir = "SA5P0";
75-
double period = 5d;
73+
// String imtName = "5s SA";
74+
// String imtDir = "SA5P0";
75+
// double period = 5d;
7676

7777
// ReturnPeriods[] rps = ReturnPeriods.values();
7878
ReturnPeriods[] rps = { ReturnPeriods.TWO_IN_50, ReturnPeriods.TEN_IN_50 };
@@ -151,6 +151,7 @@ public static void main(String[] args) throws IOException {
151151

152152
// CPT hazCPT = GMT_CPT_Files.RAINBOW_UNIFORM.instance().rescale(-3, 1);
153153
CPT hazCPT = GMT_CPT_Files.RAINBOW_UNIFORM.instance().rescale(-1.5, 0.5);
154+
hazCPT.setLog10(true);
154155
hazCPT.setNanColor(transparent);
155156

156157
// CPT pDiffCPT = MethodsAndIngredientsHazChangeFigures.getCenterMaskedCPT(GMT_CPT_Files.DIVERGING_VIK_UNIFORM.instance(), 10d, 50d);
@@ -297,10 +298,10 @@ public static void main(String[] args) throws IOException {
297298

298299
table.initNewLine();
299300

300-
mapMaker.plotXYZData(asLog10(map25), hazCPT, mapLabelAdd+name25+", "+hazLabel+" (g)");
301+
mapMaker.plotXYZData(map25, hazCPT, mapLabelAdd+name25+", "+hazLabel+" (g)");
301302
mapMaker.plot(resourcesDir, prefix+"_nshm25", " ");
302303
table.addColumn("![Map]("+resourcesDir.getName()+"/"+prefix+"_nshm25.png)");
303-
mapMaker.plotXYZData(asLog10(map03), hazCPT, mapLabelAdd+name03+", "+hazLabel+" (g)");
304+
mapMaker.plotXYZData(map03, hazCPT, mapLabelAdd+name03+", "+hazLabel+" (g)");
304305
mapMaker.plot(resourcesDir, prefix+"_nshm03", " ");
305306
table.addColumn("![Map]("+resourcesDir.getName()+"/"+prefix+"_nshm03.png)");
306307

@@ -558,19 +559,5 @@ else if (rp.oneYearProb < curve.getMinY())
558559

559560
return ret;
560561
}
561-
562-
private static GriddedGeoDataSet asLog10(GriddedGeoDataSet xyz) {
563-
xyz = zerosToNaNs(xyz);
564-
xyz.log10();
565-
return xyz;
566-
}
567-
568-
private static GriddedGeoDataSet zerosToNaNs(GriddedGeoDataSet xyz) {
569-
xyz = xyz.copy();
570-
for (int i=0; i<xyz.size(); i++)
571-
if (xyz.get(i) == 0d)
572-
xyz.set(i, Double.NaN);
573-
return xyz;
574-
}
575562

576563
}

src/main/java/scratch/kevin/prvi25/SiteHazCompNSHMPHaz.java

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,39 @@
2222
import org.opensha.sha.calc.HazardCurveCalculator;
2323
import org.opensha.sha.calc.params.filters.SourceFilterManager;
2424
import org.opensha.sha.calc.params.filters.SourceFilters;
25+
import org.opensha.sha.earthquake.ProbEqkRupture;
26+
import org.opensha.sha.earthquake.ProbEqkSource;
27+
import org.opensha.sha.earthquake.faultSysSolution.FaultSystemRupSet;
2528
import org.opensha.sha.earthquake.faultSysSolution.FaultSystemSolution;
2629
import org.opensha.sha.earthquake.faultSysSolution.erf.BaseFaultSystemSolutionERF;
30+
import org.opensha.sha.earthquake.faultSysSolution.util.FaultSectionUtils;
31+
import org.opensha.sha.earthquake.param.AseismicityAreaReductionParam;
2732
import org.opensha.sha.earthquake.param.IncludeBackgroundOption;
2833
import org.opensha.sha.earthquake.param.IncludeBackgroundParam;
34+
import org.opensha.sha.earthquake.param.UseProxySectionsParam;
35+
import org.opensha.sha.earthquake.param.UseRupMFDsParam;
36+
import org.opensha.sha.faultSurface.FaultSection;
2937
import org.opensha.sha.gui.infoTools.IMT_Info;
3038
import org.opensha.sha.imr.AttenRelRef;
3139
import org.opensha.sha.imr.ScalarIMR;
3240
import org.opensha.sha.imr.attenRelImpl.nshmp.GroundMotionLogicTreeFilter;
3341
import org.opensha.sha.imr.attenRelImpl.nshmp.NSHMP_GMM_Wrapper;
42+
import org.opensha.sha.imr.param.IntensityMeasureParams.PGA_Param;
3443
import org.opensha.sha.imr.param.IntensityMeasureParams.SA_Param;
3544
import org.opensha.sha.imr.param.OtherParams.SigmaTruncLevelParam;
3645
import org.opensha.sha.imr.param.OtherParams.SigmaTruncTypeParam;
3746

3847
import com.google.common.base.Preconditions;
48+
import com.google.common.collect.ImmutableList;
3949

4050
import gov.usgs.earthquake.nshmp.gmm.Gmm;
51+
import gov.usgs.earthquake.nshmp.gmm.GmmInput;
52+
import gov.usgs.earthquake.nshmp.gmm.GroundMotion;
4153
import gov.usgs.earthquake.nshmp.gmm.GroundMotions;
4254
import gov.usgs.earthquake.nshmp.gmm.UsgsPrviBackbone2025;
55+
import gov.usgs.earthquake.nshmp.gmm.GmmInput.Constraints;
56+
import gov.usgs.earthquake.nshmp.gmm.GmmInput.Field;
57+
import gov.usgs.earthquake.nshmp.tree.LogicTree;
4358
import net.mahdilamb.colormap.Colors;
4459

4560
public class SiteHazCompNSHMPHaz {
@@ -54,12 +69,17 @@ public static void main(String[] args) throws IOException {
5469
// + "prvi-0.2s-ask14base-crustalFaultOnly-PRVI_2025_ACTIVE_CRUST_NO_EPI_SIGMA_NGA.csv"), true);
5570

5671
// NSHMP_GMM_Wrapper gmm = new NSHMP_GMM_Wrapper.Single(Gmm.PRVI_2025_ACTIVE_CRUST);
72+
//// gmm.setGroundMotionTreeFilter(new GroundMotionLogicTreeFilter.StringMatching(
73+
////// UsgsPrviBackbone2025.SIGMA_NGA_ID,
74+
//// GroundMotions.EPI_OFF
75+
//// ));
5776
// CSVFile<String> inCSV = CSVFile.readFile(new File("/home/kevin/Downloads/"
5877
// + "prvi-0.2s-prvi25active-crustalFaultOnly-curves.csv"), true);
5978

6079
NSHMP_GMM_Wrapper gmm = new NSHMP_GMM_Wrapper.WeightedCombination(
6180
WeightedList.of(new WeightedValue<>(Gmm.PRVI_2025_ACTIVE_CRUST, 0.5),
6281
new WeightedValue<>(Gmm.PRVI_2025_ACTIVE_CRUST_ADJUSTED, 0.5)), "Name", "Name");
82+
// NSHMP_GMM_Wrapper gmm = new NSHMP_GMM_Wrapper.Single(Gmm.TOTAL_TREE_PRVI_ACTIVE_CRUST_2025);
6383
// gmm.setGroundMotionTreeFilter(new GroundMotionLogicTreeFilter.StringMatching(
6484
// UsgsPrviBackbone2025.SIGMA_NGA_ID,
6585
// GroundMotions.EPI_OFF
@@ -68,20 +88,63 @@ public static void main(String[] args) throws IOException {
6888
+ "prvi-0.2s-prvi25activeTotal-crustalFaultOnly-curves.csv"), true);
6989

7090
gmm.setIntensityMeasure(SA_Param.NAME);
71-
gmm.getOtherParams().setValue(SigmaTruncTypeParam.NAME, SigmaTruncTypeParam.SIGMA_TRUNC_TYPE_1SIDED);
72-
gmm.getOtherParams().setValue(SigmaTruncLevelParam.NAME, 3d);
7391
SA_Param.setPeriodInSA_Param(gmm.getIntensityMeasure(), 0.2);
7492
String xName = "0.2s SA (g)";
93+
// gmm.setIntensityMeasure(PGA_Param.NAME);
94+
// String xName = "PGA (g)";
95+
gmm.getOtherParams().setValue(SigmaTruncTypeParam.NAME, SigmaTruncTypeParam.SIGMA_TRUNC_TYPE_1SIDED);
96+
gmm.getOtherParams().setValue(SigmaTruncLevelParam.NAME, 3d);
97+
98+
99+
System.out.println("Zhype used ? Gmm.PRVI_2025_ACTIVE_CRUST: "+Gmm.PRVI_2025_ACTIVE_CRUST.constraints().get(Field.ZHYP).isPresent());
100+
System.out.println("Zhype used ? Gmm.PRVI_2025_ACTIVE_CRUST: "+Gmm.TOTAL_TREE_PRVI_ACTIVE_CRUST_2025.constraints().get(Field.ZHYP).isPresent());
101+
102+
if (gmm instanceof NSHMP_GMM_Wrapper.Single) {
103+
Gmm singleGMM = ((NSHMP_GMM_Wrapper.Single)gmm).getGmmRef();
104+
Constraints constraints = singleGMM.constraints();
105+
for (Field field : Field.values()) {
106+
if (constraints.get(field).isPresent()) {
107+
// this field is used
108+
System.out.println(singleGMM.name()+" reports that "+field+" is used");
109+
} else {
110+
System.out.println(singleGMM.name()+" reports that "+field+" is unused");
111+
}
112+
}
113+
}
75114

76115
FaultSystemSolution sol = FaultSystemSolution.load(new File("/home/kevin/OpenSHA/nshm23/batch_inversions/"
77116
+ "2025_08_01-prvi25_crustal_branches-dmSample10x/"
78117
+ "results_PRVI_CRUSTAL_FM_V1p1_branch_averaged_gridded_simplified.zip"));
118+
// + "results_PRVI_CRUSTAL_FM_V1p1_branch_averaged_gridded.zip"));
79119
BaseFaultSystemSolutionERF erf = new BaseFaultSystemSolutionERF();
80120
erf.setSolution(sol);
81121
erf.setParameter(IncludeBackgroundParam.NAME, IncludeBackgroundOption.EXCLUDE);
122+
// erf.setParameter(UseProxySectionsParam.NAME, false);
123+
// erf.setParameter(AseismicityAreaReductionParam.NAME, false);
124+
erf.setParameter(UseRupMFDsParam.NAME, false);
82125
erf.getTimeSpan().setDuration(1d);
83126
erf.updateForecast();
84127

128+
FaultSystemRupSet rupSet = sol.getRupSet();
129+
int testParentID = FaultSectionUtils.findParentSectionID(rupSet.getFaultSectionDataList(), "South Lajas");
130+
int testRupID = -1;
131+
double testRupMag = 0d;
132+
for (int r : rupSet.getRupturesForParentSection(testParentID)) {
133+
boolean allMatch = true;
134+
for (FaultSection sect : rupSet.getFaultSectionDataForRupture(r)) {
135+
if (sect.getParentSectionId() != testParentID) {
136+
allMatch = false;
137+
break;
138+
}
139+
}
140+
if (allMatch && rupSet.getMagForRup(r) > testRupMag) {
141+
testRupID = r;
142+
testRupMag = rupSet.getMagForRup(r);
143+
}
144+
}
145+
int testSourceID = erf.getSrcIndexForFltSysRup(testRupID);
146+
ProbEqkSource testSource = erf.getSource(testSourceID);
147+
85148
HazardCurveCalculator calc = new HazardCurveCalculator(new SourceFilterManager(SourceFilters.TRT_DIST_CUTOFFS));
86149

87150
DiscretizedFunc xVals = new IMT_Info().getDefaultHazardCurve(gmm.getIntensityMeasure());
@@ -111,6 +174,19 @@ public static void main(String[] args) throws IOException {
111174
}
112175
theirs.setName("NSHMP-Haz");
113176

177+
System.out.println("Site:\t"+name);
178+
gmm.setSite(site);
179+
for (int r=0; r<testSource.getNumRuptures(); r++) {
180+
ProbEqkRupture rup = testSource.getRupture(r);
181+
gmm.setEqkRupture(rup);
182+
GmmInput gmmInput = gmm.getCurrentGmmInput();
183+
LogicTree<GroundMotion> gmmTree = gmm.getGroundMotionTree();
184+
System.out.println("FSS rup "+testRupID+", ERF source "+testSourceID+" ("+r+")");
185+
System.out.println(gmmInput);
186+
System.out.println(gmmTree);
187+
}
188+
System.out.println();
189+
114190
calc.getHazardCurve(logXvalues, site, gmm, erf);
115191

116192
DiscretizedFunc ours = xVals.deepClone();

src/main/java/scratch/kevin/prvi25/figures/LogicTreeFigureWriter.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ public static void main(String[] args) throws IOException {
9797
List<LogicTreeLevel<? extends LogicTreeNode>> slabGMMLevels = PRVI25_LogicTree.levelsSlabGMM;
9898
LogicTree<LogicTreeNode> slabGMMTree = LogicTree.buildExhaustive(slabGMMLevels, true);
9999

100+
List<LogicTreeLevel<? extends LogicTreeNode>> subGMMLevels = new ArrayList<>();
101+
subGMMLevels.addAll(interfaceGMMLevels);
102+
subGMMLevels.addAll(slabGMMLevels);
103+
104+
LogicTree<LogicTreeNode> subGMMTree = LogicTree.buildExhaustive(subGMMLevels, true);
105+
trees.add(subGMMTree);
106+
prefixes.add("subduction_gmm");
107+
100108
for (int i=0; i<trees.size(); i++) {
101109
LogicTree<?> tree = trees.get(i);
102110
String prefix = prefixes.get(i);

src/main/java/scratch/kevin/prvi25/figures/MapSourceTypeDisagg.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,23 @@ public static void main(String[] args) throws IOException {
8080
double[] periods = {0d, 0.2d, 1d, 5d};
8181
ReturnPeriods[] rps = SolHazardMapCalc.MAP_RPS;
8282

83-
// String suffix = "-vs760";
84-
String suffix = "-vs260";
83+
String suffix = "-vs760";
84+
// String suffix = "-vs260";
8585

86-
dirs.put(MapType.COMBINED, new File(INV_DIR, COMBINED_DIR.getName()+"-ba_only"+suffix));
87-
dirs.put(MapType.CRUSTAL, new File(INV_DIR, CRUSTAL_DIR.getName()+"-ba_only"+suffix));
88-
dirs.put(MapType.SUBDUCTION, new File(INV_DIR, SUBDUCTION_DIR.getName()+"-ba_only-both_fms"+suffix));
89-
dirs.put(MapType.SUBDUCTION_INTERFACE, new File(INV_DIR, SUBDUCTION_DIR.getName()+"-ba_only-INTERFACE_only"+suffix));
90-
dirs.put(MapType.SUBDUCTION_SLAB, new File(INV_DIR, SUBDUCTION_DIR.getName()+"-ba_only-SLAB_only"+suffix));
86+
File combDir = COMBINED_DIR;
87+
File crustalDir = CRUSTAL_DIR;
88+
File subDir = SUBDUCTION_DIR;
89+
90+
suffix = "-updatedGMMs"+suffix;
91+
combDir = new File(INV_DIR, "2025_01_17"+combDir.getName().substring(10));
92+
crustalDir = new File(INV_DIR, "2025_01_17"+crustalDir.getName().substring(10));
93+
subDir = new File(INV_DIR, "2025_01_17"+subDir.getName().substring(10));
94+
95+
dirs.put(MapType.COMBINED, new File(INV_DIR, combDir.getName()+"-ba_only"+suffix));
96+
dirs.put(MapType.CRUSTAL, new File(INV_DIR, crustalDir.getName()+"-ba_only"+suffix));
97+
dirs.put(MapType.SUBDUCTION, new File(INV_DIR, subDir.getName()+"-ba_only-both_fms"+suffix));
98+
dirs.put(MapType.SUBDUCTION_INTERFACE, new File(INV_DIR, subDir.getName()+"-ba_only-INTERFACE_only"+suffix));
99+
dirs.put(MapType.SUBDUCTION_SLAB, new File(INV_DIR, subDir.getName()+"-ba_only-SLAB_only"+suffix));
91100

92101
File texFile = new File(new File(FIGURES_DIR, "hazard_map_disagg"), "disagg_stats.tex");
93102
FileWriter texFW = null;

0 commit comments

Comments
 (0)