goodman_focus package


goodman_focus.goodman_focus module

class goodman_focus.goodman_focus.GoodmanFocus(data_path='/home/docs/checkouts/', file_pattern='*.fits', obstype='FOCUS', features_model='gaussian', plot_results=False, debug=False)

Bases: object

property fwhm

Collects all the relevant data for finding best focus

It is important that the data is not very contaminated because there is no built-in cleaning process.

  • group (DataFrame) – The group refers to a set of images obtained

  • likely in series and with the same configuration. (most) –


a pandas.DataFrame with three columns. file, fwhm and focus.

goodman_focus.goodman_focus.get_fwhm(peaks, values, x_axis, profile, model, sigma=3, maxiter=3)

Finds FWHM for an image by fitting a model

For Imaging there is only one peak (the slit itself) but for spectroscopy there are many. In that case a 3-sigma clipping 1-iteration is applied to clean the values and then the mean is returned. In case that a FWHM can’t be obtained a None value is returned.

This function allows the use of Gaussian1D and Moffat1D models to be fitted to each line. Gaussian1D produces more consistent results though Moffat1D usually fits better the whole line profile.

  • peaks (numpy.ndarray) – An array of peaks present in the profile.

  • values (numpy.ndarray) – An array of values at peak location.

  • x_axis (numpy.ndarray) – X-axis for the profile, usually is equivalent to

  • `range

  • profile (numpy.ndarray) – 1-dimensional profile of the image being analyzed.

  • model (Model) – A model to fit to each peak location. Gaussian1D and

  • are supported. (Moffat1D) –

  • sigma (int) – Number sigmas to use on sigma-clipping

  • maxiter (int) – Maximum number of sigma-clipping iterations


The FWHM, mean FWHM or None.

goodman_focus.goodman_focus.get_peaks(ccd, file_name='', plots=False)

Identify peaks in an image

For Imaging and Spectroscopy the images obtained for focusing have lines that in the first case is an image of the slit and for the second is the spectrum of lamp, strategically selected for a good coverage of lines across the detector.

  • ccd (object) – Image to get peaks from

  • file_name (str) – Name of the file used. This is optional and is used

  • for debugging purposes. (only) –

  • plots (bool) – Show plots of the profile, background and

  • profile (background-subtracted) –


A list of peak values, peak intensities as well as the x-axis and the background subtracted spectral profile. For Imaging is the same axis as the spectral axis.




args (list) – (optional) a list of arguments and respective values.

goodman_focus.version module

Module contents