|
| 1 | +package nz.cri.gns.NZSHM22.opensha.ruptures.experimental; |
| 2 | + |
| 3 | +import java.io.BufferedWriter; |
| 4 | +import java.io.File; |
| 5 | +import java.io.FileWriter; |
| 6 | +import java.io.IOException; |
| 7 | +import java.util.List; |
| 8 | +import org.opensha.sha.earthquake.faultSysSolution.FaultSystemRupSet; |
| 9 | + |
| 10 | +/** Orchestrates thinning of crustal and subduction rupture sets as inputs for RuptureMerger */ |
| 11 | +public class Thinning { |
| 12 | + |
| 13 | + public static class Config { |
| 14 | + public String ruptureSetFileName; |
| 15 | + public String outputFileName; |
| 16 | + public boolean hikurangiPosition = true; |
| 17 | + public Double hikurangiSize = 0.1; |
| 18 | + public boolean puysegurPosition = true; |
| 19 | + public Double puysegurSize = 0.1; |
| 20 | + } |
| 21 | + |
| 22 | + public static void apply(Config config) throws IOException { |
| 23 | + FaultSystemRupSet rupSet = FaultSystemRupSet.load(new File(config.ruptureSetFileName)); |
| 24 | + |
| 25 | + List<Integer> crustalIds = ThinningCrustal.filterCrustal(rupSet); |
| 26 | + |
| 27 | + System.out.println("crustal after thinning " + crustalIds.size()); |
| 28 | + |
| 29 | + ThinningSubduction hikurangiThinning = |
| 30 | + new ThinningSubduction(rupSet, s -> s.startsWith("Hikurangi")); |
| 31 | + if (config.hikurangiPosition) { |
| 32 | + hikurangiThinning.filterByPosition(); |
| 33 | + } |
| 34 | + if (config.hikurangiSize != null) { |
| 35 | + hikurangiThinning.filterBySize(config.hikurangiSize); |
| 36 | + } |
| 37 | + |
| 38 | + System.out.println("hikurangi after thinning " + hikurangiThinning.getRuptures().size()); |
| 39 | + |
| 40 | + ThinningSubduction puysegurThinning = |
| 41 | + new ThinningSubduction(rupSet, s -> s.startsWith("Puysegur")); |
| 42 | + if (config.puysegurPosition) { |
| 43 | + puysegurThinning.filterByPosition(); |
| 44 | + } |
| 45 | + if (config.puysegurSize != null) { |
| 46 | + puysegurThinning.filterBySize(config.puysegurSize); |
| 47 | + } |
| 48 | + |
| 49 | + System.out.println("puysegur after thinning " + puysegurThinning.getRuptures().size()); |
| 50 | + |
| 51 | + BufferedWriter writer = new BufferedWriter(new FileWriter(config.outputFileName)); |
| 52 | + for (Integer r : crustalIds) { |
| 53 | + writer.write("" + r); |
| 54 | + writer.newLine(); |
| 55 | + } |
| 56 | + for (Integer r : hikurangiThinning.getIds()) { |
| 57 | + writer.write("" + r); |
| 58 | + writer.newLine(); |
| 59 | + } |
| 60 | + for (Integer r : puysegurThinning.getIds()) { |
| 61 | + writer.write("" + r); |
| 62 | + writer.newLine(); |
| 63 | + } |
| 64 | + writer.close(); |
| 65 | + } |
| 66 | + |
| 67 | + public static void main(String[] args) throws IOException { |
| 68 | + Config config = new Config(); |
| 69 | + config.ruptureSetFileName = "C:\\Users\\volkertj\\Code\\ruptureSets\\nzshm22_merged.zip"; |
| 70 | + config.outputFileName = "/tmp/filteredRuptures.txt"; |
| 71 | + Thinning.apply(config); |
| 72 | + } |
| 73 | +} |
0 commit comments