Re: HDF_SD_GETACCESS: No content in variable, error [message #71805 is a reply to message #71803] |
Wed, 21 July 2010 04:42   |
aa8533
Messages: 8 Registered: July 2010
|
Junior Member |
|
|
On Jul 21, 12:32 pm, Dave Poreh <d.po...@gmail.com> wrote:
> On Jul 21, 4:17 am, aa8533 <matthew.blackett.coven...@googlemail.com>
> wrote:
>
>
>
>
>
>> 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?
>
>> Would very much appreciate any help.
>
>> Matt
>
> can you post entire code from beginning to see what happen?
SURE, Thank you for getting back so quickly. It is below, the hdf bit
is contained within a for statement. So basically, i need to skip bits
where there is no data but from what I can figure out, it only knows
there is no data when I ask it to get it, hence the array error.
Very thankful - Matt (Dr Matthew Blackett, Coventry University, UK)
pro attemptcorfocusedcov
v=double(0.000003959)
e=double(2.718281828)
h=double(6.6262E-34)
c=double(2.99792458E8)
k=double(1.3807E-23)
Radearth =6378.137
height =705
r = Radearth + height
s = 1.0/height
angle=findgen(1354)
theta=((-1)*(677*s))+(0.5*s)+((angle)*s)
asps=Radearth*s*((cos(theta)/(((Radearth/r)^2)-
sin(theta)^2)^0.5)-1.0)
atps=r*s*(cos(theta)-(((Radearth/r)^2)-(sin(theta)^2))^0.5)
area=(asps)*(atps)
pathName="G:\FTPmod14\"
List = findfile(pathName+"*.hdf")
nosFiles=N_ELEMENTS(List)
for i = 0, nosFiles-1 do begin
fileName = List[i]
sd=hdf_sd_start(fileName)
index=hdf_sd_nametoindex(sd,'FP_sample')
sds=hdf_sd_select(sd,index)
hdf_sd_getdata,sds,sample
hdf_sd_endaccess,sds
index=hdf_sd_nametoindex(sd,'FP_T21')
sds=hdf_sd_select(sd,index)
hdf_sd_getdata,sds,bt21
hdf_sd_endaccess,sds
index=hdf_sd_nametoindex(sd,'FP_MeanT21')
sds=hdf_sd_select(sd,index)
hdf_sd_getdata,sds,btmean21
hdf_sd_endaccess,sds
index=hdf_sd_nametoindex(sd,'FP_latitude')
sds=hdf_sd_select(sd,index)
hdf_sd_getdata,sds,lat
hdf_sd_endaccess,sds
index=hdf_sd_nametoindex(sd,'FP_longitude')
sds=hdf_sd_select(sd,index)
hdf_sd_getdata,sds,longit
hdf_sd_endaccess,sds
index=hdf_sd_nametoindex(sd,'FP_line')
sds=hdf_sd_select(sd,index)
hdf_sd_getdata,sds,horiz
hdf_sd_endaccess,sds
index=hdf_sd_nametoindex(sd,'FP_sample')
sds=hdf_sd_select(sd,index)
hdf_sd_getdata,sds,vertic
hdf_sd_endaccess,sds
hdf_sd_end,sd
radiance=(((2.0*h*c^2)/v^5)*(1/(exp((h*c)/
(v*k*(double(bt21))))-1)))*1e-6
bgradiance=(((2.0*h*c^2)/v^5)*(1/(exp((h*c)/
(v*k*(double(btmean21))))-1)))*1.0e-6
mirpower=((area[vertic,horiz])*20.25)*((1/0.957)*(radiance-
bgradiance))
print, btmean21
results=where(((lat gt 37) and (lat lt 38)) AND ((longit gt 14.5) and
(longit lt 15.5)))
print, "___________________________________________"
print, i
print, results
print, horiz
print, vertic
print, longit
print, lat
PRINT, MIRPOWER
if (results(0) ne -1) then begin
PRINT, 'RESULTS:'
print, mirpower(results)
endif else begin
print, 'no result'
endelse
endfor
end
|
|
|