edu.sc.seis.TauP
Class VelocityModel

java.lang.Object
  extended by edu.sc.seis.TauP.VelocityModel
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class VelocityModel
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

This class defines basic classes to store and manipulate a velocity model.

See Also:
Serialized Form

Field Summary
protected  double cmbDepth
          Depth (km) of the cmb (core mantle boundary).
static double DEFAULT_CMB
           
static double DEFAULT_IOCB
           
static double DEFAULT_MOHO
           
protected  double iocbDepth
          Depth (km) of the iocb (inner core outer core boundary).
protected  java.util.List<VelocityLayer> layer
          expandable array to hold the layers
protected  double maxRadius
          maximum radius of the model (km), default 6371.0
protected  double minRadius
          minimum radius of the model (km), default 0.0
protected  java.lang.String modelName
          name of the velocity model.
protected  double mohoDepth
          Depth (km) of the moho.
protected  double radiusOfEarth
          reference radius (km), usually radius of the earth, by default 6371 kilometers.
protected  boolean spherical
          is this a spherical model? Default is true.
protected static int vectorLength
          the initial length of the layer vector.
 
Constructor Summary
VelocityModel(java.lang.String modelName, double radiusOfEarth, double mohoDepth, double cmbDepth, double iocbDepth, double minRadius, double maxRadius, boolean spherical, java.util.List<VelocityLayer> layer)
           
 
Method Summary
 double depthAtBottom(int layerNumber)
          returns the depth at the bottom of the given layer.
 double depthAtTop(int layerNumber)
          returns the depth at the top of the given layer.
 VelocityModel earthFlattenTransform()
          Returns a flat velocity model object equivalent to the spherical velocity model via the earth flattening transform.
 double evaluateAbove(double depth, char materialProperty)
          returns the value of the given material property, usually P or S velocity, at the given depth.
 double evaluateAtBottom(int layerNumber, char materialProperty)
          returns the value of the given material property, usually P or S velocity, at the bottom of the given layer.
 double evaluateAtTop(int layerNumber, char materialProperty)
          returns the value of the given material property, usually P or S velocity, at the top of the given layer.
 double evaluateBelow(double depth, char materialProperty)
          returns the value of the given material property, usually P or S velocity, at the given depth.
 boolean fixDisconDepths()
          resets depths of major discontinuities to match those existing in the input velocity model.
 double getCmbDepth()
           
 double[] getDisconDepths()
           
 double getIocbDepth()
           
 VelocityLayer[] getLayers()
           
 double getMaxRadius()
           
 double getMinRadius()
           
 java.lang.String getModelName()
          get the model name.
static java.lang.String getModelNameFromFileName(java.lang.String filename)
           
 double getMohoDepth()
           
 int getNumLayers()
          Returns the number of layers in this velocity model.
 double getRadiusOfEarth()
          gets radius of the earth (km), by default 6371 kilometers.
 boolean getSpherical()
           
 VelocityLayer getVelocityLayer(int layerNum)
           
 VelocityLayer getVelocityLayerClone(int layerNum)
           
 int layerNumberAbove(double depth)
          Finds the layer containing the given depth.
 int layerNumberBelow(double depth)
          Finds the layer containing the given depth.
 void print()
           
 void printGMT(java.io.DataOutputStream dos)
          prints out the velocity model into a file in a for suitable for plotting with GMT.
 void printGMT(java.lang.String filename)
          prints out the velocity model into a file in a form suitable for plotting with GMT.
static VelocityModel readNDFile(java.io.File file)
          This method reads in a velocity model from a "nd" ASCII text file, the format used by Xgbm.
static VelocityModel readNDFile(java.io.Reader in, java.lang.String modelName)
           
static VelocityModel readTVelFile(java.io.File file)
          This method reads in a velocity model from a "tvel" ASCII text file.
static VelocityModel readTVelFile(java.io.Reader in, java.lang.String modelName)
           
