How can I use `sunpy.io.header` to read a header from a URL?

I have URLs to header files, like this one:

https://gong2.nso.edu/HA/hah/201102/20110225/20110225175454Bh.hdr

Is there any of the astropy/sunpy modules that I can use to access such headers’ content without downloading + saving + loading + parsing the files?

Maybe sunpy.io.header, but I can’t find how to do that!

Hi,

Sorry for the late reply (I forgot to enable tag notifications), from what I can see there is no easy way to do that.

Most of functions that are present in sunpy.io assume the file is local at the very least and while some functions handle URLS, they will error if the file isn’t a FITS file.

What you can do is this however:

from astropy.io import fits
from astropy.utils.data import download_file

url =  "https://gong2.nso.edu/HA/hah/201102/20110225/20110225175454Bh.hdr"
fits.Header.fromtextfile(download_file(url))
1 Like

Thanks @nabobalis .
This probably is the next best thing.