Repository navigation
A few minor improvements to scaling and uint support - #3916
Conversation
…n _ImageBaseHDU. In addition to being non-pep-8, they are not very meaningfully named, and apply more broadly than to just image HDUs (though in fairness they apply *mostly* to image HDUs).
…e HDU summaries for scaled images to better indicate that the data will be rescaled upon access. The behavior here is still somewhat cryptic, but at least there's better indication that *something* will happen--users can then consult the documentation for more information.
… anymore but by deprecating it we can later remove this.
…lanations of the defaults.
…fault. This convention is documented in the current version of the FITS standard, and it is fairly unambiguous when it is intended to be used. For the sake of user-friendliness it should be assumed by default.
|
Incidentally, this also fixes #3766. I'm just going to cherry pick that one change out as a separate fix. |
…s to fix astropy#3766; included a regression test.
|
Need to double check if this merits any documentation changes (including a changelog entry, of course) before merging. |
…s, although they should. So I added a note explaining how FITS handles them, including how Astropy now handles them. Added a changelog entry.
|
Added a note in the docs about unsigned integers, as there really wasn't anything there before. |
A few minor improvements to scaling and uint support
…s to fix astropy#3766; included a regression test.
…s to fix astropy#3766; included a regression test.
…s to fix astropy#3766; included a regression test.
|
@embray -- what is the expected behavior of the If With If that is the intended behavior, I can add something about it to the docs. If it is not the intended behavior, I can try to fix so that |
|
@mwcraig Thanks for the catch--that sounds like a regression to me. |
|
@embray -- I see the same behaviour in 1.0.3 if I set |
|
Okay, so not technically a regression, but definitely not intentional either. |
|
Actually, no, I stand corrected. |
|
So it is intentional? |
|
Sorry, it is intentional now that I think harder about it. The reason is that there is no native unsigned integer type in FITS. So when you read unsigned int data, although technically it is rescaled, it leaves BZERO in the header because "BITPIX = N" plus "BZERO = 2**(N-1)" is the only way to unambiguously write "the data currently in the The difference with arbitrary BSCALE/BZERO is that the data is being rescaled from some storage values (perhaps detector counts or some other quantized data) to "physical values" via the scaling, and the implication is that unless otherwise requested the data will remain as the physical values (so as to not lose accuracy in case the data is modified in any way). Unsigned ints on the other hand are a special case since they're using BZERO as a kludge to represent a data type that FITS doesn't already natively support :( |
|
This should go in the docs somewhere, I guess. One day I still want a less confusing way to represent this.... (somewhere else I've mentioned wanting to make a cleaner distinction between the "logical" data (including headers) and the raw data of the FITS serialization....) |
|
I see - so in the case when It seems like that makes the meaning of the data a little ambiguous though...how does one know whether it has already been scaled with BZERO? It is remarkable that FITS can't represent something simple like this! |
|
I'll poke through the docs for a place to add it. Is there a recommended way to know whether the data has been scaled? |
|
So with Part of the point of this PR is that |
|
Makes sense -- so if, in a test, I want to check that data has been scaled, I could do something like |
|
Of course, that would only work if you knew the data had to be rescaled in the first place. If it didn't then that test (at least when applied to floats) would result in a false-positive. Maybe something we could do for now, until there's a better solution, is to publicly expose some of the the |
… that should have been included with astropy#3916 [skip ci]
…s to fix astropy#3766; included a regression test.
… that should have been included with astropy#3916 [skip ci]
See astropy/astropy#3916 for background
Just a grab bag of minor improvements from a branch I started but didn't do much else with yet (I think I had planned to do more but better to start fresh).
This improves somewhat on the surprising behavior that a FITS HDU's type changes after accessing the data when scaled data is present. Now,
fits.info()gives more info about scaled images ahead of time.This also enables unsigned integer support by default. The current version of the FITS standard even describes the convention of using BZERO=2**(BITPIX - 1) to represent unsigned ints. Although it is still "merely" a convention there's almost no reason not to assume this was the intent in practice. This hopefully shouldn't break anything existing, but in the odd case that it does the default can be changed via a config flag.