fiberlab.collimated module

Module with methods used to analyze and plot collimated test images.

fiberlab.collimated.collimated_farfield_output(img_file, bkg_file=None, threshold=None, pixelsize=None, distance=None, plot_file=None, snr_img=False, window=None, box=None, gau=None, dr=None, savgol=(301, 2))[source]

Analyze an output far-field image for a collimated input beam.

Parameters:
  • img_file (str, Path) – Image file

  • bkg_file (str, Path, optional) – Background image to subtract

  • threshold (float, optional) – S/N threshold of the contour used to define the center of the ring. If None, see default_threshold().

  • pixelsize (float, optional) – Size of the image pixels in mm.

  • distance (float, optional) – Distance from the fiber output to the detector in mm.

  • plot_file (str, Path, optional) – Name of the QA file to produce. If 'show', no file is produced, but the QA plot is displayed in a matplotlib window.

  • snr_img (bool, optional) – If creating the QA plot, plot the estimated S/N (used to set the contour level) instead of the measured counts.

  • window (float, optional) – Limit the plotted image regions to this times the best-fitting peak of the ring flux distribution. If None, the full image is shown.

  • box (int, optional) – Boxcar average the image by this number of pixels. If None, full resolution of image is used.

  • gau (float, optional) – Gaussian smooth the image used to measure the contour that is fit to find the beam center. This provides the sigma of the 2D smoothing Gaussian in binned pixels (see box). Note the smoothed image is not used to measure the ring peak or width, once the center of the beam is measured.

  • dr (float, optional) – Radial binning step. Units depend on values given for pixelsize and distance. If both are None, the value is in pixels. If pixelsize is provided, units are mm. If both are provided, units are in deg. If None, data is not binned, and the smoothed profile alone is used to find the peak and width.

  • savgol (tuple, optional) – Two parameters used for the the Savitzky-Golay filter applied to the data to “model” the flux. These two parameters are (1) window_length and (2) polyorder as implemented by the scipy.signal.savgol_filter function. When binning the data (dr is provided), the first number in this tuple should be significantly smaller.

Returns:

Three floating-point objects providing the radius at which the peak flux is found, the flux at the peak, and the width of the ring.

Return type:

tuple

fiberlab.collimated.collimated_farfield_output_plot(img_file, img, model, threshold, level, trace, circ_p, radius, flux, smooth_flux, peak_indx, left, right, snr_img=False, r_units='pix', window=None, pixelsize=None, distance=None, ofile=None)[source]

Diagnostic plot for the measurements of a collimated far-field output beam.

Parameters:
  • img_file (str, Path) – Image file

  • img (numpy.ndarray) – The background subtracted far-field image data.

  • model (numpy.ndarray) – The model of the far-field image.

  • threshold (float) – S/N threshold of the contour used to define the center of the ring.

  • level (float) – The level in the image that corresponds to the S/N threshold.

  • trace (numpy.ndarray) – The contour tracing the outside of the ring used to define the ring center.

  • circ_p (tuple) – Tuple with the best-fitting parameters for the ring contour: x center (along 2nd axis), y center (along 1st axis), and radius.

  • radius (numpy.ndarray) – A (sorted) 1D array with the radii of all pixels in img relative to the ring center.

  • flux (numpy.ndarray) – A 1D array with the flux of all pixels in img sorted by radius relative to the ring center.

  • smooth_flux (numpy.ndarray) – The smoothed version of the flux vector, used to measure the radius of the ring, its peak flux, and its full-width at half maximum.

  • peak_indx (int) – The index of the element in smooth_flux at which the peak (ring center) was found.

  • left (float) – The inner radius of the ring at half its maximum.

  • right (float) – The outer radius of the ring at half its maximum.

  • snr_img (bool, optional) – Plot the estimated S/N (used to set the contour level) instead of the measured counts.

  • r_umits (str, optional) – The units of the radius vector.

  • window (float, optional) – Limit the plotted image regions to this times the best-fitting contour radius. If None, the full image is shown.

  • ofile (str, Path, optional) – Name of the QA file to produce. If 'show', no file is produced, but the QA plot is displayed in a matplotlib window.

fiberlab.collimated.default_threshold()[source]

The default threshold to use for defining the contour used to determine the center of the output beam.