88from pyFAI .integrator .fiber import FiberIntegrator
99
1010if __name__ == "__main__" :
11-
12-
11+
12+
1313 # EXAMPLE WITH CLASSIC QIP-QOOP NM^-1
1414 fi = load (UtilsTest .getimage ("LaB6_3.poni" ), type_ = "pyFAI.integrator.fiber.FiberIntegrator" )
1515 data = fabio .open (UtilsTest .getimage ("Y6.edf" )).data
1616 air = fabio .open (UtilsTest .getimage ("air.edf" )).data
1717 data_clean = data - 0.03 * air
1818 sample_orientation = 6
19-
19+
2020 res2d_0 = fi .integrate2d_grazing_incidence (data = data_clean , sample_orientation = sample_orientation ,
2121 )
22-
22+
2323 res2d_patch_1 = fi .integrate2d_grazing_incidence (data = data_clean , sample_orientation = sample_orientation ,
2424 ip_range = [- 1 ,1 ], oop_range = [0 ,20 ],
2525 )
2626 res2d_patch_2 = fi .integrate2d_grazing_incidence (data = data_clean , sample_orientation = sample_orientation ,
2727 ip_range = [- 17.5 ,17.5 ], oop_range = [5 ,6.5 ],
2828 )
29-
30-
29+
30+
3131 res1d_0 = fi .integrate1d_grazing_incidence (data = data_clean , sample_orientation = sample_orientation ,
3232 ip_range = [- 1 ,1 ], oop_range = [0 ,20 ],
3333 npt_ip = 100 , npt_oop = 500 ,
3737 ip_range = [- 17.5 ,17.5 ], oop_range = [5 ,6.5 ],
3838 npt_ip = 500 , npt_oop = 100 ,
3939 vertical_integration = False ,
40- )
41-
40+ )
41+
4242 fig , ax = subplots (nrows = 4 , ncols = 4 )
4343 plot2d (result = res2d_0 , ax = ax [0 ,0 ])
4444 img = ax [0 ,0 ].get_images ()[0 ]
4545 img .set_cmap ("viridis" )
4646 img .set_clim (20 ,200 )
47-
47+
4848 plot2d (result = res2d_patch_1 , ax = ax [0 ,1 ])
4949 plot2d (result = res2d_patch_2 , ax = ax [0 ,1 ])
5050 plot2d (result = res2d_0 , ax = ax [0 ,1 ])
51-
51+
5252 ax [0 ,1 ].get_images ()[0 ].set_cmap ("viridis" )
5353 ax [0 ,1 ].get_images ()[1 ].set_cmap ("viridis" )
5454 ax [0 ,1 ].get_images ()[2 ].set_cmap ("gray" )
5555 ax [0 ,1 ].get_images ()[2 ].set_alpha (0.5 )
56-
56+
5757 plot1d (result = res1d_0 , ax = ax [0 ,2 ])
5858 plot1d (result = res1d_1 , ax = ax [0 ,3 ])
59-
60-
61-
59+
60+
61+
6262 # EXAMPLE WITH POLAR UNITS RAD
6363 det = detector_factory ("Eiger_4M" )
6464 cal = get_calibrant ("LaB6" )
6565 fi = FiberIntegrator (detector = det , wavelength = 1e-10 , dist = 0.1 , poni1 = 0.05 , poni2 = 0.05 )
6666 data = cal .fake_calibration_image (ai = fi ) * 1000 + 100
67-
67+
6868 sample_orientation = 1
69-
69+
7070 res2d = fi .integrate2d_grazing_incidence (data = data , sample_orientation = sample_orientation ,
7171 )
72-
72+
7373 res2d_polar = fi .integrate2d_grazing_incidence (data = data , sample_orientation = sample_orientation ,
7474 unit_ip = "qtot_nm^-1" , unit_oop = "chigi_rad" ,
7575 )
8484 unit_ip = "qtot_nm^-1" , unit_oop = "chigi_rad" ,
8585 ip_range = [0 ,40 ], oop_range = [- 0.2 ,0.2 ],
8686 )
87-
87+
8888 plot2d (result = res2d , ax = ax [1 ,0 ])
8989 plot2d (result = res2d_polar , ax = ax [1 ,1 ])
9090 plot2d (result = res2d_patch , ax = ax [1 ,2 ])
9191 plot2d (result = res2d_polar , ax = ax [1 ,2 ])
92-
92+
9393 img = ax [1 ,0 ].get_images ()[0 ]
9494 img .set_cmap ("viridis" )
9595 img = ax [1 ,1 ].get_images ()[0 ]
9696 img .set_cmap ("viridis" )
97-
97+
9898 ax [1 ,2 ].get_images ()[0 ].set_cmap ("viridis" )
9999 ax [1 ,2 ].get_images ()[1 ].set_cmap ("gray" )
100100 ax [1 ,2 ].get_images ()[1 ].set_alpha (0.5 )
101101 plot1d (result = res1d_0 , ax = ax [1 ,3 ])
102-
103-
104-
102+
103+
104+
105105 # EXAMPLE WITH POLAR UNITS DEG-QA-1
106106 det = detector_factory ("Eiger_4M" )
107107 cal = get_calibrant ("LaB6" )
108108 fi = FiberIntegrator (detector = det , wavelength = 1e-10 , dist = 0.1 , poni1 = 0.05 , poni2 = 0.05 )
109109 data = cal .fake_calibration_image (ai = fi ) * 1000 + 100
110-
110+
111111 sample_orientation = 1
112-
112+
113113 res2d = fi .integrate2d_grazing_incidence (data = data , sample_orientation = sample_orientation ,
114114 )
115-
115+
116116 res2d_polar = fi .integrate2d_grazing_incidence (data = data , sample_orientation = sample_orientation ,
117117 unit_ip = "qtot_A^-1" , unit_oop = "chigi_deg" ,
118118 )
127127 unit_ip = "qtot_A^-1" , unit_oop = "chigi_deg" ,
128128 ip_range = [0 ,4 ], oop_range = [- 10 ,10 ],
129129 )
130-
130+
131131 plot2d (result = res2d , ax = ax [2 ,0 ])
132132 plot2d (result = res2d_polar , ax = ax [2 ,1 ])
133133 plot2d (result = res2d_patch , ax = ax [2 ,2 ])
134134 plot2d (result = res2d_polar , ax = ax [2 ,2 ])
135-
135+
136136 img = ax [2 ,0 ].get_images ()[0 ]
137137 img .set_cmap ("viridis" )
138138 img = ax [2 ,1 ].get_images ()[0 ]
139139 img .set_cmap ("viridis" )
140-
140+
141141 ax [2 ,2 ].get_images ()[0 ].set_cmap ("viridis" )
142142 ax [2 ,2 ].get_images ()[1 ].set_cmap ("gray" )
143143 ax [2 ,2 ].get_images ()[1 ].set_alpha (0.5 )
144144 plot1d (result = res1d_0 , ax = ax [2 ,3 ])
145-
146-
147-
148-
145+
146+
147+
148+
149149 # EXAMPLE WITH POLAR UNITS DEG-QA-1 NOW VERTICAL
150150 det = detector_factory ("Eiger_4M" )
151151 cal = get_calibrant ("LaB6" )
152152 fi = FiberIntegrator (detector = det , wavelength = 1e-10 , dist = 0.1 , poni1 = 0.05 , poni2 = 0.05 )
153153 data = cal .fake_calibration_image (ai = fi ) * 1000 + 100
154-
154+
155155 sample_orientation = 1
156-
156+
157157 res2d = fi .integrate2d_grazing_incidence (data = data , sample_orientation = sample_orientation ,
158158 )
159-
159+
160160 res2d_polar = fi .integrate2d_grazing_incidence (data = data , sample_orientation = sample_orientation ,
161161 unit_oop = "qtot_A^-1" , unit_ip = "chigi_deg" ,
162162 )
171171 unit_oop = "qtot_A^-1" , unit_ip = "chigi_deg" ,
172172 oop_range = [0 ,4 ], ip_range = [- 10 ,10 ],
173173 )
174-
174+
175175 plot2d (result = res2d , ax = ax [3 ,0 ])
176176 plot2d (result = res2d_polar , ax = ax [3 ,1 ])
177177 plot2d (result = res2d_patch , ax = ax [3 ,2 ])
178178 plot2d (result = res2d_polar , ax = ax [3 ,2 ])
179-
179+
180180 img = ax [3 ,0 ].get_images ()[0 ]
181181 img .set_cmap ("viridis" )
182182 img = ax [3 ,1 ].get_images ()[0 ]
183183 img .set_cmap ("viridis" )
184-
184+
185185 ax [3 ,2 ].get_images ()[0 ].set_cmap ("viridis" )
186186 ax [3 ,2 ].get_images ()[1 ].set_cmap ("gray" )
187187 ax [3 ,2 ].get_images ()[1 ].set_alpha (0.5 )
188188 plot1d (result = res1d_0 , ax = ax [3 ,3 ])
189-
190- plt .show ()
189+
190+ plt .show ()
0 commit comments