goodman_focus package#

Subpackages#

Submodules#

goodman_focus.goodman_focus module#

class goodman_focus.goodman_focus.GoodmanFocus(data_path='/home/docs/checkouts/readthedocs.org/user_builds/goodman-focus/checkouts/latest/docs', file_pattern='*.fits', obstype='FOCUS', features_model='gaussian', selection_threshold=2, plot_results=False, debug=False)#

Bases: object

property fwhm#
get_focus_data(group)#

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.

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

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

Returns:

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

keywords = ['DATE', 'DATE-OBS', 'INSTCONF', 'FOCUS', 'CAM_TARG', 'GRT_TARG', 'CAM_FOC', 'COLL_FOC', 'FILTER', 'FILTER2', 'GRATING', 'SLIT', 'WAVMODE', 'EXPTIME', 'RDNOISE', 'GAIN', 'OBSTYPE', 'ROI']#
goodman_focus.goodman_focus.clean_clipped_profile(clipped_profile: MaskedArray)#

Helper function to reduce code duplicity

Creates a new x-axis for the values not masked, and also it creates the profile without the masked values. This information is used for fitting the background model for later background subtraction.

Parameters:

clipped_profile (MaskedArray) – Masked profile to clean.

Returns:

clipped_x_axis and cleaned_profile.

goodman_focus.goodman_focus.get_args(arguments=None)#
goodman_focus.goodman_focus.get_fwhm(peaks, values, x_axis, profile, model, sigma=1, 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.

Parameters:
  • 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(len(profile)).

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

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

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

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

Returns:

The FWHM, mean FWHM or None.

goodman_focus.goodman_focus.get_peaks(ccd: CCDData, file_name: str = '', split_size_for_low_snr_data: int = 10, threshold_for_selecting_peaks: float = 2, plots: bool = 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.

Parameters:
  • ccd (CCDData) – Image to get peaks from

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

  • split_size_for_low_snr_data (int) – When the data has low signal-to-noise ratio is required to split the spectral profile in this number of parts. Default: 10

  • threshold_for_selecting_peaks (float) – Factor of spectral profile’s standard deviation to discriminate peaks.

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

Returns:

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.

goodman_focus.goodman_focus.run_goodman_focus(args=None)#

Entrypoint

Parameters:

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

goodman_focus.version module#

Module contents#