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

Stephen Bailey stephenbailey at lbl.gov
Tue Jan 27 19:29:20 EST 2015


On Tue, Jan 27, 2015 at 3:45 PM, Erin Sheldon <erin.sheldon at gmail.com>
wrote:

> 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.
>

Gack.  My interpretation of that is that cfitsio is violating the FITS
standard by doing something crazy with padding and stripping spaces.  If
you have some way of working around that in fitsio, that would be great.

Stephen


>
> -e
>
> --
> Erin Scott Sheldon
> Brookhaven National Laboratory erin dot sheldon at gmail dot com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20150127/3faac60c/attachment.html>


More information about the AstroPy mailing list