SunpyMetadataWarnings when using Hinode XRT data


I’ve now upgraded to Sunpy 4.0.1. Viewing Hinode XRT data now works, but I’m getting annoying warnings regarding missing metadata:

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

The plotting still works so apparently this metadata is not needed. I am the one who runs and monitors the Hinode XRT Level 1 archive generating pipeline and I can tell you that the metadata that is in those files is all there will be. So I don’t see any point in Sunpy generating such warnings.
There was discussion among us some time ago about which metadata to include and in the end we decided to include:

So, any chance that those warnings will go away when plotting XRT data in future versions of Sunpy?



Is there a document somewhere that defines the XRT Level 1 FITS header keywords?



Hi Jon,

Without looking at a XRT Level 1 file, it is difficult for me to say.

If you think this is an issue with how sunpy is getting the metadata from the level 1 FITS file, I would ask you open an issue on the sunpy repository: Issues · sunpy/sunpy · GitHub so we can work out the problem and ideally come to a resolution.

In our Map sources we try to ensure that an instrument’s file raises the least amount of warnings so it is possible, we have missed something in the XRTMap code and that would need updating.


Thanks Nabil. The Sunpy site gave me the impression that the preference was to use the openastronomy page to raise issues. I’m happy to raise an issue on the github page.
I don’t think it’s a problem with sunpy getting the metadata. The metadata isn’t there.


Hi Jack,

I don’t think that there is one for the L1 header keywords. The SolarSoft XRT Analysis Guide has a list of the keywords for the L0 files. The L1 files have additional keywords added.


From what you have written, I gather that XRT metadata files do not include the heliographic longitude of the spacecraft (either in Stonyhurst or in Carrington), despite having the heliographic latitude (SOLAR_B0). The problem with not having that information is that it is needed for any coordinate-aware plotting, such as overlaying a heliographic grid, or coordinate-aware transformation of the data, such as reprojecting the map to another observer, Thus, when SunPy can’t find the heliographic longitude in a file, it assumes that observer is at Earth center (i.e., the Stonyhurst heliographic longitude is zero).

So I don’t see any point in Sunpy generating such warnings.

For Hinode, the assumption that it is at Earth center is probably sufficiently accurate for nearly all use cases. However, since you choose not to include HGLN_OBS = 0 in the metadata (or something equivalent), and we are currently making a guess that it is appropriate to make that assumption, we must emit the warning.

Along the lines of what @nabobalis said, one solution would be to modify SunPy’s XRTMap so that it explicitly adds HGLN_OBS = 0 to the metadata before parsing the metadata.

The plotting still works so apparently this metadata is not needed.

This conclusion is flawed because, as stated in the warning, the assumption is made that the observer is at Earth center. So, plotting and everything else will of course work, but that’s because we have made up metadata to fill in the missing metadata.

Well the plotting works because it makes a reasonable assumption in lieu of the needed metadata. Kathy Reeves, Mark Weber and I had a discussion about what metadata to include sometime back and concluded that for Hinode XRT assuming an Earth centered location is good enough.
So yes, modifying XRTMap to explicitly add HGLN_OBS = 0 to the metadata would be a good solution.


A WIP PR is here add a fixed lon,lat values on advice from xrt instr team by nabobalis · Pull Request #6328 · sunpy/sunpy · GitHub if you would like to have a review of the changes.