Example #1
0
def configuration(parent_package="", top_path=None):
    """
    Config function mainly used to compile C code.
    """
    config = Configuration("", parent_package, top_path)

    # Smoothing Matrix
    path = "src"
    files = [
        os.path.join(path, "mk_MatPaths.c"),
    ]
    # compiler specific options
    kwargs = {}
    if IS_MSVC:
        # get export symbols
        kwargs['export_symbols'] = export_symbols(path, 'mk_MatPaths.def')
    config.add_extension(
        _get_lib_name("mk_MatPaths", add_extension_suffix=False), files,
        **kwargs)

    # Smoothing Matrix
    path = "src"
    files = [
        os.path.join(path, "mkMatSmoothing.c"),
    ]
    # compiler specific options
    kwargs = {}
    if IS_MSVC:
        # get export symbols
        kwargs['export_symbols'] = export_symbols(path, 'mkMatSmoothing.def')
    config.add_extension(
        _get_lib_name("mkMatSmoothing", add_extension_suffix=False), files,
        **kwargs)

    # FTAN
    path = "src"
    files = []
    for module in [
            "configparser.cpp", "fft_NR.cpp", "fta_param.cpp", "libfta.cpp",
            "readsac.cpp", "vg_fta.cpp"
    ]:
        files.append(os.path.join(path, module))
    # compiler specific options
    kwargs = {}
    if IS_MSVC:
        # get export symbols
        kwargs['export_symbols'] = export_symbols(path, 'vg_fta.def')

    config.add_extension(_get_lib_name("vg_fta", add_extension_suffix=False),
                         files, **kwargs)

    # HACK to avoid: "WARNING: '' not a valid package name; please use only .-separated package names in setup.py"
    config = config.todict()
    config["packages"] = []
    del config["package_dir"]

    return config
Example #2
0
# -*- coding: utf-8 -*-
"""
obspy.taup - Travel time calculation tool
"""
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from future.builtins import *  # NOQA

import inspect
import numpy as np
import os
import platform
from obspy.core.util.libnames import _get_lib_name, _load_CDLL


lib_name = _get_lib_name('tau', add_extension_suffix=False)

# Import libtau in a platform specific way.
try:
    # linux / mac using python import
    libtau = __import__('obspy.lib.' + lib_name, globals(), locals(),
                        ['ttimes'])
    ttimes = libtau.ttimes
except ImportError:
    # windows using ctypes
    if platform.system() == "Windows":
        import ctypes as C
        libtau = _load_CDLL("tau")

        def ttimes(delta, depth, modnam):
            delta = C.c_float(delta)
Example #3
0
import os
from future.utils import native_str
import ctypes
import numpy as np
from obspy.core.util.libnames import cleanse_pymodule_filename, _get_lib_name
import platform

lib = "mkMatSmoothing"

libname = _get_lib_name(lib, add_extension_suffix=True)
libname = os.path.join(os.path.dirname(__file__), libname)
print("Smoothing lib name:", libname)

libsmooth = ctypes.CDLL(str(libname))

LP_c_char = ctypes.POINTER(ctypes.c_char)
LP_LP_c_char = ctypes.POINTER(LP_c_char)

libsmooth.main.argtypes = [
    ctypes.c_int,  # argc
    LP_LP_c_char
]  # argv]
libsmooth.main.restype = ctypes.c_int


def smooth(lcorr, gridfile):

    args = ["placeholder", lcorr, gridfile]
    argc = len(args)
    argv = (LP_c_char * (argc + 1))()
    for i, arg in enumerate(args):
Example #4
0
# -*- coding: utf-8 -*-
"""
obspy.taup - Travel time calculation tool
"""
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from future.builtins import *  # NOQA

import inspect
import numpy as np
import os
import platform
from obspy.core.util.libnames import _get_lib_name, _load_CDLL

lib_name = _get_lib_name('tau', add_extension_suffix=False)

# Import libtau in a platform specific way.
try:
    # linux / mac using python import
    libtau = __import__('obspy.lib.' + lib_name, globals(), locals(),
                        ['ttimes'])
    ttimes = libtau.ttimes
except ImportError:
    # windows using ctypes
    if platform.system() == "Windows":
        import ctypes as C
        libtau = _load_CDLL("tau")

        def ttimes(delta, depth, modnam):
            delta = C.c_float(delta)
            depth = C.c_float(abs(depth))