mkspatprof

sofia_redux.spectroscopy.mkspatprof.mkspatprof(rectimg, atran=None, atmosthresh=None, bgsub=True, orders=None, ndeg=4, robust=5.0, smooth_sigma=1.0, return_fit_profile=False)[source]

Construct average spatial profiles.

Each order should already be resampled onto a uniform grid. For each order, the median background is subtracted on a column by column basis. The median spatial profile is then created. If the user passes atran and atmosthresh, then pixels that have atmospheric transmission below atmosthresh are ignored. The median spatial profile is then used to normalize the image. 2D polynomial coefficients are then derived on a row by row basis, and used to construct a 2D spatial map.

Outputs from this function (median profile and spatial map) are required for all further reduction steps (setting apertures, tracing continua, and extracting spectra). The value for rectimg comes from the output of sofia_redux.spectroscopy.rectify. Atmospheric data (atran) and all other parameters are instrument dependent.

Parameters:
rectimgdict

As returned by sofia_redux.spectroscopy.rectify with integer keys indicating the order. The values are dictionaries with keys as follows:

"image"

numpy.ndarray (ns, nw) Rectified image array (required)

"wave"

numpy.ndarray (nw,) Wave coordinates along image axis=1 (required)

"spatial"

numpy.ndarray (ns,) Spatial coordinates along image axis=0 (required)

"mask"

numpy.ndarray (ns, nw)

"pixsum"

numpy.ndarray (ns, nw)

"variance"

numpy.ndarray (ns, nw)

atrannumpy.ndarray, optional

(2, Ndata) array where atran[0, :] gives the wavelengths for atmospheric transmission and atran[1, :] gives the atmospheric transmission.

atmosthreshfloat, optional

The transmission (0 -> 1) below which data are ignored.

bgsubbool, optional

If True, the median background level is subtracted from the profile. It may be useful to set this to False when using a mode with a short slit.

ordersarray_like of int, optional

List or order numbers, ordered from the bottom to the top of the image. If not provided, order numbers will be derived from a sorted list of all order numbers in the order_mask.

ndegint, optional

The degree of the polynomial row fits.

robustfloat, optional

The robust threshold for polynomial row fits.

smooth_sigmafloat, optional

If greater than 0, the fit profile will be smoothed by a Gaussian with this width.

return_fit_profilebool, optional

If set, a fit profile with dimensions (ns,nw) will be returned as well as the median profile. This spatial map is required for optimal extraction steps.

Returns:
median_profiledict
order (int) -> profile (numpy.ndarray)

(n_spatial, 2) spatial profile where profile[:, 0] = spatial coordinate and profile[:, 1] = median spatial profile.

fit_profiledict, optional

order (int) -> profile (numpy.ndarray) (n_spatial, n_wave) profile from fit coefficients.