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 filebkg_file (
str, Path, optional) – Background image to subtractthreshold (
float, optional) – S/N threshold of the contour used to define the center of the ring. If None, seedefault_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 (seebox). 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 forpixelsizeanddistance. If both are None, the value is in pixels. Ifpixelsizeis 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_lengthand (2)polyorderas implemented by thescipy.signal.savgol_filterfunction. When binning the data (dris 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 fileimg (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
imgrelative to the ring center.flux (numpy.ndarray) – A 1D array with the flux of all pixels in
imgsorted by radius relative to the ring center.smooth_flux (numpy.ndarray) – The smoothed version of the
fluxvector, 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 insmooth_fluxat 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.