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

Home » Public Forums » archive » Re: writing a structure on an HDF5 file
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
Re: writing a structure on an HDF5 file [message #57782] Sun, 30 December 2007 20:49 Go to next message
Dave Haffner is currently offline  Dave Haffner
Messages: 1
Registered: December 2007
Junior Member
djanches,


In principle you can do the following to create an hdf5 compound
datatype out of your structure which you can get back using h5_parse
(w/ the READ_DATA keyword, of course). Your structure will be under
the _data tag.

btw, I wish HDF5 was the default IDL output format, or at least a
choice. Matlab affords this already.

Hope this is some help,
Dave

; write a structure to hdf5 as a compound datatype

file = 'filename.h5'
fid = H5F_CREATE(file)

datatype_id = H5T_IDL_CREATE(structdata)
dataspace_id=H5S_CREATE_SIMPLE(1) ; not so simple..

dataset_id = H5D_CREATE(fid,'datastr',datatype_id,dataspace_id)
H5D_WRITE, dataset_id, structdata

H5S_CLOSE, dataspace_id
H5T_CLOSE, datatype_id

H5F_CLOSE, fid

; check out the file

s=h5_parse('filename.h5',/read_data)
help, /structure, s.datastr._data




On Dec 29, 8:12 pm, djanc...@gmail.com wrote:
> I recently started working with HDF5 files and seems that all what I
> learned about managing regular HDF files in the past is not directly
> applied to HDF5.
> What I am trying to do is in theory simple.
> I am trying to write a structure into an HDF5 file. The structure
> contains all sort of data (i.e, arrays, integers, and some strings).
> I was wondering if there is a simple manner to create a new hdf5 file,
> put the structure in it and close it. Something that I could later
> open it and use the HDF5 Parse command to read the entire structure at
> once.
Re: writing a structure on an HDF5 file [message #57871 is a reply to message #57782] Mon, 31 December 2007 08:46 Go to previous message
djanches is currently offline  djanches
Messages: 2
Registered: December 2007
Junior Member
On Dec 30, 9:49 pm, Dave Haffner <davehaff...@gmail.com> wrote:
> djanches,
>
> In principle you can do the following to create an hdf5 compound
> datatype out of your structure which you can get back using h5_parse
> (w/ the READ_DATA keyword, of course). Your structure will be under
> the _data tag.
>
> btw, I wish HDF5 was the default IDL output format, or at least a
> choice. Matlab affords this already.
>
> Hope this is some help,
> Dave
>
> ; write a structure to hdf5 as a compound datatype
>
> file = 'filename.h5'
> fid = H5F_CREATE(file)
>
> datatype_id = H5T_IDL_CREATE(structdata)
> dataspace_id=H5S_CREATE_SIMPLE(1) ; not so simple..
>
> dataset_id = H5D_CREATE(fid,'datastr',datatype_id,dataspace_id)
> H5D_WRITE, dataset_id, structdata
>
> H5S_CLOSE, dataspace_id
> H5T_CLOSE, datatype_id
>
> H5F_CLOSE, fid
>
> ; check out the file
>
> s=h5_parse('filename.h5',/read_data)
> help, /structure, s.datastr._data
Thanks Dave,

I'll try this

>
> On Dec 29, 8:12 pm, djanc...@gmail.com wrote:
>
>> I recently started working with HDF5 files and seems that all what I
>> learned about managing regular HDF files in the past is not directly
>> applied to HDF5.
>> What I am trying to do is in theory simple.
>> I am trying to write a structure into an HDF5 file. The structure
>> contains all sort of data (i.e, arrays, integers, and some strings).
>> I was wondering if there is a simple manner to create a new hdf5 file,
>> put the structure in it and close it. Something that I could later
>> open it and use the HDF5 Parse command to read the entire structure at
>> once.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: M-I 5`Perse cution - 22 ,544 + 837 = 23 ,381
Next Topic: M I-5 Persec ution , th e BB C, televis ion a nd rad io

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

Current Time: Wed Oct 08 15:51:48 PDT 2025

Total time taken to generate the page: 0.00547 seconds