[AstroPy] BSCALE/BZERO

Diego Farias dnfarias at uc.cl
Sat Oct 28 14:10:25 EDT 2017


Hi Matt and everyone:

I did the same 'experiments'! and I realized that I 'loose' information if
I scale to 'uint16' . That's why I don't understand the problem because I
have been told that
the *PIXEL VALUES *should remain the same it's just that the dynamic range
with the BITPIX=16,BZERO=32767 should be from 0 to 65535. As I'm not clever
enough I'm stuck in this step.. I'm guessing that later we need to use
another astronomical tool that requires the images with BITPIX = 16. In my
despair, I found this:

https://github.com/varenius/salsa/blob/master/Control_program/spectrum.py

where the important step is

#Since using int16 as datatype we use bscale and bzero to keep dynamic
range. #SalsaJ cannot read bitpix correctly except 16 bit. If SalsaJ could
read bitpix #we could just have BITPIX -64 and skip Bscale, Bzero, i.e.
just remove #astype above.

datamin = np.min(self.data)
datamax = np.max(self.data) bscale = (datamax-datamin)/65534.0 #shouldn't
be 65535.0? bzero = datamin+bscale*32767.0 scaledata = (self.data -
bzero)/bscale
hdu.data = scaledata.reshape(1, 1, self.nchans).*astype(np.int16)*

Shouldn't this *also changes *the values? (in this case, spectrum values).
Also,
bscale ~ 1., bzero ~ 326767.

Thanks a lot,

Diego
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20171028/6ce72c26/attachment.html>


More information about the AstroPy mailing list