Re: HDF_SD_GETACCESS: No content in variable, error [message #71782] |
Wed, 21 July 2010 23:54  |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
On Jul 21, 9:38 am, 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?
>
> I opened each of the two files you sent me up in my
> NCDF_Browser program and I could immediately see that
> FP_sample in the file that causes the problem has
> a dimension of 0. Obviously, nothing is there, even
> though the variable has been defined in the file!
>
> To look for this possibility (I have modified my own
> code in ncdf_data__define.pro and it will be on my
> web page shortly) you will have to check for a zero
> length dimension:
>
> sd=hdf_sd_start(fileName)
> index=hdf_sd_nametoindex(sd,'FP_sample')
> sds=hdf_sd_select(sd,index)
> HDF_SD_GetInfo, sds, DIMS=dims
> IF dims[0] NE 0 THEN BEGIN
> hdf_sd_getdata,sds,sample
> ENDIF
>
> I notice that every variable in that particular data file
> has a dimension of 0. That is one very sick puppy! :-)
>
> 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.")
That is a wise solution. You are the man David!
Cheers
Dave
|
|
|