Converting fit.fz files before uplaod

19 views
Skip to first unread message

Carrie Nugent

unread,
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 astropy.io import fits
    with fits.open(image_path) 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:

...ns.py", line 612, in dosub img = get_or_create_image(df, tempfiles=tempfiles) File "process_submissions.py", 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.

Thanks!

Carrie

Dustin Lang

unread,
Jul 25, 2022, 1:57:32 PMJul 25
to Carrie Nugent, astrometry
Hi,

Astrometry.net 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 nova.astrometry.net submission ID I can dig into the details.)

cheers,
dustin


--
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 astrometry+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/astrometry/25b29bdf-0e2b-4f4b-aeb5-3b2d77a7267fn%40googlegroups.com.

Carrie Nugent

unread,
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 fits.open(image_path) 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)

Best,
Carrie
Reply all
Reply to author
Forward
0 new messages