def extract_flatfield(prihdr, scihdu):
for ff in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>vv = prihdr.get(ff, '<STR_LIT>')<EOL>if vv != '<STR_LIT>':<EOL><INDENT>warnings.warn('<STR_LIT>'.format(ff, vv),<EOL>AstropyUserWarning)<EOL><DEDENT><DEDENT>flatfile = prihdr.get('<STR_LIT>', '<STR_LIT>')<EOL>if flatfile == '<STR_LIT>':<EOL><INDENT>return None<EOL><DEDENT>flatfile = from_irafpath(flatfile)<EOL>ampstring = prihdr['<STR_LIT>']<EOL>with fits.open(flatfile) as hduflat:<EOL><INDENT>if ampstring == '<STR_LIT>':<EOL><INDENT>invflat = np.concatenate(<EOL>(<NUM_LIT:1> / hduflat['<STR_LIT>', <NUM_LIT:1>].data,<EOL><NUM_LIT:1> / hduflat['<STR_LIT>', <NUM_LIT:2>].data[::-<NUM_LIT:1>, :]), axis=<NUM_LIT:1>)<EOL><DEDENT>elif ampstring in ('<STR_LIT:A>', '<STR_LIT:B>', '<STR_LIT>'):<EOL><INDENT>invflat = <NUM_LIT:1> / extract_ref(scihdu, hduflat['<STR_LIT>', <NUM_LIT:2>])<EOL><DEDENT>else:<EOL><INDENT>invflat = <NUM_LIT:1> / extract_ref(scihdu, hduflat['<STR_LIT>', <NUM_LIT:1>])<EOL><DEDENT><DEDENT>return invflat<EOL>
Extract flatfield data from ``PFLTFILE``.

    Parameters
    ----------
    prihdr : obj
        FITS primary header HDU.

    scihdu : obj
        Extension HDU of the science image.
        This is only used to extract subarray data.

    Returns
    -------
    invflat : ndarray or `None`
        Inverse flatfield, if any. Multiply this to apply ``FLATCORR``.