Re: Need help with HDF_VD_WRITE!!! [message #32491] |
Sun, 13 October 2002 06:13 |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Liam E. Gumley wrote:
>> Brian Huether wrote:
>>
>> I thought I had it. But man this is so complicated. Say I have one
>> column of data with one field. All the following fail:
>>
>> IDL> fileid=HDF_OPEN('e:\huether\test7.hdf',/CREATE)
>> IDL> Vdat = HDF_VD_ATTACH(fileID, -1, /WRITE)
>> IDL> HDF_VD_WRITE, Vdat, 'PX', indgen(1,10)
>
> [stuff deleted]
>
> Have you considered using the HDF Scientific Data Set model instead?
> It's much more flexible and easy to use IMHO. For example:
>
> ;- Create the file
> hdfid = hdf_sd_start('test.hdf', /create)
> varid = hdf_sd_create(hdfid, 'SS', [10, 10], /float)
> hdf_sd_adddata, varid, findgen(10, 10)
> hdf_sd_endaccess, varid
> hdf_sd_end, hdfid
>
> ;- Read the file
> hdfid = hdf_sd_start('test.hdf')
> index = hdf_sd_nametoindex(hdfid, 'SS')
> varid = hdf_sd_select(hdfid, index)
> hdf_sd_getdata, varid, data
> hdf_sd_endaccess, varid
> hdf_sd_end, hdfid
>
> For more details see my book Chapter 4, pp. 182-192, or the HDF routines
> at
Just for discussion:
Most time I am seeing HDF files the users don't care about coordination
variables or dimension names.
By the hand HDF was developed after netCDF and the mostly from the
declaration is nearly the same. Why not using the internal logic of
netCDF too.
Normally there is a bit of logic behind the data which is stored in a
scientific data format. But most people using HDF did not use the
internal mechanism. They always define for every variable all dimensions
again. So if you have 10 vectors by 10 values they wrote 10 dimensions
to the file. Normally one is enough. And for example if one of the
vectors has a realation to each of the others, e.g. time to temperature
then in netCDF the dimension name is 'time' and then you know by reading
'temperature' automaticly that's the vector 'time' belongs to this
parameter. By this mechanism it is very easy to mix multidimensional
data and vector data into one file and always to read the right
parameters. I won't wonder if they write a short_name as attribute to
the file.
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
|
|
|
Re: Need help with HDF_VD_WRITE!!! [message #32497 is a reply to message #32491] |
Fri, 11 October 2002 09:03  |
Liam E. Gumley
Messages: 378 Registered: January 2000
|
Senior Member |
|
|
> Brian Huether wrote:
>
> I thought I had it. But man this is so complicated. Say I have one
> column of data with one field. All the following fail:
>
> IDL> fileid=HDF_OPEN('e:\huether\test7.hdf',/CREATE)
> IDL> Vdat = HDF_VD_ATTACH(fileID, -1, /WRITE)
> IDL> HDF_VD_WRITE, Vdat, 'PX', indgen(1,10)
[stuff deleted]
Have you considered using the HDF Scientific Data Set model instead?
It's much more flexible and easy to use IMHO. For example:
;- Create the file
hdfid = hdf_sd_start('test.hdf', /create)
varid = hdf_sd_create(hdfid, 'SS', [10, 10], /float)
hdf_sd_adddata, varid, findgen(10, 10)
hdf_sd_endaccess, varid
hdf_sd_end, hdfid
;- Read the file
hdfid = hdf_sd_start('test.hdf')
index = hdf_sd_nametoindex(hdfid, 'SS')
varid = hdf_sd_select(hdfid, index)
hdf_sd_getdata, varid, data
hdf_sd_endaccess, varid
hdf_sd_end, hdfid
For more details see my book Chapter 4, pp. 182-192, or the HDF routines
at
http://www.gumley.com/PIP/Free_Software.html
Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
|
|
|
Re: Need help with HDF_VD_WRITE!!! [message #32505 is a reply to message #32497] |
Fri, 11 October 2002 04:10  |
Brian Huether
Messages: 12 Registered: September 2002
|
Junior Member |
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Arial size=2>I thought I had it. But man this is so complicated.
Say I have one column of data with one field. All the following
fail:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>IDL>
fileid=HDF_OPEN('e:\huether\test7.hdf',/CREATE)</FONT></DIV >
<DIV><FONT face=Arial size=2>IDL> Vdat = HDF_VD_ATTACH(fileID, -1,
/WRITE)</FONT></DIV>
<DIV><FONT face=Arial size=2>IDL> HDF_VD_WRITE, Vdat, 'PX', indgen(1,10)
</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>and also</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV><FONT size=1>
<DIV><FONT face=Arial size=2>IDL>
fileid=HDF_OPEN('e:\huether\test8.hdf',/CREATE)</FONT></DIV >
<DIV><FONT face=Arial size=2>IDL> Vdat = HDF_VD_ATTACH(fileID, -1,
/WRITE)</FONT></DIV>
<DIV><FONT face=Arial size=2>IDL> HDF_VD_FDEFINE,
Vdat,'SS',/FLOAT</FONT></DIV>
<DIV><FONT face=Arial size=2>IDL> HDF_VD_WRITE, Vdat, 'SS',
findgen(1,10)</FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>In each case the error is</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>% HDF_VD_WRITE: Data array dimensioning mismatch
(<FLOAT Array[1, 10]>).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>This is so annoying. Consider this:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV><FONT size=1>
<DIV><FONT face=Arial size=2>IDL>
fileid=HDF_OPEN('e:\huether\test10.hdf',/CREATE)</FONT></DIV >
<DIV><FONT face=Arial size=2>IDL> Vdat = HDF_VD_ATTACH(fileID, -1,
/WRITE)</FONT></DIV>
<DIV><FONT face=Arial size=2>IDL> HDF_VD_WRITE, Vdat, 'SS', indgen(10)</FONT>
</DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>This causes the error</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV><FONT face=Arial size=2><FONT
size=1>
<DIV><FONT size=2>HDF_VD_WRITE: Unable to set the VDATA fieldnames to <STRING
('SS')></FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV></FONT>But consider this:</FONT></DIV>
<DIV>
<DIV><FONT face=Arial size=2>IDL>
fileid=HDF_OPEN('e:\huether\test11.hdf',/CREATE)</FONT></DIV >
<DIV><FONT face=Arial size=2>IDL> Vdat = HDF_VD_ATTACH(fileID, -1,
/WRITE)</FONT></DIV></DIV>
<DIV><FONT face=Arial size=2>IDL> HDF_VD_WRITE, Vdat, 'PX', indgen(10)</FONT>
</DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>This works fine! The only difference is that I am
using the string 'PX'!!!!!!!!!!!!!!!!!!!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Man I have had it with this. So unbelievably
counterintuitive. Oh, and how is this for more insanity: The above works for
unclear reason as stated, but the form of</FONT></DIV>
<DIV><FONT face=Arial size=2>indgen(10) has 10 columns. Try replacing that with
indgen(1,10) and we have the same problem as above.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>If the creaters of this API are watching, can you
please write a user's manual for HDF_VD alone?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>-brian</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></FONT></FONT>
<DIV><FONT face=Arial size=2>"James Kuyper" <</FONT><A
href="mailto:kuyper@saicmodis.com"><FONT face=Arial
size=2>kuyper@saicmodis.com</FONT></A><FONT face=Arial size=2>> schrieb im
Newsbeitrag </FONT><A href="news:3DA59E5F.F5098369@saicmodis.com"><FONT
face=Arial size=2>news:3DA59E5F.F5098369@saicmodis.com</FONT></A><FONT
face=Arial size=2>...</FONT></DIV><FONT face=Arial size=2>> > Brian
Huether wrote:<BR>> > <BR>> > This is quite maddening. I am using
IDL 5.2 and am working with HDF<BR>> > files. Consider an array with 2
columns, where each col is a field and<BR>> > each row a record. In the
language of HDF, that would be a VDATA. In<BR>> > theory, then the
following commands should work:<BR>> > <BR>> >
fid=HDF_OPEN('test.hdf',/CREATE)<BR>> > Vdat2 = HDF_VD_ATTACH(fid, -1,
/WRITE)<BR>> <BR>> Before you can write any records, you first need to
call HDF_VD_DEFINE<BR>> to define each field in the vdata:<BR>> <BR>>
IDL> HDF_VD_FDEFINE, Vdat2, 'F1', /FLOAT <BR>> IDL> HDF_VD_FDEFINE,
Vdat2, 'F2', /FLOAT<BR>> <BR>> > HDF_VD_WRITE, Vdat2, 'F1,F2',
fltarr(2,10)<BR>> <BR>> I'm not entirely sure what the field list argument
is for in<BR>> HDF_VD_WRITE. The corresponding raw HDF function can only
write an<BR>> entire record, and can only be called for a vdata that has
already had<BR>> it's fields defined. I tried the following:<BR>> <BR>>
IDL> HDF_VD_WRITE, Vdat2, 'F1', 1.0<BR>> % HDF_VD_WRITE: Insufficient data
in item (<FLOAT (
1.00000)>)<BR>> to<BR>>
write even 1 record.<BR>> <BR>> However, the following was
accepted:<BR>> <BR>> HDF_VD_WRITE, Vdat2, 'F1', [1.0,2.0]<BR>> <BR>>
And vshow gave me the following results after I closed the file:<BR>> FILE:
test.hdf<BR>> No vgroups in this file<BR>> Lone vdatas:<BR>> L vs:2
<1962/2> nv=11 i=0 fld [F1,F2] vsize=8 (NoName {})<BR>> 0: fld [F1],
type=5, order=1<BR>> 1: fld [F2], type=5, order=1<BR>> 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 <BR>> 0.000000 <BR>> 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 <BR>>
0.000000 <BR>> 0.000000 0.000000 0.000000
0.000000 1.000000 2.000000 <BR>> 0
attributes.<BR>> <BR>> Which looks to me like it wrote [1.0,2.0] exactly
as if I'd indicated<BR>> "F1,F2", rather than simply "F1". So I'm
confused.<BR>> <BR>> -- <BR>> James Kuyper<BR>> MODIS Level 1
Lead<BR>> Science Data Support Team<BR>> (301)
352-2150</FONT></BODY></HTML>
|
|
|
Re: Need help with HDF_VD_WRITE!!! [message #32513 is a reply to message #32505] |
Thu, 10 October 2002 08:35  |
James Kuyper
Messages: 425 Registered: March 2000
|
Senior Member |
|
|
> Brian Huether wrote:
>
> This is quite maddening. I am using IDL 5.2 and am working with HDF
> files. Consider an array with 2 columns, where each col is a field and
> each row a record. In the language of HDF, that would be a VDATA. In
> theory, then the following commands should work:
>
> fid=HDF_OPEN('test.hdf',/CREATE)
> Vdat2 = HDF_VD_ATTACH(fid, -1, /WRITE)
Before you can write any records, you first need to call HDF_VD_DEFINE
to define each field in the vdata:
IDL> HDF_VD_FDEFINE, Vdat2, 'F1', /FLOAT
IDL> HDF_VD_FDEFINE, Vdat2, 'F2', /FLOAT
> HDF_VD_WRITE, Vdat2, 'F1,F2', fltarr(2,10)
I'm not entirely sure what the field list argument is for in
HDF_VD_WRITE. The corresponding raw HDF function can only write an
entire record, and can only be called for a vdata that has already had
it's fields defined. I tried the following:
IDL> HDF_VD_WRITE, Vdat2, 'F1', 1.0
% HDF_VD_WRITE: Insufficient data in item (<FLOAT ( 1.00000)>)
to
write even 1 record.
However, the following was accepted:
HDF_VD_WRITE, Vdat2, 'F1', [1.0,2.0]
And vshow gave me the following results after I closed the file:
FILE: test.hdf
No vgroups in this file
Lone vdatas:
L vs:2 <1962/2> nv=11 i=0 fld [F1,F2] vsize=8 (NoName {})
0: fld [F1], type=5, order=1
1: fld [F2], type=5, order=1
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000
0.000000 0.000000 0.000000 0.000000 1.000000 2.000000
0 attributes.
Which looks to me like it wrote [1.0,2.0] exactly as if I'd indicated
"F1,F2", rather than simply "F1". So I'm confused.
--
James Kuyper
MODIS Level 1 Lead
Science Data Support Team
(301) 352-2150
|
|
|