Skip to content

Commit a3f8a3f

Browse files
authored
Update environment (#83)
* updating deprecated code * cleanup of em apps * unpin matplitlib, ipywidgets * update inversion code * update NMO wiedget * update testing to run each test separately * try simplifying what pytest brings * fix import of solver_utils * update mag dipole notebook
1 parent bc150b0 commit a3f8a3f

22 files changed

Lines changed: 170 additions & 1111 deletions

.github/workflows/tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ jobs:
1818
matrix:
1919
os: ["ubuntu-latest"]
2020
python-version: ["3.10"]
21-
test-file: [
21+
test_file: [
2222
"tests/test_dcip.py",
2323
"tests/test_em.py",
2424
"tests/test_gpr.py tests/test_seismic.py",
2525
"tests/test_inversion.py",
2626
"tests/test_gravity.py tests/test_mag.py"
2727
]
28+
env:
29+
PYTEST_DISABLE_PLUGIN_AUTOLOAD: "1"
30+
MPLBACKEND: Agg # avoid GUI backends import cost
2831

2932
steps:
3033
- uses: actions/checkout@v4

environment-dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ dependencies:
77
- deepdish
88
- discretize
99
- empymod
10-
- ipywidgets>=0.6.0
10+
- ipywidgets
1111
- jupyter
12-
- matplotlib=3.4.3
12+
- matplotlib
1313
- Pillow
1414
- pip
1515
- pymatsolver

environment.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ dependencies:
66
- cvxopt
77
- deepdish
88
- discretize
9-
- ipywidgets>=0.6.0
9+
- ipywidgets
1010
- jupyter
11-
- matplotlib<3.5
11+
- matplotlib
1212
- Pillow
1313
- pip
1414
- pymatsolver
15-
- python=3.10
15+
- python=3.11
1616
- requests
1717
- simpeg
1818
- pip:

geoscilabs/dcip/DCIP_overburden_PseudoSection.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def DC2Dsimulation(mtrue, flag="PoleDipole", nmax=8):
397397
for i in range(ntx):
398398
if flag == "PoleDipole":
399399
A = np.r_[xr[i], zloc]
400-
B = np.r_[mesh.vectorCCx.min(), zloc]
400+
B = np.r_[mesh.cell_centers_x.min(), zloc]
401401
if i < ntx - nmax + 1:
402402
Mx = xr[i + 1 : i + 1 + nmax]
403403
_, Mz = get_Surface(mtrue, Mx)
@@ -421,7 +421,7 @@ def DC2Dsimulation(mtrue, flag="PoleDipole", nmax=8):
421421
if i < ntx - nmax + 1:
422422
Mx = xr[i + 2 : i + 2 + nmax]
423423
_, Mz = get_Surface(mtrue, Mx)
424-
Nx = np.ones(nmax) * mesh.vectorCCx.max()
424+
Nx = np.ones(nmax) * mesh.cell_centers_x.max()
425425
_, Nz = get_Surface(mtrue, Nx)
426426

427427
M = np.c_[Mx, Mz]
@@ -430,7 +430,7 @@ def DC2Dsimulation(mtrue, flag="PoleDipole", nmax=8):
430430
else:
431431
Mx = xr[i + 2 : ntx + 2]
432432
_, Mz = get_Surface(mtrue, Mx)
433-
Nx = np.ones(ntx - i) * mesh.vectorCCx.max()
433+
Nx = np.ones(ntx - i) * mesh.cell_centers_x.max()
434434
_, Nz = get_Surface(mtrue, Nx)
435435
M = np.c_[Mx, Mz]
436436
N = np.c_[Nx, Nz]
@@ -483,7 +483,7 @@ def IP2Dsimulation(miptrue, sigmadc, flag="PoleDipole", nmax=8):
483483
for i in range(ntx):
484484
if flag == "PoleDipole":
485485
A = np.r_[xr[i], zloc]
486-
B = np.r_[mesh.vectorCCx.min(), zloc]
486+
B = np.r_[mesh.cell_centers_x.min(), zloc]
487487
if i < ntx - nmax + 1:
488488
Mx = xr[i + 1 : i + 1 + nmax]
489489
_, Mz = get_Surface(miptrue, Mx)
@@ -507,7 +507,7 @@ def IP2Dsimulation(miptrue, sigmadc, flag="PoleDipole", nmax=8):
507507
if i < ntx - nmax + 1:
508508
Mx = xr[i + 2 : i + 2 + nmax]
509509
_, Mz = get_Surface(miptrue, Mx)
510-
Nx = np.ones(nmax) * mesh.vectorCCx.max()
510+
Nx = np.ones(nmax) * mesh.cell_centers_x.max()
511511
_, Nz = get_Surface(miptrue, Nx)
512512

513513
M = np.c_[Mx, Mz]
@@ -516,7 +516,7 @@ def IP2Dsimulation(miptrue, sigmadc, flag="PoleDipole", nmax=8):
516516
else:
517517
Mx = xr[i + 2 : ntx + 2]
518518
_, Mz = get_Surface(miptrue, Mx)
519-
Nx = np.ones(ntx - i) * mesh.vectorCCx.max()
519+
Nx = np.ones(ntx - i) * mesh.cell_centers_x.max()
520520
_, Nz = get_Surface(miptrue, Nx)
521521
M = np.c_[Mx, Mz]
522522
N = np.c_[Nx, Nz]
@@ -862,7 +862,7 @@ def DCIP2Dfwdfun(
862862
ax=ax1,
863863
clim=(u.min(), u.max()),
864864
grid=True,
865-
gridOpts={"color": "k", "alpha": 0.5},
865+
grid_opts={"color": "k", "alpha": 0.5},
866866
)
867867

868868
if which == "IP":

geoscilabs/dcip/DCWidgetPlate2_5D.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import numpy as np
22

3-
from scipy.constants import epsilon_0
4-
from scipy.ndimage.measurements import center_of_mass
5-
63
from ipywidgets import IntSlider, FloatSlider, FloatText, ToggleButtons
74

85
import matplotlib
96
import matplotlib.pyplot as plt
10-
import matplotlib.pylab as pylab
117
from matplotlib.ticker import LogFormatter
128
from matplotlib.path import Path
139
import matplotlib.patches as patches
1410

1511
from simpeg.utils.solver_utils import get_default_solver
1612

1713
from discretize import TensorMesh
18-
from simpeg import maps, SolverLU, utils
14+
from discretize.utils import closest_points_index
15+
from simpeg import maps, utils
1916
from simpeg.utils import extract_core_mesh
2017
from simpeg.electromagnetics.static import resistivity as DC
2118
from ..base import widgetify
@@ -196,7 +193,7 @@ def get_Surface_Potentials(survey, src, field_obj):
196193
phiScale = 0.0
197194

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

653650
# Get plate corners
654651
plateCorners = getPlateCorners(xc, zc, dx, dz, rotAng)

geoscilabs/dcip/DCWidgetPlate_2D.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import numpy as np
22

3-
from scipy.constants import epsilon_0
4-
from scipy.ndimage.measurements import center_of_mass
5-
6-
from ipywidgets import IntSlider, FloatSlider, FloatText, ToggleButtons
3+
from ipywidgets import FloatSlider, FloatText, ToggleButtons
74

85
import matplotlib
96
import matplotlib.pyplot as plt
10-
import matplotlib.pylab as pylab
117
from matplotlib.ticker import LogFormatter
128
from matplotlib.path import Path
139
import matplotlib.patches as patches
1410
from simpeg.utils.solver_utils import get_default_solver
1511

1612
from discretize import TensorMesh
17-
from simpeg import maps, SolverLU, utils
13+
from discretize.utils import closest_points_index
14+
15+
from simpeg import maps, utils
1816
from simpeg.utils import extract_core_mesh
1917
from simpeg.electromagnetics.static import resistivity as DC
2018

@@ -200,7 +198,7 @@ def get_Surface_Potentials(survey, src, field_obj):
200198
phiScale = 0.0
201199

202200
if survey == "Pole-Dipole" or survey == "Pole-Pole":
203-
refInd = utils.closestPoints(mesh, [xmax + 60.0, 0.0], gridLoc="CC")
201+
refInd = closest_points_index(mesh, [xmax + 60.0, 0.0], grid_loc="CC")
204202
# refPoint = CCLoc[refInd]
205203
# refSurfaceInd = np.where(xSurface == refPoint[0])
206204
# phiScale = np.median(phiSurface)
@@ -649,7 +647,7 @@ def plot_Surface_Potentials(
649647
view=view,
650648
stream_opts=streamOpts,
651649
pcolor_opts=pcolorOpts,
652-
) # gridOpts={'color':'k', 'alpha':0.5}
650+
) # grid_opts={'color':'k', 'alpha':0.5}
653651

654652
# Get plate corners
655653
if dx >= 80.0:

geoscilabs/dcip/DCWidgetResLayer2D.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from simpeg.utils import extract_core_mesh
44
import numpy as np
55
from simpeg.electromagnetics.static import resistivity as DC
6+
from discretize.utils import closest_points_index
67
import matplotlib
78
import matplotlib.pyplot as plt
89
import matplotlib.pylab as pylab
@@ -263,7 +264,7 @@ def get_Surface_Potentials(survey, src, field_obj):
263264
phiScale = 0.0
264265

265266
if survey == "Pole-Dipole" or survey == "Pole-Pole":
266-
refInd = utils.closestPoints(mesh, [xmax + 60.0, 0.0], gridLoc="CC")
267+
refInd = closest_points_index(mesh, [xmax + 60.0, 0.0], grid_loc="CC")
267268
# refPoint = CCLoc[refInd]
268269
# refSurfaceInd = np.where(xSurface == refPoint[0])
269270
# phiScale = np.median(phiSurface)
@@ -678,7 +679,7 @@ def plot_Surface_Potentials(
678679
view=view,
679680
stream_opts=streamOpts,
680681
pcolor_opts=pcolorOpts,
681-
) # gridOpts={'color':'k', 'alpha':0.5}
682+
) # grid_opts={'color':'k', 'alpha':0.5}
682683

