Skip to content

Commit

Permalink
Make reduce_to_pole work for arbitrary dimension names (#509)
Browse files Browse the repository at this point in the history
Fix bug in `reduction_to_pole` that made it to work only if the
dimensions of the passed grid were `northing` and `easting`. Now the
grid can have arbitrary dimension names. Add tests for these changes.

---------

Co-authored-by: YagoMCastro <[email protected]>
  • Loading branch information
zaarcvon and YagoMCastro authored Aug 12, 2024
1 parent 99c5c01 commit 07a5af3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion harmonica/filters/_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def reduction_to_pole_kernel(
magnetization_declination,
)
# Set 0 wavenumber to 0
da_filter.loc[dict(freq_northing=0, freq_easting=0)] = 0
da_filter.loc[{dims[0]: 0, dims[1]: 0}] = 0
return da_filter


Expand Down
10 changes: 10 additions & 0 deletions harmonica/tests/test_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,16 @@ def test_upward_continuation(sample_g_z, sample_g_z_upward):
xrt.assert_allclose(continuation, g_z_upward, atol=1e-8)


def test_reduction_to_pole(sample_potential):
"""
Test reduction_to_pole function with non-typical dim names
"""
renamed_dims_grid = sample_potential.rename(
{"easting": "name_one", "northing": "name_two"}
)
reduction_to_pole(renamed_dims_grid, 60, 45)


class TestTotalGradientAmplitude:
"""
Test total_gradient_amplitude function
Expand Down

0 comments on commit 07a5af3

Please sign in to comment.