Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fpack compression stopped working? #283

Closed
dstndstn opened this issue Dec 11, 2019 · 18 comments · Fixed by #285
Closed

Fpack compression stopped working? #283

dstndstn opened this issue Dec 11, 2019 · 18 comments · Fixed by #285

Comments

@dstndstn
Copy link
Contributor

Hi,

In fitsio 0.9.12, this code:

import fitsio
import numpy as np
img = np.zeros((1000,1000), np.float32)
fitsio.write('/tmp/test.fits.fz[compress R 100,100; qz -1e-4]', img, clobber=True)

produces a FITS file that is fpack compressed.

In fitsio 1.0.5, the same code results in a non-compressed file.

Also, clobber=True doesn't work in the latter case.

This is in python3, with fitsio installed on a fresh ubuntu 18.04 container using
pip3 install fitsio==0.9.12
or
pip3 install fitsio==1.0.5

cheers,
--dustin

@dstndstn
Copy link
Contributor Author

1.0.2 shows the same behavior as 1.0.5

@dstndstn
Copy link
Contributor Author

Same with 1.0.1

@dstndstn
Copy link
Contributor Author

Down at DESI LegacySurvey.org headquarters, this is forcing us to revert back to 0.9.12

@esheldon
Copy link
Owner

I never even knew that this worked, putting compress information into the filename, it isn't something I ever tested.

@esheldon
Copy link
Owner

the clobber fails because it looks for that filename, including the bracketed information

@dstndstn
Copy link
Contributor Author

dstndstn commented Dec 24, 2019 via email

@dstndstn
Copy link
Contributor Author

dstndstn commented Dec 24, 2019 via email

@beckermr
Copy link
Collaborator

Ugh. The fits standard has too many features. Supporting everything and making sure it doesn’t break is a pain for sure. :/

@esheldon
Copy link
Owner

In the short term you can keep 1.x (and proper python 3 strings etc) and instead add this information to a header that you write, and then run fpack yourself on it

@esheldon
Copy link
Owner

As for a solution, the right thing to do is probably to just try opening the file with cfitsio and looking for error conditions rather than doing filename processing in python

@dstndstn
Copy link
Contributor Author

dstndstn commented Dec 24, 2019 via email

@esheldon
Copy link
Owner

(above was solution for clobber)

a solution for the compression issue is probably something to do with python 3 strings and conversion to a c string in the C code

@beckermr
Copy link
Collaborator

There is an open issue about using this lib with an in memory file btw. If you have an example of how to do that, can you post it?

@esheldon
Copy link
Owner

the string that's being fed to cfitsio looks fine... I'm a bit baffled. Maybe there is a problem with the updated version of cfitsio we are using, or our hacks to cfitsio

@moustakas
Copy link

@esheldon @beckermr any additional thoughts on this issue? We're a couple short weeks away from launching DR9 (http://legacysurvey.org) and although 0.9.12 doesn't suffer from the fpack compression bug reported here, it has a number of other problems that were fixed in fitsio/1.0.x.

@beckermr
Copy link
Collaborator

I've got nothing here. Can you check cfitsio 3470 at the C level directly?

Assuming that works, then it is us. Otherwise, we will need to find / patch the bug or rollback the update.

@beckermr
Copy link
Collaborator

BTW, the version of cfitsio we bundle is here: https://github.com/esheldon/fitsio/tree/master/cfitsio3470

We apply patches to the build from here: https://github.com/esheldon/fitsio/tree/master/patches

So you might also check the actual version we use with patches at the C level as well.

@esheldon
Copy link
Owner

I've been unusually swamped, but I can try to look at this soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants