code: def _write_header(self, image, hdu):
          
          hduhdr = hdu.header
  
          # Ginga image header object for the given extension only.
          # Cannot use get_header() because that might also return PRI hdr.
          ghdr = image.metadata['header']
  
          for key in ghdr:
              # Need this to avoid duplication because COMMENT is a weird field
              if key.upper() == 'COMMENT':
                  continue
  
              bnch = ghdr.get_card(key)
  
              # Insert new keyword
              if key not in hduhdr:
                  hduhdr[key] = (bnch.value, bnch.comment)
  
              # Update existing keyword
              elif hduhdr[key] != bnch.value:
                  hduhdr[key] = bnch.value
docs: Write header from image object to given HDU.