GeoTessJavaExamples  2.0
PhaseData.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 /**
10  * Defines travel time information for an event hypothesis
11  * at a single grid point and single station - phase.
12  * @author sandy
13  *
14  */
15 public class PhaseData extends HashMap<GeoAttributes, Double>
16 {
17  /**
18  *
19  */
20  private static final long serialVersionUID = 7339325174314271494L;
21 
22  /**
23  * Whether or not this is a primary phase. Need more information about this.
24  */
25  boolean primary;
26 
27  public PhaseData() {
28  }
29 
30  /**
31  *
32  * @param input
33  * @param attributes A list of all the attributes supported by this model.
34  * All of these attributes will have values in each PhaseData map and will
35  * be read from, and written to the output files.
36  * @throws IOException
37  */
38  public PhaseData(DataInputStream input, GeoAttributes[] attributes) throws IOException
39  {
40  primary = input.readBoolean();
41  for (GeoAttributes a : attributes)
42  put(a, input.readDouble());
43  }
44 
45  /**
46  *
47  * @param output
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 void write(DataOutputStream output, GeoAttributes[] attributes) throws IOException
54  {
55  output.writeBoolean(primary);
56  for (GeoAttributes a : attributes)
57  output.writeDouble(get(a));
58  }
59 
60  /**
61  *
62  * @param input
63  * @param attributes A list of all the attributes supported by this model.
64  * All of these attributes will have values in each PhaseData map and will
65  * be read from, and written to the output files.
66  */
67  public PhaseData(Scanner input, GeoAttributes[] attributes)
68  {
69  primary = input.nextBoolean();
70  for (GeoAttributes a : attributes)
71  put(a, input.nextDouble());
72  }
73 
74  /**
75  *
76  * @param output A list of all the attributes supported by this model.
77  * All of these attributes will have values in each PhaseData map and will
78  * be read from, and written to the output files.
79  * @param attributes
80  */
81  public void write(StringBuffer output, GeoAttributes[] attributes) {
82  output.append(primary);
83  for (GeoAttributes a : attributes)
84  {
85  Double value = get(a);
86  output.append(' ');
87  output.append(value == null ? "NaN"
88  : Double.toString(value));
89  }
90  }
91 
92 }
gov.sandia.geotess.examples.customdata.PhaseData.write
void write(DataOutputStream output, GeoAttributes[] attributes)
Definition: PhaseData.java:53
gov.sandia.geotess.examples.customdata.PhaseData.PhaseData
PhaseData(DataInputStream input, GeoAttributes[] attributes)
Definition: PhaseData.java:38
gov.sandia.geotess.examples.customdata.PhaseData.PhaseData
PhaseData(Scanner input, GeoAttributes[] attributes)
Definition: PhaseData.java:67
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.PhaseData.PhaseData
PhaseData()
Definition: PhaseData.java:27
gov.sandia.geotess.examples.customdata.PhaseData.write
void write(StringBuffer output, GeoAttributes[] attributes)
Definition: PhaseData.java:81
gov.sandia.geotess.examples.customdata.GeoAttributes
Definition: GeoAttributes.java:3
gov.sandia.geotess.examples.customdata.PhaseData.serialVersionUID
static final long serialVersionUID
Definition: PhaseData.java:20