solid_waffle.flat_simulator.detector_functions

Functions to create various detector effect. The structure will change, but for now this will be the location for functions related to IPC, BFE, etc.

Functions

simple_ipc_kernel

Makes a simple IPC kernel with single nearest-neighbor coupling.

ipc_kernel_HV

A 3x3 kernel with horizontal and vertical alpha, which can be different.

calculate_ipc

Convolves the input charge data cube with an IPC kernel and returns an output data cube.

calc_area_defect

Computes the area defect of an array of pixels due to a BFE kernel.

ipc_invkernel_HV

Return an inverse 3x3 kernel with horizontal and vertical alpha, which can be different.

auto_convolve_kernel

Return the auto-convolution of the kernel.

K2a

Return the convolution of the BFE a coefficients with the IPC kernel.

Classes

TestKernels

Makes BFE kernels for testing inputs.

Classes

TestKernels

Makes BFE kernels for testing inputs.

Functions

simple_ipc_kernel([alpha])

Makes a simple IPC kernel with single nearest-neighbor coupling.

ipc_kernel_HV([alpha_H, alpha_V])

A 3x3 kernel with horizontal and vertical alpha, which can be different.

calculate_ipc(data_cube_Q, ipc_list[, npad])

Convolves the input charge data cube with an IPC kernel and returns an output data cube.

calc_area_defect(ap, Q[, npad])

Computes the area defect of an array of pixels due to a BFE kernel.

ipc_invkernel_HV([alpha_H, alpha_V])

Return an inverse 3x3 kernel with horizontal and vertical alpha, which can be different.

auto_convolve_kernel(kern1)

Return the auto-convolution of the kernel.

K2a(ipc_kernel2, bfe_a[, round])

Return the convolution of the BFE a coefficients with the IPC kernel.

a_symmetric_avg(coeffs[, round])

Return the symmetric averages over a given 5x5 matrix of coefficients.

_main()

Tests from the Choi et al. paper.

Module Contents

simple_ipc_kernel(alpha=0.01)[source]

Makes a simple IPC kernel with single nearest-neighbor coupling.

Simple function to return a 3 x 3 kernel with an alpha where alpha is the kernel value for the 4 adjacent pixels, and the central value is 1-4*`alpha`. This is a symmetric kernel.

Parameters:

alpha (float, optional) – Nearest-neighbor coupling.

Returns:

The shape (3,3) IPC kernel, centered at zero.

Return type:

np.array of float

ipc_kernel_HV(alpha_H=0.01, alpha_V=0.01)[source]

A 3x3 kernel with horizontal and vertical alpha, which can be different.

Parameters:
  • alpha_H (float, optional) – The horizontal IPC coupling.

  • alpha_V (float, optional) – The vertical IPC coupling.

Returns:

The shape (3,3) IPC kernel, centered at zero.

Return type:

np.array of float

calculate_ipc(data_cube_Q, ipc_list, npad=2)[source]

Convolves the input charge data cube with an IPC kernel and returns an output data cube.

Calls “simple” or “HV” IPC kernel depending on ipc_list, which is either one value (all directions) or two (horiz, vertical) Currently cannot specify horiz or vertically asymmetric alpha.

Parameters:
  • data_cube_Q (np.array) – A 3D charge image (t,y,x). Updated in place.

  • ipc_list (np.array or list of float) – If length 1, an isotropic alpha; if length 2, interpreted as [alpha_H, alphaV].

  • npad (int, optional) – Amount by which to pad the image before IPC convolution (adjusts how boundaries are handled; default of 2 is probably fine for almost all purposes).

Returns:

Returns a view of the new charge image.

Return type:

np.array

class TestKernels[source]

Makes BFE kernels for testing inputs.

get_bfe_kernel_3x3()[source]

Returns a simple, currently arbitrary bfe 3 x 3 kernel.

get_bfe_kernel_5x5_ir()[source]

Returns a bfe 5x5 kernel like for SCA 20829.

get_bfe_kernel_5x5_vis()[source]

Returns a bfe 5x5 kernel like for SCA 20829 vis.

get_bfe_kernel_5x5_18237ir()[source]

Returns an arbitrary bfe 5x5 kernel; these numbers are similar to SCA 18237.

get_bfe_kernel_5x5_symm()[source]

Returns a symmetric bfe 5x5 kernel.

get_bfe_kernel_zeros()[source]

Returns a 5x5 matrix of 0s for testing.

classmethod get_bfe_kernel_3x3()[source]

Returns a simple, currently arbitrary bfe 3 x 3 kernel.

classmethod get_bfe_kernel_5x5_ir()[source]

Returns a bfe 5x5 kernel like for SCA 20829.

classmethod get_bfe_kernel_5x5_vis()[source]

Returns a bfe 5x5 kernel like for SCA 20829 vis.

classmethod get_bfe_kernel_5x5_18237ir()[source]

Returns an arbitrary bfe 5x5 kernel; these numbers are similar to SCA 18237.

classmethod get_bfe_kernel_5x5_symm()[source]

Returns a symmetric bfe 5x5 kernel.

classmethod get_bfe_kernel_zeros()[source]

Returns a 5x5 matrix of 0s for testing.

calc_area_defect(ap, Q, npad=2)[source]

Computes the area defect of an array of pixels due to a BFE kernel.

Paramters

apnp.array

The a_{deltai,deltaj} coefficient matrix, units of 1/e, centered at (0,0). (Size should be an odd number and should be square.)

Qnp.array

A 2D array of the charge.

npadint, optional

Amount of padding to apply (radius of BFE kernel is a good choice).

returns:

The area defect, i.e. area of each pixel relative to the unperturbed area. The area defect is unitless. The shape is the same as for Q.

rtype:

np.array

ipc_invkernel_HV(alpha_H=0.01, alpha_V=0.01)[source]

Return an inverse 3x3 kernel with horizontal and vertical alpha, which can be different.

Parameters:
  • alpha_H (float, optional) – The IPC coupling coefficients in the horizontal and vertical directions.

  • alpha_V (float, optional) – The IPC coupling coefficients in the horizontal and vertical directions.

Returns:

The shape (3,3) approximation to the inverse IPC kernel.

Return type:

np.array

auto_convolve_kernel(kern1)[source]

Return the auto-convolution of the kernel.

Parameters:

kern1 (np.array) – The input kernel as a 2D array.

Returns:

The autoconvolution of the input kernel as a 2D array.

Return type:

np.array

K2a(ipc_kernel2, bfe_a, round=None)[source]

Return the convolution of the BFE a coefficients with the IPC kernel.

Parameters:
  • ipc_kernel2 (np.array) – Autoconvolution of the IPC kernel (centered at 0).

  • bfe_a (np.array) – The BFE kernel.

  • round (int, optional) – If given, rounds for ease of display; default is no rounding.

Returns:

The convolition K*K*a, trimmed to the same size as bfe_a.

Return type:

np.array

a_symmetric_avg(coeffs, round=None)[source]

Return the symmetric averages over a given 5x5 matrix of coefficients.

Parameters:
  • coeffs (np.array) – A 5x5 matrix of coefficients.

  • round (int, optional) – If given, rounds for ease of display; default is no rounding.

Returns:

A length 6 array of the symmetrized kernel. Ordering is <0,0>, <1,0>, <1,1>, <2,0>, <2,1>, <2,2>.

Return type:

np.array

_main()[source]

Tests from the Choi et al. paper.