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>
|
|
|