Skip to content
Merged
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
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ jobs:
matrix:
os: ["ubuntu-latest"]
python-version: ["3.10"]
test-file: [
test_file: [
"tests/test_dcip.py",
"tests/test_em.py",
"tests/test_gpr.py tests/test_seismic.py",
"tests/test_inversion.py",
"tests/test_gravity.py tests/test_mag.py"
]
env:
PYTEST_DISABLE_PLUGIN_AUTOLOAD: "1"
MPLBACKEND: Agg # avoid GUI backends import cost

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ dependencies:
- deepdish
- discretize
- empymod
- ipywidgets>=0.6.0
- ipywidgets
- jupyter
- matplotlib=3.4.3
- matplotlib
- Pillow
- pip
- pymatsolver
Expand Down
6 changes: 3 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ dependencies:
- cvxopt
- deepdish
- discretize
- ipywidgets>=0.6.0
- ipywidgets
- jupyter
- matplotlib<3.5
- matplotlib
- Pillow
- pip
- pymatsolver
- python=3.10
- python=3.11
- requests
- simpeg
- pip:
Expand Down
14 changes: 7 additions & 7 deletions geoscilabs/dcip/DCIP_overburden_PseudoSection.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def DC2Dsimulation(mtrue, flag="PoleDipole", nmax=8):
for i in range(ntx):
if flag == "PoleDipole":
A = np.r_[xr[i], zloc]
B = np.r_[mesh.vectorCCx.min(), zloc]
B = np.r_[mesh.cell_centers_x.min(), zloc]
if i < ntx - nmax + 1:
Mx = xr[i + 1 : i + 1 + nmax]
_, Mz = get_Surface(mtrue, Mx)
Expand All @@ -421,7 +421,7 @@ def DC2Dsimulation(mtrue, flag="PoleDipole", nmax=8):
if i < ntx - nmax + 1:
Mx = xr[i + 2 : i + 2 + nmax]
_, Mz = get_Surface(mtrue, Mx)
Nx = np.ones(nmax) * mesh.vectorCCx.max()
Nx = np.ones(nmax) * mesh.cell_centers_x.max()
_, Nz = get_Surface(mtrue, Nx)

M = np.c_[Mx, Mz]
Expand All @@ -430,7 +430,7 @@ def DC2Dsimulation(mtrue, flag="PoleDipole", nmax=8):
else:
Mx = xr[i + 2 : ntx + 2]
_, Mz = get_Surface(mtrue, Mx)
Nx = np.ones(ntx - i) * mesh.vectorCCx.max()
Nx = np.ones(ntx - i) * mesh.cell_centers_x.max()
_, Nz = get_Surface(mtrue, Nx)
M = np.c_[Mx, Mz]
N = np.c_[Nx, Nz]
Expand Down Expand Up @@ -483,7 +483,7 @@ def IP2Dsimulation(miptrue, sigmadc, flag="PoleDipole", nmax=8):
for i in range(ntx):
if flag == "PoleDipole":
A = np.r_[xr[i], zloc]
B = np.r_[mesh.vectorCCx.min(), zloc]
B = np.r_[mesh.cell_centers_x.min(), zloc]
if i < ntx - nmax + 1:
Mx = xr[i + 1 : i + 1 + nmax]
_, Mz = get_Surface(miptrue, Mx)
Expand All @@ -507,7 +507,7 @@ def IP2Dsimulation(miptrue, sigmadc, flag="PoleDipole", nmax=8):
if i < ntx - nmax + 1:
Mx = xr[i + 2 : i + 2 + nmax]
_, Mz = get_Surface(miptrue, Mx)
Nx = np.ones(nmax) * mesh.vectorCCx.max()
Nx = np.ones(nmax) * mesh.cell_centers_x.max()
_, Nz = get_Surface(miptrue, Nx)

M = np.c_[Mx, Mz]
Expand All @@ -516,7 +516,7 @@ def IP2Dsimulation(miptrue, sigmadc, flag="PoleDipole", nmax=8):
else:
Mx = xr[i + 2 : ntx + 2]
_, Mz = get_Surface(miptrue, Mx)
Nx = np.ones(ntx - i) * mesh.vectorCCx.max()
Nx = np.ones(ntx - i) * mesh.cell_centers_x.max()
_, Nz = get_Surface(miptrue, Nx)
M = np.c_[Mx, Mz]
N = np.c_[Nx, Nz]
Expand Down Expand Up @@ -862,7 +862,7 @@ def DCIP2Dfwdfun(
ax=ax1,
clim=(u.min(), u.max()),
grid=True,
gridOpts={"color": "k", "alpha": 0.5},
grid_opts={"color": "k", "alpha": 0.5},
)

if which == "IP":
Expand Down
11 changes: 4 additions & 7 deletions geoscilabs/dcip/DCWidgetPlate2_5D.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import numpy as np

from scipy.constants import epsilon_0
from scipy.ndimage.measurements import center_of_mass

from ipywidgets import IntSlider, FloatSlider, FloatText, ToggleButtons

import matplotlib
import matplotlib.pyplot as plt
import matplotlib.pylab as pylab
from matplotlib.ticker import LogFormatter
from matplotlib.path import Path
import matplotlib.patches as patches

from simpeg.utils.solver_utils import get_default_solver

from discretize import TensorMesh
from simpeg import maps, SolverLU, utils
from discretize.utils import closest_points_index
from simpeg import maps, utils
from simpeg.utils import extract_core_mesh
from simpeg.electromagnetics.static import resistivity as DC
from ..base import widgetify
Expand Down Expand Up @@ -196,7 +193,7 @@ def get_Surface_Potentials(survey, src, field_obj):
phiScale = 0.0

if survey == "Pole-Dipole" or survey == "Pole-Pole":
refInd = utils.closestPoints(mesh, [xmax + 60.0, 0.0], gridLoc="CC")
refInd = closest_points_index(mesh, [xmax + 60.0, 0.0], grid_loc="CC")
# refPoint = CCLoc[refInd]
# refSurfaceInd = np.where(xSurface == refPoint[0])
# phiScale = np.median(phiSurface)
Expand Down Expand Up @@ -648,7 +645,7 @@ def PLOT(
view=view,
stream_opts=streamOpts,
pcolor_opts=pcolorOpts,
) # gridOpts={'color':'k', 'alpha':0.5}
) # grid_opts={'color':'k', 'alpha':0.5}

