Package edu.sc.seis.TauP
Class TauP_Time
- java.lang.Object
-
- edu.sc.seis.TauP.TauP_Tool
-
- edu.sc.seis.TauP.TauP_Time
-
- Direct Known Subclasses:
TauP_Curve
,TauP_PhaseDescribe
,TauP_Pierce
,TauP_SetSac
,TauP_Table
public class TauP_Time extends TauP_Tool
Calculate travel times for different branches using linear interpolation between known slowness samples.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<Arrival>
arrivals
protected double
azimuth
protected double
backAzimuth
static java.lang.String
DEFAULT_PHASES
protected java.util.List<java.lang.Double>
degreesList
protected double
depth
protected java.util.List<java.lang.Double>
distKilometersList
For when command line args uses --km for distance.protected double
eventLat
protected double
eventLon
protected boolean
GUI
protected java.lang.String
modelName
protected boolean
onlyFirst
protected boolean
onlyPrintRayP
protected boolean
onlyPrintTime
protected java.util.List<PhaseName>
phaseNames
names of phases to be used, ie PKIKP.protected double
receiverDepth
protected java.lang.String
relativePhaseName
protected double
scattererDepth
protected double
scattererDistDeg
protected double
shootRayp
protected double
stationLat
protected double
stationLon
protected double
takeoffAngle
protected TauModel
tMod
Tau model calculated previously.protected TauModel
tModDepth
TauModel derived from tMod by correcting it for a non-surface source.-
Fields inherited from class edu.sc.seis.TauP.TauP_Tool
cmdLineArgs, CSV, DEBUG, GMT, JSON, outFileBase, outForms, outputFormat, SVG, TEXT, toolProps, verbose, writer
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.String[]
allowedOutputFormats()
void
appendPhaseName(PhaseName phaseName)
void
appendPhaseName(java.lang.String phaseName)
java.util.List<Arrival>
calcEventStation(java.lang.Double[] evloc, java.util.List<java.lang.Double[]> staloc)
java.util.List<Arrival>
calcRayParameter(double rayparameter)
java.util.List<Arrival>
calcRayParameter(java.util.List<java.lang.Double> rayParameterList)
Shoots ray parameters for each phases from the source.java.util.List<Arrival>
calcRayParameterSDeg(java.util.List<java.lang.Double> rayParameterList)
Shoots ray parameters for each phases from the source.java.util.List<Arrival>
calcTakeoff(double takeoffAngle)
java.util.List<Arrival>
calcTakeoff(java.util.List<java.lang.Double> takeoffAngleList)
java.util.List<Arrival>
calcTime(double degrees)
java.util.List<Arrival>
calcTime(java.util.List<java.lang.Double> degreesList)
java.util.List<Arrival>
calculate(double degrees)
java.util.List<Arrival>
calculate(java.util.List<java.lang.Double> degreesList)
Arrival
calculateRelativeArrival(double degrees)
void
clearArrivals()
void
clearPhaseNames()
void
clearPhases()
void
depthCorrect()
corrects the TauModel for the source, receiver and scatter depths.void
depthCorrect(double depth)
Deprecated.use setSourceDepth insteadvoid
depthCorrect(double depth, double receiverDepth)
In general, this is called by each tool's calculate methods, and so should not need to be called by outside code.void
depthCorrect(double depth, double receiverDepth, double scatterDepth)
In general, this is called by each tool's calculate methods, and so should not need to be called by outside code.void
destroy()
static java.util.List<java.lang.String>
extractPhaseNames(java.lang.String phaseNames)
Parse comma separated list of phase names, expanding convience phase names like ttp into real phase names.Arrival
getArrival(int i)
java.util.List<Arrival>
getArrivals()
double[]
getDisconDepths()
int
getNumArrivals()
int
getNumPhases()
java.lang.String[]
getPhaseNames()
static java.util.List<java.lang.String>
getPhaseNames(java.lang.String phaseName)
Deprecated.see extractPhaseNamesjava.lang.String
getPhaseNameString()
double
getReceiverDepth()
double
getScattererDepth()
double
getScattererDistDeg()
java.util.List<SeismicPhase>
getSeismicPhases()
double
getSourceDepth()
TauModel
getTauModel()
TauModel
getTauModelDepthCorrected()
Gets depth corrected TauModel.java.lang.String
getTauModelName()
void
init()
preforms intialization of the tool.static double
linearInterp(double xa, double ya, double xb, double yb, double x)
solves the equation (yb-ya)/(xb-xa) = (y-ya)/(x-xa) for y given x.void
loadTauModel(java.lang.String modelName)
static void
main(java.lang.String[] args)
Allows TauP_Time to run as an application.protected java.lang.String[]
parseCmdLineArgs(java.lang.String[] origArgs)
static java.util.List<java.lang.Double>
parseDegreeList(java.lang.String degList)
Parses a comma separated list of distances and returns them in an array.void
parsePhaseList(java.lang.String phaseList)
parses a comma separated list of phase names and adds them to the phaseNames vector.protected java.lang.String[]
parseSourceModelCmdLineArgs(java.lang.String[] origArgs)
void
printDistanceUsage()
void
printHelp()
void
printLimitUsage()
void
printPhaseUsage()
void
printResult(java.io.PrintWriter out)
void
printResultJSON(java.io.PrintWriter out)
void
printResultText(java.io.PrintWriter out)
void
printStdUsage()
Prints the command line arguments common to all TauP tools.void
printStdUsageHead()
void
printUsage()
protected void
readPhaseFile(java.lang.String filename)
Reads in list of phase names from a text file.protected void
readTauModel()
Reads the velocity model, slowness model, and tau model from a file saved using Java's Serializable interface.protected void
recalcPhases()
recalculates the given phases using a possibly new or changed tau model.static java.lang.String
resultAsJSON(java.lang.String modelName, double depth, double receiverDepth, java.lang.String[] phases, java.util.List<Arrival> arrivals)
static java.lang.String
resultAsJSON(java.lang.String modelName, double depth, double receiverDepth, java.lang.String[] phases, java.util.List<Arrival> arrivals, boolean withPierce, boolean withPath)
void
setEventLatLon(double lat, double lon)
void
setPhaseNames(PhaseName[] phaseNames)
void
setPhaseNames(java.lang.String[] phaseNames)
void
setReceiverDepth(double receiverDepth)
void
setScatterer(double depth, double degrees)
void
setScattererDepth(double depth)
void
setScattererDistDeg(double distDeg)
void
setSourceDepth(double depth)
void
setStationLatLon(double lat, double lon)
void
setTauModel(TauModel tMod)
java.util.List<Arrival>
sortArrivals(java.util.List<Arrival> arrivals)
static java.lang.String[]
splitPhaseNameList(java.lang.String phaseList)
void
start()
void
validateArguments()
-
Methods inherited from class edu.sc.seis.TauP.TauP_Tool
closeWriter, configDefaults, dashEquals, endGmtAndCleanUp, getOutFile, getOutFileBase, getOutFileExtension, getOutputFormat, getWriter, parseCommonCmdLineArgs, printModDepthUsage, printNoComprendoArgs, printScriptBeginning, printStdUsageHead, printStdUsageTail, setOutFileBase, setOutFileExtension, setOutputFormat, setWriter, toolNameFromClass
-
-
-
-
Field Detail
-
modelName
protected java.lang.String modelName
-
tModDepth
protected transient TauModel tModDepth
TauModel derived from tMod by correcting it for a non-surface source.
-
phaseNames
protected java.util.List<PhaseName> phaseNames
names of phases to be used, ie PKIKP.
-
depth
protected double depth
-
receiverDepth
protected double receiverDepth
-
degreesList
protected java.util.List<java.lang.Double> degreesList
-
scattererDepth
protected double scattererDepth
-
scattererDistDeg
protected double scattererDistDeg
-
distKilometersList
protected java.util.List<java.lang.Double> distKilometersList
For when command line args uses --km for distance. Have to wait until after the model is read in to get radius of earth.
-
azimuth
protected double azimuth
-
backAzimuth
protected double backAzimuth
-
takeoffAngle
protected double takeoffAngle
-
shootRayp
protected double shootRayp
-
stationLat
protected double stationLat
-
stationLon
protected double stationLon
-
eventLat
protected double eventLat
-
eventLon
protected double eventLon
-
arrivals
protected java.util.List<Arrival> arrivals
-
GUI
protected boolean GUI
-
onlyPrintRayP
protected boolean onlyPrintRayP
-
onlyPrintTime
protected boolean onlyPrintTime
-
onlyFirst
protected boolean onlyFirst
-
relativePhaseName
protected java.lang.String relativePhaseName
-
DEFAULT_PHASES
public static final java.lang.String DEFAULT_PHASES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TauP_Time
public TauP_Time()
-
TauP_Time
public TauP_Time(TauModel tMod)
-
TauP_Time
public TauP_Time(java.lang.String modelName) throws TauModelException
creates a TauP_Time object with the tau model specified by modelName already loaded.- Throws:
TauModelException
- if the file can't be found or is corrupted in some way.
-
-
Method Detail
-
allowedOutputFormats
public java.lang.String[] allowedOutputFormats()
- Specified by:
allowedOutputFormats
in classTauP_Tool
-
getPhaseNames
public java.lang.String[] getPhaseNames()
-
getPhaseNameString
public java.lang.String getPhaseNameString()
-
setPhaseNames
public void setPhaseNames(java.lang.String[] phaseNames) throws TauModelException
- Throws:
TauModelException
-
setPhaseNames
public void setPhaseNames(PhaseName[] phaseNames)
-
getPhaseNames
public static java.util.List<java.lang.String> getPhaseNames(java.lang.String phaseName)
Deprecated.see extractPhaseNames- Parameters:
phaseName
-- Returns:
-
extractPhaseNames
public static java.util.List<java.lang.String> extractPhaseNames(java.lang.String phaseNames)
Parse comma separated list of phase names, expanding convience phase names like ttp into real phase names.- Parameters:
phaseNames
- string to parse- Returns:
- parsed list of phase names
-
appendPhaseName
public void appendPhaseName(java.lang.String phaseName) throws TauModelException
- Throws:
TauModelException
-
appendPhaseName
public void appendPhaseName(PhaseName phaseName)
-
getNumPhases
public int getNumPhases()
-
clearPhaseNames
public void clearPhaseNames()
-
getSourceDepth
public double getSourceDepth()
-
setSourceDepth
public void setSourceDepth(double depth)
-
getReceiverDepth
public double getReceiverDepth()
-
setReceiverDepth
public void setReceiverDepth(double receiverDepth)
-
getScattererDepth
public double getScattererDepth()
-
setScattererDepth
public void setScattererDepth(double depth)
-
getScattererDistDeg
public double getScattererDistDeg()
-
setScattererDistDeg
public void setScattererDistDeg(double distDeg)
-
setScatterer
public void setScatterer(double depth, double degrees)
-
setEventLatLon
public void setEventLatLon(double lat, double lon)
-
setStationLatLon
public void setStationLatLon(double lat, double lon)
-
getTauModelName
public java.lang.String getTauModelName()
-
getTauModel
public TauModel getTauModel()
-
getTauModelDepthCorrected
public TauModel getTauModelDepthCorrected() throws TauModelException
Gets depth corrected TauModel.- Throws:
TauModelException
-
setTauModel
public void setTauModel(TauModel tMod)
-
loadTauModel
public void loadTauModel(java.lang.String modelName) throws java.io.FileNotFoundException, java.io.InvalidClassException, java.io.IOException, java.io.StreamCorruptedException, java.io.OptionalDataException, TauModelException
- Throws:
java.io.FileNotFoundException
java.io.InvalidClassException
java.io.IOException
java.io.StreamCorruptedException
java.io.OptionalDataException
TauModelException
-
getDisconDepths
public double[] getDisconDepths()
-
clearPhases
public void clearPhases()
-
clearArrivals
public void clearArrivals()
-
getNumArrivals
public int getNumArrivals()
-
getArrival
public Arrival getArrival(int i)
-
getArrivals
public java.util.List<Arrival> getArrivals()
-
getSeismicPhases
public java.util.List<SeismicPhase> getSeismicPhases()
-
readTauModel
protected void readTauModel() throws TauModelException
Reads the velocity model, slowness model, and tau model from a file saved using Java's Serializable interface. Performs a depth correction if the current depth is not 0.0- Throws:
TauModelException
-
readPhaseFile
protected void readPhaseFile(java.lang.String filename) throws java.io.IOException
Reads in list of phase names from a text file. So long as each phase name is separated by some whitespace, " " or newline or tab, it should read them fine. Also, comments are allowed, either # or // are comments to the end of the line while c style slash-star make a block a comment.- Throws:
java.io.IOException
-
parsePhaseList
public void parsePhaseList(java.lang.String phaseList)
parses a comma separated list of phase names and adds them to the phaseNames vector. Each phase can have an optional argument after a dash. This would be used for specifying which sac header to put the time in, or for other unforeseen uses. This may be called multiple times to append more phases. For example: P-0,PcP-1,ScP-4,Sn,SS,S^410S would, assuming no previous phases have been added, put P in T0, PcP in T1, ScP in T5, Sn in T2, SS in T3, and S^410S in T6.
-
splitPhaseNameList
public static java.lang.String[] splitPhaseNameList(java.lang.String phaseList)
-
parseDegreeList
public static java.util.List<java.lang.Double> parseDegreeList(java.lang.String degList)
Parses a comma separated list of distances and returns them in an array.
-
parseSourceModelCmdLineArgs
protected java.lang.String[] parseSourceModelCmdLineArgs(java.lang.String[] origArgs) throws java.io.IOException
- Throws:
java.io.IOException
-
parseCmdLineArgs
protected java.lang.String[] parseCmdLineArgs(java.lang.String[] origArgs) throws java.io.IOException
- Specified by:
parseCmdLineArgs
in classTauP_Tool
- Throws:
java.io.IOException
-
calculate
public java.util.List<Arrival> calculate(double degrees) throws TauModelException
- Throws:
TauModelException
-
calculate
public java.util.List<Arrival> calculate(java.util.List<java.lang.Double> degreesList) throws TauModelException
- Throws:
TauModelException
-
calcEventStation
public java.util.List<Arrival> calcEventStation(java.lang.Double[] evloc, java.util.List<java.lang.Double[]> staloc) throws TauModelException
- Throws:
TauModelException
-
calculateRelativeArrival
public Arrival calculateRelativeArrival(double degrees) throws TauModelException
- Throws:
TauModelException
-
validateArguments
public void validateArguments() throws TauModelException
- Specified by:
validateArguments
in classTauP_Tool
- Throws:
TauModelException
-
calcTime
public java.util.List<Arrival> calcTime(double degrees) throws TauModelException
- Throws:
TauModelException
-
calcTime
public java.util.List<Arrival> calcTime(java.util.List<java.lang.Double> degreesList) throws TauModelException
- Throws:
TauModelException
-
calcTakeoff
public java.util.List<Arrival> calcTakeoff(double takeoffAngle) throws TauModelException
- Throws:
TauModelException
-
calcTakeoff
public java.util.List<Arrival> calcTakeoff(java.util.List<java.lang.Double> takeoffAngleList) throws TauModelException
- Throws:
TauModelException
-
calcRayParameter
public java.util.List<Arrival> calcRayParameter(double rayparameter) throws TauModelException
- Throws:
TauModelException
-
calcRayParameterSDeg
public java.util.List<Arrival> calcRayParameterSDeg(java.util.List<java.lang.Double> rayParameterList) throws TauModelException
Shoots ray parameters for each phases from the source.- Parameters:
rayParameterList
- ray parameter list in s/deg- Throws:
TauModelException
-
calcRayParameter
public java.util.List<Arrival> calcRayParameter(java.util.List<java.lang.Double> rayParameterList) throws TauModelException
Shoots ray parameters for each phases from the source.- Parameters:
rayParameterList
- ray parameter list in s/radian- Throws:
TauModelException
-
depthCorrect
public void depthCorrect() throws TauModelException
corrects the TauModel for the source, receiver and scatter depths. In general, this is called by each tool's calculate methods, and so should not need to be called by outside code. Most of the time calling setSourceDepth, setReceiverDepth and setScatterDepth is preferred, allowing the tool to choose when to call depthCorrect.- Throws:
TauModelException
-
depthCorrect
@Deprecated public void depthCorrect(double depth) throws TauModelException
Deprecated.use setSourceDepth insteadcorrects the TauModel for the given source depth. It only performs the correction of the model is not already corrected to that depth. In general, this is called by each tool's calculate methods, and so should not need to be called by outside code. Most of the time calling setSourceDepth is preferred, allowing the tool to choose when to call depthCorrect.- Throws:
TauModelException
-
depthCorrect
public void depthCorrect(double depth, double receiverDepth) throws TauModelException
In general, this is called by each tool's calculate methods, and so should not need to be called by outside code. Most of the time calling setSourceDepth and setReceiverDepth is preferred, allowing the tool to choose when to call depthCorrect.- Parameters:
depth
- the source depthreceiverDepth
- the receiver depth- Throws:
TauModelException
-
depthCorrect
public void depthCorrect(double depth, double receiverDepth, double scatterDepth) throws TauModelException
In general, this is called by each tool's calculate methods, and so should not need to be called by outside code. Most of the time calling setSourceDepth and setReceiverDepth and setScatterDepth is preferred, allowing the tool to choose when to call depthCorrect.- Parameters:
depth
- the source depthreceiverDepth
- the receiver depthscatterDepth
- scatterer depth, set to zero if no scattering- Throws:
TauModelException
-
recalcPhases
protected void recalcPhases()
recalculates the given phases using a possibly new or changed tau model. This should not need to be called by outside classes as it is called by depthCorrect, and calculate.
-
printResult
public void printResult(java.io.PrintWriter out) throws java.io.IOException
- Throws:
java.io.IOException
-
printResultText
public void printResultText(java.io.PrintWriter out) throws java.io.IOException
- Throws:
java.io.IOException
-
printResultJSON
public void printResultJSON(java.io.PrintWriter out)
-
resultAsJSON
public static java.lang.String resultAsJSON(java.lang.String modelName, double depth, double receiverDepth, java.lang.String[] phases, java.util.List<Arrival> arrivals)
-
resultAsJSON
public static java.lang.String resultAsJSON(java.lang.String modelName, double depth, double receiverDepth, java.lang.String[] phases, java.util.List<Arrival> arrivals, boolean withPierce, boolean withPath)
-
init
public void init() throws TauPException
preforms intialization of the tool. Properties are queried for the the default model to load, source depth to use, phases to use, etc. Note that because of the IO inherent in these operations, this method is not appropriate for Applets. Applets should load TauModels themselves and use the setTauModel(TauModel) method.- Specified by:
init
in classTauP_Tool
- Throws:
TauPException
-
printHelp
public void printHelp()
-
start
public void start() throws java.io.IOException, TauModelException, TauPException
- Specified by:
start
in classTauP_Tool
- Throws:
java.io.IOException
TauModelException
TauPException
-
destroy
public void destroy() throws TauPException
- Specified by:
destroy
in classTauP_Tool
- Throws:
TauPException
-
printStdUsageHead
public void printStdUsageHead()
-
printStdUsage
public void printStdUsage()
Prints the command line arguments common to all TauP tools.
-
printPhaseUsage
public void printPhaseUsage()
-
printDistanceUsage
public void printDistanceUsage()
-
printLimitUsage
public void printLimitUsage()
-
printUsage
public void printUsage()
- Specified by:
printUsage
in classTauP_Tool
-
linearInterp
public static final double linearInterp(double xa, double ya, double xb, double yb, double x)
solves the equation (yb-ya)/(xb-xa) = (y-ya)/(x-xa) for y given x. Useful for finding the pixel for a value given the dimension of the area and the range of values it is supposed to cover. Note, this does not check for xa == xb, in which case a divide by zero would occur.
-
main
public static void main(java.lang.String[] args) throws java.io.IOException
Allows TauP_Time to run as an application. Creates an instance of TauP_Time. ToolRun.main should be used instead.- Throws:
java.io.IOException
-
-