[AstroPy] writing 2D string column to fits binary table

Erin Sheldon erin.sheldon at gmail.com
Tue Jan 27 18:45:09 EST 2015


On 1/27/15, Stephen Bailey <stephenbailey at lbl.gov> wrote:
> On Tue, Jan 27, 2015 at 10:28 AM, Erin Sheldon <erin.sheldon at gmail.com>
> wrote:
>
>> Hi Stephen -
>>
>> This is a difficult problem I think.
>>
>> In FITS, the strings must get padded with spaces when written.  That is
>> my
>> understanding of the format.
>>
>
> From
> https://archive.stsci.edu/fits/fits_standard/node70.html#SECTION001233130000000000000
> :
>
> 8.3.3 Data Sequence -> 8.3.3.1 Main Data Table  -> Character
>
> If the value of the TFORMn keyword specifies data type A, field n shall
> contain a character string of  zero or more members, composed of  ASCII
> text. This character string may be terminated before the length specified
> by the repeat count  by  an ASCII NULL (hexadecimal code 00). Characters
> after the first ASCII NULL are not defined. A string with the number of
> characters specified by the repeat count is not NULL terminated. Null
> strings are defined by the presence of an ASCII NULL as the first
> character.
>
>
> This indicates that padding with NULLs is the correct thing to do when the
> string is shorter than the field.  This is also how the data are in the
> ndarray memory and it is distinguishable from the case of strings that end
> with trailing spaces when reading it back in.

Hi Stephen -

Interesting, compare this to the cfitsio manual

http://heasarc.nasa.gov/docs/software/fitsio/c/c_user/node24.html

So this may be cfitsio specific, and perhaps something we should work around
in fitsio.

-e

-- 
Erin Scott Sheldon
Brookhaven National Laboratory erin dot sheldon at gmail dot com



More information about the AstroPy mailing list