ticket-1094-headless
Last change
on this file since 9cc1f49 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 | """ |
---|
2 | This module is a small tool to allow user to quickly |
---|
3 | determine the size value in real space from the |
---|
4 | fringe width in q space. |
---|
5 | """ |
---|
6 | from math import pi, fabs |
---|
7 | _DQ_DEFAULT = 0.05 |
---|
8 | |
---|
9 | |
---|
10 | class 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.