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

Home » Public Forums » archive » HDF_VD_WRITE for string data
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
HDF_VD_WRITE for string data [message #62875] Tue, 14 October 2008 05:32 Go to next message
Brian is currently offline  Brian
Messages: 27
Registered: March 2001
Junior Member
I'm attempting to add string data to VDATA. I've been mixing data
types using the HDF_PACKDATA function (float and long in example
below), but can't get the string type to work. Instead of "Test" I get
a 4 byte value.

Any suggestions?

------------------------------------------------------------ ------------------------------------------
PRO testvd

fid = HDF_OPEN('out.hdf', /CREATE)
Vdat = HDF_VD_ATTACH(fid, -1, /WRITE)
HDF_VD_SETINFO, Vdat, NAME='ancillary'
HDF_VD_FDEFINE, Vdat, 'VAR1', /FLOAT, ORDER=1
HDF_VD_FDEFINE, Vdat, 'VAR2', /LONG, ORDER=1
HDF_VD_FDEFINE, Vdat, 'VAR3', /BYTE, ORDER=4

v1 = 134.5
v2 = 30000L
v3 = 'Test'

odata = HDF_PACKDATA(v1,v2,v3,HDF_TYPE=[5,24,4],HDF_ORDER=[0,0,4])
HDF_VD_WRITE,Vdat,'VAR1, VAR2, VAR3',odata

HDF_VD_Detach,Vdat
HDF_CLOSE, fid

END
Re: HDF_VD_WRITE for string data [message #62955 is a reply to message #62875] Tue, 14 October 2008 11:42 Go to previous message
jameskuyper is currently offline  jameskuyper
Messages: 79
Registered: October 2007
Member
Brian wrote:
> I'm attempting to add string data to VDATA. I've been mixing data
> types using the HDF_PACKDATA function (float and long in example
> below), but can't get the string type to work. Instead of "Test" I get
> a 4 byte value.
>
> Any suggestions?
>
> ------------------------------------------------------------ ------------------------------------------
> PRO testvd
>
> fid = HDF_OPEN('out.hdf', /CREATE)
> Vdat = HDF_VD_ATTACH(fid, -1, /WRITE)
> HDF_VD_SETINFO, Vdat, NAME='ancillary'
> HDF_VD_FDEFINE, Vdat, 'VAR1', /FLOAT, ORDER=1
> HDF_VD_FDEFINE, Vdat, 'VAR2', /LONG, ORDER=1
> HDF_VD_FDEFINE, Vdat, 'VAR3', /BYTE, ORDER=4
>
> v1 = 134.5
> v2 = 30000L
> v3 = 'Test'
>
> odata = HDF_PACKDATA(v1,v2,v3,HDF_TYPE=[5,24,4],HDF_ORDER=[0,0,4])
> HDF_VD_WRITE,Vdat,'VAR1, VAR2, VAR3',odata
>
> HDF_VD_Detach,Vdat
> HDF_CLOSE, fid
>
> END

HDF doesn't have a string type, as such. The closest it comes is an
array of character type. It has special type codes for DFNT_CHAR8 (=4)
and DFNT_UCHAR (=3). These are different type codes than the ones
used for 8 bit integers: DFNT_INT8(=20) and DFNT_UINT8(=21). However,
not all of the IDL HDF routine support all of the possible HDF type
codes. The /BYTE option of HDF_VD_FDEFINE is the only documented
option that produces an 8-bit type, and that type is DFNT_UINT8.

According to the documentation for "IDL and HDF Data Types",
DFNT_CHAR8 is recognized by IDL's routines, and in some unspecified
contexts it is matched up with IDL's string types, but HDF_VD_FDEFINE
is apparantly not one of those contexts.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: assign an octal number to a variable
Next Topic: Send object graphics hierarchy to POV-Ray destination class

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

Current Time: Fri Oct 10 01:05:52 PDT 2025

Total time taken to generate the page: 0.64011 seconds