|
1 | 1 | package gov.usgs.earthquake.nshmp; |
2 | 2 |
|
3 | | -//....................................... Import .......................................... |
4 | 3 | import java.util.ArrayList; |
5 | 4 | import java.util.List; |
6 | 5 | import java.util.Map; |
|
13 | 12 | import gov.usgs.earthquake.nshmp.data.Data; |
14 | 13 | import gov.usgs.earthquake.nshmp.gmm.Gmm; |
15 | 14 | import gov.usgs.earthquake.nshmp.gmm.GmmInput; |
| 15 | +import gov.usgs.earthquake.nshmp.gmm.GroundMotionModel; |
16 | 16 | import gov.usgs.earthquake.nshmp.gmm.Imt; |
17 | 17 | import gov.usgs.earthquake.nshmp.gmm.ScalarGroundMotion; |
18 | 18 | import gov.usgs.earthquake.nshmp.util.Maths; |
19 | | -//--------------------------------------- End Import -------------------------------------- |
20 | | - |
21 | | - |
22 | 19 |
|
23 | 20 | public class GroundMotions { |
24 | | - |
25 | | - |
26 | | - //................................ Method: distanceGroundMotion ......................... |
| 21 | + |
27 | 22 | public static DistanceResult distanceGroundMotions( |
28 | 23 | Set<Gmm> gmms, |
29 | 24 | GmmInput inputModel, |
30 | 25 | Imt imt, |
31 | 26 | double rMax) { |
32 | | - |
33 | | - |
34 | | - //.............................. Set Distance and Gmm Inputs .......................... |
| 27 | + |
35 | 28 | int round = 5; |
36 | | - double rJB; |
| 29 | + double rJB; |
37 | 30 | double rX; |
38 | 31 | double rRup; |
39 | 32 | double rMin = 0.001; |
40 | 33 | double rPoints = 100.0; |
41 | | - double rStep = (Math.log10(rMax/rMin))/(rPoints-1); |
42 | | - double[] distance = Data.round(round, Data.pow10(Data.buildSequence( |
43 | | - Math.log10(rMin), Math.log10(rMax), rStep, true))); |
44 | | - |
45 | | - List<GmmInput> gmmInputs = new ArrayList<>(); |
46 | | - |
47 | | - for(double r : distance) { |
| 34 | + double rStep = (Math.log10(rMax / rMin)) / (rPoints - 1); |
| 35 | + double[] distance = Data.round(round, Data.pow10( |
| 36 | + Data.buildSequence(Math.log10(rMin), Math.log10(rMax), rStep, true))); |
| 37 | + |
| 38 | + List<GmmInput> gmmInputs = new ArrayList<>(); |
| 39 | + GmmInput.Builder gmmBuilder = GmmInput.builder().fromCopy(inputModel); |
| 40 | + |
| 41 | + for (double r : distance) { |
48 | 42 | rJB = r; |
49 | 43 | rX = r; |
50 | 44 | rRup = Maths.hypot(r, inputModel.zTop); |
51 | | - GmmInput.Builder gmmBuilder = GmmInput.builder().fromModel(inputModel); |
52 | | - gmmInputs.add(gmmBuilder.distances(rJB, rRup, rX).build()); |
| 45 | + gmmBuilder.distances(rJB, rRup, rX); |
| 46 | + gmmInputs.add(gmmBuilder.build()); |
53 | 47 | } |
54 | | - //------------------------------------------------------------------------------------- |
55 | | - |
56 | | - |
57 | | - //........................... Calculate Ground Motion ................................. |
| 48 | + |
58 | 49 | Map<Gmm, List<Double>> distanceMap = Maps.newEnumMap(Gmm.class); |
59 | 50 | Map<Gmm, List<Double>> meanMap = Maps.newEnumMap(Gmm.class); |
60 | 51 | Map<Gmm, List<Double>> sigmaMap = Maps.newEnumMap(Gmm.class); |
61 | | - |
62 | | - for(Gmm gmm : gmms) { |
| 52 | + |
| 53 | + for (Gmm gmm : gmms) { |
63 | 54 | ImmutableList.Builder<Double> means = ImmutableList.builder(); |
64 | 55 | ImmutableList.Builder<Double> sigmas = ImmutableList.builder(); |
65 | | - |
66 | | - for(GmmInput gmmInput : gmmInputs) { |
67 | | - ScalarGroundMotion gm = gmm.instance(imt).calc(gmmInput); |
| 56 | + |
| 57 | + GroundMotionModel model = gmm.instance(imt); |
| 58 | + for (GmmInput gmmInput : gmmInputs) { |
| 59 | + ScalarGroundMotion gm = model.calc(gmmInput); |
68 | 60 | means.add(gm.mean()); |
69 | | - sigmas.add(gm.sigma()); |
| 61 | + sigmas.add(gm.sigma()); |
70 | 62 | } |
71 | | - |
| 63 | + |
72 | 64 | meanMap.put(gmm, means.build()); |
73 | 65 | sigmaMap.put(gmm, sigmas.build()); |
74 | 66 | distanceMap.put(gmm, Doubles.asList(distance)); |
75 | 67 | } |
76 | | - //------------------------------------------------------------------------------------- |
77 | | - |
| 68 | + |
78 | 69 | return new DistanceResult( |
79 | 70 | Maps.immutableEnumMap(distanceMap), |
80 | 71 | Maps.immutableEnumMap(meanMap), |
81 | | - Maps.immutableEnumMap(sigmaMap) |
82 | | - ); |
| 72 | + Maps.immutableEnumMap(sigmaMap)); |
83 | 73 | } |
84 | | - //------------------------------ End Method: distanceGroundMotion ----------------------- |
85 | | - |
86 | | - |
87 | | - |
88 | | - //............................. Class: DistanceResult ................................... |
| 74 | + |
89 | 75 | public static class DistanceResult { |
90 | | - |
| 76 | + |
91 | 77 | public final Map<Gmm, List<Double>> means; |
92 | 78 | public final Map<Gmm, List<Double>> distance; |
93 | 79 | public final Map<Gmm, List<Double>> sigmas; |
94 | | - |
| 80 | + |
95 | 81 | DistanceResult( |
96 | 82 | Map<Gmm, List<Double>> distance, |
97 | 83 | Map<Gmm, List<Double>> means, |
98 | | - Map<Gmm, List<Double>> sigmas){ |
99 | | - this.distance = distance; |
| 84 | + Map<Gmm, List<Double>> sigmas) { |
| 85 | + this.distance = distance; |
100 | 86 | this.means = means; |
101 | 87 | this.sigmas = sigmas; |
102 | 88 | } |
103 | 89 | } |
104 | | - //------------------------------ End Class: DistanceResult ------------------------------ |
105 | 90 |
|
106 | | - |
107 | | - |
108 | 91 | } |
109 | | -//-------------------------------- End Class: GroundMotions ------------------------------- |
0 commit comments