Re: HDF Data sets containg strings? [message #13302] |
Mon, 02 November 1998 00:00  |
Richard Penrose
Messages: 4 Registered: November 1998
|
Junior Member |
|
|
David Fanning wrote:
> Richard Penrose (rpenrose@uk.ibm.com) writes:
>
>> I would very much like to be able to append an array of three character
>> strings to an HDF file using the 'HDF_SD_ADDDATA' command. I have tried
>> to do this without any luck, and can find no documentation to help me
>> with this.
>>
>> In the end I have had to resort to appending a 3*n dimensional array,
>> i.e. 3 characters * however many dimensions are required.
>>
>> Does anyone have a solution to this problem, I would be most grateful!
>
> I'm no HDF expert by any means, but a quick look at the
> HDF chapter in my IDL Programming Techniques book suggests that
> the HDF_SD_ADDDATA command is for adding a "slab" of data.
> I understand "slab" to mean a two or three dimensional
> array which has been assigned an SDS identifier with the
> HDF_SD_Create command. For character data, I guess I would
> use a byte array. Probably something like this:
>
> strArray = StrArr(4)
> strArray[0] = 'ABC'
> strArray[1] = 'DEF'
> strArray[2] = 'GHI'
> strArray[3] = 'JKL'
> hdfFileID = HDF_SD_START('newfile.hdf')
> sdsID = HDF_SD_CREATE(hdfFileID, 'Comment Array', [3,4], /Byte)
> HDF_SD_ADDDATA, sdsID, Byte(strArray)
>
> Another alternative is to add each string to the file as a file
> attribute with the HDF_SD_AttrSet command.
>
> Cheers,
>
> David
> ----------------------------------------------------------
> David Fanning, Ph.D.
> Fanning Software Consulting
> E-Mail: davidf@dfanning.com
> Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
>
> Note: A copy of this article was e-mailed to the original poster.
David
Thanks very much for you're prompt response.
I had already tried the 'byte' method that you suggested, it just creates a 3
* n dimensional dataset with a byte in each element, I actually did this
using '/STRING' instead of '/BYTE' the result is the same but you get
characters instead of byte values in each dataset element.
I hadn't thought of the 'HDF_SD_AttrSet' work around, I think I will either
use this or just accept that I'll get a dataset element for each character.
Thanks again
Richard
P.S. I thought the newsgroup was pretty good, its the first time I've used
it.
|
|
|