Pad grids automatically before applying transformations#608
Pad grids automatically before applying transformations#608
Conversation
Changes how keyword arguments are handled by this function since we now need one set for the padding and one for the filter.
They are failing but I don't know why yet
We have a better test now against a synthetic and this test didn't work very well before, since it required removing a mean from the Oasis result for some unspecified reason.
Was using the potential but it's too smooth and causes problems at the edges. Switch to gz instead and it works when looking at a smaller region inside the area.
5fd8ce8 to
2f886f6
Compare
|
To do:
|
Introduce an argument to apply_filter for dropping coordinates. We only really need to do this for upward continuation. The other filters don't alter the location of points. Update the filter tests to use synthetics instead of Montaj results.
|
@santisoler @mdtanker I'm done here and could use a quick review. The transformations are much better now and so are the tests. @mdtanker I ended up sticking with the "edge" mode since it seemed to work better in the tests and docs than the "reflect" mode. Not sure why. |
santisoler
left a comment
There was a problem hiding this comment.
Thanks for pushing this forward, @leouieda!
I think it's looking great. I left a few suggestions to follow numpydoc style for optional arguments. I just went with , optional, but we can also use default: ... if you like it better.
I also added a few suggestions to force to pass optional arguments as keyword arguments. I know that would break backward compatibility, but I don't think a lot of users are actually using them, and the change wouldn't be too hard to update on their side. Let me know what do you think.
Feel free to merge afterwards!
| fft_filter : func | ||
| Callable that builds the filter in the frequency domain. | ||
| kwargs : | ||
| filter_kwargs : dict |
There was a problem hiding this comment.
| filter_kwargs : dict | |
| filter_kwargs : dict or None, optional |
| Any additional keyword argument that should be passed to the | ||
| ``fft_filter``. | ||
| ``fft_filter`` in the form of a dictionary. | ||
| pad : bool |
There was a problem hiding this comment.
| pad : bool | |
| pad : bool, optional |
| and applying the filter and remove it after the inverse Fourier Transform. | ||
| Adding padding usually helps reduce edge effects from signal truncation. | ||
| Default is True. | ||
| pad_kwargs : dict |
There was a problem hiding this comment.
| pad_kwargs : dict | |
| pad_kwargs : dict or None, optional |
| :meth:`xarray.DataArray.pad` function. If none are given, the default | ||
| padding of 25% the dimensions of the grid will be added using the | ||
| "edge" method. | ||
| drop_coords : bool |
There was a problem hiding this comment.
| drop_coords : bool | |
| drop_coords : bool, optional |
| def apply_filter( | ||
| grid, fft_filter, filter_kwargs=None, pad=True, pad_kwargs=None, drop_coords=False | ||
| ): |
There was a problem hiding this comment.
I'd be inclined to force passing optional arguments as keyword arguments:
| def apply_filter( | |
| grid, fft_filter, filter_kwargs=None, pad=True, pad_kwargs=None, drop_coords=False | |
| ): | |
| def apply_filter( | |
| grid, fft_filter, *, filter_kwargs=None, pad=True, pad_kwargs=None, drop_coords=False | |
| ): |
| evenly spaced (regular grid). Its dimensions should be in the following | ||
| order: *northing*, *easting*. Its coordinates should be defined in the | ||
| same units. | ||
| pad : bool |
There was a problem hiding this comment.
| pad : bool | |
| pad : bool, optional |
| and applying the filter and remove it after the inverse Fourier Transform. | ||
| Adding padding usually helps reduce edge effects from signal truncation. | ||
| Default is True. | ||
| pad_kwargs : dict or None |
There was a problem hiding this comment.
| pad_kwargs : dict or None | |
| pad_kwargs : dict or None, optional |
|
|
||
|
|
||
| def tilt_angle(grid): | ||
| def tilt_angle(grid, pad=True, pad_kwargs=None): |
There was a problem hiding this comment.
| def tilt_angle(grid, pad=True, pad_kwargs=None): | |
| def tilt_angle(grid, *, pad=True, pad_kwargs=None): |
| evenly spaced (regular grid). Its dimensions should be in the following | ||
| order: *northing*, *easting*. Its coordinates should be defined in the | ||
| same units. | ||
| pad : bool |
There was a problem hiding this comment.
| pad : bool | |
| pad : bool, optional |
| and applying the filter and remove it after the inverse Fourier Transform. | ||
| Adding padding usually helps reduce edge effects from signal truncation. | ||
| Default is True. | ||
| pad_kwargs : dict or None |
There was a problem hiding this comment.
| pad_kwargs : dict or None | |
| pad_kwargs : dict or None, optional |
Rework the
apply_filterfunction to make it apply and then remove padding when applying a filter automatically. The padding can be turned off or controlled by passing keyword arguments. The default padding mode is "edge" which works well with our tests and examples. Dropping non-dimensional coordinates is now handled byapply_filteras well instead of the FFT functions. Only drop non-dimensional coordinates on upward continuation since that's the only transformation that changes coordinates. Update the tests for transformations, in particular the tilt, Gaussian filters, and reduction to the pole which now test against a synthetic instead of the Montaj results from previously. Remove the unused Montaj testing grid.Relevant issues/PRs: Fixes #390 and fixes #630