idlastro mrdfits and strings [message #68635] |
Wed, 11 November 2009 12:58 |
Chris Thom
Messages: 2 Registered: November 2009
|
Junior Member |
|
|
hi,
i spend a lot of time reading/writing idl structures to fits files
using the idlastro library commands mwrfits/mrdfits. I just noticed
the following behaviour, and wonder if it's a bug or a feature? If i
write a structure to a fits file with mwrfits, and read it back again
immediately, all the string tags will be space-padded out to the
longest string in that tag. i.e.
IDL> foo = replicate({mystrct, strtag:''},3)
IDL> foo[0].strtag = 'ABC'
IDL> foo[1].strtag = 'ABCDEF'
IDL> foo[2].strtag = 'ABCDEFGHI'
IDL> help,foo[0].strtag
<Expression> STRING = 'ABC'
IDL> help,foo[1].strtag
<Expression> STRING = 'ABCDEF'
IDL> help,foo[2].strtag
<Expression> STRING = 'ABCDEFGHI'
IDL> mwrfits, foo, 'foo.fits'
IDL> bar = mrdfits('foo.fits',1)
IDL> help,bar[0].strtag
<Expression> STRING = 'ABC '
IDL> help,bar[1].strtag
<Expression> STRING = 'ABCDEF '
IDL> help,bar[2].strtag
<Expression> STRING = 'ABCDEFGHI'
I'm not sure if these tags are being padded in the write or the read
phase, but it'd be nice if there was a way to trim these tags on read.
Or is there some reason this is a bad idea?
The work-around (sprinkling strtrim()s throughout the code) is
functional if a little ugly.
cheers
chris
|
|
|