harmonica icon indicating copy to clipboard operation
harmonica copied to clipboard

Fix bug in reduction to the pole requiring dims "easting" and "northing"

Open zaarcvon opened this issue 1 year ago • 4 comments

Relevant issues/PRs:

Fixes #439 bug issue: the reduction_to_pole filter produces an error when grid coordinate names are not "northing" and "easting".
Now, it works regardless of grid coordinate names.

zaarcvon avatar Jun 13 '24 14:06 zaarcvon

@zaarcvon thank you for the fix! Would you mind adding a quick test in that runs the reduction to the pole with a grid with dims that have another name? It could be a modification of this test https://github.com/fatiando/harmonica/blob/main/harmonica/tests/test_transformations.py#L615 that renames the dims of the test grid before doing RTP. Would be worth checking that the test fails with the code in main first.

leouieda avatar Jun 14 '24 12:06 leouieda

Hi, @leouieda! I included a test function. I hope everything is done correctly. This is my first experience working with pytest

zaarcvon avatar Jun 14 '24 18:06 zaarcvon

Hi, @leouieda . I see that some checks are failing. I understand one related to style and will fix it, but it's not clear what the code style/format check is really about.

zaarcvon avatar Jun 18 '24 20:06 zaarcvon

Hi @zaarcvon. The two check that are failing are due to code style. The format one is easy to solve, we just need to run black on the project. You can do it by running make format in your local repo (https://github.com/fatiando/community/blob/main/CONTRIBUTING.md#code-style). The style one is telling us that flake8 is raising some warnings. You can check them out by clicking in Details, next to the failing check. In this particular case, flake8 is complaining about trailing whitespaces (whitespaces left after the last character of certain lines). When you run make format, black will take care of those as well.

santisoler avatar Jun 25 '24 16:06 santisoler

Hi @zaarcvon! Today @YagoMCastro fixed the code style issues in your PR, so now we are ready to merge this. Thanks a lot for the contribution! 🚀

santisoler avatar Aug 12 '24 19:08 santisoler

Hi, I've just used harmonica.reduction_to_pole (v 0.7.0) and am plotting input padded magnetic anomaly and the output RTP (still padded) with a matplotlib helper function. Both data arrays have similar spatial attributes (pasted below). Note that the CRS is dropped in the output. My main issue is that the output has the Y order flipped i.e anomalies are upside down... I am using the same matplotlib helper for plotting both.

=== magnetic_data_padded=== dims: ('y', 'x') shape: (3652, 4262) dtype: float32 values: min=-1525.04 max=1987.58 mean=-28.7252 std=75.8211 robust[2-98%]=(-214.205,100.949) pixels: total=15564824 valid=15564824 NaN=0 NoData(-999999.0)=0 y: 2.64381e+06 → 2.42475e+06 (decreasing, ~step=-60, nonuniform±=0) x: 346410 → 602070 (increasing, ~step=60, nonuniform±=0) CRS: EPSG:9358 resolution: (60.0, -60.0) (yres sign <0 north-up) bounds: (xmin, ymin, xmax, ymax) = (346380.0, 2424720.0, 602100.0, 2643840.0) transform: | 60.00, 0.00, 346380.00| | 0.00,-60.00, 2643840.00| | 0.00, 0.00, 1.00|

=== rtp_data_padded === dims: ('y', 'x') shape: (3652, 4262) dtype: float64 values: min=-1516.02 max=3525.91 mean=1.49482e-14 std=143.131 robust[2-98%]=(-267.522,284.456) pixels: total=15564824 valid=15564824 NaN=0 y: 2.64381e+06 → 2.42475e+06 (decreasing, ~step=-60, nonuniform±=0) x: 346410 → 602070 (increasing, ~step=60, nonuniform±=0) CRS: None resolution: (60.0, -60.0) (yres sign <0 north-up) bounds: (xmin, ymin, xmax, ymax) = (346380.0, 2424720.0, 602100.0, 2643840.0) transform: | 60.00, 0.00, 346380.00| | 0.00,-60.00, 2643840.00| | 0.00, 0.00, 1.00|

fearaschiarrai avatar Sep 23 '25 10:09 fearaschiarrai

Hi @fearaschiarrai. Could you open a new Issue with an example that reproduces the issue? In both cases I see your y coordinate being "inverted", going from a north value to a shout one with a negative step of -60.

santisoler avatar Sep 24 '25 17:09 santisoler