undistort

sofia_redux.instruments.forcast.undistort.undistort(data, header=None, pinhole=None, rotate=False, variance=None, default_platescale=0.768, extrapolate=False)[source]

Corrects distortion due to camera optics.

Resamples data with a polynomial warping calculated from known pinhole positions to correct for optical distortions. Applies a border to the image to avoid losing data off the edge of the array. After distortion correction, the WCS keywords are updated. This function is typicalled called without the rotate parameter and pinpos provided by the output of discorr_model. The border width can be set in the border parameter in the configuration file; default is 128 pixels. The border pixels are set to NaN to mark them as non-data.

Parameters:
datanumpy.ndarray

Input data array (nrow, ncol)

headerastropy.io.fits.header.Header, optional

Input header; will be updated with a HISTORY message

pinholedict or str, optional

dictionary defining the pinhole model or path to a pinhole file. If None, will generate a default model based on the drip configuration file. If ‘default’ will use model defined in the default_pinpos() function. See get_pinpos() for a description of keys and values.

rotatebool, optional

If True, distortion model data will be rotated by NODANGLE (in header) before applying distortion correction.

variancenumpy.ndarray, optional

Variance array (nrow, ncol) to update in parallel with the data array

default_platescalefloat, optional

If set, CDELT1 and CDELT2 will be set to this value. Set to None to automatically update.

extrapolatebool, optional

If False, values outside of the rectangular range of xout and yout will be set to cval.

Returns:
2-tuple

numpy.ndarray : The distortion-corrected array (nrow, ncol) numpy.ndarray : The distortion-corrected variance (nrow, ncol)