683684
# Get cylinder outline
684685
cylinderPoints = getCylinderPoints(xc, zc, r)

geoscilabs/dcip/DCWidgetResLayer2_5D.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
from matplotlib.path import Path
1111
import matplotlib.patches as patches
1212

13-
from simpeg import maps, SolverLU, utils
13+
from simpeg import maps, utils
1414
from simpeg.utils import extract_core_mesh
1515
from simpeg.electromagnetics.static import resistivity as DC
1616
from simpeg.utils.solver_utils import get_default_solver
1717

1818
from discretize import TensorMesh
19+
from discretize.utils import closest_points_index
1920

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

@@ -266,7 +267,7 @@ def get_Surface_Potentials(survey, src, field_obj):
266267
phiScale = 0.0
267268

268269
if survey == "Pole-Dipole" or survey == "Pole-Pole":
269-
refInd = utils.closestPoints(mesh, [xmax + 60.0, 0.0], gridLoc="CC")
270+
refInd = closest_points_index(mesh, [xmax + 60.0, 0.0], grid_loc="CC")
270271
# refPoint = CCLoc[refInd]
271272
# refSurfaceInd = np.where(xSurface == refPoint[0])
272273
# phiScale = np.median(phiSurface)
@@ -684,7 +685,7 @@ def PLOT(
684685
view=view,
685686
stream_opts=streamOpts,
686687
pcolor_opts=pcolorOpts,
687-
) # gridOpts={'color':'k', 'alpha':0.5}
688+
) # grid_opts={'color':'k', 'alpha':0.5}
688689

