JuliaAstro / FITSIO.jl

Flexible Image Transport System (FITS) file support for Julia
http://juliaastro.org/FITSIO.jl/
MIT License
55 stars 29 forks source link

Cannot open GZip compressed file #160

Closed karlwessel closed 3 years ago

karlwessel commented 3 years ago

When I try to open a GZipped file (.fits.gz-extension) I get the following error message

julia> using FITSIO

julia> FITS("pyobs-20210305-0228-e00.fits.gz")
ERROR: CFITSIO has encountered an error while processing pyobs-20210305-0228-e00.fits.gz. Error code 113: could not allocate memory
Detailed error message follows: 
Failed to reduce size of allocated memory (compress_open)
failed to find or open the following file: (ffopen)
pyobs-20210305-0228-e00.fits.gz

Stacktrace:
 [1] fits_assert_ok at .julia/packages/CFITSIO/uzw9u/src/CFITSIO.jl:205 [inlined]
 [2] fits_open_file(::String, ::Int64) at .julia/packages/CFITSIO/uzw9u/src/CFITSIO.jl:294
 [3] FITS(::String, ::String) at .julia/packages/FITSIO/dBcm0/src/FITSIO.jl:170 (repeats 2 times)
 [4] top-level scope at REPL[4]:1

Opening the file with astropy works fine.

If you want I can also upload the fits file where it does not work.

This is the state of my environment:

(jl_BYqwHQ) pkg> st
Status `/tmp/jl_BYqwHQ/Project.toml`
  [525bcba6] FITSIO v0.16.7
giordano commented 3 years ago

It works for me with this FITS file, compressed with gzip:

julia> using FITSIO

julia> FITS("WFPC2u5780205r_c0fx.fits.gz")
File: WFPC2u5780205r_c0fx.fits.gz
Mode: "r" (read-only)
HDUs: Num  Name                   Type        
      1                           Image       
      2    u5780205r_cvt.c0h.tab  ASCIITable  

But 99% this is an upstream issue with CFITSIO, we don't do anything special to open compressed files (differently from Astropy, see #135)

karlwessel commented 3 years ago

Thanks for the quick check!

For that one it works for me to. It also works if I create a gzipped FITS file with astropy.

Don't know whats wrong with that file.

For now I will just use GZip.jl to decompress the file it into a temporary file beforehand.

karlwessel commented 3 years ago

I will close this, since it seems to be some special problem with my file. And maybe it could be solved by FileIOs handling of compressed files...