static VelocityModel readVelocityFile(java.lang.String filename, java.lang.String fileType)
          Reads in a velocity file.
 VelocityModel replaceLayers(VelocityLayer[] newLayers, java.lang.String name, boolean matchTop, boolean matchBot)
           
 void setCmbDepth(double cmbDepth)
           
 void setIocbDepth(double iocbDepth)
           
 void setMaxRadius(double maxRadius)
           
 void setMinRadius(double minRadius)
           
 void setModelName(java.lang.String modelName)
          set the model name.
 void setMohoDepth(double mohoDepth)
           
 void setRadiusOfEarth(double radiusOfEarth)
          sets radius of the earth (km), by default 6371 kilometers.
 void setSpherical(boolean spherical)
           
 java.lang.String toString()
           
 boolean validate()
          Performs internal consistency checks on the velocity model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

modelName

protected java.lang.String modelName
name of the velocity model.


radiusOfEarth

protected double radiusOfEarth
reference radius (km), usually radius of the earth, by default 6371 kilometers.


DEFAULT_MOHO

public static final double DEFAULT_MOHO
See Also:
Constant Field Values

DEFAULT_CMB

public static final double DEFAULT_CMB
See Also:
Constant Field Values

DEFAULT_IOCB

public static final double DEFAULT_IOCB
See Also:
Constant Field Values

mohoDepth

protected double mohoDepth
Depth (km) of the moho. It can be input from velocity model (*.nd) or should be explicitly set. By default it is 35 kilometers (from Iasp91). For phase naming, the tau model will choose the closest 1st order discontinuity. Thus for most simple earth models these values are satisfactory. Take proper care if your model has a thicker crust and a discontinuity near 35 km depth.


cmbDepth

protected double cmbDepth
Depth (km) of the cmb (core mantle boundary). It can be input from velocity model (*.nd) or should be explicitly set. By default it is 2889 kilometers (from Iasp91). For phase naming, the tau model will choose the closest 1st order discontinuity. Thus for most simple earth models these values are satisfactory.


iocbDepth

protected double iocbDepth
Depth (km) of the iocb (inner core outer core boundary). It can be input from velocity model (*.nd) or should be explicitly set. By default it is 5153.9 kilometers (from Iasp91). For phase naming, the tau model will choose the closest 1st order discontinuity. Thus for most simple earth models these values are satisfactory.


minRadius

protected double minRadius
minimum radius of the model (km), default 0.0


maxRadius

protected double maxRadius
maximum radius of the model (km), default 6371.0


spherical

protected boolean spherical
is this a spherical model? Default is true.


vectorLength

protected static int vectorLength
the initial length of the layer vector.


layer

protected java.util.List<VelocityLayer> layer
expandable array to hold the layers

Constructor Detail

VelocityModel

public VelocityModel(java.lang.String modelName,
                     double radiusOfEarth,
                     double mohoDepth,
                     double cmbDepth,
                     double iocbDepth,
                     double minRadius,
                     double maxRadius,
                     boolean spherical,
                     java.util.List<VelocityLayer> layer)
Method Detail

getModelName

public java.lang.String getModelName()
get the model name.


setModelName

public void setModelName(java.lang.String modelName)
set the model name.


setRadiusOfEarth

public void setRadiusOfEarth(double radiusOfEarth)
sets radius of the earth (km), by default 6371 kilometers.


getRadiusOfEarth

public double getRadiusOfEarth()
gets radius of the earth (km), by default 6371 kilometers.


getDisconDepths

public double[] getDisconDepths()
Returns:
the depths of discontinuities within the velocity model

getMohoDepth

public double getMohoDepth()
Returns:
depth (km) of the moho. It can be input from velocity model (*.nd) or should be explicitly set. By default it is 35 kilometers (from Iasp91). For phase naming, the tau model will choose the closest 1st order discontinuity. Thus for most simple earth models these values are satisfactory. Take proper care if your model has a thicker crust and a discontinuity near 35 km depth.

setMohoDepth

public void setMohoDepth(double mohoDepth)

getCmbDepth

public double getCmbDepth()
Returns:
depth (km) of the cmb (core mantle boundary). It can be input from velocity model (*.nd) or should be explicitly set. By default it is 2889 kilometers (from Iasp91). For phase naming, the tau model will choose the closest 1st order discontinuity. Thus for most simple earth models these values are satisfactory.

