quadrantdetector.detector module

This code defines functions needed to create a gaussian laser beam and mask it according to the specifications of our quandrant cell photodiode.

quadrantdetector.detector.compute_signals(beam: numpy.ndarray, area: numpy.ndarray) → Tuple[float, float, float]

This routine computes–for a given beam intensity– the sum, left-right, and top-bottom signals.

Parameters:
  • beam (array_like) – Array of laser beam intensity
  • area (array_like) – Array representing the detector.
Returns:

  • sum_signal (float) – Sum of all 4 quadrants
  • l_r (float) – Left minus right quadrants
  • t_b (float) – Top minus bottom quadrants

quadrantdetector.detector.create_detector(n: int, diameter: float, gap: float, roundoff=1e-14) → numpy.ndarray

This routine creates the entire detector array. It does so by assuming a square array and eliminating chunks not within the circular detector boundary.

Parameters:
  • n (int) – Number of chunks to divide detector into, rounded up to the nearest even number.
  • diameter (float) – Diameter of full detector (in mm)
  • gap (float) – Gap width between the quadrants of the detector (in mm)
  • roundoff (float) – Scalar fudge factor needed for round-off error (default = 1e-14)
Returns:

active_area (array_like) – 2d array with effective area of each cell; if the cell is dead, it’s area will be zero. Most cells will have and area of (diameter/n)**2, but some cells which straddle the gap will have a fraction of this area.

Note

From the Numpy masking module np.ma manual:

A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.

When an element of the mask is False, the corresponding element of the associated array is valid and is said to be unmasked.

When an element of the mask is True, the corresponding element of the associated array is said to be masked (invalid).

In other words, for the code below, I want to create an array of values where the laser beam’s intensity is specified for all points within the detector’s active radius. The easiest way to do this is to assign the value TRUE to all points within this radius. BUT, in numpy’s way of thinking, these points are to be neglected (masked); however, since the logical equivalent to TRUE is 1, a mutiplication of this mask with the x and y arrays will yield an array with the points outside the detector eliminated. Technically, I am using my mask in the OPPOSITE manner in which numpy intends.

quadrantdetector.detector.intensity(y: Union[float, numpy.ndarray], x: Union[float, numpy.ndarray], sigma: float) → Union[float, numpy.ndarray]

Computes the intensity of a Gaussian beam centered on the origin at the position (x,y)

Parameters:
  • y (float or np.ndarray) – The x-coordinite in Cartesian space to be evaluated
  • x (float or np.ndarray) – The x-coordinite in Cartesian space to be evaluated
  • sigma (float) – The sigma value used in the Gaussian.
Returns:

Union[float, np.ndarray] – A float if (x, y) were both floats, or an np.ndarray if (x, y) were both np.ndarray. In all cases, represents the Gaussian evaluated at those point(s).

Notes

(x, y) must have the same dimentions, otherwise behavior is undefined and may result in an exception.

quadrantdetector.detector.laser(diameter, n, x_c, y_c, sigma)

This cute function uses the wondrousness of NumPy to produce a gaussian beam in one line of code. The resulting array will be masked in the compute_signals function to eliminate the beam outside the detector and also to account for the dead zones due to the gap.

Parameters:
  • diameter (float) – Diameter of full detector (in mm)
  • n (int) – Number of chunks to divide detector into (in the x direction and in the y direction; thus the total number of area chuncks is N^2), rounded up to the nearest even number.
  • x_c, y_c (float) – x and y Cartesian coordinates of the center of the laser spot (not necessarily on the detector!)
  • sigma (float) – the standard deviation for the gaussian beam; FWHM ~ 2.355σ
Returns:

array_like – NumPy array of normalized beam intensity values over the detector array

quadrantdetector.detector.n_critical(detector_diameter: float, detector_gap: float) → int

This function computes the smallest even integer value for the number of cells, n_crit, is such that no more than 2 complete cells fall within the detector gap width δ (i.e. Δ = δ/2 yielding N = 2 d0/δ) The code makes sure that N is even.

Parameters:
  • detector_diameter (float) – The diameter of the quadrant cell photo diode (in mm)
  • detector_gap (float) – The gap distance between the quadrants of the photo diode (in mm)
Returns:

n_crit (int) – The critical number of cells (an even number)

quadrantdetector.detector.signal_over_path(n: int, diameter: float, gap: float, x_max: float, sigma: float, track: Callable[[float, float], float], n_samples: int, roundoff=1e-14) → Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray]

This routine executes the compute_signals function multiple times over a user specified path function and returns the path and the expected signals.

Parameters:
  • n (int) – Number of cells to divide diameter up into
  • diameter (float) – Diameter of detector in mm
  • gap (float) – Gap width between quadrants of detector in mm
  • x_max (float) – horizontal domain for sweeping across detector x from -xmax to +xmax
  • sigma (float) – Width of gaussian beam
  • track (Callable[Union[float, np.ndarray], float]) – A function describing path across detector. Must take the arguments (x_position, detector_diameter).
  • n_samples (int) – Number of samples in domain; dx = 2 * xmax / n_samples
  • roundoff (float) – Fudge factor needed for roundoff error (default = 1e-14)
Returns:

  • xp (array_like) – list of x coordinates for path
  • sum_signal (array_like) – List of the sums of all 4 quadrants
  • l_r (array_like) – List of the left minus right quadrants
  • t_b (array_like) – List of the top minus bottom quadrants

quadrantdetector.detector.signal_over_time(n: int, diameter: float, gap: float, amplitude: float, period: float, t_max: float, sigma: float, track: Callable[[float, float], float], n_samples: int, roundoff=1e-14)

This routine executes the compute_signals function multiple times over a user specified TIME interval and returns the path and the expected signals. This routine is more relevant to someone using a quadrant cell detector as a way to measure zero crossings of torsional pendulum undergoing angular oscillations with amplitude significantly greater that the effective angular amplitude defined by the detector. That being said, this function allows the users to specify the amplitude to any value desired.

Parameters:
  • n (int) – The number of cells to divide diameter up into
  • diameter (float) – Diameter of detector in mm
  • gap (float) – Gap width between quadrants of detector in mm
  • amplitude (float) – Amplitude of sinusoidal motion
  • period (float) – Period of sinusoidal signal in seconds
  • t_max (float) – Maximum time for simulation in seconds
  • sigma (float) – width of gaussian beam in mm
  • track (Callable[Union[float, np.ndarray], float]) – A function describing path across detector. Must take the arguments (x_position, detector_diameter).
  • n_samples (int) – number of samples in time domain; dt = 2*t_max/n_samples
  • roundoff (float) – Fudge factor needed for roundoff error (default = 1e-14)
Returns:

  • tp (array_like) – List of time values in seconds
  • xp (array_like) – :ist of x coordinates for path
  • sum_signal (float) – Sum of all 4 quadrants
  • l_r (float) – Left minus right quadrants
  • t_b (float) – Top minus bottom quadrants

Notes

1. the track function specifies the y-coordinate of the spot center as it tracks across the detector.

quadrantdetector.detector.total_signal(detector_gap: float, sigma: float, detector_radius: float) → float

Computes the theoretical sum signal by numerical integration; assumes a centered beam.

Parameters:
  • detector_gap (float) – Gap width between the quadrants of the detector (in mm)
  • sigma (float) – Width of gaussian beam
Returns:

float – A value representing the sum signal of the detector.