Skip to content

Commit

Permalink
small changes to make msnoise CLI faster (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasLecocq committed Nov 11, 2020
1 parent 3eb227d commit 40c5b67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions msnoise/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
except:
import pickle as cPickle
import math
import pkg_resources

import sys

from logbook import Logger, StreamHandler
Expand All @@ -24,7 +24,7 @@
import numpy as np
import pandas as pd
import scipy as sp
import scipy.signal as ss

if sp.__version__ < "1.4.0":
import scipy.fftpack as sf
from scipy.fftpack.helper import next_fast_len
Expand All @@ -34,7 +34,7 @@
from scipy.fft import next_fast_len


import scipy.optimize
# import scipy.optimize

from obspy.core import Stream, Trace, read, AttribDict, UTCDateTime
from obspy.core.inventory import Inventory
Expand Down Expand Up @@ -212,6 +212,7 @@ def get_config(session, name=None, isbool=False, plugin=None):
:returns: the value for `name` or a dict of all config values
"""
if plugin:
import pkg_resources
for ep in pkg_resources.iter_entry_points(
group='msnoise.plugins.table_def'):
if ep.name.replace("Config", "") == plugin:
Expand Down Expand Up @@ -259,6 +260,7 @@ def update_config(session, name, value, plugin=None):
"""
if plugin:
import pkg_resources
for ep in pkg_resources.iter_entry_points(
group='msnoise.plugins.table_def'):
if ep.name.replace("Config", "") == plugin:
Expand Down Expand Up @@ -1316,6 +1318,7 @@ def stack(data, stack_method="linear", pws_timegate=10.0, pws_power=2,
corr = data.mean(axis=0)

elif stack_method == "pws":
import scipy.signal as ss
# logging.debug("Doing a PWS stack")
corr = np.zeros(data.shape[1], dtype='f8')
phasestack = np.zeros(data.shape[1], dtype='c8')
Expand Down
3 changes: 2 additions & 1 deletion msnoise/scripts/msnoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import time

import click
import pkg_resources


from .. import MSNoiseError, DBConfigNotFoundError
from ..api import connect, get_config, update_station, get_logger, get_job_types
Expand Down Expand Up @@ -200,6 +200,7 @@ def info_plugins(db):
if not plugins:
return
plugins = plugins.split(",")
import pkg_resources
for ep in pkg_resources.iter_entry_points(group='msnoise.plugins.jobtypes'):
module_name = ep.module_name.split(".")[0]
if module_name in plugins:
Expand Down

0 comments on commit 40c5b67

Please sign in to comment.