# Get plate corners
plateCorners = getPlateCorners(xc, zc, dx, dz, rotAng)
Expand Down
14 changes: 6 additions & 8 deletions geoscilabs/dcip/DCWidgetPlate_2D.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import numpy as np

from scipy.constants import epsilon_0
from scipy.ndimage.measurements import center_of_mass

from ipywidgets import IntSlider, FloatSlider, FloatText, ToggleButtons
from ipywidgets import FloatSlider, FloatText, ToggleButtons

import matplotlib
import matplotlib.pyplot as plt
import matplotlib.pylab as pylab
from matplotlib.ticker import LogFormatter
from matplotlib.path import Path
import matplotlib.patches as patches
from simpeg.utils.solver_utils import get_default_solver

from discretize import TensorMesh
from simpeg import maps, SolverLU, utils
from discretize.utils import closest_points_index

from simpeg import maps, utils
from simpeg.utils import extract_core_mesh
from simpeg.electromagnetics.static import resistivity as DC

Expand Down Expand Up @@ -200,7 +198,7 @@ def get_Surface_Potentials(survey, src, field_obj):
phiScale = 0.0

if survey == "Pole-Dipole" or survey == "Pole-Pole":
refInd = utils.closestPoints(mesh, [xmax + 60.0, 0.0], gridLoc="CC")
refInd = closest_points_index(mesh, [xmax + 60.0, 0.0], grid_loc="CC")
# refPoint = CCLoc[refInd]
# refSurfaceInd = np.where(xSurface == refPoint[0])
# phiScale = np.median(phiSurface)
Expand Down Expand Up @@ -649,7 +647,7 @@ def plot_Surface_Potentials(
view=view,
stream_opts=streamOpts,
pcolor_opts=pcolorOpts,
) # gridOpts={'color':'k', 'alpha':0.5}
) # grid_opts={'color':'k', 'alpha':0.5}

