Skip to content
Open
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
16 changes: 5 additions & 11 deletions src/harmonica/_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ def reduction_to_pole(
grid,
inclination,
declination,
magnetization_inclination=None,
magnetization_declination=None,
magnetization_inclination,
magnetization_declination,
*,
pad=True,
pad_kwargs=None,
Expand All @@ -412,16 +412,10 @@ def reduction_to_pole(
The inclination of the inducing Geomagnetic field.
declination : float in degrees
The declination of the inducing Geomagnetic field.
magnetization_inclination : float in degrees or None
The inclination of the total magnetization of the anomaly source. If
None, the ``magnetization_inclination`` will be set equal to the
``inclination``, neglecting remanent magnetization and self
demagnetization. Default None.
magnetization_inclination : float in degrees
The inclination of the total magnetization of the anomaly source.
magnetization_declination : float in degrees
The declination of the total magnetization of the anomaly source. If
None, the ``magnetization_declination`` will be set equal to the
``declination``, neglecting remanent magnetization and self
demagnetization. Default None.
The declination of the total magnetization of the anomaly source.
pad : bool, optional
If True, will add padding to the grid before taking the Fourier Transform
and applying the filter and remove it after the inverse Fourier Transform.
Expand Down
15 changes: 15 additions & 0 deletions test/test_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,21 @@ def test_reduction_to_pole_dim_names(sample_potential):
reduction_to_pole(renamed_dims_grid, 60, 45, 60, 45)


def test_reduction_to_pole_magnetization_required(sample_potential):
"""
The magnetization direction must be a required argument.

Making it required forces users to be explicit about the induced-only
magnetization assumption (see #440 and #661). It used to default to None on
the public ``reduction_to_pole`` function, which crashed deep inside the
kernel after #661 removed the None handling.
"""
with pytest.raises(TypeError, match="magnetization_inclination"):
reduction_to_pole(sample_potential, 60, 45)
with pytest.raises(TypeError, match="magnetization_declination"):
reduction_to_pole(sample_potential, 60, 45, 60)


class TestTotalGradientAmplitude:
"""
Test total_gradient_amplitude function.
Expand Down