source: sasview/src/sas/sascalc/calculator/kiessig_calculator.py @ d04ac05

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalcmagnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since d04ac05 was 235f514, checked in by andyfaff, 8 years ago

MAINT: replace '== None' by 'is None'

  • Property mode set to 100644
File size: 1.4 KB
Line 
1"""
2This module is a small tool to allow user to quickly
3determine the size value in real space  from the
4fringe width in q space.
5"""
6from math import pi, fabs
7_DQ_DEFAULT = 0.05
8
9
10class KiessigThicknessCalculator(object):
11    """
12    compute thickness from the fringe width of data
13    """
14    def __init__(self):
15
16        # dq value
17        self.deltaq = _DQ_DEFAULT
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
30        self.deltaq = dq
31
32    def get_deltaq(self):
33        """
34        return deltaQ value in 1/A unit
35        """
36        # return dq
37        return self.deltaq
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 is None:
52            return None
53        else:
54            # calculate thickness
55            thickness = 2*pi/fabs(dq)
56            # return thickness value
57            return thickness
58
59    def get_thickness_unit(self):
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.