'Update the header keywords to agree with the data.'

def update_header(self):

    if (not (self._modified or self._header._modified or (self._has_data and (self.shape != self.data.shape)))):
        return
    old_naxis = self._header.get('NAXIS', 0)
    if ('BITPIX' not in self._header):
        bitpix_comment = self.standard_keyword_comments['BITPIX']
    else:
        bitpix_comment = self._header.comments['BITPIX']
    self._header.set('BITPIX', self._bitpix, bitpix_comment, after=0)
    if (self._has_data and (self.shape != self.data.shape)):
        self._axes = list(self.data.shape)
        self._axes.reverse()
    if ('NAXIS' in self._header):
        naxis_comment = self._header.comments['NAXIS']
    else:
        naxis_comment = self.standard_keyword_comments['NAXIS']
    self._header.set('NAXIS', len(self._axes), naxis_comment, after='BITPIX')
    for (idx, axis) in enumerate(self._axes):
        naxisn = ('NAXIS' + str((idx + 1)))
        if (naxisn in self._header):
            self._header[naxisn] = axis
        else:
            if (idx == 0):
                after = 'NAXIS'
            else:
                after = ('NAXIS' + str(idx))
            self._header.set(naxisn, axis, after=after)
    for idx in range((len(self._axes) + 1), (old_naxis + 1)):
        try:
            del self._header[('NAXIS' + str(idx))]
        except KeyError:
            pass
    if ('BLANK' in self._header):
        self._blank = self._header['BLANK']
    self._update_uint_scale_keywords()
    self._modified = False
