sky
– Sky subtraction and estimation¶
Modules that provides utilities related with the sky background
The main products are:
fe_sky_subtraction()
: sky subtraction from fiber extracted framesfe_sky_background()
: estimate the sky background from a filehdu_fe_sky_background()
: estimate the sky background (the content of the file is passed)
-
pyhetdex.tools.astro.sky.
fe_sky_subtraction
(fname, sig=2.5, iters=None, wmin=None, wmax=None, width=20, prefix='S', skyprefix='Sky', output_both=True)[source]¶ Perform the sky subtraction from a fiber extracted frame
Parameters: - fname : string
name of the fits file to process
- sig : float, optional
number of standard deviations to use for the clipping limit
- iters : int or None, optional
number of iterations to perform clipping for, or None to clip until convergence is achieved (i.e. continue until the last iteration clips nothing).
- wmin, wmax : floats, optional
maximum and minimum wavelength in Armstrong to use for the sigma clipping. Converted to indices using the ‘CRVAL1’ and ‘CDELT1’ keyword in the header of the fits file. If None the minimum and/or maximum of the range used
- width : int, optional
width of the moving window used to estimate the sky background
- prefix : string, optional
prefix of the sky subtracted file
- skyprefix : string, optional
prefix of the sky file
- output_both : bool, optional
save both sky and sky subtracted frames, instead of the latter alone
-
pyhetdex.tools.astro.sky.
fe_sky_background
(fname, **kwargs)[source]¶ Estimate the sky background as the (sigma clipped) median of medians within the required wavelengths and fiber number boundaries.
The input is read from fname. The keyword arguments are passed to
hdu_fe_sky_background()
Parameters: - fname : string
file to average
- sig : None or float, optional
if not None, ignore fibers with signal outside sig standard deviation
- iters : int or None, optional
number of iterations to perform clipping for, or None to clip until convergence is achieved (i.e. continue until the last iteration clips nothing).
- wmin, wmax : float, optional
minimum and maximum wavelength to consider for the average
- wmin, wmax : floats, optional
maximum and minimum wavelength in Armstrong to use for the estimate. Converted to indices using the ‘CRVAL1’ and ‘CDELT1’ keyword in the header of the fits file. If None the minimum and/or maximum of the range used
- fibmin, fibmax : float, optional
minimum and maximum fiber number to consider
Returns: - median : float
average
- n_fibs : int
number of fibers used for the final median
-
pyhetdex.tools.astro.sky.
hdu_fe_sky_background
(data, header, sig=2.5, iters=None, wmin=None, wmax=None, fibmin=None, fibmax=None)[source]¶ Estimate the sky background as the (sigma clipped) median of medians within the required wavelengths and fiber number boundaries
Parameters: - data : numpy ndarray
data of the fits image
- header : astropy.io.fits.Header instance
header of the fits image
- sig : None or float, optional
if not None, ignore fibers with signal outside sig standard deviation
- iters : int or None, optional
number of iterations to perform clipping for, or None to clip until convergence is achieved (i.e. continue until the last iteration clips nothing).
- wmin, wmax : float, optional
minimum and maximum wavelength to consider for the average
- wmin, wmax : floats, optional
maximum and minimum wavelength in Armstrong to use for the estimate. Converted to indices using the ‘CRVAL1’ and ‘CDELT1’ keyword in the header of the fits file. If None the minimum and/or maximum of the range used
- fibmin, fibmax : float, optional
minimum and maximum fiber number to consider
Returns: - median : float
average
- n_fibs : int
number of fibers used for the final median
-
pyhetdex.tools.astro.sky.
moving_window
(mask, cindex, width=20)[source]¶ Modify the mask to exclude rows outside the mask
Parameters: - mask : 1d array of bool
mask across with the window moves
- cindex : int
central index of the window
- width : int, optional
maximum width of the window. Edges are not wrapped around
Returns: - window_mask : 1d array of bool
mask with all the elements outside the window set to False