689690
# Get cylinder outline
690691
cylinderPoints = getCylinderPoints(xc, zc, r)

geoscilabs/dcip/DCWidget_Overburden_2_5D.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@
1010
import matplotlib.patches as patches
1111

1212
from ipywidgets import (
13-
interact,
14-
interact_manual,
15-
IntSlider,
1613
FloatSlider,
1714
FloatText,
1815
ToggleButtons,
1916
fixed,
20-
Widget,
2117
)
2218

2319
from discretize import TensorMesh
20+
from discretize.utils import closest_points_index
21+
2422
from simpeg import maps, utils
2523
from simpeg.utils import extract_core_mesh
2624
from simpeg.electromagnetics.static import resistivity as DC
@@ -216,7 +214,7 @@ def get_Surface_Potentials(mtrue, survey, src, field_obj):
216214
phiScale = 0.0
217215

218216
if survey == "Pole-Dipole" or survey == "Pole-Pole":
219-
refInd = utils.closestPoints(mesh, [xmax + 60.0, 0.0], gridLoc="CC")
217+
refInd = closest_points_index(mesh, [xmax + 60.0, 0.0], grid_loc="CC")
220218
# refPoint = CCLoc[refInd]
221219
# refSurfaceInd = np.where(xSurface == refPoint[0])
222220
# phiScale = np.median(phiSurface)
@@ -689,7 +687,7 @@ def PLOT(
689687
view=view,
690688
stream_opts=streamOpts,
691689
pcolor_opts=pcolorOpts,
692-
) # gridOpts ={'color':'k', 'alpha':0.5}
690+
) # grid_opts ={'color':'k', 'alpha':0.5}
693691

694692
# Get cylinder outline
695693
cylinderPoints = getCylinderPoints(xc, zc, ellips_a, ellips_b)

geoscilabs/dcip/DC_Pseudosections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ def DC2Dfwdfun(
542542
ax=ax1,
543543
clim=(1, 3),
544544
grid=True,
545-
gridOpts={"color": "k", "alpha": 0.5},
545+
grid_opts={"color": "k", "alpha": 0.5},
546546
)
547547
cb1ticks = [1.0, 2.0, 3.0]
548548
cb1 = plt.colorbar(dat1[0], ax=ax1, ticks=cb1ticks)
@@ -582,7 +582,7 @@ def DC2Dfwdfun(
582582
ax=ax1,
583583
clim=(1, 3),
584584
grid=True,
585-
gridOpts={"color": "k", "alpha": 0.5},
585+
grid_opts={"color": "k", "alpha": 0.5},
586586
)
587587
cb1ticks = [1.0, 2.0, 3.0]
588588
cb1 = plt.colorbar(dat1[0], ax=ax1, ticks=cb1ticks)

0 commit comments

Comments
 (0)