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
13 changes: 10 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ v2.5.x
""""""


*latest*
--------
v2.5.4: Bugfix ext. fcts with z+ up
-----------------------------------

**2026-01-21**

- Bugfix: Since v1.10.5, one can provide depth also in decreasing order.
Internally, all parameters are reversed then. However, parameters in
user-provided ``func_eta`` and ``func_zeta`` were not reversed, so far the
user had to take care of this (and hence define them differently to the rest,
which is a bug really). Now any provided parameter in the ``res``-dict is
also reversed. If verb>2, these parameters are finally also printed.

- Gallery

- New example *IP and VRM*, based on a notebook from @orerocks.



v2.5.3: Flexible bipole coordinates
-----------------------------------

Expand Down
6 changes: 5 additions & 1 deletion empymod/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ def check_model(depth, res, aniso, epermH, epermV, mpermH, mpermV, xdirect,

# Check if the user provided a model for etaH/etaV/zetaH/zetaV
if isinstance(res, dict):
res = copy.deepcopy(res)
res_dict, res = res, res['res']
else:
res_dict = False
Expand Down Expand Up @@ -824,7 +825,10 @@ def check_inp(var, name, min_val):
# Loop over key, value pair and check
for key, value in res_dict.items():
if key not in ['res', 'func_eta', 'func_zeta']:
res_dict[key] = check_inp(value, key, None)
res_dict[key] = check_inp(value, key, None)[::swap]
# Print model parameters
if verb > 2:
print(f" {key:16}: {_strvar(res_dict[key])}")

# Put res back
res_dict['res'] = res
Expand Down
2 changes: 1 addition & 1 deletion examples/time_domain/ip_vrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def simulate_empymod(inp, res, times, compute_B_field=True, loop_current=1.0,
'inp': {
'src': src_bipole,
'rec': rec,
'depth': [0.0, -50.0],
'depth': [0.0, 50.0],
'verb': 1,
}
}
Expand Down
50 changes: 30 additions & 20 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def test_multisrc_multirec(self):
assert_allclose(out0f, out1f)
assert_allclose(out0t, out1t)

def test_cole_cole(self):
def test_cole_cole(self, capsys):
# Check user-hook for eta/zeta

def func_eta(inp, pdict):
Expand All @@ -518,25 +518,35 @@ def func_zeta(inp, pdict):

return etaH, etaV

model = {'src': [0, 0, 500, 0, 0], 'rec': [500, 0, 600, 0, 0],
'depth': [0, 550], 'freqtime': [0.1, 1, 10]}
res = np.array([2, 10, 5])
fact = np.array([2, 2, 2])
eta = {'res': fact*res, 'fact': fact, 'func_eta': func_eta}
zeta = {'res': res, 'fact': fact, 'func_zeta': func_zeta}

# Frequency domain
standard = bipole(res=res, **model)
outeta = bipole(res=eta, **model)
assert_allclose(standard, outeta)
outzeta = bipole(res=zeta, mpermH=fact, mpermV=fact, **model)
assert_allclose(standard, outzeta)
# Time domain
standard = bipole(res=res, signal=0, **model)
outeta = bipole(res=eta, signal=0, **model)
assert_allclose(standard, outeta)
outzeta = bipole(res=zeta, signal=0, mpermH=fact, mpermV=fact, **model)
assert_allclose(standard, outzeta)
for rev in [1, -1]:
model = {
'src': [0, 0, 500, 0, 0], 'rec': [500, 0, 600, 0, 0],
'depth': [0, rev*550], 'freqtime': [0.1, 1, 10], 'verb': 3,
}
res = np.array([2, 10, 5])
fact = np.array([1.5, 2, 2.5])
eta = {'res': fact*res, 'fact': fact, 'func_eta': func_eta}
zeta = {'res': res, 'fact': fact, 'func_zeta': func_zeta}

# Frequency domain
standard = bipole(res=res, **model)
_, _ = capsys.readouterr()
outeta = bipole(res=eta, **model)
out, _ = capsys.readouterr()
if rev == 1:
assert "fact : 1.5 2 2.5" in out
else:
assert "fact : 2.5 2 1.5" in out
assert_allclose(standard, outeta)
outzeta = bipole(res=zeta, mpermH=fact, mpermV=fact, **model)
assert_allclose(standard, outzeta)
# Time domain
standard = bipole(res=res, signal=0, **model)
outeta = bipole(res=eta, signal=0, **model)
assert_allclose(standard, outeta)
outzeta = bipole(
res=zeta, signal=0, mpermH=fact, mpermV=fact, **model)
assert_allclose(standard, outzeta)

def test_src_rec_definitions(self):
inp = {'depth': [0, -250], 'res': [1e20, 0.3, 5], 'freqtime': 1.23456}
Expand Down
Loading