Skip to content

Commit

Permalink
Update livetime correction
Browse files Browse the repository at this point in the history
  • Loading branch information
samaloney committed Apr 29, 2024
1 parent d72c4c1 commit b376ab4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
33 changes: 28 additions & 5 deletions stixpy/calibration/livetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,35 @@
import astropy.units as u
import numpy as np

__all__ = ["get_livetime_fraction"]
__all__ = ["pileup_correction_factor", "get_livetime_fraction"]

from stixpy.io.readers import read_subc_params

def get_livetime_fraction(trigger_rate, *, eta=2.63 * u.us, tau=10.1 * u.us):

def pileup_correction_factor():
r"""
Estimate the fractional area of a single large pixel compared with the rest of the detector group.
This is used in estimating the probability that when two photons are detected in the same group if
the first hits a given large pixel that the second hits a different pixel resulting in anti-coincidence rejection.
Otherwise if both hit the same pixel pileup will occur.
Notes
-----
This assumes uniform illumination over the detector pair
This ignores the possibility of the first hit being a small pixel
"""

subc_str = read_subc_params()
large_pixel_area = (subc_str['L Pixel Xsize'] * subc_str['L Pixel Ysize'])[0]
detector_area = (subc_str['Detect Xsize'] * subc_str['Detect Xsize'])[0]
big_pixel_fraction = large_pixel_area/detector_area
prob_diff_pix = (2./big_pixel_fraction - 1.)/(2./big_pixel_fraction)

return prob_diff_pix


def get_livetime_fraction(trigger_rate, *, eta=1.10 * u.us, tau=10.1 * u.us):
"""
Return the live time fraction for the given trigger rate.
Expand All @@ -83,9 +108,7 @@ def get_livetime_fraction(trigger_rate, *, eta=2.63 * u.us, tau=10.1 * u.us):
`float`, `float`, `float`:
The live time fraction
"""

# TODO implement full calculation code this values was taken from IDL
beta = 0.94059104
beta = pileup_correction_factor()

photons_in = trigger_rate / (1.0 - trigger_rate * (tau + eta))
livetime_fraction = 1 / (1.0 + (tau + eta) * photons_in)
Expand Down
7 changes: 6 additions & 1 deletion stixpy/calibration/tests/test_livetime.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import numpy as np

from stixpy.calibration.livetime import get_livetime_fraction
from stixpy.calibration.livetime import get_livetime_fraction, pileup_correction_factor


def test_pileup_correction_factor():
pileup_factor = pileup_correction_factor()
assert pileup_factor == 0.9346590909090909


def test_get_livetime():
Expand Down

0 comments on commit b376ab4

Please sign in to comment.