Skip to content

Commit 480bfa3

Browse files
authored
Merge pull request #2380 from EdgarGF93/grazingincidence_exitangles
Support for grazing-incidence exit angles and polar angle
2 parents eaf5e67 + ae489ed commit 480bfa3

File tree

3 files changed

+371
-34
lines changed

3 files changed

+371
-34
lines changed

sandbox/test_gi_different_units.py

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
from pyFAI.gui.jupyter import plot1d, plot2d, subplots
2+
import matplotlib.pyplot as plt
3+
from pyFAI.test.utilstest import UtilsTest
4+
from pyFAI import load
5+
import fabio
6+
from pyFAI import detector_factory
7+
from pyFAI.calibrant import get_calibrant
8+
from pyFAI.integrator.fiber import FiberIntegrator
9+
10+
if __name__ == "__main__":
11+
12+
13+
# EXAMPLE WITH CLASSIC QIP-QOOP NM^-1
14+
fi = load(UtilsTest.getimage("LaB6_3.poni"), type_="pyFAI.integrator.fiber.FiberIntegrator")
15+
data = fabio.open(UtilsTest.getimage("Y6.edf")).data
16+
air = fabio.open(UtilsTest.getimage("air.edf")).data
17+
data_clean = data - 0.03 * air
18+
sample_orientation = 6
19+
20+
res2d_0 = fi.integrate2d_grazing_incidence(data=data_clean, sample_orientation=sample_orientation,
21+
)
22+
23+
res2d_patch_1 = fi.integrate2d_grazing_incidence(data=data_clean, sample_orientation=sample_orientation,
24+
ip_range=[-1,1], oop_range=[0,20],
25+
)
26+
res2d_patch_2 = fi.integrate2d_grazing_incidence(data=data_clean, sample_orientation=sample_orientation,
27+
ip_range=[-17.5,17.5], oop_range=[5,6.5],
28+
)
29+
30+
31+
res1d_0 = fi.integrate1d_grazing_incidence(data=data_clean, sample_orientation=sample_orientation,
32+
ip_range=[-1,1], oop_range=[0,20],
33+
npt_ip=100, npt_oop=500,
34+
vertical_integration=True,
35+
)
36+
res1d_1 = fi.integrate1d_grazing_incidence(data=data_clean, sample_orientation=sample_orientation,
37+
ip_range=[-17.5,17.5], oop_range=[5,6.5],
38+
npt_ip=500, npt_oop=100,
39+
vertical_integration=False,
40+
)
41+
42+
fig, ax = subplots(nrows=4, ncols=4)
43+
plot2d(result=res2d_0, ax=ax[0,0])
44+
img = ax[0,0].get_images()[0]
45+
img.set_cmap("viridis")
46+
img.set_clim(20,200)
47+
48+
plot2d(result=res2d_patch_1, ax=ax[0,1])
49+
plot2d(result=res2d_patch_2, ax=ax[0,1])
50+
plot2d(result=res2d_0, ax=ax[0,1])
51+
52+
ax[0,1].get_images()[0].set_cmap("viridis")
53+
ax[0,1].get_images()[1].set_cmap("viridis")
54+
ax[0,1].get_images()[2].set_cmap("gray")
55+
ax[0,1].get_images()[2].set_alpha(0.5)
56+
57+
plot1d(result=res1d_0, ax=ax[0,2])
58+
plot1d(result=res1d_1, ax=ax[0,3])
59+
60+
61+
62+
# EXAMPLE WITH POLAR UNITS RAD
63+
det = detector_factory("Eiger_4M")
64+
cal = get_calibrant("LaB6")
65+
fi = FiberIntegrator(detector=det, wavelength=1e-10, dist=0.1, poni1=0.05, poni2=0.05)
66+
data = cal.fake_calibration_image(ai=fi) * 1000 + 100
67+
68+
sample_orientation = 1
69+
70+
res2d= fi.integrate2d_grazing_incidence(data=data, sample_orientation=sample_orientation,
71+
)
72+
73+
res2d_polar = fi.integrate2d_grazing_incidence(data=data, sample_orientation=sample_orientation,
74+
unit_ip="qtot_nm^-1", unit_oop="chigi_rad",
75+
)
76+
res1d_0 = fi.integrate1d_grazing_incidence(data=data, sample_orientation=sample_orientation,
77+
unit_ip="qtot_nm^-1", unit_oop="chigi_rad",
78+
ip_range=[0,40], oop_range=[-0.2,0.2],
79+
npt_ip=1000, npt_oop=500,
80+
vertical_integration=False,
81+
)
82+
83+
res2d_patch = fi.integrate2d_grazing_incidence(data=data, sample_orientation=sample_orientation,
84+
unit_ip="qtot_nm^-1", unit_oop="chigi_rad",
85+
ip_range=[0,40], oop_range=[-0.2,0.2],
86+
)
87+
88+
plot2d(result=res2d, ax=ax[1,0])
89+
plot2d(result=res2d_polar, ax=ax[1,1])
90+
plot2d(result=res2d_patch, ax=ax[1,2])
91+
plot2d(result=res2d_polar, ax=ax[1,2])
92+
93+
img = ax[1,0].get_images()[0]
94+
img.set_cmap("viridis")
95+
img = ax[1,1].get_images()[0]
96+
img.set_cmap("viridis")
97+
98+
ax[1,2].get_images()[0].set_cmap("viridis")
99+
ax[1,2].get_images()[1].set_cmap("gray")
100+
ax[1,2].get_images()[1].set_alpha(0.5)
101+
plot1d(result=res1d_0, ax=ax[1,3])
102+
103+
104+
105+
# EXAMPLE WITH POLAR UNITS DEG-QA-1
106+
det = detector_factory("Eiger_4M")
107+
cal = get_calibrant("LaB6")
108+
fi = FiberIntegrator(detector=det, wavelength=1e-10, dist=0.1, poni1=0.05, poni2=0.05)
109+
data = cal.fake_calibration_image(ai=fi) * 1000 + 100
110+
111+
sample_orientation = 1
112+
113+
res2d= fi.integrate2d_grazing_incidence(data=data, sample_orientation=sample_orientation,
114+
)
115+
116+
res2d_polar = fi.integrate2d_grazing_incidence(data=data, sample_orientation=sample_orientation,
117+
unit_ip="qtot_A^-1", unit_oop="chigi_deg",
118+
)
119+
res1d_0 = fi.integrate1d_grazing_incidence(data=data, sample_orientation=sample_orientation,
120+
unit_ip="qtot_A^-1", unit_oop="chigi_deg",
121+
ip_range=[0,4], oop_range=[-10,10],
122+
npt_ip=1000, npt_oop=500,
123+
vertical_integration=False,
124+
)
125+
126+
res2d_patch = fi.integrate2d_grazing_incidence(data=data, sample_orientation=sample_orientation,
127+
unit_ip="qtot_A^-1", unit_oop="chigi_deg",
128+
ip_range=[0,4], oop_range=[-10,10],
129+
)
130+
131+
plot2d(result=res2d, ax=ax[2,0])
132+
plot2d(result=res2d_polar, ax=ax[2,1])
133+
plot2d(result=res2d_patch, ax=ax[2,2])
134+
plot2d(result=res2d_polar, ax=ax[2,2])
135+
136+
img = ax[2,0].get_images()[0]
137+
img.set_cmap("viridis")
138+
img = ax[2,1].get_images()[0]
139+
img.set_cmap("viridis")
140+
141+
ax[2,2].get_images()[0].set_cmap("viridis")
142+
ax[2,2].get_images()[1].set_cmap("gray")
143+
ax[2,2].get_images()[1].set_alpha(0.5)
144+
plot1d(result=res1d_0, ax=ax[2,3])
145+
146+
147+
148+
149+
# EXAMPLE WITH POLAR UNITS DEG-QA-1 NOW VERTICAL
150+
det = detector_factory("Eiger_4M")
151+
cal = get_calibrant("LaB6")
152+
fi = FiberIntegrator(detector=det, wavelength=1e-10, dist=0.1, poni1=0.05, poni2=0.05)
153+
data = cal.fake_calibration_image(ai=fi) * 1000 + 100
154+
155+
sample_orientation = 1
156+
157+
res2d= fi.integrate2d_grazing_incidence(data=data, sample_orientation=sample_orientation,
158+
)
159+
160+
res2d_polar = fi.integrate2d_grazing_incidence(data=data, sample_orientation=sample_orientation,
161+
unit_oop="qtot_A^-1", unit_ip="chigi_deg",
162+
)
163+
res1d_0 = fi.integrate1d_grazing_incidence(data=data, sample_orientation=sample_orientation,
164+
unit_oop="qtot_A^-1", unit_ip="chigi_deg",
165+
oop_range=[0,4], ip_range=[-10,10],
166+
npt_oop=1000, npt_ip=500,
167+
vertical_integration=True,
168+
)
169+
170+
res2d_patch = fi.integrate2d_grazing_incidence(data=data, sample_orientation=sample_orientation,
171+
unit_oop="qtot_A^-1", unit_ip="chigi_deg",
172+
oop_range=[0,4], ip_range=[-10,10],
173+
)
174+
175+
plot2d(result=res2d, ax=ax[3,0])
176+
plot2d(result=res2d_polar, ax=ax[3,1])
177+
plot2d(result=res2d_patch, ax=ax[3,2])
178+
plot2d(result=res2d_polar, ax=ax[3,2])
179+
180+
img = ax[3,0].get_images()[0]
181+
img.set_cmap("viridis")
182+
img = ax[3,1].get_images()[0]
183+
img.set_cmap("viridis")
184+
185+
ax[3,2].get_images()[0].set_cmap("viridis")
186+
ax[3,2].get_images()[1].set_cmap("gray")
187+
ax[3,2].get_images()[1].set_alpha(0.5)
188+
plot1d(result=res1d_0, ax=ax[3,3])
189+
190+
plt.show()

src/pyFAI/integrator/fiber.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def integrate_fiber(self, data,
276276
else:
277277
sum_variance = None
278278
sigma = None
279-
result = Integrate1dResult(res.azimuthal * unit_scale, intensity, sigma)
279+
result = Integrate1dResult(res.azimuthal, intensity, sigma)
280280
result._set_method_called("integrate_radial")
281281
result._set_unit(output_unit)
282282
result._set_sum_normalization(sum_normalization)

0 commit comments

Comments
 (0)