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

Home » Public Forums » archive » Reading HDF5 Variable
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
Reading HDF5 Variable [message #42521] Mon, 14 February 2005 07:14 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Folks,

Does anyone know if it is even *possible* to learn how
to access a variable from an HDF5 file from the IDL
documentation!?

I really don't have a week to figure this out. Does
anyone have a simple example. I can see and access
the data with H5_QUERY. But I can't make any sense
of the palette that is suppose to be attached to the
data. It is 976 elements long. That doesn't even
begin to divide by 256. :-(

What I am trying to do is extract a 2D image and its
accompanying palette in order to build and save a JPEG
file. (Typically I don't mind spending hours and hours
researching a topic, but the FAFSA Student Aid forms
are due today and I'm working on income taxes. :-(

Thanks,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Reading HDF5 Variable [message #42588 is a reply to message #42521] Mon, 14 February 2005 18:10 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
James Kuyper writes:

> I'm not sure what you mean by a "variable". HDF5 files contain groups,
> which can contain datasets, and virtually any HDF5 feature can have an
> attribute. I'll assume you're talking about a dataset.

All I'm sayin' is, whatever you call it, you ain't
gonna learn about it from the IDL documentation!

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Reading HDF5 Variable [message #42591 is a reply to message #42521] Mon, 14 February 2005 16:43 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
David Fanning wrote:
> Folks,
>
> Does anyone know if it is even *possible* to learn how
> to access a variable from an HDF5 file from the IDL
> documentation!?

I'm not sure what you mean by a "variable". HDF5 files contain groups,
which can contain datasets, and virtually any HDF5 feature can have an
attribute. I'll assume you're talking about a dataset.

> I really don't have a week to figure this out. Does
> anyone have a simple example. I can see and access
> the data with H5_QUERY. But I can't make any sense
> of the palette that is suppose to be attached to the
> data. It is 976 elements long. That doesn't even
> begin to divide by 256. :-(
>
> What I am trying to do is extract a 2D image and its
> accompanying palette in order to build and save a JPEG
> file. (Typically I don't mind spending hours and hours
> researching a topic, but the FAFSA Student Aid forms
> are due today and I'm working on income taxes. :-(

I didn't know much of anything about HDF5 a few minutes ago, but I am
quite familiar with HDF4. The IDL interface for HDF5 is sufficiently
similar to the one for HDF4 that it didn't take me long to figure out
the following from the IDL documentation. However, I have no easy way to
obtain a test file to try it with. Since you're having problems, and
this was so trivial, I presume that it either doesn't work, or that
you're talking about something else.

file_id = H5F_Open(filename)
dataset_id = H5D_Open(file_id, dataset_name)
data = H5D_Read(dataset_id)
H5D_Close, dataset_id
H5F_Close, file_id
Re: Reading HDF5 Variable [message #42595 is a reply to message #42521] Mon, 14 February 2005 14:12 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
>> Cool. I tried doing this a while back but I was never successful.
>> Which versions of hdfdump and ncgen are you using? If I can simply do
>> that from the command line now, that'd be so much easier.
>
>
> Oopsy - I should've read the subject line closer. I've only done it for
> HDF4 files (v4.1r3). Sorry. When I found out HDF5 was incompatible with
> HDF4 (is that still true?) I avoided HDF5 like the plague and plead
> total ignorance when someone wants to give me a HDF5 file. ;o)
>
> However, if the hdfdump for HDF5 libraries outputs in CDL, ncgen should
> understand it, right? I just had a quick look at the HDF5 website and
> h5dump doesn't mention CDL, just XML. Bummer. Maybe h5toh4 -> h4dump ->
> ncgen ??
>

Yeah, I was working with HDF5 rather than HDF4. While I attempt to
avoid HDF5 like the plague some of my scientific colleagues do not. The
hdf5 -> hdf4 -> netCDF route isn't one I've thought of before -- maybe
I'll give that a try one day.

-Mike
Re: Reading HDF5 Variable [message #42597 is a reply to message #42521] Mon, 14 February 2005 14:03 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Michael Wallace wrote:
>> Hey - me too! Except rather than write a conversion program each time,
>> I just pipe the hdfdump[*] utility output into the ncgen utility to
>> convert files I use. E.g.
>>
>> hdfdump <hdfile> | ncgen -b <ncfile>
>>
>> and I end up with a nice simple, useful netCDF file. :o)
>>
>
> Cool. I tried doing this a while back but I was never successful. Which
> versions of hdfdump and ncgen are you using? If I can simply do that
> from the command line now, that'd be so much easier.

Oopsy - I should've read the subject line closer. I've only done it for HDF4 files
(v4.1r3). Sorry. When I found out HDF5 was incompatible with HDF4 (is that still true?) I
avoided HDF5 like the plague and plead total ignorance when someone wants to give me a
HDF5 file. ;o)

However, if the hdfdump for HDF5 libraries outputs in CDL, ncgen should understand it,
right? I just had a quick look at the HDF5 website and h5dump doesn't mention CDL, just
XML. Bummer. Maybe h5toh4 -> h4dump -> ncgen ??

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Mapping the Pacific
Next Topic: GDL 0.8.8 released...

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

Current Time: Wed Oct 08 18:09:51 PDT 2025

Total time taken to generate the page: 0.00437 seconds