shifter.py 1.51 KB
Newer Older
1
2
3
4
5
6
from pyrocko.guts import Object, Float, String
from pyrocko import cake
from pyrocko.gf import Earthmodel1D
import numpy as num
import logging

Sebastian Heimann's avatar
Sebastian Heimann committed
7
8

guts_prefix = 'lassie'
9
logger = logging.getLogger('lassie.config')
Sebastian Heimann's avatar
Sebastian Heimann committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


class Shifter(Object):
    pass


class VelocityShifter(Shifter):
    velocity = Float.T()

    def get_table(self, grid, receivers):
        distances = grid.distances(receivers)
        return distances / self.velocity

    def get_vmin(self):
        return self.velocity


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class CakePhaseShifter(Shifter):
    earthmodel1d = Earthmodel1D.T()
    phase = String.T()

    def get_table(self, grid, receivers):
        distances = grid.lateral_distances(receivers)
        s_depths = grid._coords[2]

        n_x = len(distances)

        phase = cake.PhaseDef(self.phase)
        arrivals = num.zeros((len(distances)*len(s_depths), len(receivers)))
        logger.info('calculating arrivals - %s' % self.phase)
        for i_r, r in enumerate(receivers):
            logger.info('receiver %s / %s' % (i_r+1, len(receivers)))
            for i_z, z in enumerate(s_depths):
                distances = grid.lateral_distances([r])
                arr = self.earthmodel1d.arrivals(
                    distances=distances*cake.m2d, phases=[phase],
                    zstart=z, zstop=r.z)

                assert len(arr) == len(distances)
                arrivals[i_z * n_x: (i_z+1) * n_x, i_r] = [a.t for a in arr]

        return num.array(arrivals)


Sebastian Heimann's avatar
Sebastian Heimann committed
54
55
56
__all__ = [
    'Shifter',
    'VelocityShifter',
57
    'CakePhaseShifter',
Sebastian Heimann's avatar
Sebastian Heimann committed
58
]