SasView / sasview

Code for the SasView application.
BSD 3-Clause "New" or "Revised" License
52 stars 41 forks source link

Resolution smearing is only applied to positive Qx and Qy in 2D (Trac #1242) #1268

Closed smk78 closed 5 years ago

smk78 commented 5 years ago

User Bei Tian notes that in 2D fitting/calculation, instrument smearing is only applied to positive values of Qx and Qy.

Migrated from http://trac.sasview.org/ticket/1242

{
    "status": "new",
    "changetime": "2019-03-19T02:51:39",
    "_ts": "2019-03-19 02:51:39.607247+00:00",
    "description": "User Bei Tian notes that in 2D fitting/calculation, instrument smearing is only applied to positive values of Qx and Qy.",
    "reporter": "smk78",
    "cc": "",
    "resolution": "",
    "workpackage": "SasView Bug Fixing",
    "time": "2019-03-08T16:43:25",
    "component": "SasView",
    "summary": "Resolution smearing is only applied to positive Qx and Qy in 2D",
    "priority": "blocker",
    "keywords": "",
    "milestone": "SasView 4.2.2",
    "owner": "",
    "type": "defect"
}
smk78 commented 5 years ago

Trac update at 2019/03/08 16:44:01:

Screen shot from Bei

smk78 commented 5 years ago

Trac update at 2019/03/08 16:47:29: smk78 commented:

@pkienzle says:

Here's a quick fix.  A full solution involves thinking a lot more about what happens to 
pixels near the origin wrt phi in the polar representation.

diff --git a/src/sas/sasgui/perspectives/fitting/fitpage.py 
b/src/sas/sasgui/perspectives/fitting/fitpage.py
index f3baf06b9..ad82c3081 100644
--- a/src/sas/sasgui/perspectives/fitting/fitpage.py
+++ b/src/sas/sasgui/perspectives/fitting/fitpage.py
@@ -2364,8 +2364,8 @@ class FitPage(BasicPage):
            elif self.dx_percent is not None:
                percent = self.dx_percent/100
                if self._is_2D():
-                    data.dqx_data[data.dqx_data == 0] = percent * data.qx_data
-                    data.dqy_data[data.dqy_data == 0] = percent * data.qy_data
+                    q = np.sqrt(data.qx_data**2 + data.qy_data**2)
+                    data.dqx_data = data.dqy_data = percent*q                 else:
                    data.dx = percent * data.x
            self.current_smearer = smear_selection(data, self.model)
smk78 commented 5 years ago

Trac update at 2019/03/08 16:48:27: smk78 commented:

@pkienzle also says:

The code for generating resolution should not be in the GUI.  Put it in 
sascalc/fit/qsmearing.py or sasmodels/resolution2d.py so that the qt gui 
can use the same code.
pkienzle commented 5 years ago

Trac update at 2019/03/12 14:22:07: pkienzle commented:

A proper estimate of resolution requires too many details about the experiment configuration for the fitting panel. Could we perhaps attach it to the Q resolution estimator window that we already have?

Note: playing with resolution estimator, it seems to always give the same value for sigma x and sigma y even when the resolution is clearly an ellipse. That should be fixed before using the calculator elsewhere. Hammouda's online [https://www.ncnr.nist.gov/staff/hammouda/distance_learning/chapter_15.pdf SANS course] (ch 15, pg 9) has formulas for sigma x and sigma y.

pkienzle commented 5 years ago

Trac update at 2019/03/12 22:48:10: pkienzle commented:

Resolution calculator note turned into Ticket #1270.

butlerpd commented 5 years ago

Trac update at 2019/03/19 02:51:39: butler changed milestone from "SasView 4.3.0" to "SasView 4.2.2"