Files
aare/python/aare/calibration.py
Erik Fröjdh abae2674a9 Apply calibration to Jungfrau raw data (#216)
- Added function to read calibration file
- Multi threaded pedestal subtraction and application of the calibration
2025-07-18 10:19:14 +02:00

21 lines
602 B
Python

#Calibration related functions
import numpy as np
def load_calibration(fname, hg0=False):
"""
Load calibration data from a file.
Parameters:
fname (str): Path to the calibration file.
hg0 (bool): If True, load HG0 calibration data instead of G0.
"""
gains = 3
rows = 512
cols = 1024
with open(fname, 'rb') as f:
cal = np.fromfile(f, count=gains * rows * cols, dtype=np.double).reshape(
gains, rows, cols
)
if hg0:
cal[0] = np.fromfile(f, count=rows * cols, dtype=np.double).reshape(rows, cols)
return cal