Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homogenize imports of kirchhoff and lsm #493

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions pylops/waveeqprocessing/kirchhoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,26 @@

from pylops import LinearOperator
from pylops.signalprocessing import Convolve1D
from pylops.utils import deps
from pylops.utils._internal import _value_or_sized_to_array
from pylops.utils.decorators import reshaped
from pylops.utils.tapers import taper
from pylops.utils.typing import DTypeLike, NDArray

try:
skfmm_message = deps.skfmm_import("the kirchhoff module")
jit_message = deps.numba_import("the kirchhoff module")

if skfmm_message is None:
import skfmm
except ModuleNotFoundError:
skfmm = None
skfmm_message = (
"Skfmm package not installed. Choose method=analytical "
"if using constant velocity or run "
'"pip install scikit-fmm" or '
'"conda install -c conda-forge scikit-fmm".'
)
except Exception as e:
skfmm = None
skfmm_message = f"Failed to import skfmm (error:{e})."

try:

if jit_message is None:
from numba import jit, prange

# detect whether to use parallel or not
numba_threads = int(os.getenv("NUMBA_NUM_THREADS", "1"))
parallel = True if numba_threads != 1 else False
except ModuleNotFoundError:
jit = None
else:
prange = range
jit_message = "Numba not available, reverting to numpy."
except Exception as e:
jit = None
jit_message = "Failed to import numba (error:%s), use numpy." % e


logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)

Expand Down
14 changes: 0 additions & 14 deletions pylops/waveeqprocessing/lsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@
from pylops.waveeqprocessing.kirchhoff import Kirchhoff
from pylops.waveeqprocessing.twoway import AcousticWave2D

try:
import skfmm
except ModuleNotFoundError:
skfmm = None
skfmm_message = (
"Skfmm package not installed. Choose method=analytical "
"if using constant velocity or run "
'"pip install scikit-fmm" or '
'"conda install -c conda-forge scikit-fmm".'
)
except Exception as e:
skfmm = None
skfmm_message = f"Failed to import skfmm (error:{e})."

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)


Expand Down