Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't compute correction if no pinhole. #725

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 32 additions & 23 deletions hexrd/instrument/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def beam_position(self):
"""
raise NotImplementedError


@property
def extra_config_kwargs(self):
return {}
Expand Down Expand Up @@ -289,7 +288,8 @@ def __init__(
self.group = group

if detector_filter is None:
detector_filter = detector_coatings.Filter(**FILTER_DEFAULTS.TARDIS)
detector_filter = detector_coatings.Filter(
**FILTER_DEFAULTS.TARDIS)
self.filter = detector_filter

if detector_coating is None:
Expand Down Expand Up @@ -1709,7 +1709,7 @@ def calc_physics_package_transmission(self, energy: np.floating,
need to consider HED and HEDM samples separately
"""
bvec = self.bvec
sample_normal = np.dot(rMat_s, [0.,0.,-1.])
sample_normal = np.dot(rMat_s, [0., 0., -1.])
seca = 1./np.dot(bvec, sample_normal)

tth, eta = self.pixel_angles()
Expand All @@ -1720,7 +1720,8 @@ def calc_physics_package_transmission(self, energy: np.floating,

secb = np.abs(1./np.dot(dvecs, sample_normal).reshape(self.shape))

T_sample = self.calc_transmission_sample(seca, secb, energy, physics_package)
T_sample = self.calc_transmission_sample(
seca, secb, energy, physics_package)
T_window = self.calc_transmission_window(secb, energy, physics_package)

transmission_physics_package = T_sample * T_window
Expand All @@ -1729,45 +1730,53 @@ def calc_physics_package_transmission(self, energy: np.floating,
def calc_transmission_sample(self, seca: np.array,
secb: np.array, energy: np.floating,
physics_package: AbstractPhysicsPackage) -> np.array:
thickness_s = physics_package.sample_thickness # in microns
mu_s = 1./physics_package.sample_absorption_length(energy) # in microns^-1
thickness_s = physics_package.sample_thickness # in microns
# in microns^-1
mu_s = 1./physics_package.sample_absorption_length(energy)
x = (mu_s*thickness_s)
pre = 1./x/(secb - seca)
num = np.exp(-x*seca) - np.exp(-x*secb)
return pre * num

def calc_transmission_window(self, secb: np.array, energy: np.floating,
physics_package: AbstractPhysicsPackage) -> np.array:
thickness_w = physics_package.window_thickness # in microns
mu_w = 1./physics_package.window_absorption_length(energy) # in microns^-1
thickness_w = physics_package.window_thickness # in microns
# in microns^-1
mu_w = 1./physics_package.window_absorption_length(energy)
return np.exp(-thickness_w*mu_w*secb)

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.):
saransh13 marked this conversation as resolved.
Show resolved Hide resolved

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,
secb: np.array,
thickness: np.floating,
absorption_length: np.floating) -> np.array:
mu = 1./absorption_length # in microns^-1
mu = 1./absorption_length # in microns^-1
return np.exp(-thickness*mu*secb)

def calc_transmission_phosphor(self,
Expand Down
Loading