AIA-related SunpyMetadataWarning: Missing metadata for observer

This issue is happenning in both Sunpy 5.0.1 and 5.1 RC:

I’m following the guide for Reprojecting to a Map Projection with a Custom Origin

When plotting the reprojected Postel map with Sunpy AIA sample AIA_171_IMAGE, I get

WARNING: SunpyMetadataWarning: Missing metadata for observer: assuming Earth-based observer.
For frame ‘heliographic_stonyhurst’ the following metadata is missing: hgln_obs,dsun_obs,hglt_obs
For frame ‘heliographic_carrington’ the following metadata is missing: dsun_obs,crln_obs,crlt_obs

Yet these keywords exist in the sample’s FITS headers:

from import fits
hdul =
kv = [hdul[1].header[key] for key in ['hgln_obs', 'dsun_obs', 'hglt_obs', 'crln_obs' , 'crlt_obs']]

[0.0, 151846026489.0, 0.048591, 340.698273, 0.048591]

It looks like the same issue that used to be reported (and solved) for XRT: SunpyMetadataWarnings when using Hinode XRT data

Is this a known issue or should I raise it in Github?

That warning shouldn’t be emitted, but I don’t know if it’ll be easy to fix. Go ahead and report it.

The keywords exist in the original FITS header, but the keywords are not carried over to the header for the reprojected map. That’s because observer heliographic location and distance are irrelevant for a map in Stonyhurst heliographic coordinates. So, the warning is correct that the keywords are not there, but ideally no code should looking for those keywords, which is why I say that the warning shouldn’t be emitted.

Okay, so the problem is not the out_map.plot() call, but rather the subsequent calls to out_map.draw_grid() and out_map.draw_limb(). You could manually add the keywords to the header of out_map, but the most expedient thing you can do to avoid the warning is to simply call aia_map.draw_grid() and aia_map.draw_limb() instead. Unlike out_map, aia_map has the full observer information.