[AstroPy] AstroPy Digest, Vol 117, Issue 3

Leonard Burtscher burtscher at mpe.mpg.de
Fri Jun 10 09:40:55 EDT 2016


Hi Pey-Lian,

Indeed this bug is similar to what I described, but not the same. I have added to this bug report.

Regards,
Leonard


> Am 10.06.2016 um 14:54 schrieb Pey Lian Lim <p3y1i4n at gmail.com>:
> 
> Hi Leonard,
> 
> Perhaps your issue has been reported at https://github.com/astropy/astropy/issues/4588 by someone else.
> 
> Sincerely,
> Pey-Lian
> 
> 
> On Fri, Jun 10, 2016 at 8:00 AM, <astropy-request at scipy.org> wrote:
> Send AstroPy mailing list submissions to
>         astropy at scipy.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.scipy.org/mailman/listinfo/astropy
> or, via email, send a message with subject or body 'help' to
>         astropy-request at scipy.org
> 
> You can reach the person managing the list at
>         astropy-owner at scipy.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of AstroPy digest..."
> 
> 
> Today's Topics:
> 
>    1. Error when reading binary table with scaled integers
>       (Leonard Burtscher)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Thu, 9 Jun 2016 15:39:59 +0200
> From: Leonard Burtscher <burtscher at mpe.mpg.de>
> To: Astronomical Python mailing list <astropy at scipy.org>
> Subject: [AstroPy] Error when reading binary table with scaled
>         integers
> Message-ID: <6688A424-5217-4A6B-BD50-FFA513218FA6 at mpe.mpg.de>
> Content-Type: text/plain; charset="us-ascii"
> 
> Hi,
> 
> I am trying to read an image cube with scaled integers that is contained in the binary table of a FITS file. I read the file with
> 
> hdu=fits.open(file)
> 
> and hdu.info() looks like this:
> 
> ...
> 7    IMAGING_DATA  BinTableHDU    107   1000R x 17C   ['1J', '1D', '1E', '2I', '2I', '1I', '2D', '2D', '2E', '1E', '1I', '1I', '2A', '1I', '2A', '4278I', '4278I']
> ...
> 
> And hdu[7].data.columns looks like this:
> 
> ColDefs(
>     [...other tables...]
>     name = 'DATA1'; format = '4278I'; unit = 'ADU'; bscale = 1.0; bzero = 32768.0; dim = '(62,69)'
>     name = 'DATA2'; format = '4278I'; unit = 'ADU'; bscale = 1.0; bzero = 32768.0; dim = '(62,69)'
> )
> 
> When trying to access these image cubes I get the following error:
> 
> 
> In [32]: img=hdu[7].data["DATA1"]
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call last)
> <ipython-input-32-426539ce5f7e> in <module>()
> ----> 1 img=hdu[7].data["DATA1"]
> 
> /usr/local/lib/python3.5/site-packages/astropy/io/fits/fitsrec.py in __getitem__(self, key)
>     482     def __getitem__(self, key):
>     483         if isinstance(key, string_types):
> --> 484             return self.field(key)
>     485         elif isinstance(key, (slice, np.ndarray, tuple, list)):
>     486             # Have to view as a recarray then back as a FITS_rec, otherwise the
> 
> /usr/local/lib/python3.5/site-packages/astropy/io/fits/fitsrec.py in field(self, key)
>     656                 # Handle all other column data types which are fixed-width
>     657                 # fields
> --> 658                 converted = self._convert_other(column, field, recformat)
>     659
>     660             self._converted[name] = converted
> 
> /usr/local/lib/python3.5/site-packages/astropy/io/fits/fitsrec.py in _convert_other(self, column, field, recformat)
>     875                         field = test_overflow
>     876                 else:
> --> 877                     field += bzero
>     878         elif _bool and field.dtype != bool:
>     879             field = np.equal(field, ord('T'))
> 
> TypeError: Cannot cast ufunc add output from dtype('float64') to dtype('uint16') with casting rule 'same_kind'
> 
> 
> Can someone help me out?
> 
> Thanks,
> Leonard
> 
> --
> http://www.mpe.mpg.de/~burtscher/
> 
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: smime.p7s
> Type: application/pkcs7-signature
> Size: 4709 bytes
> Desc: not available
> URL: <https://mail.scipy.org/pipermail/astropy/attachments/20160609/fe1fb70b/attachment-0001.p7s>
> 
> ------------------------------
> 
> Subject: Digest Footer
> 
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> https://mail.scipy.org/mailman/listinfo/astropy
> 
> 
> ------------------------------
> 
> End of AstroPy Digest, Vol 117, Issue 3
> ***************************************
> 
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> https://mail.scipy.org/mailman/listinfo/astropy

--
http://www.mpe.mpg.de/~burtscher/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4709 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/astropy/attachments/20160610/05367139/attachment.bin>


More information about the AstroPy mailing list