Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Functions to caluclate the radial average power spectrum #303
This time I've written two new functions in gravmag.transform: a simple one that calculates the Power-Density Spectra (PDS) of regular gridded data and the other one radially averages this PDS (or any real 2D-array in the wavenumber domain).
As discussed in #230, this new functions has the following characteristics:
I leave an example with its outputs:
@santis19 thank you for opening this again!
I've taken a quick look at the code and it's very nice and clean! There isn't much to add to the code. I'll leave some comments inline with some suggestions to improve the interface and docstrings. Great job!
A nice thing about the separation is that we can now test the
Another test could then be to create a data array that is the distance from the center of the grid. The radial average should be the distance returned to us.
These two test cases should cover most of the code and usage of this function.
I'm having a harder time thinking how we could test the
Another point I'm considering is if it would be better to make a
I like this approach better because it gets rid of repeated code in the
For this PR, I think you should focus now on implementing the tests discussed above. They should go in the
Let me know if you need help with these. I recently updated the reduction to the pole tests and the tilt tests are brand new so you should use those as inspiration.
I've just finished the radial_average tests: one with integers and another one with distances (as @leouieda proposed).
I have a problem with the last one: the first ring (not the one related to k=0, but the next one) has more than 0.1 relative error. I think that may be related to the fact that this ring is the least populated, so the values are not so randomly spread inside it. But for the rest of the array the test doesn't fail.
I leave the codes here. I don't know if I should start another PR for this test or just push the edited test_transform.py into my branch...please help this github newbie! haha
@santis19 you can push the test here as well. A PR will only be merged when tests are implemented and passing, that's a way to guarantee that all new code works properly. You'll notice that one of the reasons why "All checks have failed" is that the code test coverage decreased (meaning that you added untested code). Just avoid pushing things that do have anything to do with these two functions (typo fixes elsewhere, bugs in other functions, etc). Those should be submitted as separate PRs.
@santis19 perfect! Sorry for the delay, I was away on vacation
I've sent you a pull request to add the changelog entry. You can merge that and add yourself to
Thank you so much for taking the time to implement this! I'm working on ways of making the PR processes faster and less of a burden.