basic_beam_size

laserbeamsize.analysis.basic_beam_size(original: ndarray, phi_fixed: float | None = None) → tuple[float, float, float, float | None, float][source]

Determine the beam center, diameters, and tilt using ISO 11146 standard.

Find the center and sizes of an elliptical spot in an 2D array. The function does nothing to eliminate background noise. It just finds the first and second order moments and returns the beam parameters. Consequently a beam spot in an image with a constant background will fail badly.

FWIW, this implementation is roughly 800X faster than one that finds the moments using for loops.

When background noise dominates, the moments are taken over the whole frame and the returned diameters are meaningless — they come out comparable to the image dimensions rather than to the beam. Use beam_size() instead, which subtracts the background first.

If every pixel is zero there is no centroid to find, so the image center is returned with both diameters and phi set to zero.

phi_fixed defaults to None, in which case the best fitted angle for the ellipse is found. If phi_fixed is specified, then an ellipse is rotated to that angle and fitted to the image.

If the input is a masked array, masked pixels are treated as having zero weight in the moment calculations.

Parameters:
  • original – 2D array of image with beam spot (may be masked array)

  • phi_fixed – angle that major axis of ellipse makes with horizontal [radians]

Returns:

xc – horizontal center of beam yc: vertical center of beam d_major: major axis (i.e, major diameter) d_minor: minor axis (i.e, minor diameter) phi: angle between major axis and horizontal [radians]