'Reads `distortion paper`_ table-lookup keywords and data, and
returns a 2-tuple of `~astropy.wcs.DistortionLookupTable`
objects.
If no `distortion paper`_ keywords are found, ``(None, None)``
is returned.'

def _read_distortion_kw(self, header, fobj, dist=u'CPDIS', err=0.0):

    if isinstance(header, (six.text_type, six.binary_type)):
        return (None, None)
    if (dist == u'CPDIS'):
        d_kw = str(u'DP')
        err_kw = str(u'CPERR')
    else:
        d_kw = str(u'DQ')
        err_kw = str(u'CQERR')
    tables = {}
    for i in range(1, (self.naxis + 1)):
        d_error_key = (err_kw + str(i))
        if (d_error_key in header):
            d_error = header[d_error_key]
            del header[d_error_key]
        else:
            d_error = 0.0
        if (d_error < err):
            tables[i] = None
            continue
        distortion = (dist + str(i))
        if (distortion in header):
            dis = header[distortion].lower()
            del header[distortion]
            if (dis == u'lookup'):
                if (not isinstance(fobj, fits.HDUList)):
                    raise ValueError(u'an    astropy.io.fits.HDUList    is    required    for    Lookup    table    distortion.')
                dp = (d_kw + str(i)).strip()
                dp_extver_key = (dp + str(u'.EXTVER'))
                if (dp_extver_key in header):
                    d_extver = header[dp_extver_key]
                    del header[dp_extver_key]
                else:
                    d_extver = 1
                dp_axis_key = (dp + str(u'.AXIS.{0:d}'.format(i)))
                if (i == header[dp_axis_key]):
                    d_data = fobj[(str(u'WCSDVARR'), d_extver)].data
                else:
                    d_data = fobj[(str(u'WCSDVARR'), d_extver)].data.transpose()
                del header[dp_axis_key]
                d_header = fobj[(str(u'WCSDVARR'), d_extver)].header
                d_crpix = (d_header.get(str(u'CRPIX1'), 0.0), d_header.get(str(u'CRPIX2'), 0.0))
                d_crval = (d_header.get(str(u'CRVAL1'), 0.0), d_header.get(str(u'CRVAL2'), 0.0))
                d_cdelt = (d_header.get(str(u'CDELT1'), 1.0), d_header.get(str(u'CDELT2'), 1.0))
                d_lookup = DistortionLookupTable(d_data, d_crpix, d_crval, d_cdelt)
                tables[i] = d_lookup
                for key in list(header):
                    if key.startswith((dp + str(u'.'))):
                        del header[key]
            else:
                warnings.warn(u'Polynomial    distortion    is    not    implemented.\n', AstropyUserWarning)
        else:
            tables[i] = None
    if (not tables):
        return (None, None)
    else:
        return (tables.get(1), tables.get(2))
