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

Home » Public Forums » archive » skip the corrupted hdf file and continue the for lood for uncorrupted hdfs
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
skip the corrupted hdf file and continue the for lood for uncorrupted hdfs [message #87349] Mon, 27 January 2014 00:22 Go to previous message
Brent Fallarcuna is currently offline  Brent Fallarcuna
Messages: 6
Registered: July 2013
Junior Member
Hello everyone!

I'm extracting values on a specific pixel from hundreds of hdf files and used for loop.

This is my code:

;Daily NPP/GPP Plotting
cd, ('C:\Users\Brent\Documents\NPP Annual Files\MODIS17A2v5')
filelist = file_search('*.*.h29v07.005.*.hdf')
i = 0
arr = strarr(1,637)

FOR i = 0, 636 DO BEGIN
; Open HDF and Import SDS
filename = filelist[i]

;access hdf file
hdf_id = hdf_sd_start(filename);this is where my program stops

;return the index of 'Npp_1km' variable
index = hdf_sd_nametoindex(hdf_id, 'PsnNet_1km')

;access the dataset
varid = hdf_sd_select(hdf_id, index)

;read the contents of the variable
hdf_sd_getdata, varid, data

;endaccess
hdf_sd_endaccess, varid
hdf_sd_end, hdf_id

;rotate hdf
data = rotate(data, 7)
;scale the data
kaliwa_tile = data * (0.0001)
point = kaliwa_tile[880,566]

print, point
arr[0,i] = point
ENDFOR

cd, ('C:\Users\Brent\Documents\MOD17A3UTM')
openw, lun, 'outputfilefor8dayPsnNet1km.csv', /get_lun
printf, lun, arr, format= '(a)'
close, lun
free_lun, lun

END


After the values from several hdfs are printed, there's an error on the console saying "HDF_SD_START: Unable to start the HDF-SD interface."
As I checked the variables tab, the i stopped at the 24th hdf file. As I checked the file using hdf browser, it didn't open, thus the file seems to be corrupted.

My question is, can I continue my for loop and proceed reading the other uncorrupted hdf files every time I got the said error?

I've tried catch statement but I can't figure it out on how to use and implement it correctly.


Brent
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Instances of structure array with varying no. of elements
Next Topic: How can I change from qwerty keyboard to azerty ?

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

Current Time: Wed Oct 08 15:22:43 PDT 2025

Total time taken to generate the page: 0.00528 seconds