-
Notifications
You must be signed in to change notification settings - Fork 2
/
c_wrappers.py
89 lines (79 loc) · 2.83 KB
/
c_wrappers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# -*- coding: utf-8 -*-
"""
C wrappers for some crucial inner loops of TauPy written in C.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from future.builtins import * # NOQA
from future.utils import native_str
import ctypes as C # NOQA
import numpy as np
from obspy.core.util.libnames import _load_cdll
from .helper_classes import SlownessLayer, TimeDist
clibtau = _load_cdll("tau")
clibtau.tau_branch_calc_time_dist_inner_loop.argtypes = [
# ray_params
np.ctypeslib.ndpointer(dtype=np.float64, ndim=2,
flags=native_str('C_CONTIGUOUS')),
# time
np.ctypeslib.ndpointer(dtype=np.float64, ndim=2,
flags=native_str('C_CONTIGUOUS')),
# dist
np.ctypeslib.ndpointer(dtype=np.float64, ndim=2,
flags=native_str('C_CONTIGUOUS')),
# layer, record array, 64bit floats. 2D array in memory
np.ctypeslib.ndpointer(dtype=SlownessLayer, ndim=1,
flags=native_str('C_CONTIGUOUS')),
# time_dist, record array, 64bit floats. 2D array in memory
np.ctypeslib.ndpointer(dtype=TimeDist, ndim=1,
flags=native_str('C_CONTIGUOUS')),
# max_i
C.c_int32,
# max_j
C.c_int32,
# max ray param
C.c_double,
# allow_turn
C.c_int32
]
clibtau.tau_branch_calc_time_dist_inner_loop.restype = None
clibtau.seismic_phase_calc_time_inner_loop.argtypes = [
# degree
C.c_double,
# max_distance
C.c_double,
# dist
np.ctypeslib.ndpointer(dtype=np.float64, ndim=1,
flags=native_str('C_CONTIGUOUS')),
# ray_param
np.ctypeslib.ndpointer(dtype=np.float64, ndim=1,
flags=native_str('C_CONTIGUOUS')),
# search_dist_results
np.ctypeslib.ndpointer(dtype=np.float64, ndim=1,
flags=native_str('C_CONTIGUOUS')),
# ray_num_results
np.ctypeslib.ndpointer(dtype=np.int32, ndim=1,
flags=native_str('C_CONTIGUOUS')),
# count
C.c_int
]
clibtau.seismic_phase_calc_time_inner_loop.restype = C.c_int
clibtau.bullen_radial_slowness_inner_loop.argtypes = [
# layer, record array, 64bit floats. 2D array in memory
np.ctypeslib.ndpointer(dtype=SlownessLayer, ndim=1,
flags=native_str('C_CONTIGUOUS')),
# p
np.ctypeslib.ndpointer(dtype=np.float64, ndim=1,
flags=native_str('C_CONTIGUOUS')),
# time
np.ctypeslib.ndpointer(dtype=np.float64, ndim=1,
flags=native_str('C_CONTIGUOUS')),
# dist
np.ctypeslib.ndpointer(dtype=np.float64, ndim=1,
flags=native_str('C_CONTIGUOUS')),
# radius
C.c_double,
# max_i
C.c_int
]
clibtau.bullen_radial_slowness_inner_loop.restype = None