|
| 1 | +package scratch.kevin.nshm23.figures; |
| 2 | + |
| 3 | +import java.awt.Color; |
| 4 | +import java.io.File; |
| 5 | +import java.io.IOException; |
| 6 | +import java.util.List; |
| 7 | + |
| 8 | +import org.opensha.commons.geo.Location; |
| 9 | +import org.opensha.commons.geo.Region; |
| 10 | +import org.opensha.commons.gui.plot.GeographicMapMaker; |
| 11 | +import org.opensha.commons.mapping.gmt.elements.GMT_CPT_Files; |
| 12 | +import org.opensha.commons.util.cpt.CPT; |
| 13 | +import org.opensha.sha.earthquake.rupForecastImpl.nshm23.logicTree.NSHM23_DeformationModels; |
| 14 | +import org.opensha.sha.earthquake.rupForecastImpl.nshm23.logicTree.NSHM23_FaultModels; |
| 15 | +import org.opensha.sha.faultSurface.FaultSection; |
| 16 | + |
| 17 | +import com.google.common.base.Preconditions; |
| 18 | + |
| 19 | +public class GarlockMojaveECSZ_DMsPlot { |
| 20 | + |
| 21 | + public static void main(String[] args) throws IOException { |
| 22 | + File outputDir = new File("/tmp/garlock_mojave_ecsz"); |
| 23 | + Preconditions.checkState(outputDir.exists() || outputDir.mkdir()); |
| 24 | + |
| 25 | + NSHM23_DeformationModels[] dms = { |
| 26 | + NSHM23_DeformationModels.GEOLOGIC, // must be first |
| 27 | + NSHM23_DeformationModels.EVANS, |
| 28 | + NSHM23_DeformationModels.POLLITZ, |
| 29 | + NSHM23_DeformationModels.SHEN_BIRD, |
| 30 | + NSHM23_DeformationModels.ZENG |
| 31 | + }; |
| 32 | + NSHM23_DeformationModels refDM = NSHM23_DeformationModels.GEOLOGIC; |
| 33 | + NSHM23_FaultModels fm = NSHM23_FaultModels.WUS_FM_v3; |
| 34 | + |
| 35 | + Region reg = new Region(new Location(34, -119), new Location(37, -116)); |
| 36 | + |
| 37 | + List<? extends FaultSection> refSubSects = refDM.build(fm); |
| 38 | + |
| 39 | + GeographicMapMaker mapMaker = new GeographicMapMaker(refSubSects); |
| 40 | + mapMaker.setRegion(reg); |
| 41 | + |
| 42 | + CPT linearSlipCPT = GMT_CPT_Files.SEQUENTIAL_BATLOW_UNIFORM.instance().rescale(0d, 10d); |
| 43 | + CPT logSlipCPT = GMT_CPT_Files.RAINBOW_UNIFORM.instance().rescale(-2, Math.log10(30)); |
| 44 | + logSlipCPT.setNanColor(Color.LIGHT_GRAY); |
| 45 | + CPT pDiffCPT = GMT_CPT_Files.DIVERGING_VIK_UNIFORM.instance().rescale(-60d, 60d).trim(-50, 50); |
| 46 | + |
| 47 | + double[] refSlips = null; |
| 48 | + |
| 49 | + for (NSHM23_DeformationModels dm : dms) { |
| 50 | + List<? extends FaultSection> subSects; |
| 51 | + if (dm == refDM) |
| 52 | + subSects = refSubSects; |
| 53 | + else |
| 54 | + subSects = dm.build(fm); |
| 55 | + |
| 56 | + double[] slips = new double[subSects.size()]; |
| 57 | + double[] pDiffs = dm == refDM ? null : new double[subSects.size()]; |
| 58 | + for (int s=0; s<subSects.size(); s++) { |
| 59 | + double slip = subSects.get(s).getOrigAveSlipRate(); |
| 60 | + slips[s] = slip; |
| 61 | + if (pDiffs != null) |
| 62 | + pDiffs[s] = 100d*(slip - refSlips[s])/refSlips[s]; |
| 63 | + } |
| 64 | + double[] logSlips = new double[subSects.size()]; |
| 65 | + for (int s=0; s<slips.length; s++) |
| 66 | + logSlips[s] = slips[s] > 0 ? Math.log10(slips[s]) : Double.NaN; |
| 67 | + if (dm == refDM) |
| 68 | + refSlips = slips; |
| 69 | + |
| 70 | + String prefix = dm.getFilePrefix(); |
| 71 | + |
| 72 | + mapMaker.plotSectScalars(slips, linearSlipCPT, dm.getShortName()+" Slip Rate (mm/yr)"); |
| 73 | + mapMaker.plot(outputDir, prefix+"_slips", " "); |
| 74 | + |
| 75 | + mapMaker.plotSectScalars(logSlips, logSlipCPT, "Log10["+dm.getShortName()+" Slip Rate (mm/yr)]"); |
| 76 | + mapMaker.plot(outputDir, prefix+"_slips_log", " "); |
| 77 | + |
| 78 | + if (pDiffs != null) { |
| 79 | + mapMaker.plotSectScalars(pDiffs, pDiffCPT, dm.getShortName()+" vs "+refDM.getShortName()+", % Change"); |
| 80 | + mapMaker.plot(outputDir, prefix+"_slips_pDiff", " "); |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | +} |
0 commit comments