Adds dummy err_data to residual data for slicers to work#3931
Adds dummy err_data to residual data for slicers to work#3931jellybean2004 wants to merge 1 commit intomainfrom
Conversation
| residuals.q_data = current_data.q_data | ||
| residuals.err_data = None | ||
| # Slicers expect residuals to have err_data, so add dummy error data of ones | ||
| residuals.err_data = numpy.ones(len(residuals.data)) |
There was a problem hiding this comment.
Wouldn't numpy.zeros make more sense?
There was a problem hiding this comment.
In manipulations.py, a zero value in err-data triggers a fallback, and data is used as a proxy. So I used ones.
There was a problem hiding this comment.
χ² = Σ (f(x) - y)²/Δy² so Δy=1 is a natural value to use in the absence of any information about the data uncertainty. Parameter uncertainties can be normalized by √(χ²/DOF) to account for improperly scaled error bars. I'm not doing this by default because this assumes that there is no systematic error.
Note: in the broader stats world where measurement uncertainty is unknown, data is generally drawn without uncertainty. Whether the result of SasView (i.e., the plotting infrastructure and the bumps interface) can handle the missing error bars is a separate question. They probably should, since fixed Δy = 1 will make for ugly plots.
What does sasdata do with datasets that don't have any associated uncertainty? Does it return them as None? In which case, the correct fix is to leave err_data as None and fix the "isfinite" masking.
Note 2: If this is acting on a normalized residual, then the Δy is supposed to be one. It should be put there by whatever generated the residual, though, and not be introduced by the slicer.
|
I'm not even able to get to a 2D residual plot. Choosing exp18_14_igor_2dqxqy.dat I can't send it to fitting without seeing the error: It also fails for 1D datasets. I suspect the problem is outside the scope of this PR, but the result is that I can't test the fix. |
Odd. That means you have no active perspective. Can you plot the data? What OS are running and are you testing with the built binary or directly from source? |
@pkienzle @krzywon, I tried this data file, and I faced no issues. The original file I tested on was |
|
I was messing with bumps and that broke the fitting perspective. It is not incorrect to introduce err_data=1 in this code, assuming the reference data is a theory function with no uncertainty. The 1D residuals function does not define dy, so it is a little odd that we have it for 2D. The question still stands whether it is better add the uncertainty here or to fix the slicers to handle data without uncertainty. If we keep the current fix, then please make sure that all sasdata 2D loaders define err_data = 1 for all datasets which do not otherwise define uncertainty. |
Description
Trying to average a residual plot using slicers would throw errors. This is because slicers expect an
err_dataarray, which is set toNonefor residuals.This PR fixes that by adding a dummy
err_dataof ones for residual plots.Fixes #3765
How Has This Been Tested?
Manually tested by attempting to reproduce the issue.
Review Checklist:
Documentation
Installers
Licensing