From 08aedbb7ac59a9341618f31e977bb7b822a73cda Mon Sep 17 00:00:00 2001 From: Kevin Milner Date: Mon, 3 Jun 2024 09:08:46 -0700 Subject: [PATCH] initial interpolation scheme --- .../nshm23/prvi/SubductionDefModConvert.java | 53 ++++++++++++++++++- ....java => PRVI_SubductionSubSectPlots.java} | 36 ++++++++++++- 2 files changed, 86 insertions(+), 3 deletions(-) rename src/main/java/scratch/kevin/nshm23/prvi/figures/{SubductionMinMaxMagPlots.java => PRVI_SubductionSubSectPlots.java} (71%) diff --git a/src/main/java/scratch/kevin/nshm23/prvi/SubductionDefModConvert.java b/src/main/java/scratch/kevin/nshm23/prvi/SubductionDefModConvert.java index 1e3f3605..0917f5bb 100644 --- a/src/main/java/scratch/kevin/nshm23/prvi/SubductionDefModConvert.java +++ b/src/main/java/scratch/kevin/nshm23/prvi/SubductionDefModConvert.java @@ -18,6 +18,7 @@ import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.chart.ui.TextAnchor; +import org.opensha.commons.data.function.ArbitrarilyDiscretizedFunc; import org.opensha.commons.geo.Location; import org.opensha.commons.geo.LocationList; import org.opensha.commons.geo.LocationUtils; @@ -62,6 +63,8 @@ public static void main(String[] args) throws IOException { boolean[] fullRateBools = { true, false }; boolean[] largePolyBools = { true, false }; + boolean interpolate = true; + File debugDir = new File("/tmp/sub_fm_dm_debug"); Preconditions.checkState(debugDir.exists() || debugDir.mkdir()); @@ -158,6 +161,12 @@ public static void main(String[] args) throws IOException { int prevID = -1; + List minisectionDASs = new ArrayList<>(); + ArbitrarilyDiscretizedFunc dasSlipFunc = new ArbitrarilyDiscretizedFunc(); + ArbitrarilyDiscretizedFunc dasSlipUncertFunc = new ArbitrarilyDiscretizedFunc(); + ArbitrarilyDiscretizedFunc dasRakeFunc = new ArbitrarilyDiscretizedFunc(); + double runningDAS = 0d; + for (Feature feature : features) { Preconditions.checkState(feature.geometry.type == GeoJSON_Type.MultiLineString); MultiLineString geometry = (MultiLineString)feature.geometry; @@ -226,16 +235,43 @@ public static void main(String[] args) throws IOException { double slipUncert = props.getDouble(rateUncertPropName, Double.NaN); double rake = props.getDouble(rakePropName, Double.NaN); - // TODO convert to plane rates + if (runningDAS == 0d) { + dasSlipFunc.set(0d, slip); + dasSlipUncertFunc.set(0d, slipUncert); + dasRakeFunc.set(0d, rake); + } + + double myStartDAS = runningDAS; + for (int i=1; i= 0 && das <= runningDAS); + minisectionRecs.set(i, new MinisectionSlipRecord(rec.parentID, rec.minisectionID, + rec.startLoc, rec.endLoc, + dasRakeFunc.getInterpolatedY(das), + dasSlipFunc.getInterpolatedY(das), + dasSlipUncertFunc.getInterpolatedY(das))); + } + } + minisectionRecsMap.put(outID, minisectionRecs); } diff --git a/src/main/java/scratch/kevin/nshm23/prvi/figures/SubductionMinMaxMagPlots.java b/src/main/java/scratch/kevin/nshm23/prvi/figures/PRVI_SubductionSubSectPlots.java similarity index 71% rename from src/main/java/scratch/kevin/nshm23/prvi/figures/SubductionMinMaxMagPlots.java rename to src/main/java/scratch/kevin/nshm23/prvi/figures/PRVI_SubductionSubSectPlots.java index 0ca3fff1..238c9780 100644 --- a/src/main/java/scratch/kevin/nshm23/prvi/figures/SubductionMinMaxMagPlots.java +++ b/src/main/java/scratch/kevin/nshm23/prvi/figures/PRVI_SubductionSubSectPlots.java @@ -24,7 +24,7 @@ import org.opensha.sha.earthquake.rupForecastImpl.prvi25.logicTree.PRVI25_SubductionScalingRelationships; import org.opensha.sha.faultSurface.FaultSection; -public class SubductionMinMaxMagPlots { +public class PRVI_SubductionSubSectPlots { public static void main(String[] args) throws IOException { LogicTreeBranch branch = PRVI25_LogicTreeBranch.DEFAULT_SUBDUCTION_INTERFACE; @@ -39,7 +39,12 @@ public static void main(String[] args) throws IOException { DecimalFormat magDF = new DecimalFormat("0.00"); CPT magCPT = GMT_CPT_Files.SEQUENTIAL_BATLOW_UNIFORM.instance().rescale(7.5d, 9d); + CPT slipCPT = GMT_CPT_Files.SEQUENTIAL_BATLOW_UNIFORM.instance().rescale(0d, 5d); + CPT slipUncertCPT = GMT_CPT_Files.SEQUENTIAL_BATLOW_UNIFORM.instance().rescale(0d, 2d); + CPT rakeCPT = GMT_CPT_Files.SEQUENTIAL_NAVIA_UNIFORM.instance().rescale(0d, 90d); for (PRVI25_SubductionFaultModels fm : PRVI25_SubductionFaultModels.values()) { + if (fm.getNodeWeight(branch) == 0d) + continue; branch = branch.copy(); branch.setValue(fm); branch.requireValue(PRVI25_SubductionDeformationModels.class).build(fm); @@ -74,7 +79,6 @@ public static void main(String[] args) throws IOException { mapMaker.addAnnotation(rangeAnn); mapMaker.plot(outputDir, "subduction_min_mag_"+fm.getFilePrefix(), " "); - mapMaker.plotSectScalars(maxMags, magCPT, "Maximum Magnitude ("+scale.getShortName()+")"); mapMaker.clearAnnotations(); rangeAnn = new XYTextAnnotation("["+magDF.format(minMax)+", "+magDF.format(maxMax)+"]", annX, annY); @@ -82,6 +86,34 @@ public static void main(String[] args) throws IOException { rangeAnn.setFont(font); mapMaker.addAnnotation(rangeAnn); mapMaker.plot(outputDir, "subduction_max_mag_"+fm.getFilePrefix(), " "); + + mapMaker.clearAnnotations(); + + for (PRVI25_SubductionDeformationModels dm : PRVI25_SubductionDeformationModels.values()) { + if (dm.getNodeWeight(branch) == 0d) + continue; + sects = dm.build(fm); + + mapMaker.setFaultSections(sects); + List slips = new ArrayList<>(sects.size()); + List slipUncerts = new ArrayList<>(sects.size()); + List rakes = new ArrayList<>(sects.size()); + for (FaultSection sect : sects) { + slips.add(sect.getOrigAveSlipRate()); + slipUncerts.add(sect.getOrigSlipRateStdDev()); + rakes.add(sect.getAveRake()); + } + + mapMaker.plotSectScalars(slips, slipCPT, dm.getShortName()+" Slip Rate (mm/yr)"); + mapMaker.plot(outputDir, "subduction_slip_"+fm.getFilePrefix()+"_"+dm.getFilePrefix(), " "); + + mapMaker.plotSectScalars(slipUncerts, slipUncertCPT, dm.getShortName()+" Slip Rate Uncertainty (mm/yr)"); + mapMaker.plot(outputDir, "subduction_slip_uncert_"+fm.getFilePrefix()+"_"+dm.getFilePrefix(), " "); + + mapMaker.plotSectScalars(rakes, rakeCPT, dm.getShortName()+" Rake"); + mapMaker.plot(outputDir, "subduction_rake_"+fm.getFilePrefix()+"_"+dm.getFilePrefix(), " "); + + } } }