Estimators¶
The PointEstimator base class, inherited by each implementation.
- class x_ray_imager_bagriff.position_estimation._estimator.PointEstimator¶
Base class for converting an x-ray observation into an energy/position.
- short_name¶
A string of a name that should be used for the method implemented in each subclass.
- response¶
An NDArray[float] with the expected responses for each point.
- points¶
An NDArray[float] with the energy, x, y of the points.
- __init__(response, energies, positions)¶
Loads the generic estimator.
- Parameters:
response (ArrayLike) – Expected responses for an array of points. The array can be any shape that matches the energies and positions:
(*shape of measurements, n detectors).energies (ArrayLike) – Array with energies of samples. Shape is
(*shape of measurements)positions (ArrayLike) – Array with axis 0 having x and y of samples. Shape is
(2, *shape of measurements).
- get_value(observations)¶
Estimate the x-ray energy/possition producing the observations.
- Parameters:
observations (ArrayLike) – Measurements from the x-ray imager. Can be any shape, but the last dimmention must have n_detectors elements. Shape is
(*any_measurements_shape, n_detectors).- Returns:
An array of the estimated energy, x, and y. Shape is
(3, *any_measurements_shape).- Return type:
NDArray[float64]
- get_values_with_error(observations)¶
Estimate x-ray energy/position with uncertainties.
- Parameters:
observations (ArrayLike) – See get_values
- Return type:
tuple[NDArray[float64], NDArray[float64]]
- save_to(path)¶
Save this estimator to a file to be reloaded later.
This method should be undone by
load_from(path). If not overridden, the input response arrays will be saved in the “npz” format to be reloaded by the initializer. For subclasses where this is an expensive operation, this method could be used to save an intermediate result instead.
- classmethod load_from(path)¶
Reloads the estimator from a file made using
save_to(path).
- property energies: NDArray[float64]¶
Returns the energy component of points.
- property positions: NDArray[float64]¶
Returns the position components of points.
- class x_ray_imager_bagriff.position_estimation._lookup.PointLookup¶
A generic base for estimator methods using closest calibration.
- __init__(response, energies, positions)¶
Loads the generic estimator.
- Parameters:
response (ArrayLike) – Expected responses for an array of points. The array can be any shape that matches the energies and positions:
(*shape of measurements, n detectors).energies (ArrayLike) – Array with energies of samples. Shape is
(*shape of measurements)positions (ArrayLike) – Array with axis 0 having x and y of samples. Shape is
(2, *shape of measurements).
- lookup_index(observations)¶
Find the closest calibration points and their weight.
Using any lookup method, grab the index some number of points. Also return a weight for each point. All weights for an observation should sum to one.
Both arrays should have shape
(*any_measurements_shape, n_indices).- Parameters:
observations (ArrayLike) – See get_value. Shape should be
(*any_measurements_shape, n_detectors).- Returns:
A tuple of two arrays. The first is a set of indices for close calibration points from each measurement. The second is the relative weight for each index.
- Return type:
tuple[NDArray[int64], NDArray[float64]]
- get_value(observations)¶
Estimate using a weighted set of close calibration points.
- class x_ray_imager_bagriff.position_estimation._lookup.TreeLookup¶
Point lookup using a KDTree.
- __init__(response, energies, positions, k_lookup=None)¶
Loads the generic estimator.
- Parameters:
response (ArrayLike) – Expected responses for an array of points. The array can be any shape that matches the energies and positions:
(*shape of measurements, n detectors).energies (ArrayLike) – Array with energies of samples. Shape is
(*shape of measurements)positions (ArrayLike) – Array with axis 0 having x and y of samples. Shape is
(2, *shape of measurements).k_lookup (int | None)
- lookup_index(observations)¶
Find closes indices in the KDtree.
Anger imager style portioning algorithms.
- x_ray_imager_bagriff.position_estimation._anger.anger_basis(X)¶
Simple Anger imager positioning algorithm.
Example:
x = sum(detectors_plus_x) - sum(detectors_minus_x) y = sum(detectors_plus_y) - sum(detectors_minus_y) an then normalized by the sum of all detectore
It is assumed here that the detectors are numbered:
+y (2) | (1) ----+---- +x (3) | (0)
- Parameters:
X (ArrayLike) – Array of measurements. Shape is
(n events, n detectors).- Returns:
Tuple of three arrays. The amplitude, sum of all detectors. The Anger x position. The Anger y position.
- Return type:
tuple[NDArray[float64], NDArray[float64], NDArray[float64]]
- class x_ray_imager_bagriff.position_estimation._anger.AngerSimple¶
Anger algorithm based PointEstimator.
- __init__(channels, energies, positions)¶
Loads the generic estimator.
- Parameters:
response – Expected responses for an array of points. The array can be any shape that matches the energies and positions:
(*shape of measurements, n detectors).energies – Array with energies of samples. Shape is
(*shape of measurements)positions – Array with axis 0 having x and y of samples. Shape is
(2, *shape of measurements).
- get_value(channels, return_error=False)¶
Estimate the x-ray energy/possition producing the observations.
- Parameters:
observations – Measurements from the x-ray imager. Can be any shape, but the last dimmention must have n_detectors elements. Shape is
(*any_measurements_shape, n_detectors).- Returns:
An array of the estimated energy, x, and y. Shape is
(3, *any_measurements_shape).