setCmbDepth

public void setCmbDepth(double cmbDepth)

getIocbDepth

public double getIocbDepth()
Returns:
the depth (km) of the iocb (inner core outer core boundary). It can be input from velocity model (*.nd) or should be explicitly set. By default it is 5153.9 kilometers (from Iasp91). For phase naming, the tau model will choose the closest 1st order discontinuity. Thus for most simple earth models these values are satisfactory.

setIocbDepth

public void setIocbDepth(double iocbDepth)

getMinRadius

public double getMinRadius()

setMinRadius

public void setMinRadius(double minRadius)

getMaxRadius

public double getMaxRadius()

setMaxRadius

public void setMaxRadius(double maxRadius)

getSpherical

public boolean getSpherical()

setSpherical

public void setSpherical(boolean spherical)

getVelocityLayerClone

public VelocityLayer getVelocityLayerClone(int layerNum)

getVelocityLayer

public VelocityLayer getVelocityLayer(int layerNum)

getNumLayers

public int getNumLayers()
Returns the number of layers in this velocity model.


getLayers

public VelocityLayer[] getLayers()

layerNumberAbove

public int layerNumberAbove(double depth)
                     throws NoSuchLayerException
Finds the layer containing the given depth. Note this returns the upper layer if the depth happens to be at a layer boundary.

Returns:
the layer number
Throws:
NoSuchLayerException - occurs if no layer contains the given depth.

layerNumberBelow

public int layerNumberBelow(double depth)
                     throws NoSuchLayerException
Finds the layer containing the given depth. Note this returns the lower layer if the depth happens to be at a layer boundary.

Returns:
the layer number
Throws:
NoSuchLayerException - occurs if no layer contains the given depth.

evaluateAbove

public double evaluateAbove(double depth,
                            char materialProperty)
                     throws NoSuchLayerException,
                            NoSuchMatPropException
returns the value of the given material property, usually P or S velocity, at the given depth. Note this returns the value at the bottom of the upper layer if the depth happens to be at a layer boundary.

Returns:
the value of the given material property
Throws:
NoSuchLayerException - occurs if no layer contains the given depth.
NoSuchMatPropException - occurs if the material property is not recognized.

evaluateBelow

public double evaluateBelow(double depth,
                            char materialProperty)
                     throws NoSuchLayerException,
                            NoSuchMatPropException
returns the value of the given material property, usually P or S velocity, at the given depth. Note this returns the value at the top of the lower layer if the depth happens to be at a layer boundary.

Returns:
the value of the given material property
Throws:
NoSuchLayerException - occurs if no layer contains the given depth.
NoSuchMatPropException - occurs if the material property is not recognized.

evaluateAtTop

public double evaluateAtTop(int layerNumber,
                            char materialProperty)
                     throws NoSuchMatPropException
returns the value of the given material property, usually P or S velocity, at the top of the given layer.

Returns:
the value of the given material property
Throws:
NoSuchMatPropException - occurs if the material property is not recognized.

evaluateAtBottom

public double evaluateAtBottom(int layerNumber,
                               char materialProperty)
                        throws NoSuchMatPropException
returns the value of the given material property, usually P or S velocity, at the bottom of the given layer.

Returns:
the value of the given material property
Throws:
NoSuchMatPropException - occurs if the material property is not recognized.

depthAtTop

public double depthAtTop(int layerNumber)
returns the depth at the top of the given layer.

Returns:
the depth.

depthAtBottom

public double depthAtBottom(int layerNumber)
                     throws NoSuchMatPropException
returns the depth at the bottom of the given layer.

Returns:
the depth.
Throws:
NoSuchMatPropException - occurs if the material property is not recognized.

replaceLayers

public VelocityModel replaceLayers(VelocityLayer[] newLayers,
                                   java.lang.String name,
                                   boolean matchTop,
                                   boolean matchBot)
                            throws NoSuchLayerException
Throws:
NoSuchLayerException

printGMT

public void printGMT(java.lang.String filename)
              throws java.io.IOException
