tuskitoo.sky_sub.tools module

combine_2D_spectra_sky_sub(paths, method='mean', verbose=True, pre_combine=False, save='', person='F. Avila-Vera', telluric_corrected=True)[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. This is results that came for our sky sub :param paths:

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)

Parameters:
  • 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.

off(hdr)[source]
Ref(header_1, header_2)[source]
ToAng(hdr)[source]

Converts header information to an array of arcsecond values.

Parameters: hdr (astropy.io.fits.Header): FITS header containing necessary keywords.

Returns: numpy.ndarray: Array of arcsecond values.

correct(hdrs)[source]

header list TODO change this name i dont really like this

extract_wavelength_array(fits_file)[source]
flux_correction(image_in_counts, Re, exptime, airmass, gain, bin, extinction)[source]
flux_correctionv2(image_in_counts, Re, exptime, airmass, band, separations=None, gain=2.12, bin=1, extinction=0, mask_image_x=None, do_mask=False)[source]
create_fits_with_table(data_array, header_dict=None, extra_table=None, table_columns=None, output_filename='output.fits')[source]

Create a FITS file from a 1D array with an optional header and extra table.

Parameters: - data_array: 1D array of data to save in the primary HDU. - header_dict: Dictionary containing header key-value pairs to add to the primary header. - extra_table: 2D array or structured data for the additional table (optional). - table_columns: List of tuples (name, format, data) for creating table columns if extra_table is None. - output_filename: The output FITS filename.

image_response_reader(image_path, response_path, **kwargs)[source]