def update_dq(filename, ext, mask, dqval=<NUM_LIT>, verbose=True):
with fits.open(filename, mode='<STR_LIT>') as pf:<EOL><INDENT>dqarr = pf[ext].data<EOL>old_mask = (dqval & dqarr) != <NUM_LIT:0>  <EOL>new_mask = mask & ~old_mask  <EOL>npix_updated = np.count_nonzero(new_mask)<EOL>if npix_updated > <NUM_LIT:0>:<EOL><INDENT>pf[ext].data[new_mask] += dqval<EOL>pf['<STR_LIT>'].header.add_history('<STR_LIT>'.format(<EOL>time.ctime(), __version__, __vdate__))<EOL>pf['<STR_LIT>'].header.add_history(<EOL>'<STR_LIT>'.format(<EOL>npix_updated, ext, dqval))<EOL><DEDENT><DEDENT>if verbose:<EOL><INDENT>fname = '<STR_LIT>'.format(filename, ext)<EOL>print('<STR_LIT>'.format(dqval))<EOL>print('<STR_LIT>'.format(np.count_nonzero(mask)))<EOL>print('<STR_LIT>'.format(np.count_nonzero(old_mask)))<EOL>print('<STR_LIT>'.format(npix_updated))<EOL>if npix_updated > <NUM_LIT:0>:<EOL><INDENT>print('<STR_LIT>'.format(fname))<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>'.format(fname))<EOL><DEDENT><DEDENT>
Update the given image and DQ extension with the given
    satellite trails mask and flag.

    Parameters
    ----------
    filename : str
        FITS image filename to update.

    ext : int, str, or tuple
        DQ extension, as accepted by ``astropy.io.fits``, to update.

    mask : ndarray
        Boolean mask, with `True` marking the satellite trail(s).
        This can be the result(s) from :func:`make_mask`.

    dqval : int, optional
        DQ value to use for the trail. Default value of 16384 is
        tailored for ACS/WFC.

    verbose : bool, optional
        Print extra information to the terminal.