Skip to content

Commit

Permalink
Remove backwards incompatible change.
Browse files Browse the repository at this point in the history
Makes model.analytical a tad more complex due to the inclusion of
Laplace, but keeps utils.check_frequency backwards compatible.
  • Loading branch information
prisae committed Sep 11, 2019
1 parent 83a8c6f commit 7f65e3a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
20 changes: 11 additions & 9 deletions empymod/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def bipole(src, rec, depth, res, freqtime, signal=None, aniso=None,
# Check frequency => get etaH, etaV, zetaH, and zetaV
frequency = check_frequency(freq, res, aniso, epermH, epermV, mpermH,
mpermV, verb)
freq, etaH, etaV, zetaH, zetaV, _ = frequency
freq, etaH, etaV, zetaH, zetaV = frequency

# Update etaH/etaV and zetaH/zetaV according to user-provided model
if isinstance(res, dict) and 'func_eta' in res:
Expand Down Expand Up @@ -904,7 +904,7 @@ def dipole(src, rec, depth, res, freqtime, signal=None, ab=11, aniso=None,
# Check frequency => get etaH, etaV, zetaH, and zetaV
frequency = check_frequency(freq, res, aniso, epermH, epermV, mpermH,
mpermV, verb)
freq, etaH, etaV, zetaH, zetaV, _ = frequency
freq, etaH, etaV, zetaH, zetaV = frequency

# Update etaH/etaV and zetaH/zetaV according to user-provided model
if isinstance(res, dict) and 'func_eta' in res:
Expand Down Expand Up @@ -1123,7 +1123,7 @@ def analytical(src, rec, res, freqtime, solution='fs', signal=None, ab=11,
# Check frequency => get etaH, etaV, zetaH, and zetaV
frequency = check_frequency(freqtime, res, aniso, epermH, epermV, mpermH,
mpermV, verb)
time, etaH, etaV, zetaH, zetaV, sval = frequency
freq, etaH, etaV, zetaH, zetaV = frequency

# Update etaH/etaV and zetaH/zetaV according to user-provided model
if isinstance(res, dict) and 'func_eta' in res:
Expand Down Expand Up @@ -1152,10 +1152,12 @@ def analytical(src, rec, res, freqtime, solution='fs', signal=None, ab=11,
# === 3. EM-FIELD CALCULATION ============

if solution[0] == 'd':
if signal is not None:
freqtime = time
else:
freqtime = sval
# To make it work with Laplace domain calculations.
if signal is None:
if np.any(freqtime > 0):
freqtime = 2j*np.pi*freq
else:
freqtime = freq
EM = kernel.halfspace(off, angle, zsrc, zrec, etaH, etaV,
freqtime[:, None], ab_calc, signal, solution)
else:
Expand All @@ -1166,7 +1168,7 @@ def analytical(src, rec, res, freqtime, solution='fs', signal=None, ab=11,
# If <ab> = 36 (or 63), field is zero
# In `bipole` and in `dipole`, this is taken care of in `fem`. Here
# we have to take care of it separately
EM = np.zeros((sval.size*nrec*nsrc), dtype=etaH.dtype)
EM = np.zeros((freq.size*nrec*nsrc), dtype=etaH.dtype)

# Squeeze
if solution[1:] == 'split':
Expand Down Expand Up @@ -1403,7 +1405,7 @@ def dipole_k(src, rec, depth, res, freq, wavenumber, ab=11, aniso=None,

# Check frequency => get etaH, etaV, zetaH, and zetaV
f = check_frequency(freq, res, aniso, epermH, epermV, mpermH, mpermV, verb)
freq, etaH, etaV, zetaH, zetaV, _ = f
freq, etaH, etaV, zetaH, zetaV = f

# Check src-rec configuration
# => Get flags if src or rec or both are magnetic (msrc, mrec)
Expand Down
2 changes: 1 addition & 1 deletion empymod/scripts/tmtemod.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def dipole(src, rec, depth, res, freqtime, aniso=None, eperm=None, mperm=None,
# Check frequency => get etaH, etaV, zetaH, and zetaV
frequency = check_frequency(freqtime, res, aniso, epermH, epermV, mpermH,
mpermV, verb)
freq, etaH, etaV, zetaH, zetaV, _ = frequency
freq, etaH, etaV, zetaH, zetaV = frequency

# Check src and rec
src, nsrc = check_dipole(src, 'src', verb)
Expand Down
5 changes: 1 addition & 4 deletions empymod/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,6 @@ def check_frequency(freq, res, aniso, epermH, epermV, mpermH, mpermV, verb):
zetaH, zetaV : array
Parameters zetaH/zetaV, same size as provided resistivity.
sval : float
Laplace parameter.
"""
global _min_freq

Expand Down Expand Up @@ -462,7 +459,7 @@ def check_frequency(freq, res, aniso, epermH, epermV, mpermH, mpermV, verb):
zetaH = np.outer(sval, mpermH*mu_0)
zetaV = np.outer(sval, mpermV*mu_0)

return freq, etaH, etaV, zetaH, zetaV, sval
return freq, etaH, etaV, zetaH, zetaV


def check_hankel(ht, htarg, verb):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_hankel(htype): # 1. fht / 2. hqwe / 3. hquad
depth, res, aniso, epermH, epermV, mpermH, mpermV, _ = model
frequency = utils.check_frequency(1, res, aniso, epermH, epermV, mpermH,
mpermV, 0)
_, etaH, etaV, zetaH, zetaV, _ = frequency
_, etaH, etaV, zetaH, zetaV = frequency
src = [0, 0, 0]
src, nsrc = utils.check_dipole(src, 'src', 0)
for ab_inp in [11, 12, 13, 33]:
Expand Down Expand Up @@ -368,7 +368,7 @@ def test_dlf(): # 10. dlf
depth, res, aniso, epermH, epermV, mpermH, mpermV, _ = model
frequency = utils.check_frequency(1, res, aniso, epermH, epermV,
mpermH, mpermV, 0)
_, etaH, etaV, zetaH, zetaV, _ = frequency
_, etaH, etaV, zetaH, zetaV = frequency
src = [0, 0, 0]
src, nsrc = utils.check_dipole(src, 'src', 0)
ab, msrc, mrec = utils.check_ab(ab, 0)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_check_frequency(capsys):
out, _ = capsys.readouterr()
assert " frequency [Hz] : " in out
assert "* WARNING :: Frequencies < " in out
freq, etaH, etaV, zetaH, zetaV, _ = output
freq, etaH, etaV, zetaH, zetaV = output
assert_allclose(freq, rfreq)
assert_allclose(etaH, retaH)
assert_allclose(etaV, retaV)
Expand All @@ -228,7 +228,7 @@ def test_check_frequency(capsys):
out, _ = capsys.readouterr()
assert " s-value [Hz] : " in out
assert "* WARNING :: Laplace val < " in out
freq, etaH, etaV, zetaH, zetaV, _ = output
freq, etaH, etaV, zetaH, zetaV = output
assert_allclose(freq, rfreq)


Expand Down

0 comments on commit 7f65e3a

Please sign in to comment.