Calibration

Functions for applying calibration to data.

import aare

# Load calibration data for a single JF module (512x1024 pixels)
calibration = aare.load_calibration('path/to/calibration/file.bin')

raw_data = ...  # Load your raw data here
pedestal = ...  # Load your pedestal data here

# Apply calibration to raw data to convert from raw ADC values to keV
data = aare.apply_calibration(raw_data, pd=pedestal, cal=calibration)

# If you pass a 2D pedestal and calibration only G0 will be used for the conversion
# Pixels that switched to G1 or G2 will be set to 0
data = aare.apply_calibration(raw_data, pd=pedestal[0], cal=calibration[0])
aare.apply_calibration(*args, **kwargs)

Overloaded function.

  1. apply_calibration(raw_data: numpy.ndarray[numpy.uint16], *, pd: numpy.ndarray[numpy.float64], cal: numpy.ndarray[numpy.float64], n_threads: int = 4) -> numpy.ndarray[numpy.float64]

  2. apply_calibration(raw_data: numpy.ndarray[numpy.uint16], *, pd: numpy.ndarray[numpy.float32], cal: numpy.ndarray[numpy.float32], n_threads: int = 4) -> numpy.ndarray[numpy.float32]

aare.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.

aare.calculate_pedestal(raw_data: numpy.ndarray[numpy.uint16], n_threads: int = 4) numpy.ndarray[numpy.float64]

Calculate the pedestal for all three gains and return the result as a 3D array of doubles.

Parameters:
  • raw_data (array_like) – 3D array of shape (frames, rows, cols) to calculate the pedestal from. Needs to contain data for all three gains (G0, G1, G2).

  • n_threads (int) – The number of threads to use for the calculation.

aare.calculate_pedestal_float(raw_data: numpy.ndarray[numpy.uint16], n_threads: int = 4) numpy.ndarray[numpy.float32]

Same as calculate_pedestal but returns a 3D array of floats.

Parameters:
  • raw_data (array_like) – 3D array of shape (frames, rows, cols) to calculate the pedestal from. Needs to contain data for all three gains (G0, G1, G2).

  • n_threads (int) – The number of threads to use for the calculation.

aare.calculate_pedestal_g0(raw_data: numpy.ndarray[numpy.uint16], n_threads: int = 4) numpy.ndarray[numpy.float64]

Calculate the pedestal for G0 and return the result as a 2D array of doubles. Pixels in G1 and G2 are ignored.

Parameters:
  • raw_data (array_like) – 3D array of shape (frames, rows, cols) to calculate the pedestal from.

  • n_threads (int) – The number of threads to use for the calculation.

aare.calculate_pedestal_g0_float(raw_data: numpy.ndarray[numpy.uint16], n_threads: int = 4) numpy.ndarray[numpy.float32]

Same as calculate_pedestal_g0 but returns a 2D array of floats.

Parameters:
  • raw_data (array_like) – 3D array of shape (frames, rows, cols) to calculate the pedestal from.

  • n_threads (int) – The number of threads to use for the calculation.

aare.count_switching_pixels(raw_data: numpy.ndarray[numpy.uint16], *, n_threads: int = 4) numpy.ndarray[numpy.int32]

Count the number of time each pixel switches to G1 or G2.

Parameters:
  • raw_data (array_like) – 3D array of shape (frames, rows, cols) to count the switching pixels from.

  • n_threads (int) – The number of threads to use for the calculation.