[AstroPy] Need Help about Astropy.table.Table.write

Peter Teuben teuben at astro.umd.edu
Fri Jul 25 08:19:43 EDT 2014


Guang,
   in your case I think you were done a service, so make 'ct' become
"count", since the (FITS) community has decided this to be a better more
descriptive word. Most non-english speakers might even have difficulties
with "ct" so your desire to there be a future that can override the fits
standard has to be take with caution, especially if the column has a 
meaning we already agreed upon.

Perhaps the code can emit a warning and refer to the FITS resource where
all the units are defined, or even spit out the ones the code knows
about .... heaven forbid?

peter

On 07/25/2014 08:07 AM, Guang Yang wrote:
> Hi Tom,
>
> Great, it works. Hope in the future there will be keywords that can overriede the fits standard constraints. 
>
> Thank you very much,
> Guang
>
>
>> -----Original email-----
>> From: "Thomas Robitaille" <thomas.robitaille at gmail.com>
>> Sent Time: Jul 25, 2014 6:59:21 PM
>> To: "Astronomical Python mailing list" <astropy at scipy.org>
>> Cc: 
>> Subject: Re: [AstroPy] Need Help about Astropy.table.Table.write
>>
>> Hi Guang,
>>
>> To overwrite a file, you can use:
>>
>>   cat.write('new.fits', format='fits', overwrite=True)
>>
>> For the unit, the issue is that ``ct`` is not a valid unit according to
>> the FITS standard. The 'correct' unit for FITS is ``count``. We may be
>> overly strict at the moment in that Table.write will simply crash if a
>> unit is not standard-compliant, when we could simply emit a warning and
>> still write it out, so I will open an issue for that.
>>
>> So in the mean time, the solution is to do:
>>
>>   cat['name'].unit = 'count'
>>
>> where 'name' is the name of the problematic column. Do this before
>> writing it out to FITS.
>>
>> Cheers,
>> Tom
>>
>> Guang Yang wrote:
>>> Hi All,
>>>
>>> I've found Astropy.table.Table.write is unable to write tables with arbitrary units. 
>>> For example, after using sextractor to generate a fits table, 
>>>
>>> from astropy.table import Table
>>> cat = Table.read('sextractor_output.fits', format='fits')
>>> cat.write('new.fits', format='fits')
>>>
>>> Then, the error comes: Unit u'ct' is not part of the FITS standard. And I've found no parameter to avoid the unit problem.
>>>
>>> Also, when the file 'new.fits' already exists, there seems to be no keyword to overwrite the file.
>>>
>>> Thanks,
>>> Guang Yang
>>>
>>>  
>>>
>>>
>>>
>>> _______________________________________________
>>> 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
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy




More information about the AstroPy mailing list