- 
                Notifications
    You must be signed in to change notification settings 
- Fork 44
Add Azimuthal Averaging #1255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Azimuthal Averaging #1255
Conversation
| sorry, this is my 1st time creating a new feature. I'm not sure how to properly link this to the issue or attach a "new feature" label. | 
| This seems similar to #941 | 
| perhaps the case where a bin contains 0 hits (i.e., hit_count[ii] = 0) should be set to nan in the output data array. so before the continue statement: | 
| why are the outer radius and radius step arguments required to be integers rather than any non-negative scalar? | 
| 
 Good catch, I've updated the type hints. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds an azimuthal_mean function to the UxDataArray class that computes averages along circles of constant great-circle distance from a central point. The implementation follows a similar pattern to the existing zonal_mean function and uses ball tree spatial queries to efficiently identify faces within radial bins.
- Adds azimuthal_meanmethod to compute radial averages around a specified center coordinate
- Implements spatial binning using KD-tree ball queries with radial ring exclusion logic
- Returns a UxDatasetcontaining both the azimuthal means and hit counts for each radius
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description | 
|---|---|
| uxarray/core/dataarray.py | Adds the azimuthal_meanmethod implementation with radial binning logic | 
| test/core/test_azimuthal.py | Adds basic tests for Gaussian and inverse Gaussian distributions | 
| docs/api.rst | Updates API documentation to include the new azimuthal mean functionality | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| 
 Not really, based on my understanding of each. Geometrically, #941 suggests that a bounding circular neighborhood is obtained for each grid face (where the center coordinate varies per face center but the radius is constant) while this one looks into bounding circles centered on a fixed center coordinate but differs from each other with varying radii. Do you agree with this? | 
| 
 I do agree. #941 applies an aggregation within all points that lie a given radius from a center coordinate. This one incrementally increases the radius and applies the aggregation within those circles. | 
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The functionality seems great!
I think I am hesitant though about returning UxDataset out of such an aggregation function (it likewise applies to zonal_mean() as well; I think I overlooked it before): Shouldn't the logic be to create x number of scalars that are corresponding to the mean of each circular region, and not to worry about providing an USG topology? If so, shouldn't return types simply be np.ndarray, or something similar?
cc: @rajeeja
| 
 Good suggestion. Since there's no longer a valid grid associate with the output, the result should be an  | 
| 
 Absolutely! Probably multiple  | 
| 
 Yep! Added a  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks great to me; thanks very much! No plans with an immediate notebook into the user guide with this PR? If the preference is to add that later, could you please create an issue regarding that, if none exists. Also, who is going to write that guide, @jpan84 maybe you?
| 
 Any thoughts @jpan84? I'm happy to move forward with this PR with the simple docstring example, and create an issue to develop a notebook down the line. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am approving it to help make its way forward. Thanks a lot for this addition!
| Good PR. Thanks this work and I agree that we should not return Uxdataset here as already handled. Couple of minor points: | 
| Thank you for moving forward with this PR—the tweaks to the docstring and functionality look great! Please do create an issue for the notebook. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor safeguards as pointed in comments
UxDataArray.azimuthal_mean functionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Closes #1254
Compute azimuthal mean in radial rings around a central point.
Overview
Like
uxarray.UxDataArray.zonal_mean(), this aggregates over faces to output the data with a new horizontal dimensionradius. Followinguxarray.UxDataArray.subset.bounding_circle, this function usesball_tree.query_radiusto select grid elements in a circular neighborhood from one center coordinate. For radii r=[r1, r2, r3, ...], face centers at distance d (given in great-circle degrees), where r2<d<=r3 will be used for the azimuthal mean at r3.This is one solution for issue #1254
This may be tangentially relevant to issue #930.
Expected Usage
PR Checklist
General
Testing
Documentation
_) and have been added todocs/internal_api/index.rstdocs/user_api/index.rstExamples
docs/examples/folderdocs/examples.rsttoctreedocs/gallery.ymlwith appropriate thumbnail photo indocs/_static/thumbnails/