Skip to content

Commit e980155

Browse files
committed
return all ones when pinhole has 0 thickness or diamter
1 parent 785431e commit e980155

File tree

1 file changed

+38
-28
lines changed

1 file changed

+38
-28
lines changed

hexrd/core/instrument/detector.py

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,35 +2061,45 @@ def calc_effective_pinhole_area(self, physics_package: AbstractPhysicsPackage) -
20612061
CeO2 data recorded on NIF. An extra factor of sec(beta)
20622062
was included as compared to RSI 91, 043902 (2020).
20632063
'''
2064-
hod = (
2065-
physics_package.pinhole_thickness /
2066-
physics_package.pinhole_diameter
2067-
)
2064+
if (
2065+
np.isclose(
2066+
physics_package.pinhole_thickness,
2067+
0.0) or
2068+
np.isclose(
2069+
physics_package.pinhole_diameter,
2070+
0.0)):
2071+
return np.ones(self.shape)
20682072

2069-
'''we compute the beta angle using existing
2070-
functions by just changing beam vector
2071-
to be the z-axis with the right sign.
2072-
'''
2073-
bvec = np.array([0., 0., np.sign(self.bvec[2])])
2074-
beta, eta = self.pixel_angles(bvec=bvec)
2075-
2076-
tb = np.tan(beta)
2077-
jb = hod*tb
2078-
jb[jb > 1] = np.nan
2079-
jb2 = jb**2
2080-
mask = np.isclose(jb2, 0.)
2081-
2082-
f1 = np.zeros_like(jb)
2083-
f3 = 1/jb2[~mask] - 1
2084-
f3[f3<0.] = np.nan
2085-
f1[~mask] = np.arctan(np.sqrt(f3))
2086-
f1[mask] = np.pi/2
2087-
2088-
f3 = 1 - jb2
2089-
f3[f3<0.] = np.nan
2090-
f2 = jb*np.sqrt(f3)
2091-
2092-
return 0.5*(f1 - f2)
2073+
else:
2074+
hod = (
2075+
physics_package.pinhole_thickness /
2076+
physics_package.pinhole_diameter
2077+
)
2078+
2079+
'''we compute the beta angle using existing
2080+
functions by just changing beam vector
2081+
to be the z-axis with the right sign.
2082+
'''
2083+
bvec = np.array([0., 0., np.sign(self.bvec[2])])
2084+
beta, eta = self.pixel_angles(bvec=bvec)
2085+
2086+
tb = np.tan(beta)
2087+
jb = hod*tb
2088+
jb[jb > 1] = np.nan
2089+
jb2 = jb**2
2090+
mask = np.isclose(jb2, 0.)
2091+
2092+
f1 = np.zeros_like(jb)
2093+
f3 = 1/jb2[~mask] - 1
2094+
f3[f3<0.] = np.nan
2095+
f1[~mask] = np.arctan(np.sqrt(f3))
2096+
f1[mask] = np.pi/2
2097+
2098+
f3 = 1 - jb2
2099+
f3[f3<0.] = np.nan
2100+
f2 = jb*np.sqrt(f3)
2101+
2102+
return 0.5*(f1 - f2)
20932103

20942104
def calc_transmission_generic(
20952105
self,

0 commit comments

Comments
 (0)