#1191 closed defect (obsolete)
Correct erroneous Scale reported by Spinodal model
Reported by: | smk78 | Owned by: | |
---|---|---|---|
Priority: | blocker | Milestone: | SasView 4.2.0 |
Component: | sasmodels | Keywords: | |
Cc: | Work Package: | SasView Bug Fixing |
Description
This ticket is being used to report changed (for the better!) behaviour in 4.2.0 that does not appear to have been previously ticketed or documented, so that the issue can be appropriately reported in future release notes, and to draw attention to the change.
This issue was verified in the presence of @richardh.
To reproduce the issue:
Load the attached data in 4.1.2, send it for fitting, select the spinodal model. Increase Qmin to 0.05. Select scale, background & q_0. Fit. Now repeat the fit in 4.2.0.
The Chi2/Npts, Npts(Fit), theory curve, residuals, and indeed the theory intensities reported by DataInfo, are all the same. As are the fitted background and q_0 parameters (and their uncertainties). But the scale (and scale uncertainty) values reported are DIFFERENT. However, simple visual inspection shows that it is 4.2.0 which is giving the correct scale.
Closer inspection shows that 4.1.2 is actually reporting the square root of the correct scale.
The underlying code did not change (apart from the inclusion of an inconsequential numpy import):
This is 4.1.2 from numpy import inf, errstate name = "spinodal" title = "Spinodal decomposition model" description = """\ I(q) = scale ((1+gamma/2)x^2)/(gamma/2+x^(2+gamma))+background List of default parameters: scale = scaling gamma = exponent x = q/q_0 q_0 = correlation peak position [1/A] background = Incoherent background""" category = "shape-independent" # pylint: disable=bad-whitespace, line-too-long # ["name", "units", default, [lower, upper], "type", "description"], parameters = [["scale", "", 1.0, [-inf, inf], "", "Scale factor"], ["gamma", "", 3.0, [-inf, inf], "", "Exponent"], ["q_0", "1/Ang", 0.1, [-inf, inf], "", "Correlation peak position"] ] # pylint: enable=bad-whitespace, line-too-long def Iq(q, scale=1.0, gamma=3.0, q_0=0.1): """ :param q: Input q-value :param scale: Scale factor :param gamma: Exponent :param q_0: Correlation peak position :return: Calculated intensity """ with errstate(divide='ignore'): x = q/q_0 inten = scale * ((1 + gamma / 2) * x ** 2) / (gamma / 2 + x ** (2 + gamma)) return inten Iq.vectorized = True # Iq accepts an array of q values
This is 4.2.0 import numpy as np from numpy import inf, errstate name = "spinodal" title = "Spinodal decomposition model" description = """\ I(q) = Imax ((1+gamma/2)x^2)/(gamma/2+x^(2+gamma)) + background List of default parameters: Imax = correlation peak intensity at q_0 background = incoherent background gamma = exponent (see model documentation) q_0 = correlation peak position [1/A] x = q/q_0""" category = "shape-independent" # pylint: disable=bad-whitespace, line-too-long # ["name", "units", default, [lower, upper], "type", "description"], parameters = [["gamma", "", 3.0, [-inf, inf], "", "Exponent"], ["q_0", "1/Ang", 0.1, [-inf, inf], "", "Correlation peak position"] ] # pylint: enable=bad-whitespace, line-too-long def Iq(q, gamma=3.0, q_0=0.1): """ :param q: Input q-value :param gamma: Exponent :param q_0: Correlation peak position :return: Calculated intensity """ with errstate(divide='ignore'): x = q/q_0 inten = ((1 + gamma / 2) * x ** 2) / (gamma / 2 + x ** (2 + gamma)) return inten Iq.vectorized = True # Iq accepts an array of q values
@richardh theorised that this might have something to do with the spinodal model being a non-SLD model, so we also tested the behaviour of the gaussian_peak model. The scale values from that reported by 4.1.2 and 4.2.0 were the same.
Does anyone remember making a change elsewhere that might account for this issue?
Attachments (2)
Change History (5)
Changed 2 months ago by smk78
comment:1 Changed 2 months ago by smk78
- Resolution set to obsolete
- Status changed from new to closed
comment:2 Changed 2 months ago by smk78
The spinodal model was first added in 4.1.0. See #723.
Thus versions (tested as being) affected are 4.1.0, 4.1.1, and 4.1.2.
Release notes in (post-4.2.0 release) master have been updated.
Dataset for testing spinodal model