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, ring_box=None)[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.

  • ring_box (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.

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', ring_box=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.

  • ring_box (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.