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

Home » Public Forums » archive » Re: HDF_SD_ADDDATA problem
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: HDF_SD_ADDDATA problem [message #59939 is a reply to message #59938] Tue, 22 April 2008 07:23 Go to previous messageGo to previous message
brodzik@nsidc.org is currently offline  brodzik@nsidc.org
Messages: 7
Registered: July 2005
Junior Member
On Apr 21, 5:24 pm, adfra...@utas.edu.au wrote:
> Dear Everyone,
>
> I'm having trouble writing to an HDF file using HDF_SD_ADDDATA, but
> let me set the scene quickly first.
>
> I'm using a multispectral satellite imagery dataset in its native L1B
> (HDF-EOS, it's MODIS for those who care!) format. When ordering the
> data, one has the option to channel subset the data to reduce size.
>
> I've written IDL programs to cloud mask the data, which involves
> manipulating an SDS within the HDF. My programs all work fine using
> the full, un-subsetted data, but whenever I try them on the subsetted
> HDFs, they fall over with this error.
>
> ------------------------------------------------------------ -----------
> % HDF_SD_ADDDATA: Unable to write the specified HDF-SD slice.
> % Execution halted at: HDFEDITSDS 28 /array/work/adfraser/
> MODIS
> images/18_4_08 processing of winter2 data/output/HDFeditSDS.pro
> % $MAIN$
> ------------------------------------------------------------ -----------
>
> Here is the code which I've been using to write successfully to the
> unsubsetted data but unsuccessfully to the subsetted data:
>
> ------------------------------------------------------------ ------------
> PRO HDFeditSDS, filename, sdsname, newdata
>
> sdfileid=hdf_sd_start(filename, /rdwr)
>
> ; Find the index of the "Gridded Data" SDS.
> index = HDF_SD_NAMETOINDEX(sdFileID, sdsname)
>
> ; Select the Gridded Data SDS.
> thisSdsID = HDF_SD_SELECT(sdFileID, index)
>
> HDF_SD_AddData, thisSdsID, newdata
>
> hdf_sd_end, sdfileid
>
> END
> ------------------------------------------------------------ -------------
>
> I've checked all the obvously stupid things (file access permissions
> are identical, and the SDS name exists within the HDF). I'm at a loss,
> please help!
>
> Cheers,
> Alex.
>
> Alex Fraser
> Ph.D. candidate
> University of Tasmania
> Antarctic Climate and Ecosystems Cooperative Research Centre
> Sandy Bay Campus
> Tasmania 7001

Alex,

I have also been working with MODIS HDF data lately, and sympathize
with your troubles.

The workings of HDF routines are very murky to me. As a result, my
behavior reduces to superstitious little rules like these. Makes me
understand how ignorance during the Middle Ages led people to do all
kinds of crazy things.

My wacky rules are:

a) always check return codes--they often behave in strange ways when
the object interface gets confused
b) always bracket an hdf_sd_select call with an hdf_sd_endaccess, (I
think you're missing an hdf_sd_endaccess in your sample, but that
doesn't explain why it works for unsubsetted data but not subsetted)
c) likewise with hdf_sd_start and hdf_sd_end

and, finally, after I recently added a new SD to a MODIS tile using
the HDF_SD interface, I learned that I really needed to use the EOS_GD
interface, so the new SD was really part of the HDF-EOS grid object
and other software (the MODIS reprojection tool) was only looking in
the grid object, and was ignoring any other SDs in the file. Just an
aside, but it might affect whatever you're doing downstream.

Ohmygosh, I never thought it would happen to me, but I'm speaking HDF-
bot...need to go get some Listerine.

Good luck,
Mary Jo
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Using make_rt on a Mac
Next Topic: General purpose tooltip routine

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

Current Time: Thu Oct 09 23:13:20 PDT 2025

Total time taken to generate the page: 0.29471 seconds