# Get plate corners
if dx >= 80.0:
Expand Down
5 changes: 3 additions & 2 deletions geoscilabs/dcip/DCWidgetResLayer2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from simpeg.utils import extract_core_mesh
import numpy as np
from simpeg.electromagnetics.static import resistivity as DC
from discretize.utils import closest_points_index
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.pylab as pylab
Expand Down Expand Up @@ -263,7 +264,7 @@ def get_Surface_Potentials(survey, src, field_obj):
phiScale = 0.0

if survey == "Pole-Dipole" or survey == "Pole-Pole":
refInd = utils.closestPoints(mesh, [xmax + 60.0, 0.0], gridLoc="CC")
refInd = closest_points_index(mesh, [xmax + 60.0, 0.0], grid_loc="CC")
# refPoint = CCLoc[refInd]
# refSurfaceInd = np.where(xSurface == refPoint[0])
# phiScale = np.median(phiSurface)
Expand Down Expand Up @@ -678,7 +679,7 @@ def plot_Surface_Potentials(
view=view,
stream_opts=streamOpts,
pcolor_opts=pcolorOpts,
) # gridOpts={'color':'k', 'alpha':0.5}
) # grid_opts={'color':'k', 'alpha':0.5}

# Get cylinder outline
cylinderPoints = getCylinderPoints(xc, zc, r)
Expand Down
7 changes: 4 additions & 3 deletions geoscilabs/dcip/DCWidgetResLayer2_5D.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
from matplotlib.path import Path
import matplotlib.patches as patches

from simpeg import maps, SolverLU, utils
from simpeg import maps, utils
from simpeg.utils import extract_core_mesh
from simpeg.electromagnetics.static import resistivity as DC
from simpeg.utils.solver_utils import get_default_solver

from discretize import TensorMesh
from discretize.utils import closest_points_index

from ipywidgets import interact, IntSlider, FloatSlider, FloatText, ToggleButtons

Expand Down Expand Up @@ -266,7 +267,7 @@ def get_Surface_Potentials(survey, src, field_obj):
phiScale = 0.0

if survey == "Pole-Dipole" or survey == "Pole-Pole":
refInd = utils.closestPoints(mesh, [xmax + 60.0, 0.0], gridLoc="CC")
refInd = closest_points_index(mesh, [xmax + 60.0, 0.0], grid_loc="CC")
# refPoint = CCLoc[refInd]
# refSurfaceInd = np.where(xSurface == refPoint[0])
# phiScale = np.median(phiSurface)
Expand Down Expand Up @@ -684,7 +685,7 @@ def PLOT(
view=view,
stream_opts=streamOpts,
pcolor_opts=pcolorOpts,
) # gridOpts={'color':'k', 'alpha':0.5}
) # grid_opts={'color':'k', 'alpha':0.5}

# Get cylinder outline
cylinderPoints = getCylinderPoints(xc, zc, r)
Expand Down
10 changes: 4 additions & 6 deletions geoscilabs/dcip/DCWidget_Overburden_2_5D.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@
import matplotlib.patches as patches

from ipywidgets import (
interact,
interact_manual,
IntSlider,
FloatSlider,
FloatText,
ToggleButtons,
fixed,
Widget,
)

from discretize import TensorMesh
from discretize.utils import closest_points_index

from simpeg import maps, utils
from simpeg.utils import extract_core_mesh
from simpeg.electromagnetics.static import resistivity as DC
Expand Down Expand Up @@ -216,7 +214,7 @@ def get_Surface_Potentials(mtrue, survey, src, field_obj):
phiScale = 0.0

if survey == "Pole-Dipole" or survey == "Pole-Pole":
refInd = utils.closestPoints(mesh, [xmax + 60.0, 0.0], gridLoc="CC")
refInd = closest_points_index(mesh, [xmax + 60.0, 0.0], grid_loc="CC")
# refPoint = CCLoc[refInd]
# refSurfaceInd = np.where(xSurface == refPoint[0])
# phiScale = np.median(phiSurface)
Expand Down Expand Up @@ -689,7 +687,7 @@ def PLOT(
view=view,
stream_opts=streamOpts,
pcolor_opts=pcolorOpts,
) # gridOpts ={'color':'k', 'alpha':0.5}
) # grid_opts ={'color':'k', 'alpha':0.5}

