Skip to content

Commit de36700

Browse files
author
field
committed
Misc ned work in scratch
1 parent c529937 commit de36700

File tree

10 files changed

+466
-131
lines changed

10 files changed

+466
-131
lines changed

src/main/java/gov/usgs/earthquake/nshmp/model/NshmErf.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private List<NshmSource> sourcesFromBranch(
169169

170170
case ZONE:
171171
ZoneRuptureSet zrs = (ZoneRuptureSet) ruptureSet;
172-
return (grid)
172+
return (faults)
173173
? pointRuptureSetToSources(zrs, weight, duration)
174174
: List.of();
175175

src/main/java/scratch/kevin/nshm23/timeDependence/DOLE_DemosForNed.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.opensha.sha.earthquake.param.ProbabilityModelOptions;
1010
import org.opensha.sha.earthquake.param.ProbabilityModelParam;
1111
import org.opensha.sha.earthquake.rupForecastImpl.nshm23.timeDependence.DOLE_SubsectionMapper;
12-
import org.opensha.sha.earthquake.rupForecastImpl.nshm23.timeDependence.DOLE_SubsectionMapper.DOLE_MappingAlgorithm;
12+
import org.opensha.sha.earthquake.rupForecastImpl.nshm23.timeDependence.DOLE_SubsectionMapper.PaleoMappingAlgorithm;
1313

1414
import scratch.UCERF3.erf.FaultSystemSolutionERF;
1515

@@ -27,7 +27,7 @@ public static void main(String[] args) throws IOException {
2727
// sol = MergedSolutionCreator.merge(sol1, sol2);
2828

2929
// load DOLE data
30-
DOLE_SubsectionMapper.mapDOLE(sol.getRupSet().getFaultSectionDataList(), DOLE_MappingAlgorithm.FULL_PARENT, true); // boolean is for verbose
30+
DOLE_SubsectionMapper.mapDOLE(sol.getRupSet().getFaultSectionDataList(), PaleoMappingAlgorithm.FULL_PARENT, true); // boolean is for verbose
3131

3232
// ERF
3333
FaultSystemSolutionERF erf = new FaultSystemSolutionERF(sol);

src/main/java/scratch/ned/FSS_Inversion2019/PlottingUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static void writeAndOrPlotUncertFuncs(
9595
UncertainArbDiscFunc func = uncertFuncs.get(i);
9696
funcs.add(func);
9797
funcs.add(func);
98-
plotChars2.add(new PlotCurveCharacterstics(PlotLineType.SOLID, 2f, plotChars.get(i).getColor()));
98+
plotChars2.add(new PlotCurveCharacterstics(PlotLineType.SOLID, 1f, plotChars.get(i).getColor()));
9999
plotChars2.add(new PlotCurveCharacterstics(PlotLineType.SHADED_UNCERTAIN_TRANS, 1f, plotChars.get(i).getColor()));
100100
}
101101

src/main/java/scratch/ned/GK_Declustering/U3ETAS_LossSimulationAnalysis.java

Lines changed: 136 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3395,9 +3395,13 @@ public void plotMaxAndAggrLossesPerYearInCatalog(int catalogIndex) {
33953395

33963396
// plot aggr/max loss histrograms as func of log10(maxLoss):
33973397
for(int i=0;i<ratioHistPoiss.size(); i++) {
3398-
double newVal = ratioHistTD.getY(i)/numHistTD.getY(i);
3398+
double newVal = 1;
3399+
if(numHistTD.getY(i) != 0)
3400+
newVal = ratioHistTD.getY(i)/numHistTD.getY(i);
33993401
ratioHistTD.set(i,newVal);
3400-
newVal = ratioHistPoiss.getY(i)/numHistPoiss.getY(i);
3402+
newVal = 1;
3403+
if(numHistPoiss.getY(i) != 0)
3404+
newVal = ratioHistPoiss.getY(i)/numHistPoiss.getY(i);
34013405
ratioHistPoiss.set(i,newVal);
34023406
}
34033407
ratioHistTD.setName("ratioHistTD");
@@ -3416,6 +3420,132 @@ public void plotMaxAndAggrLossesPerYearInCatalog(int catalogIndex) {
34163420
}
34173421

34183422

3423+
public void plotAveAggrVsMaxLosses() {
3424+
3425+
HistogramFunction ratioHistTD = getBlankIncrLossCurveLogX();
3426+
HistogramFunction numHistTD = getBlankIncrLossCurveLogX();
3427+
HistogramFunction ratioHistPoiss = getBlankIncrLossCurveLogX();
3428+
HistogramFunction numHistPoiss = getBlankIncrLossCurveLogX();
3429+
3430+
File outputDir = new File(dirName+ "/AveAggrVsMaxLosses");
3431+
if(!outputDir.exists()) outputDir.mkdir();
3432+
3433+
double maxLossFromAllCats = 0;
3434+
3435+
double aveAggrOverMax_TD=0;
3436+
double aveAggrOverMax_Pois=0;
3437+
double aveAggrOverMax_TD_num=0;
3438+
double aveAggrOverMax_Pois_num=0;
3439+
double aveAggrOverMax_TD_gt1Billion=0;
3440+
double aveAggrOverMax_Pois_gt1Billion=0;
3441+
double aveAggrOverMax_TD_gt1Billion_num=0;
3442+
double aveAggrOverMax_Pois_gt1Billion_num=0;
3443+
3444+
3445+
for(int catalogIndex=0;catalogIndex<getCatalogs().size();catalogIndex++) {
3446+
3447+
ArrayList<ObsEqkRupList> tempCatList = new ArrayList<ObsEqkRupList>();
3448+
tempCatList.add(getCatalogs().get(catalogIndex));
3449+
3450+
ArrayList<ObsEqkRupList> subCatList = getSubcatalogList(tempCatList, 1d);
3451+
for (ObsEqkRupList catalog:subCatList) {
3452+
double maxLoss=0, aggrLoss=0;
3453+
for (ObsEqkRupture obsRup : catalog) {
3454+
ETAS_EqkRupture rup = (ETAS_EqkRupture)obsRup;
3455+
double randLoss = randomLossForEventID[rup.getID()]; // covModel.getDistribution(aveLoss).sample(); // get randome sample
3456+
if(maxLoss<randLoss) maxLoss=randLoss;
3457+
aggrLoss+=randLoss;
3458+
if(maxLossFromAllCats<randLoss)
3459+
maxLossFromAllCats=randLoss;
3460+
}
3461+
if(maxLoss != 0.0) {
3462+
aveAggrOverMax_TD += aggrLoss/maxLoss;
3463+
aveAggrOverMax_TD_num+=1;
3464+
if(maxLoss>1e9) {
3465+
aveAggrOverMax_TD_gt1Billion+=aggrLoss/maxLoss;
3466+
aveAggrOverMax_TD_gt1Billion_num+=1;
3467+
}
3468+
}
3469+
else {
3470+
aveAggrOverMax_TD += 1.0;
3471+
}
3472+
if(Math.log10(maxLoss)>ratioHistTD.getMinX()-ratioHistTD.getDelta()/2) {
3473+
ratioHistTD.add(Math.log10(maxLoss), aggrLoss/maxLoss);
3474+
numHistTD.add(Math.log10(maxLoss), 1.0);
3475+
}
3476+
}
3477+
3478+
// Now do poisson result
3479+
tempCatList = new ArrayList<ObsEqkRupList>();
3480+
tempCatList.add(getRandomizedCatalogs().get(catalogIndex));
3481+
subCatList = getSubcatalogList(tempCatList, 1d);
3482+
for (ObsEqkRupList catalog:subCatList) {
3483+
double maxLoss=0, aggrLoss=0;
3484+
for (ObsEqkRupture obsRup : catalog) {
3485+
ETAS_EqkRupture rup = (ETAS_EqkRupture)obsRup;
3486+
double randLoss = randomLossForEventID[rup.getID()]; // covModel.getDistribution(aveLoss).sample(); // get randome sample
3487+
if(maxLoss<randLoss) maxLoss=randLoss;
3488+
aggrLoss+=randLoss;
3489+
}
3490+
if(maxLoss != 0.0) {
3491+
aveAggrOverMax_Pois += aggrLoss/maxLoss;
3492+
aveAggrOverMax_Pois_num+=1;
3493+
if(maxLoss>1e9) {
3494+
aveAggrOverMax_Pois_gt1Billion+=aggrLoss/maxLoss;
3495+
aveAggrOverMax_Pois_gt1Billion_num+=1;
3496+
}
3497+
3498+
}
3499+
else {
3500+
aveAggrOverMax_Pois += 1.0;
3501+
}
3502+
3503+
if(Math.log10(maxLoss)>ratioHistPoiss.getMinX()-ratioHistPoiss.getDelta()/2) {
3504+
ratioHistPoiss.add(Math.log10(maxLoss), aggrLoss/maxLoss);
3505+
numHistPoiss.add(Math.log10(maxLoss), 1.0);
3506+
}
3507+
3508+
}
3509+
3510+
}
3511+
3512+
aveAggrOverMax_TD_gt1Billion /= aveAggrOverMax_TD_gt1Billion_num;
3513+
aveAggrOverMax_TD /= aveAggrOverMax_TD_num;
3514+
3515+
aveAggrOverMax_Pois_gt1Billion /= aveAggrOverMax_Pois_gt1Billion_num;
3516+
aveAggrOverMax_Pois /= aveAggrOverMax_Pois_num;
3517+
3518+
// plot aggr/max loss histrograms as func of log10(maxLoss):
3519+
for(int i=0;i<ratioHistPoiss.size(); i++) {
3520+
double newVal = 1;
3521+
// if(numHistTD.getY(i) != 0)
3522+
// newVal = ratioHistTD.getY(i)/numHistTD.getY(i);
3523+
// ratioHistTD.set(i,newVal);
3524+
ratioHistTD.set(i,ratioHistTD.getY(i)/numHistTD.getY(i));
3525+
// newVal = 1;
3526+
// if(numHistPoiss.getY(i) != 0)
3527+
// newVal = ratioHistPoiss.getY(i)/numHistPoiss.getY(i);
3528+
// ratioHistPoiss.set(i,newVal);
3529+
ratioHistPoiss.set(i,ratioHistPoiss.getY(i)/numHistPoiss.getY(i));
3530+
}
3531+
ratioHistTD.setName("ratioHistTD");
3532+
ratioHistTD.setInfo("maxLossFromAllCats="+maxLossFromAllCats+"\naveAggrOverMax_TD="+aveAggrOverMax_TD+"\naveAggrOverMax_TD_gt1Billion="+aveAggrOverMax_TD_gt1Billion);
3533+
ratioHistPoiss.setName("ratioHistPoiss");
3534+
ratioHistPoiss.setInfo("aveAggrOverMax_Pois="+aveAggrOverMax_Pois+"\naveAggrOverMax_Pois_gt1Billion="+aveAggrOverMax_Pois_gt1Billion);
3535+
3536+
ArrayList<XY_DataSet> funcList2 = new ArrayList<XY_DataSet>();
3537+
funcList2.add(ratioHistTD);
3538+
funcList2.add(ratioHistPoiss);
3539+
ArrayList<PlotCurveCharacterstics> plotChars2 = new ArrayList<PlotCurveCharacterstics>();
3540+
plotChars2.add(new PlotCurveCharacterstics(PlotLineType.SOLID, 1f, Color.RED));
3541+
plotChars2.add(new PlotCurveCharacterstics(PlotLineType.SOLID, 1f, Color.BLACK));
3542+
String fileNamePrefix = dirName+"/AveAggrVsMaxLosses/aveAggrVsMaxLosses";
3543+
PlottingUtils.writeAndOrPlotFuncs(funcList2, plotChars2, "", "Log10(MaxLoss ($))", "Ratio", null, null, false, false, fileNamePrefix, true);
3544+
3545+
}
3546+
3547+
3548+
34193549
public void plotAccumulatedLossVsTimeForCatalog(int catalogIndex) {
34203550

34213551
ArbitrarilyDiscretizedFunc accumLossFunc_TD = new ArbitrarilyDiscretizedFunc();
@@ -4230,7 +4360,7 @@ public static void main(String[] args) throws IOException, DocumentException {
42304360
U3ETAS_LossSimulationAnalysis analysis = new U3ETAS_LossSimulationAnalysis(seed);
42314361

42324362
// this shows the MagProbDist discrepancy is less for 1 day than 1 wk or 1 month, as found for losses
4233-
analysis.makeFigSetG_MagExceedances();
4363+
// analysis.makeFigSetG_MagExceedances();
42344364

42354365

42364366
// this examines conditional loss exceedance curves for the year 2024
@@ -4253,6 +4383,7 @@ public static void main(String[] args) throws IOException, DocumentException {
42534383

42544384
// no popup window here
42554385
// analysis.makeFig1_100yrRates(432, 231-50); // put sequence at 50-yr mark
4386+
// System.out.println("Done");
42564387

42574388

42584389
// these are long term MFDs so COV not needed
@@ -4278,6 +4409,8 @@ public static void main(String[] args) throws IOException, DocumentException {
42784409
// analysis.makeFigSetE_Exceedances();
42794410

42804411
// analysis.plotMaxAndAggrLossesPerYearInCatalog(432);
4412+
4413+
analysis.plotAveAggrVsMaxLosses();
42814414

42824415

42834416
// this plots the distribution of rupture losses as a function of magnitude (not including rup rates)

src/main/java/scratch/ned/nshm23/AK_FSS_creator.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ private static ArrayList<GeoJSONFaultSection> getIsolatedFaultSectionsList(Strin
256256
list.add(getIsolatedFaultSection(nshmModelDirPath+"active-crust/fault/Chugach - St.Elias.geojson", elliotSlipRateMap, geoSlipRateMap));
257257
list.add(getIsolatedFaultSection(nshmModelDirPath+"active-crust/fault/Cordova.geojson", elliotSlipRateMap, geoSlipRateMap));
258258
list.add(getIsolatedFaultSection(nshmModelDirPath+"active-crust/fault/Council.geojson", elliotSlipRateMap, geoSlipRateMap));
259-
list.add(getIsolatedFaultSection(nshmModelDirPath+"active-crust/fault/DOT T Johnson.geojson", elliotSlipRateMap, geoSlipRateMap));
259+
// list.add(getIsolatedFaultSection(nshmModelDirPath+"active-crust/fault/DOT T Johnson.geojson", elliotSlipRateMap, geoSlipRateMap)); // remove in version 3.0.0
260260
list.add(getIsolatedFaultSection(nshmModelDirPath+"active-crust/fault/Dall Mountain.geojson", elliotSlipRateMap, geoSlipRateMap));
261261
list.add(getIsolatedFaultSection(nshmModelDirPath+"active-crust/fault/Decoeli Mountain.geojson", elliotSlipRateMap, geoSlipRateMap));
262262
list.add(getIsolatedFaultSection(nshmModelDirPath+"active-crust/fault/Denali (Holitna).geojson", elliotSlipRateMap, geoSlipRateMap));
@@ -574,17 +574,16 @@ private static List<Integer> parseSectionsInRupture(String cellString) {
574574

575575
public static void main(String[] args) {
576576

577-
String nshmModelDirPath = "/Users/field/nshm-haz_data/nshm-alaska-main_Jan10_2024/";
578-
579-
DeformationModelEnum defModel = DeformationModelEnum.BOTH;
580-
// getFaultSystemSolutionList(nshmModelDirPath, DeformationModelEnum.BOTH);
581-
582-
NshmErf erf = AK_FaultZones_creator.getNshmERF(nshmModelDirPath);
583-
getBigFSS(nshmModelDirPath,defModel,erf);
577+
String nshmModelDirPath = "/Users/field/nshm-haz_data/nshm-alaska-3.0.1/";
578+
DeformationModelEnum defModel = DeformationModelEnum.ELLIOT;
579+
getFaultSystemSolutionList(nshmModelDirPath, defModel);
584580

585581
// System.exit(0);
586582

587583

584+
// NshmErf erf = AK_FaultZones_creator.getNshmERF(nshmModelDirPath);
585+
// getBigFSS(nshmModelDirPath,defModel,erf);
586+
588587
// forPeter();
589588
//
590589
// double length = 34.983*1e3;

0 commit comments

Comments
 (0)