View Javadoc

1   /*
2     The TauP Toolkit: Flexible Seismic Travel-Time and Raypath Utilities.
3     Copyright (C) 1998-2000 University of South Carolina
4   
5     This program is free software; you can redistribute it and/or
6     modify it under the terms of the GNU General Public License
7     as published by the Free Software Foundation; either version 2
8     of the License, or (at your option) any later version.
9   
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14  
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  
19    The current version can be found at 
20    <A HREF="www.seis.sc.edu">http://www.seis.sc.edu</A>
21  
22    Bug reports and comments should be directed to 
23    H. Philip Crotwell, crotwell@seis.sc.edu or
24    Tom Owens, owens@seis.sc.edu
25  
26  */
27  
28  package edu.sc.seis.TauP;
29  
30  import java.awt.Container;
31  import java.util.Vector;
32  
33  /***
34    * Velocity versus depth plot.
35    *
36    * @version 1.1.3 Wed Jul 18 15:00:35 GMT 2001
37  
38  
39  
40    * @author H. Philip Crotwell
41    */
42  public class VelocityPlot extends XYPlot {
43  
44     public VelocityPlot(Container parent) {
45        super(parent);
46        title = "Velocity";
47        xLabel = "velocity (km/sec)";
48        yLabel = "depth (km)";
49        xTickWidth = 1;
50        yTickWidth = 500;
51     }
52  
53     public VelocityPlot(Container parent, int width, int height) {
54        super(parent, width, height);
55        title = "Velocity";
56        xLabel = "velocity (km/sec)";
57        yLabel = "depth (km)";
58        xTickWidth = 1;
59        yTickWidth = 500;
60     }
61  
62     public void plot(VelocityModel velModel, char waveTypeA, char waveTypeB) 
63        throws NoSuchMatPropException
64     {
65        plot(velModel,waveTypeA);
66  
67        xData = new double[2*velModel.getNumLayers()];
68        yData = new double[2*velModel.getNumLayers()];
69  
70        int j=0;
71        for (int i=0;i<velModel.getNumLayers();i++) {
72           yData[j]=velModel.radiusOfEarth - velModel.depthAtTop(i);
73           xData[j]=velModel.evaluateAtTop(i,waveTypeB);
74           if (DEBUG) System.out.println("x "+xData[j]+" y "+yData[j]);
75           j++;
76   
77           yData[j]=velModel.radiusOfEarth -velModel.depthAtBottom(i)-minY;
78           xData[j]=velModel.evaluateAtBottom(i,waveTypeB);
79           if (DEBUG) System.out.println("x "+xData[j]+" y "+yData[j]);
80           j++;
81        }
82        xSegments.addElement(xData);
83        ySegments.addElement(yData);
84        xData=null;
85        yData=null;
86     }
87  
88     public void plot(VelocityModel velModel, char waveType) 
89        throws NoSuchMatPropException
90     {
91  
92        minX = 0.0;
93        zoomMinX = minX;
94        maxX = 15.0;
95        zoomMaxX = maxX;
96        minY = 0.0;
97        zoomMinY = minY;
98        maxY = velModel.radiusOfEarth;
99        zoomMaxY = maxY;
100 
101       xSegments = new Vector();
102       ySegments = new Vector();
103       xData = new double[2*velModel.getNumLayers()];
104       yData = new double[2*velModel.getNumLayers()];
105 
106 
107       int j=0;
108       for (int i=0;i<velModel.getNumLayers();i++) {
109          yData[j]=velModel.radiusOfEarth - velModel.depthAtTop(i);
110          xData[j]=velModel.evaluateAtTop(i,waveType);
111          if (DEBUG) System.out.println(xData[j]+" "+yData[j]);
112          j++;
113 
114          yData[j]=velModel.radiusOfEarth -velModel.depthAtBottom(i)-minY;
115          xData[j]=velModel.evaluateAtBottom(i,waveType);
116          if (DEBUG) System.out.println(xData[j]+" "+yData[j]);
117          j++;
118       }
119       if (DEBUG) System.out.println("> ");
120       xSegments.addElement(xData);
121       ySegments.addElement(yData);
122       xData=null;
123       yData=null;
124       repaint();
125    }
126  
127 }