1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 package edu.sc.seis.TauP;
30
31 /*** convenience class for storing the parameters associated with a
32 * phase arrival.
33 *
34 * @version 1.1.3 Wed Jul 18 15:00:35 GMT 2001
35
36
37
38 * @author H. Philip Crotwell
39 *
40 */
41 public class Arrival implements Cloneable {
42
43 public Arrival(SeismicPhase phase,
44 double time,
45 double dist,
46 double rayParam,
47 int rayParamIndex,
48 String name,
49 String puristName,
50 double sourceDepth) {
51 this.phase = phase;
52 this.time = time;
53 this.dist = dist;
54 this.rayParam = rayParam;
55 this.rayParamIndex = rayParamIndex;
56 this.name = name;
57 this.puristName = puristName;
58 this.sourceDepth = sourceDepth;
59 }
60
61 /*** phase that generated this arrival. */
62 protected SeismicPhase phase;
63
64 /*** travel time in seconds */
65 protected double time;
66
67 /*** angular distance (great circle) in radians */
68 protected double dist;
69
70 /*** ray parameter in seconds per radians. */
71 protected double rayParam;
72
73 protected int rayParamIndex;
74
75 /*** phase name */
76 protected String name;
77
78 /*** phase name changed for true depths */
79 protected String puristName;
80
81 /*** source depth in kilometers */
82 protected double sourceDepth;
83
84 /*** pierce and path points */
85 protected TimeDist[] pierce, path;
86
87
88
89 /*** @returns the phase used to calculate this arrival.*/
90 public SeismicPhase getPhase() {
91 return phase;
92 }
93
94 /*** returns travel time in seconds */
95 public double getTime() {
96 return time;
97 }
98
99 /*** returns travel distance in radians */
100 public double getDist() {
101 return dist;
102 }
103
104 /*** returns travel distance in degrees.
105 */
106 public double getDistDeg() {
107 return RtoD * getDist();
108 }
109
110 /*** returns distance in radians and in the range 0-PI.
111 Note this may not be the actual distance traveled.
112 */
113 public double getModuloDist() {
114 double moduloDist = getDist() % TWOPI;
115 if (moduloDist > Math.PI) { moduloDist = TWOPI - moduloDist; }
116 return moduloDist;
117 }
118
119 /*** returns distance in degrees and in the range 0-180.
120 Note this may not be the actual distance traveled.
121 */
122 public double getModuloDistDeg() {
123 double moduloDist = ( RtoD *getDist()) % 360;
124 if (moduloDist > 180) { moduloDist = 360 - moduloDist; }
125 return moduloDist;
126 }
127
128 /*** returns ray parameter in seconds per radian */
129 public double getRayParam() {
130 return rayParam;
131 }
132
133 /*** returns phase name */
134 public String getName() {
135 return name;
136 }
137
138 /*** returns purist's version of name. Depths are changed to reflect
139 * the true depth of the interface. */
140 public String getPuristName() {
141 return puristName;
142 }
143
144 /*** returns source depth in kilometers */
145 public double getSourceDepth() {
146 return sourceDepth;
147 }
148
149 /*** returns pierce points as TimeDist objects. */
150 public TimeDist[] getPierce() {
151 return pierce;
152 }
153
154 /*** returns pierce points as TimeDist objects. */
155 public TimeDist[] getPath() {
156 return path;
157 }
158
159 public Object clone() {
160 try {
161 Arrival newObject = (Arrival)super.clone();
162 if (pierce != null) {
163 newObject.pierce = new TimeDist[pierce.length];
164 for (int i=0; i<pierce.length; i++) {
165 if (pierce[i] != null) {
166 newObject.pierce[i] = (TimeDist)pierce[i].clone();
167 } else {
168 newObject.pierce[i] = null;
169 }
170 }
171 }
172 if (path != null) {
173 newObject.path = new TimeDist[path.length];
174 for (int i=0; i<path.length; i++) {
175 newObject.path[i] = (TimeDist)path[i].clone();
176 }
177 }
178 return newObject;
179 } catch (CloneNotSupportedException e) {
180
181 throw new InternalError(e.toString());
182 }
183 }
184
185 public String toString() {
186 String desc = "time="+time+" dist="+dist+" rayParam="+rayParam+" rayParamIndex="+rayParamIndex+" name="+name;
187 if (pierce != null) {
188 System.out.println("\nPierce:");
189 for (int i=0;i<pierce.length;i++) {
190 System.out.println(pierce[i]);
191 }
192 }
193 return desc;
194 }
195
196 public int getNumPiercePoints() {
197 if (pierce != null) {
198 return pierce.length;
199 } else {
200 return 0;
201 }
202 }
203
204 public int getNumPathPoints() {
205 if (path != null) {
206 return path.length;
207 } else {
208 return 0;
209 }
210 }
211
212 public TimeDist getPiercePoint(int i) {
213
214 return pierce[i];
215 }
216
217 /*** finds the first pierce point at the given depth.
218 * @throws ArrayIndexOutOfBoundsException if depth is not found
219 */
220 public TimeDist getFirstPiercePoint(double depth) {
221 for (int i=0; i< pierce.length; i++) {
222 if (pierce[i].depth == depth) {
223 return pierce[i];
224 }
225 }
226 throw new ArrayIndexOutOfBoundsException(
227 "No Pierce point found for depth "+depth);
228 }
229
230 /*** finds the last pierce point at the given depth.
231 * @throws ArrayIndexOutOfBoundsException if depth is not found
232 */
233 public TimeDist getLastPiercePoint(double depth) {
234 TimeDist piercepoint = null;
235 for (int i=0; i< pierce.length; i++) {
236 if (pierce[i].depth == depth) {
237 piercepoint = pierce[i];
238 }
239 }
240 if (piercepoint == null) {
241 throw new ArrayIndexOutOfBoundsException(
242 "No Pierce point found for depth "+depth);
243 }
244 return piercepoint;
245 }
246
247 public TimeDist getPathPoint(int i) {
248
249 return path[i];
250 }
251
252 protected static final double TWOPI = 2.0 * Math.PI;
253 protected static final double DtoR = Math.PI / 180.0;
254 protected static final double RtoD = 180.0 / Math.PI;
255 }