File: test_pytte.py

package info (click to toggle)
python-xrt 1.6.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 17,572 kB
  • sloc: python: 59,424; xml: 4,786; lisp: 4,082; sh: 22; javascript: 18; makefile: 17
file content (49 lines) | stat: -rw-r--r-- 1,973 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import numpy as np
import os, sys; sys.path.append(os.path.join('..', '..'))  # analysis:ignore
import xrt.backends.raycing.materials as rm
import xrt.backends.raycing as raycing
from xrt.backends.raycing.pyTTE_x import TTcrystal, TTscan, Quantity
from xrt.backends.raycing.pyTTE_x.pyTTE_rkpy import TakagiTaupin 
from matplotlib import pyplot as plt

thickness=0.3
#geometry = 'Laue reflected'  # for xrt. pytte will return transmitted as well
geometry = 'Bragg reflected'  # for xrt. pytte will return transmitted as well
#crystal = rm.CrystalSi(hkl=[1,1,1], geom=geometry)
crystal = rm.CrystalSi(hkl=[10,10,0], geom=geometry)
Rcurv = 2e4
alpha=np.radians(0.0)
E=[19728]
dtheta=np.linspace(-50, 10, 300)*1e-6

geotag = 0 if geometry.startswith('B') else np.pi*0.5

ttx = TTcrystal(crystal = 'Si', hkl=crystal.hkl, thickness = Quantity(thickness*1e3,'um'), 
                debye_waller = 1, xrt_crystal=crystal, Rx=Quantity(Rcurv, 'mm'),
                asymmetry = Quantity(alpha+geotag, 'rad'))
tts = TTscan(constant=Quantity(E[0],'eV'),
             scan=Quantity(dtheta, 'rad'),
             polarization='sigma')
#            ttp = TTscan(constant=Quantity(E[0],'eV'),
#                         scan=Quantity(theta-thetaCenter, 'rad'),
#                         polarization='pi')

scan_tt_s=TakagiTaupin(ttx, tts)
#            scan_tt_p=TakagiTaupin(ttx, ttp)        

if __name__ == '__main__':
    scan_vector, R, T, curSD = scan_tt_s.run()
#    print(curSD.shape)

#    dtheta = np.linspace(-5, 10, 501)
    theta = crystal.get_Bragg_angle(E[0]) + dtheta
    curS, curP = crystal.get_amplitude(E[0], np.sin(theta))
    
    plt.figure("reflectivity")
    plt.plot(np.degrees(dtheta)*3600, R, label='Reflectivity pytte')
    plt.plot(np.degrees(dtheta)*3600, abs(curS)**2, label='Reflectivity xrt plain')
    plt.legend()
    
    plt.figure("transmittivity")
    plt.plot(np.degrees(dtheta)*3600, T)
    plt.show()