Splice the data¶
Welcome to the documentation for the ‘splice.py’ module. This module is used to splice the data from the WiFeS spectrograph by combining the reduced data from the blue and red arms of the spectrograph. The module provides two main functions, splice_spectra and splice_cubes, which are used to splice the spectra and the cubes respectively.
- pywifes.splice.a_lanczos(x_original, x, a=2, missing=nan)¶
Returns transformation matrix for Lanczos (sinc) interpolation
- Inputs
- x_originalarray
x-values at which the original function is sampled
- xarray
x-values to which we want to interpolate
- aint, optional
integer order of the kernel. Default is 2.
- missingfloat/NaN
value to use for missing data (default: numpy.nan)
- Outputs
- Aarray
sparse representation of the transformation matrix
- pywifes.splice.calculate_wavelength_array(blue_CRVAL, blue_CDELT, blue_CRPIX, red_CRVAL, red_CDELT, red_CRPIX, red_NAXIS, wstep)¶
Calculates the wavelength array for the merged blue and red spectra, using the wavelength step of the blue spectrum.
- Parameters:
blue_CRVAL (float) – Wavelength of the reference pixel for the blue spectrum.
blue_CDELT (float) – Wavelength increment per pixel for the blue spectrum.
blue_CRPIX (float) – Reference pixel for the blue spectrum.
red_CRVAL (float) – Wavelength of the reference pixel for the red spectrum.
red_CDELT (float) – Wavelength increment per pixel for the red spectrum.
red_CRPIX (float) – Reference pixel for the red spectrum.
red_NAXIS (int) – Number of pixels in the red spectrum.
wstep (float) – Wavelength increment per pixel for the output spectrum.
- Return type:
Wavelength array calculated from the given parameters.
- pywifes.splice.splice_cubes(blue_path, red_path, output_path, get_dq=False, wstep=None, debug=False)¶
Main function to splice two previously generated cubes from both WiFeS arms together.
- Parameters:
blue_path (str) – Path to the blue cube FITS file.
red_path (str) – Path to the red cube FITS file.
output_path (str) – Path to save the spliced cube FITS file.
get_dq (bool, optional) – Whether to include the DQ extension in the output. Default: False.
wstep (float, optional) – User-defined wavelength step of output cubes. Default: None (minimum blue wavelength step).
debug (bool, optional) – Whether to report the parameters used in this function call. Default: False.
- Return type:
None
Notes
This function joins the blue and red cubes together, and saves the spliced cube to the specified output path. It uses the header information from the red cube as a starting point and adds additional blue CCD keywords as required.
The spliced cube is saved in FITS format with the following extensions: - Primary HDU: Contains the spliced flux data. - Extension HDU: Contains the variance data. - Optional Extension HDU: Contains the data quality data.
Examples
>>> splice_cubes('blue_cube.fits', 'red_cube.fits', 'spliced_cube.fits')
- pywifes.splice.splice_spectra(blue_spec_path, red_spec_path, output_path, get_dq=False, wstep=None)¶
Main routine to splice two spectra together.
- Parameters:
blue_spec_path (str) – Path to the blue spectrum FITS file.
red_spec_path (str) – Path to the red spectrum FITS file.
output_path (str) – Path to save the spliced spectrum FITS file.
get_dq (bool, optional) – Whether to include the DQ extension in the output. Default: False.
wstep (float, optional) – User-defined wavelength step of output spectra. Default: None (minimum blue wavelength step).
- Return type:
None
Notes
This function reads two spectra from FITS files, joins them together, and saves the spliced spectrum to a new FITS file.
The splicing process involves combining the flux data from the blue and red spectra, and updating the header information of the red spectrum to match the blue spectrum.
The spliced spectrum is saved as a FITS file with the provided output path.
Examples
splice_spectra(‘blue_spectrum.fits’, ‘red_spectrum.fits’, ‘spliced_spectrum.fits’)