comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » idlastro mrdfits and strings
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
idlastro mrdfits and strings [message #68635] Wed, 11 November 2009 12:58
Chris Thom is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Randomu seed initialization
Next Topic: Tough System Variable Question for the IDL Gurus

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:55:42 PDT 2025

Total time taken to generate the page: 0.00470 seconds