Re: HDF_SD_GETACCESS: No content in variable, error [message #71801 is a reply to message #71800] |
Wed, 21 July 2010 07:59   |
aa8533
Messages: 8 Registered: July 2010
|
Junior Member |
|
|
On Jul 21, 1:54 pm, David Fanning <n...@dfanning.com> wrote:
> aa8533 writes:
>> Hi - I'm trying to make a program which automatically runs through
>> 100s of images (MODIS Fire data) and extracts data at a particular
>> point. The program works fine where there is data to extract (in the
>> case below, when there is data in FP_Sample) but halts for an image
>> where there is none with message "Array dimensions must be greater
>> than 0".
>
>> Extract of code is:
>
>> sd=hdf_sd_start(fileName)
>> index=hdf_sd_nametoindex(sd,'FP_sample')
>> sds=hdf_sd_select(sd,index)
>> hdf_sd_getdata,sds,sample <------------------ Halts with message
>> here
>
>> Is there a way to test the size of the variable (in this case Sample)
>> and if, say it's -1 (no data) then skip the last line of this code?
>
> In my code, I check the index number to see if it is
> valid (e.g., something other than -1) before I try
> to read the data. Do you know what the value of the
> index number is when you get this error?
>
> My code looks like this:
>
> ; Get the index of the variable.
> index = HDF_SD_NameToIndex(fileID, theVariable)
> IF index EQ -1 THEN $
> Message, 'Variable (' + theVariable + ') not found.'
>
> ; Select the variable and read it.
> varID = HDF_SD_Select(fileID, index)
> HDF_SD_GetData, varID, data, COUNT=count, $
> START=start, STRIDE=stride
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Hi - thanks for that David. However, I examined the index values and
they are the same (3) both for scenes where there is (and is not)
data. So the problem seems to remain.
What I think I need to do is kind of what you suggested but to check
the sample for data (i.e. check that it is not -1) before I get to
hdf_sd_getdata,sds,sample - I just don't know how ...!
Thank you again and if you have any more suggestions, I'd be most
grateful.
Regards, Matt
|
|
|