Hi Tom,
Thanks for your question. Below I've included a minimal working version of your code snippet. Note that here I am using astropy v5.0, sunpy v3.1.3 and aiapy v0.6.4.
```
import sunpy.map
import aiapy
from aiapy.calibrate import update_pointing
from astropy.io.fits import CompImageHDU
m_l1 = sunpy.map.Map(dataFile)
m_l1_pupdate = update_pointing(m_l1)
m_l1_pupdate.meta['history'] = f'AIApy (v{aiapy.__version__}): Update pointing'
m_l1_pupdate.save('data/TestOutput.fits', checksum=True, hdu_type=CompImageHDU, overwrite=True)
# Or using sunpy.io.fits
sunpy.io.fits.write('data/TestOutput.fits', m_l1_pupdate.data, m_l1_pupdate.fits_header, checksum=True, hdu_type=CompImageHDU, overwrite=True)
# Or using astropy.io.fits
CompImageHDU(m_l1_pupdate.data, m_l1_pupdate.fits_header).writetoto('data/TestOutput.fits', checksum=True, overwrite=True)
```
A few clarifying comments:
* All three ways of writing the file out to a FITS file should yield equivalent results.
* The `fits_header` property of a sunpy Map is immutable and is just a representation (in astropy.io.fits.Header
format) of the `meta` attribute. This is why you're change was not updating the header. If you want to explicitly modify the
underlying metadata, you should modify the keys in `map.meta`. This will then be reflected in `map.fits_header`.
* The most convenient way to write a Map to a FITS file is through the Map.save method. As I've shown above, most of the arguments that you can pass to sunpy.io.fits.write (and by extension astropy.io.fits.writeto) can also be passed to Map.save.
* Regarding your statement "I understand that SunPy FITS and AstroPy
FITS do not exactly play nice together," sunpy.io.fits is a wrapper
around astropy.io.fits that provides a lot of convenience when dealing
with solar data. This convenience is at the cost of generality. The main
purpose of sunpy.io.fits is to provide a FITS reader for 2D image data
ingested through sunpy.map.Map and a writer for sunpy.map.Map.save. For a general purpose FITS reader or in cases where you want *very* fine-grained control over what gets written to your FITS file, astropy.io.fits is the recommended solution.
* I am unsure as to what is causing the SunpyMetadataWarning. I was not able to reproduce that behavior.
Best,
Will