-
Notifications
You must be signed in to change notification settings - Fork 57
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
Fix misinterpretation of byte order of blocks stored in FITS files #810
Fix misinterpretation of byte order of blocks stored in FITS files #810
Conversation
Codecov Report
@@ Coverage Diff @@
## master #810 +/- ##
==========================================
+ Coverage 94.26% 94.27% +0.01%
==========================================
Files 42 42
Lines 4971 4980 +9
==========================================
+ Hits 4686 4695 +9
Misses 285 285
Continue to review full report at Codecov.
|
FYI: I tested on the case that prompted the issue report and it does fix the issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this gives me a chance to review a part of the code I've never looked over before. Using this trickery of ASDF redirecting its blocks to FITS extension data sections makes me a bit queasy, not that I have better suggestions (though I wonder if making the FITS references more explicit and requiring manual data extraction might have been a better thing; but I haven't really thought about it).
I wonder why it took this long to find the problem. Seems like any access of raw data would have triggered this. I'll ask Jonathan.
I suspect this was hidden because |
Yeah but it has been doing that for a while. Did the jwst.datamodels bug actually counteract the ASDF bug? (so two wrongs do make a right?) |
This PR fixes an issue with reading binary blocks stored in FITS files.
When astropy reads data that requires scaling, it performs said scaling and returns the result in native byte order. Until now asdf has been assuming that all data from a FITS file is big-endian, since that's how the bytes are stored on disk, but due to the scaling operation that's not always the case.
The fix is to accept that the dtype reported by an array from a FITS file is correct.
CC @stscieisenhamer