GeoTessJavaExamples  2.0
StationData.java
Go to the documentation of this file.
1 package gov.sandia.geotess.examples.customdata;
2 
3 import java.io.DataInputStream;
4 import java.io.DataOutputStream;
5 import java.io.IOException;
6 import java.util.HashMap;
7 import java.util.Scanner;
8 
9 import gov.sandia.geotess.GeoTessUtils;
10 
11 /**
12  * Defines information for an event hypothesis at a single grid
13  * point and a single station.
14  * @author sandy
15  *
16  */
17 public class StationData extends HashMap<SeismicPhase, PhaseData>
18 {
19  /**
20  *
21  */
22  private static final long serialVersionUID = -8612644644926375628L;
23 
24  /**
25  * Distance from station to grid point, in degrees.
26  * (Easily computed from grid point and station locations.)
27  */
28  double delta;
29 
30  /**
31  * Azimuth from station to grid point, in degrees.
32  * (In GMS system is azimuth station-to-event or other way around?)
33  */
34  double azimuth;
35 
36  /**
37  * Backazimuth from grid point to station, in degrees.
38  * (In GMS system is backAzimuth station-to-event or other way around?)
39  */
40  double backAzimuth;
41 
42  public StationData() {
43  }
44 
45  /**
46  *
47  * @param input
48  * @param attributes A list of all the attributes supported by this model.
49  * All of these attributes will have values in each PhaseData map and will
50  * be read from, and written to the output files.
51  * @throws IOException
52  */
53  public StationData(DataInputStream input, GeoAttributes[] attributes) throws IOException
54  {
55  delta = input.readDouble();
56  azimuth = input.readDouble();
57  backAzimuth = input.readDouble();
58 
59  int nPhases = input.readInt();
60 
61  for (int i=0; i<nPhases; ++i)
62  {
63  SeismicPhase phase = SeismicPhase.valueOf(GeoTessUtils.readString(input));
64  put(phase, new PhaseData(input, attributes));
65  }
66  }
67 
68  /**
69  *
70  * @param output
71  * @param attributes A list of all the attributes supported by this model.
72  * All of these attributes will have values in each PhaseData map and will
73  * be read from, and written to the output files.
74  * @throws IOException
75  */
76  public void write(DataOutputStream output,
77  GeoAttributes[] attributes) throws IOException {
78  output.writeDouble(delta);
79  output.writeDouble(azimuth);
80  output.writeDouble(backAzimuth);
81 
82  output.writeInt(size()); // number phases
83  for (Entry<SeismicPhase, PhaseData> entry : entrySet())
84  {
85  GeoTessUtils.writeString(output, entry.getKey().toString()); // phase name
86  entry.getValue().write(output, attributes); // PhaseData
87  }
88  }
89 
90  /**
91  *
92  * @param input
93  * @param attributes A list of all the attributes supported by this model.
94  * All of these attributes will have values in each PhaseData map and will
95  * be read from, and written to the output files.
96  */
97  public StationData(Scanner input, GeoAttributes[] attributes)
98  {
99  delta = input.nextDouble();
100  azimuth = input.nextDouble();
101  backAzimuth = input.nextDouble();
102 
103  int nPhases = input.nextInt();
104  for (int i=0; i<nPhases; ++i)
105  {
106  SeismicPhase phase = SeismicPhase.valueOf(input.next());
107  put(phase, new PhaseData(input, attributes));
108  }
109  }
110 
111  /**
112  *
113  * @param output
114  * @param attributes A list of all the attributes supported by this model.
115  * All of these attributes will have values in each PhaseData map and will
116  * be read from, and written to the output files.
117  */
118  public void write(StringBuffer output,
119  GeoAttributes[] attributes) {
120  output.append(Double.toString(delta)).append(" ");
121  output.append(Double.toString(azimuth)).append(" ");
122  output.append(Double.toString(backAzimuth)).append('\n');
123 
124  for (Entry<SeismicPhase, PhaseData> entry : entrySet())
125  {
126  output.append(entry.getKey().toString()).append('\n'); // phase name
127  entry.getValue().write(output, attributes); // PhaseData
128  }
129  }
130 
131 }
gov
gov.sandia.geotess.examples.customdata.StationData.write
void write(StringBuffer output, GeoAttributes[] attributes)
Definition: StationData.java:118
gov.sandia.geotess.examples.customdata.StationData.StationData
StationData(DataInputStream input, GeoAttributes[] attributes)
Definition: StationData.java:53
gov.sandia.geotess
gov.sandia.geotess.examples.customdata.StationData.serialVersionUID
static final long serialVersionUID
Definition: StationData.java:22
gov.sandia.geotess.examples.customdata.StationData.StationData
StationData(Scanner input, GeoAttributes[] attributes)
Definition: StationData.java:97
gov.sandia.geotess.examples.customdata.PhaseData
Defines travel time information for an event hypothesis at a single grid point and single station - p...
Definition: PhaseData.java:16
gov.sandia.geotess.examples.customdata.StationData.write
void write(DataOutputStream output, GeoAttributes[] attributes)
Definition: StationData.java:76
gov.sandia.geotess.examples.customdata.StationData.StationData
StationData()
Definition: StationData.java:42
gov.sandia.geotess.examples.customdata.GeoAttributes
Definition: GeoAttributes.java:3
gov.sandia.geotess.examples.customdata.SeismicPhase
Definition: SeismicPhase.java:3
gov.sandia.geotess.examples.customdata.StationData
Defines information for an event hypothesis at a single grid point and a single station.
Definition: StationData.java:18
gov.sandia