[AstroPy] help with writing a boolean column with astropy.io.Table

Rose Finn rfinn at siena.edu
Thu Jan 9 13:01:21 EST 2014


Thanks Tom, for your quick reply!  In case this is useful, when I open
test.fits in topcat (v3.9), the column data is not imported correctly -
there are no values under the test column, nor the typical buttons that
appear with other boolean columns.  Topcat does know it is a boolean column
with format code L.  So this seems to indicate that there is something
non-standard in how the column is written.

Take care,
Rose


On Thu, Jan 9, 2014 at 12:44 PM, Aldcroft, Thomas <
aldcroft at head.cfa.harvard.edu> wrote:

> Hi Rose,
>
> I'm able to reproduce this and I've confirmed that the test.fits file
> output seems to be correct (by reading with an independent FITS reader).
>  This would appear to be a bug in FITS reading, though it's just a little
> surprising that something so basic as reading a FITS file with a boolean
> column could have a bug like this.
>
> I'm opening an astropy github issue on this now.
>
> - Tom
>
>
> On Thu, Jan 9, 2014 at 11:57 AM, Finn, Rose <rfinn at siena.edu> wrote:
>
>> Hi,
>>
>> I am trying to write a fits table with astropy.io.Table and am having
>> trouble with a boolean array.  Basically, all the values turn out to be
>> false, regardless of what the values are in the input array.  I have
>> included an example below - any help would be appreciated!  I am trying to
>> avoid writing the table with astropy.io.fits because it is cumbersome.
>>  Everything works fine with floating point arrays.
>>
>> Thanks,
>> Rose
>>
>>
>> from astropy.io import Column
>>
>> from astropy.table import Table
>>
>> from astropy.table import Column
>>
>> newcol=Column(data=np.ones(10),name='test',dtype='bool')
>>
>> dt=Table()
>>
>> dt.add_column(newcol)
>>
>> dt.write('test.fits')
>>
>> dat=dt.read('test.fits')
>>
>> In [*48*]: dat['test']
>>
>> Out[*48*]:
>>
>> <Column name='test' unit=None format=None description=None>
>>
>> array([False, False, False, False, False, False, False, False, False,
>> False], dtype=bool)
>>
>>
>> In [*45*]: newcol
>>
>> Out[*45*]:
>>
>> <Column name='test' unit=None format=None description=None>
>>
>> array([ True,  True,  True,  True,  True,  True,  True,  True,  True,
>> True], dtype=bool)
>>
>>
>> --
>> Rose A. Finn
>> Department of Physics & Astronomy
>> Siena College
>> Loudonville, NY  12211
>>
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at scipy.org
>> http://mail.scipy.org/mailman/listinfo/astropy
>>
>>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>
>


-- 
Rose A. Finn, PhD
Department of Physics & Astronomy
Siena College
Loudonville, NY
(518) 782-6764
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20140109/73084b5c/attachment.html>


More information about the AstroPy mailing list