Converting fit.fz files before uplaod

Skip to first unread message

Carrie Nugent

Jul 25, 2022, 12:31:40 PMJul 25
to astrometry
Hi all,

I'd like to upload a set of fit.fz files, but that's not a supported file type. I've tried converting them to .fits files using:

from import fits
    with as hdul:
        hdul.writeto(new_name, overwrite=True)

Where image_path is the fit.fz file and new_name is the .fits file. But when I upload the resulting .fits file, I get the error:", line 612, in dosub img = get_or_create_image(df, tempfiles=tempfiles) File "", line 663, in get_or_create_image raise Exception("This file's type is not supported.") Exception: This file's type is not supported.

so the conversion isn't behaving as I intend. I can convert the fit.fz files to fits using DS9, but I'd like a solution I can apply to large number of files. Any help is welcome.



Dustin Lang

Jul 25, 2022, 1:57:32 PMJul 25
to Carrie Nugent, astrometry
Hi, isn't smart about multi-HDU image either! -- FITS images have to be in the primary HDU -- is there any chance that astropy is writing out an empty primary HDU followed by an image extension HDU?

(If you send a submission ID I can dig into the details.)


You received this message because you are subscribed to the Google Groups "astrometry" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Carrie Nugent

Jul 26, 2022, 2:56:35 PMJul 26
to Dustin Lang, astrometry
Hi Dustin,

Thanks for the advice. Here's a solution, in case it is useful to others:

    with as hdul:
        files[name]["data"] = hdul[1].data
        files[name]["header"] = hdul[1].header
    hdu = fits.PrimaryHDU(files[name]["data"], header=files[name]["header"])
    hdu.writeto(new_file_name, overwrite=True)

Reply all
Reply to author
0 new messages