'Writes a `distortion paper`_ type lookup table to the given
`astropy.io.fits.HDUList`.'

def _write_det2im(self, hdulist):

    if ((self.det2im1 is None) and (self.det2im2 is None)):
        return
    dist = u'D2IMDIS'
    d_kw = u'D2IM'
    err_kw = u'D2IMERR'
    def write_d2i(num, det2im):
        if (det2im is None):
            return
        (str(u'{0}{1:d}').format(dist, num),)
        hdulist[0].header[str(u'{0}{1:d}').format(dist, num)] = (u'LOOKUP', u'Detector    to    image    correction    type')
        hdulist[0].header[str(u'{0}{1:d}.EXTVER').format(d_kw, num)] = (num, u'Version    number    of    WCSDVARR    extension')
        hdulist[0].header[str(u'{0}{1:d}.NAXES').format(d_kw, num)] = (len(det2im.data.shape), u'Number    of    independent    variables    in    d2im    function')
        for i in range(det2im.data.ndim):
            hdulist[0].header[str(u'{0}{1:d}.AXIS.{2:d}').format(d_kw, num, (i + 1))] = ((i + 1), u'Axis    number    of    the    jth    independent    variable    in    a    d2im    function')
        image = fits.ImageHDU(det2im.data, name=str(u'D2IMARR'))
        header = image.header
        header[str(u'CRPIX1')] = (det2im.crpix[0], u'Coordinate    system    reference    pixel')
        header[str(u'CRPIX2')] = (det2im.crpix[1], u'Coordinate    system    reference    pixel')
        header[str(u'CRVAL1')] = (det2im.crval[0], u'Coordinate    system    value    at    reference    pixel')
        header[str(u'CRVAL2')] = (det2im.crval[1], u'Coordinate    system    value    at    reference    pixel')
        header[str(u'CDELT1')] = (det2im.cdelt[0], u'Coordinate    increment    along    axis')
        header[str(u'CDELT2')] = (det2im.cdelt[1], u'Coordinate    increment    along    axis')
        image.ver = int(hdulist[0].header[str(u'{0}{1:d}.EXTVER').format(d_kw, num)])
        hdulist.append(image)
    write_d2i(1, self.det2im1)
    write_d2i(2, self.det2im2)
