Interpolation Methods

Interpolate between calibration source positions and energies.

class x_ray_imager_bagriff.response_interpolation._interpolate.Interpolation

Generic base to interpolate x-ray detector response and validate it.

This is intended to produce the best estimate of what the mean response from the imager would be for a given x-ray position and energy. Specific implementation is left for inherited classes.

points
responses
positions
energies
__init__(energies, positions, responses, input_diagnostic=None)

Initialize the interpolation.

Parameters:
  • energy – Array of energies used for the calibration points. Shape is (n_energies).

  • positions (ArrayLike) – Array of the x and y position for each calibration point. It’s expected that the same points are used for each energy. Shape should be (2, n_x_positions, n_y_positions)

  • responses (ArrayLike) – Array of expected response for each x-ray energy and position used in calibration. Shape should be (n_energies, n_x_positions, n_y_positions, n_detectors)

  • input_diagnostic (GenericResponseDiagnostic | None) – Diagnostic plot of the calibration responses.

  • energies (ArrayLike)

Return type:

None

property x

TODO

property y

TODO

values(energy, x, y)

Estimate the response for an energy and position.

Implementation is left for the specific subclass. It should be able to tolarate any array shape, provided it’s the same for all three variables.

Parameters:
  • energy (ArrayLike) – Array of energies for each response to predict.

  • x (ArrayLike) – Array of x position coordinate for each response to predict.

  • y (ArrayLike) – Array of y position coordinate for each response to predict.

Return type:

NDArray[float64]

validate(output_diagnostic=None, error_diagnostic=None)

Check the predictions against calibration and plot diagnostics.

Parameters:
  • energy – Energy of the calibration source.

  • positions – Array of calibration points.

  • responses – Array of detector outputs for each calibration point.

  • output_diagnostic (GenericResponseDiagnostic | None) – Diagnostic plot to use for the predicted output at each calibration point and the specified energy.

  • error_diagnostic (GenericResponseDiagnostic | None) – Diagnostic plot of the difference between responses from calibration and the prediction.

Returns:

Tuple of the maximum and mean error between the calibration responses and the predicted output for the same energies and positions.

Return type:

tuple[float, float]

class x_ray_imager_bagriff.response_interpolation._interpolate.LinearInterpolation

Linearly interpolate responses in both energy and postion.

__init__(*args, **kwargs)

Initialize the interpolator, creating a scipy interpolator.

values(energy, x, y)

Estimate the response for an energy and position.

Implementation is left for the specific subclass. It should be able to tolarate any array shape, provided it’s the same for all three variables.

Parameters:
  • energy – Array of energies for each response to predict.

  • x – Array of x position coordinate for each response to predict.

  • y – Array of y position coordinate for each response to predict.

class x_ray_imager_bagriff.response_interpolation._interpolate.BasisFilteredInterpolation

Linear interpolation, using responses projected into a given basis.

__init__(energies, positions, responses, basis, **kwargs)

Initialize the interpolation, cleaning the responses array.

Parameters:
  • energy – Energy of the calibration source.

  • positions (ArrayLike) – Array of calibration points.

  • responses (ArrayLike) – Array of detector outputs for each calibration point.

  • basis (ArrayLike) – Set of orthonormal basis vectors. Each vector should have the same shape as the position grid. The array shape is (n_components, n_x, n_y).

  • input_diagnostic – Diagnostic plot of the calibration responses.

  • energies (ArrayLike)

Return type:

None

class x_ray_imager_bagriff.response_interpolation._interpolate.PCAEnergyInterpolation

Response function is an energy dependent sum of position functions.

$$ frac{x}{E} = v_0 + sum_{i = 1}^n v_i E $$

__init__(energies, positions, responses, basis, **kwargs)

Initialize, determining the energy least squared dependence.

Parameters:
  • energies (ArrayLike)

  • positions (ArrayLike)

  • responses (ArrayLike)

  • basis (ArrayLike)

Return type:

None

values(energy, x, y)

Estimate the response for an energy and position.

Implementation is left for the specific subclass. It should be able to tolarate any array shape, provided it’s the same for all three variables.

Parameters:
  • energy – Array of energies for each response to predict.

  • x – Array of x position coordinate for each response to predict.

  • y – Array of y position coordinate for each response to predict.