tort

sofia_redux.instruments.exes.tort.tort(data, header, variance=None, skew=False, order=3, missing=nan, badfrac=0.5, get_illum=False, interpolation_method='spline')[source]

Correct image for optical distortion.

Calls exes.tortcoord to calculate undistorted coordinates from raw pixel coordinates and distortion parameters in the header. The image is then interpolated onto the undistorted coordinates. If the variance is provided, it is also interpolated onto undistorted coordinates.

Parameters:
datanumpy.ndarray

[nframe, nspec, nspat] cube or [nspec, nspat] image.

headerfits.Header

FITS header with distortion parameters set.

variancenumpy.ndarray, optional

Variance array matching data dimensions.

skewbool, optional

If True, correct for echelon slit skewing.

orderint, optional

Order of interpolation (0-5). 0 is nearest value, 1 is linear interpolation, 3 is cubic interpolation.

missingfloat, optional

Value to use in output frames for missing data.

badfracfloat, optional

The allowable fraction of NaN-valued points used to generate an interpolated value. If this fraction is greater than badfrac, it will be replaced by missing. Note that all NaNs are replaced by zero before interpolation.

get_illumbool, optional

If set, an undistorted illumination mask will be returned.

interpolation_method{‘spline’, ‘convolution’}, optional

If ‘convolution’, a separable parametric cubic convolution algorithm is applied, replicating the original IDL interpolation method for the EXES pipeline. If ‘spline’, the interpolation is performed via piecewise splines of the specified order.

Returns:
tortdata, [tortvar], [tortillum]numpy.ndarray or tuple of numpy.ndarray

The corrected data and optional variance and illumination arrays (if supplied and/or requested). Will be of shape [nframe, nspec, nspat] if nframe > 1; [nspec, nspat] otherwise.