prints out the velocity model into a file in a form suitable for plotting with GMT.

Throws:
java.io.IOException

printGMT

public void printGMT(java.io.DataOutputStream dos)
              throws java.io.IOException
prints out the velocity model into a file in a for suitable for plotting with GMT.

Throws:
java.io.IOException

validate

public boolean validate()
Performs internal consistency checks on the velocity model.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

print

public void print()

getModelNameFromFileName

public static java.lang.String getModelNameFromFileName(java.lang.String filename)

readVelocityFile

public static VelocityModel readVelocityFile(java.lang.String filename,
                                             java.lang.String fileType)
                                      throws java.io.IOException,
                                             VelocityModelException
Reads in a velocity file. The type of file is determined by the fileType var. Calls readTVelFile or readNDFile.

Throws:
VelocityModelException - if the type of file cannot be determined.
java.io.IOException

readTVelFile

public static VelocityModel readTVelFile(java.io.File file)
                                  throws java.io.IOException,
                                         VelocityModelException
This method reads in a velocity model from a "tvel" ASCII text file. The name of the model file for model "modelname" should be "modelname.tvel". The format of the file is: comment line - generally info about the P velocity model comment line - generally info about the S velocity model depth pVel sVel Density depth pVel sVel Density . . . The velocities are assumed to be linear between sample points. Because this type of model file doesn't give complete information we make the following assumptions: modelname - from the filename, with ".tvel" dropped if present radiusOfEarth - the largest depth in the model meanDensity - 5517.0 G - 6.67e-11 Also, because this method makes use of the string tokenizer, comments are allowed. # as well as // signify that the rest of the line is a comment. C style slash-star comments are also allowed.

Throws:
VelocityModelException - occurs if an EOL should have been read but wasn't. This may indicate a poorly formatted tvel file.
java.io.IOException

readTVelFile

public static VelocityModel readTVelFile(java.io.Reader in,
                                         java.lang.String modelName)
                                  throws java.io.IOException,
                                         VelocityModelException
Throws:
java.io.IOException
VelocityModelException

readNDFile

public static VelocityModel readNDFile(java.io.File file)
                                throws java.io.IOException,
                                       VelocityModelException
This method reads in a velocity model from a "nd" ASCII text file, the format used by Xgbm. The name of the model file for model "modelname" should be "modelname.nd". The format of the file is: depth pVel sVel Density Qp Qs depth pVel sVel Density Qp Qs . . . with each major boundary separated with a line with "mantle", "outer-core" or "inner-core". "moho", "cmb" and "icocb" are allowed as synonyms respectively. This feature makes phase interpretation much easier to code. Also, as they are not needed for travel time calculations, the density, Qp and Qs may be omitted. The velocities are assumed to be linear between sample points. Because this type of model file doesn't give complete information we make the following assumptions: modelname - from the filename, with ".nd" dropped, if present radiusOfEarth - the largest depth in the model Also, because this method makes use of the string tokenizer, comments are allowed. # as well as // signify that the rest of the line is a comment. C style slash-star comments are also allowed.

Throws:
VelocityModelException - occurs if an EOL should have been read but wasn't. This may indicate a poorly formatted model file.
java.io.IOException

readNDFile

public static VelocityModel readNDFile(java.io.Reader in,
                                       java.lang.String modelName)
                                throws java.io.IOException,
                                       VelocityModelException
Throws:
java.io.IOException
VelocityModelException

fixDisconDepths

public boolean fixDisconDepths()
resets depths of major discontinuities to match those existing in the input velocity model. The initial values are set such that if there is no discontinuity within the top 100 km then the moho is set to 0.0. Similarly, if there are no discontinuities at al then the cmb is set to the radius of the earth. Similarly for the iocb, except it must be a fluid to solid boundary and deeper than 100km to avoid problems with shallower fluid layers, eg oceans.


earthFlattenTransform

public VelocityModel earthFlattenTransform()
                                    throws VelocityModelException
Returns a flat velocity model object equivalent to the spherical velocity model via the earth flattening transform.

Returns:
the flattened VelocityModel object.
Throws:
VelocityModelException - occurs ???.