Skip to content

Commit

Permalink
don't compute if no pinhole
Browse files Browse the repository at this point in the history
  • Loading branch information
saransh13 committed Oct 15, 2024
1 parent 45847c9 commit 54a4b03
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions hexrd/instrument/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1745,22 +1745,28 @@ def calc_transmission_window(self, secb: np.array, energy: np.floating,
def calc_effective_pinhole_area(self, physics_package: AbstractPhysicsPackage) -> np.array:
"""get the effective pinhole area correction
"""
hod = (physics_package.pinhole_thickness /
physics_package.pinhole_diameter)
bvec = self.bvec
effective_pinhole_area = np.ones(self.shape)

tth, eta = self.pixel_angles()
angs = np.vstack((tth.flatten(), eta.flatten(),
np.zeros(tth.flatten().shape))).T
dvecs = angles_to_dvec(angs, beam_vec=bvec)
if (physics_package.pinhole_diameter !=0.
and physics_package.pinhole_thickness != 0.):

hod = (physics_package.pinhole_thickness /
physics_package.pinhole_diameter)
bvec = self.bvec

tth, eta = self.pixel_angles()
angs = np.vstack((tth.flatten(), eta.flatten(),
np.zeros(tth.flatten().shape))).T
dvecs = angles_to_dvec(angs, beam_vec=bvec)

cth = -dvecs[:,2].reshape(self.shape)
tanth = np.tan(np.arccos(cth))
f = hod*tanth
f[np.abs(f) > 1.] = np.nan
asinf = np.arcsin(f)
effective_pinhole_area = (
(2/np.pi) * cth * (np.pi/2 - asinf - f*np.cos(asinf)))

cth = -dvecs[:,2].reshape(self.shape)
tanth = np.tan(np.arccos(cth))
f = hod*tanth
f[np.abs(f) > 1.] = np.nan
asinf = np.arcsin(f)
effective_pinhole_area = (
(2/np.pi) * cth * (np.pi/2 - asinf - f*np.cos(asinf)))
return effective_pinhole_area

def calc_transmission_generic(self,
Expand Down

0 comments on commit 54a4b03

Please sign in to comment.