mkapmask

sofia_redux.spectroscopy.mkapmask.mkapmask(slit, wave, apertures, background=None)[source]

Constructs a 2D aperture mask.

First, the mask is set to zero for all values. Then, the backgrounds are set to NaN without regard to the apertures.

Then, for each aperture, the ‘trace’ value +/- the ‘psf_radius’ value is set to the aperture number. The full PSF apertures are indexed to apnum, inner aperture radii to -apnum. PSF radius is required, aperture radius is optional. It is assumed that the PSF radius is larger than the aperture radius if present.

The edge pixels for the PSF aperture are set to reflect their fractional pixel values. To determine where the full aperture n is:

z = (abs(mask) > n-1) & (abs(mask) <= n)

Inner aperture radii are set to whole pixels only. To determine the central region of the aperture n:

z = (mask == -1 * n)

Parameters:
slitarray_like of float

(n_values,) 1D array of slit position values (e.g. pixels, arcseconds).

wavearray_like of float

(n_values,) 1D array of wavelength coordinate values (e.g. um).

apertureslist of dict
Required keys and values for the dictionaries are:

trace : float aperture_radius : float psf_radius : float

apertureslist of dict
Required keys and values for the dictionaries are:

trace : float aperture_radius : float psf_radius : float

backgroundlist of list, optional

Each element should be a [start, stop] pair of spatial coordinates indicating a background region.

Returns:
numpy.ndarray

(ns, nw) array of int