# Get cylinder outline
cylinderPoints = getCylinderPoints(xc, zc, ellips_a, ellips_b)
Expand Down
4 changes: 2 additions & 2 deletions geoscilabs/dcip/DC_Pseudosections.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def DC2Dfwdfun(
ax=ax1,
clim=(1, 3),
grid=True,
gridOpts={"color": "k", "alpha": 0.5},
grid_opts={"color": "k", "alpha": 0.5},
)
cb1ticks = [1.0, 2.0, 3.0]
cb1 = plt.colorbar(dat1[0], ax=ax1, ticks=cb1ticks)
Expand Down Expand Up @@ -582,7 +582,7 @@ def DC2Dfwdfun(
ax=ax1,
clim=(1, 3),
grid=True,
gridOpts={"color": "k", "alpha": 0.5},
grid_opts={"color": "k", "alpha": 0.5},
)
cb1ticks = [1.0, 2.0, 3.0]
cb1 = plt.colorbar(dat1[0], ax=ax1, ticks=cb1ticks)
Expand Down
5 changes: 3 additions & 2 deletions geoscilabs/dcip/DC_cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from simpeg.utils.solver_utils import get_default_solver
from discretize import TensorMesh
from discretize.utils import closest_points_index

from simpeg import maps, utils
from simpeg.utils import extract_core_mesh, mkvc
Expand Down Expand Up @@ -139,7 +140,7 @@ def get_Surface_Potentials(survey, src, field_obj):
phiScale = 0.0

if survey == "Pole-Dipole" or survey == "Pole-Pole":
refInd = utils.closestPoints(mesh, [xmax + 60.0, 0.0], gridLoc="CC")
refInd = closest_points_index(mesh, [xmax + 60.0, 0.0], grid_loc="CC")
phiScale = phi[refInd]
phiSurface = phiSurface - phiScale

Expand Down Expand Up @@ -528,7 +529,7 @@ def plot_Surface_Potentials(
view=view,
stream_opts=streamOpts,
pcolor_opts=pcolorOpts,
) # gridOpts={'color':'k', 'alpha':0.5}
) # grid_opts={'color':'k', 'alpha':0.5}

# Get cylinder outline
cylinderPoints = getCylinderPoints(xc, zc, r)
Expand Down
6 changes: 3 additions & 3 deletions geoscilabs/em/InductionLoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def calc_PrimaryRegion(self, X, Z):
bot = Z ** 2 + (s - a1) ** 2

try:
bot[bot==0] = np.NaN
bot[bot==0] = np.nan
except:
pass

Expand Down Expand Up @@ -219,7 +219,7 @@ def calc_PrimaryLoop(self):

bot = z ** 2 + (s - a1) ** 2
try:
bot[bot == 0.0] = np.NaN
bot[bot == 0.0] = np.nan
except:
pass

Expand Down Expand Up @@ -424,7 +424,7 @@ def plot_PrimaryRegion(self, X, Z, Bpx, Bpz, Babs, ax):
ax.plot(xRx, zRx, color="black", linewidth=6)
ax.plot(xRx, zRx, color=((0.4, 0.4, 0.4)), linewidth=4)
# Cplot = ax.contourf(X,Z,np.log10(Babs),40,cmap='ocean_r')
Babs[Babs == 0.0] = np.NaN
Babs[Babs == 0.0] = np.nan
Cplot = ax.contourf(X, Z, np.log10(1e9 * Babs), 40, cmap="viridis")
cbar = plt.colorbar(Cplot, ax=ax, pad=0.02)
cbar.set_label(
Expand Down
2 changes: 1 addition & 1 deletion geoscilabs/em/InductionSphereFEM.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def plotAnomalyXYplane(Ax, f, X, Y, Z, H, Comp, Phase):
H = np.abs(H)
MAX = np.max(H)

H[H == 0] = np.NaN
H[H == 0] = np.nan
H = np.log10(tol * H / MAX)

Sign[H < 0] = 0.0
Expand Down
Loading
Loading