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

Fix calc_Q for shared theta_offset #175

Merged
merged 3 commits into from
Apr 3, 2024
Merged

Conversation

bmaranville
Copy link
Member

In models with a shared theta_offset (where the parameter is tied, for example for mm and pp) the values of Q at which the model is evaluated were not properly calculated (PolarizedNeutronProbe.calc_Q).

The first time calc_Q is determined, measurement_union is called, and then probe.T is set to the xs.T + shared_offset. Later calls to _calculate_union add the current theta_offset to that T, which is incorrect (should be added to the original probe.T).

This PR stores the original T (as probe._To) and when _calculate_union() is called for a shared theta_offset, it will add the current offset to the original T.

Note that currently oversampling is not compatible with _calculate_union. Need to fix that separately (oversampling is ignored when calculating new values of calc_Q when theta_offset is a fittable parameter)

@bmaranville
Copy link
Member Author

Note that the result of this bug is that calc_Q for PolarizedNeutronProbe does not always line up perfectly with data Q values, so that some interpolation is done (data Q is always interpolated to calc_Q, but it's easier when they line up so the interpolation is trivial). It should not affect chisq or any correctness, but it might if the data is not sampled densely enough (the minimum chisq for a fit is sensitive to choice of calc_Q for undersampled calc_Q - this is a known effect).

The "right" thing to do is to either take data densely enough to cover the convolution shape of dQ at each Q, or oversample the calc_Q values.

@bmaranville bmaranville merged commit 880c1a3 into webview Apr 3, 2024
2 checks passed
@bmaranville bmaranville deleted the fix_shared_theta_offset branch April 3, 2024 15:36
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.

1 participant