tuskitoo.spectral_tools.spectral_tools module

apply_telluric_correction(path_images, path_tellurics, save=False)[source]

Apply telluric correction to one or more image FITS files using corresponding telluric files.

Parameters:
  • path_images (Union[str, List[str]]) – A single file path or a list of file paths to the image FITS file(s).

  • path_tellurics (Union[str, List[str]]) – A single file path or a list of file paths to the telluric FITS file(s).

  • save (bool, optional) – If True, saves the corrected images to new FITS files.

Returns:

A list containing the telluric-corrected image data arrays.

Return type:

List

Raises:

ValueError – If the number of image paths and telluric paths differ, or if a telluric file does not contain 2 HDUs.

combine_2D_spectra(paths, method='mean', verbose=True, pre_combine=False, save='', person='F. Avila-Vera', telluric_corrected=True, sub_name='', extra_shif=[])[source]

Combine multiple 2D spectra (and their errors/quality arrays) into a single 2D output using weighted combination. The function can also return the pre-combined arrays for inspection.

Parameters:
  • paths (list of str) –

    List of file paths to FITS files. Each file should have:
    • EXT 0: 2D flux image

    • EXT 1: 2D error map

    • EXT 2: 2D quality map (integer or float)

  • method (str, optional) – Combination method. Currently only ‘mean’ (weighted) is implemented. Could be extended to ‘median’ or other methods in the future.

  • verbose (bool, optional) – If True, print diagnostic information.

  • pre_combine (bool, optional) – If True, the function returns the stacked array (without weighting) before doing the final combination.

Returns:

  • combined_flux (2D np.ndarray) – Weighted-combined flux image (shape: [Y, X]).

  • combined_error (2D np.ndarray) – Propagated error image for the combined flux (shape: [Y, X]).

  • combined_quality (2D np.ndarray) – Average (or some combined) quality map (shape: [Y, X]).

Notes

  • This function attempts to correct image offsets in the Y dimension by using the correct(headers) function (not shown here) to determine shifts.

  • If pre_combine is True, it returns the large stacked arrays without applying weighted combination. This can be used for debugging.