Skip to content
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 percentile averaging mode #20

Merged
merged 1 commit into from
Apr 6, 2023
Merged

Conversation

svank
Copy link
Contributor

@svank svank commented Apr 6, 2023

This adds "percentile" as an averaging mode.

As I was updating the tests, I noticed that for the "mean" averaging mode, nan values are rejected by the nansum, but they're still counted in the counts array, which will mean pixels that have nans in some of the input patches will get a downward bias. I changed counts to count the number of non-nan inputs per-pixel, rather than being a simple sum of the number of input patches, to address this.

(This will cause a merge conflict for the visualization PR, as that one had also made changes to the counts array. Once one of these PRs is merged, I'll update the other, where there will probably end up being a mean_counts tracker of the number of non-nan contributions to each pixel for the average, and a separate counts tracker that just tracks the number of input patches to each combined patch.)

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.14 🎉

Comparison is base (941fc85) 93.39% compared to head (f744a35) 93.54%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #20      +/-   ##
==========================================
+ Coverage   93.39%   93.54%   +0.14%     
==========================================
  Files           9        9              
  Lines         757      774      +17     
==========================================
+ Hits          707      724      +17     
  Misses         50       50              
Impacted Files Coverage Δ
regularizepsf/fitter.py 86.26% <100.00%> (+0.15%) ⬆️
tests/test_fitter.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

# n.b. If mode is 'median', we could set mode='percentile'
# and percentile=50 to simplify parts of this function, but
# np.nanpercentile(x, 50) seems to be about half as fast as
# np.nanmedian(x), so let's keep a speedy special case for medians.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what optimizations they're doing to achieve that speedup.

Copy link
Member

@jmbhughes jmbhughes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I appreciate that you use nans in the test!

@jmbhughes jmbhughes merged commit ded2c7b into punch-mission:main Apr 6, 2023
@svank svank deleted the averaging branch April 7, 2023 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants