Skip to content

Commit

Permalink
Merge remote-tracking branch 'taupy/master' into taupy
Browse files Browse the repository at this point in the history
Conflicts:
	.gitignore
	README.md
	setup.py
  • Loading branch information
megies committed Jan 25, 2015
2 parents c9b890f + abbbfe5 commit 55b0e9a
Show file tree
Hide file tree
Showing 50 changed files with 9,754 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -31,3 +31,4 @@ obspy/core/tests/images/testrun/
obspy/station/tests/images/testrun/
obspy/imaging/tests/images/testrun/
misc/docker_tests/temp/
obspy/taup/data/models
674 changes: 674 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions setup.py
Expand Up @@ -599,6 +599,28 @@ def run(self):
self.copy_tree(srcdir, mandir)


def build_taup_models():
"""
Builds the taup models during install time. This is needed as the models are
pickled Python classes which are not compatible across Python versions.
"""
taupy_path = os.path.join(ROOT, "taupy")
model_input = os.path.join(taupy_path, "data")

sys.path.insert(0, ROOT)
from taupy.TauP_Create import TauP_Create
from taupy.utils import _get_model_filename

for model in glob.glob(os.path.join(model_input, "*.tvel")):
print("Building model '%s'..." % model)
sys.stdout.flush()
output_filename = _get_model_filename(model)
mod_create = TauP_Create(input_filename=model,
output_filename=output_filename)
mod_create.loadVMod()
mod_create.run()


def setupPackage():
# setup package
setup(
Expand Down
78 changes: 78 additions & 0 deletions taupy/Arrival.py
@@ -0,0 +1,78 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from future.builtins import *
from math import pi


class Arrival:
"""
Convenience class for storing the parameters associated with a phase
arrival.
"""
def __init__(self, phase, time, dist, rayParam, rayParamIndex,
name, puristName, sourceDepth, takeoffAngle, incidentAngle):
# phase that generated this arrival
self.phase = phase
# travel time in seconds
self.time = time
# angular distance (great circle) in radians
self.dist = dist
# ray parameter in seconds per radians
self.rayParam = rayParam
self.rayParamIndex = rayParamIndex
# phase name
self.name = name
# phase name changed for true depths
self.puristName = puristName
# source depth in kilometers
self.sourceDepth = sourceDepth
self.incidentAngle = incidentAngle
self.takeoffAngle = takeoffAngle
# pierce and path points
self.pierce, self.path = [], []

def __str__(self):
return "%s phase arrival at %.3f seconds" % (self.phase.name,
self.time)

@property
def rayParam_sec_degree(self):
"""
Returns the ray parameter in seconds per degree.
"""
return self.rayParam * pi / 180.0

@property
def purist_distance(self):
return self.dist * 180.0 / pi

def getPierce(self):
"""
Returns pierce points as TimeDist objects.
"""
if not self.pierce:
self.pierce == self.phase.calcPierce(self).getPierce()
return self.pierce

def getPath(self):
"""
Returns pierce points as TimeDist objects.
"""
if not self.path:
self.path == self.phase.calcPath(self).getPath()
return self.path

def getModuloDistDeg(self):
"""
Returns distance in degrees from 0 - 180. Note this may not be the
actual distance travelled.
"""
moduloDist = ((180.0 / pi) * self.dist) % 360.0
if moduloDist > 180:
moduloDist = 360 - moduloDist
return moduloDist

def getDistDeg(self):
return self.dist * 180 / pi

0 comments on commit 55b0e9a

Please sign in to comment.