source: sasview/src/sas/calculator/kiessig_calculator.py @ 573e7034

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 573e7034 was 79492222, checked in by krzywon, 10 years ago

Changed the file and folder names to remove all SANS references.

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[96c0234]1"""
2This module is a small tool to allow user to quickly
[8a621ac]3determine the size value in real space  from the
[96c0234]4fringe width in q space.
5"""
6from math import pi, fabs
7_DQ_DEFAULT = 0.05
[8a621ac]8
9
[96c0234]10class KiessigThicknessCalculator(object):
11    """
12    compute thickness from the fringe width of data
13    """
14    def __init__(self):
15       
16        # dq value
[8a621ac]17        self.deltaq = _DQ_DEFAULT
[96c0234]18        # thickenss value
19        self.thickness = None
20        # unit of the thickness
21        self.thickness_unit = 'A'
22       
23    def set_deltaq(self, dq=None):
24        """
25        Receive deltaQ value
26       
27        :param dq: q fringe width in 1/A unit
28        """
29        # set dq
[8a621ac]30        self.deltaq = dq
[96c0234]31       
32    def get_deltaq(self):
33        """
34        return deltaQ value in 1/A unit
35        """
36        # return dq
[8a621ac]37        return self.deltaq
[96c0234]38
39    def compute_thickness(self):
40        """
41        Calculate thickness.
42       
43        :return: the thickness.
44        """
45        # check if it is float
46        try:
47            dq = float(self.deltaq)
48        except:
49            return None
50        # check if delta_q is zero
51        if dq == 0.0 or dq == None:
52            return None
53        else:
54            # calculate thickness
[8a621ac]55            thickness = 2*pi/fabs(dq)
56            # return thickness value
[96c0234]57            return thickness
58 
[8a621ac]59    def get_thickness_unit(self):
[96c0234]60        """
61        :return: the thickness unit.
62        """
63        # unit of thickness
64        return self.thickness_unit
Note: See TracBrowser for help on using the repository browser.