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

clip I for Sigma calc #235

Closed
wants to merge 5 commits into from
Closed

clip I for Sigma calc #235

wants to merge 5 commits into from

Conversation

DHekstra
Copy link
Contributor

When using scale_merged_intensities to perform French-Wilson scaling in the anisotropic mode, the local Sigma is calculated by a local weighted average of observed intensities. As a consequence, Sigma can be negative. This leads to NaNs in the calculation of the logpdf used to calculate the posterior expected intensity. To remedy this, I propose clipping the observed intensities to be positive in (and only in) the calculation of Sigma in mean_intensity_by_miller_index(I, H, bandwidth).

@codecov-commenter
Copy link

codecov-commenter commented Dec 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0e2f5e2) 92.39% compared to head (d25d7da) 92.40%.
Report is 3 commits behind head on main.

❗ Current head d25d7da differs from pull request most recent head f7f472e. Consider uploading reports for the commit f7f472e to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #235   +/-   ##
=======================================
  Coverage   92.39%   92.40%           
=======================================
  Files          37       37           
  Lines        2434     2435    +1     
=======================================
+ Hits         2249     2250    +1     
  Misses        185      185           
Flag Coverage Δ
unittests 92.40% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kmdalton
Copy link
Member

I'm not certain that fw should really be applied to data with resolution shells that have negative average intensity. Silently clipping the values is not a good solution if it leads to the user unknowingly processing such data. If you want to merge a change like this, it needs to print a warning or better yet be implemented as an optional flag which is disabled by default.

@DHekstra
Copy link
Contributor Author

That makes sense. In my single test, Sigma was negative for ~0.01% of reflections. I'll think some more about this when time permits.

@DHekstra DHekstra closed this Dec 17, 2023
@DHekstra DHekstra deleted the fw_fix branch December 17, 2023 17:30
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