FUNCTION HandleAttribute, FileId, dataname, attrname, data, swathname=swathname, verbose=verbose, success=success geo_group = "Geolocation Fields" dat_group = "Data Fields" ;; get the swathname IF N_ELEMENTS(swathname) EQ 0 THEN $ BEGIN IF h5g_get_nmembers(FileId, '/HDFEOS/SWATHS/') EQ 1 THEN swathname = h5g_get_member_name(FileId, '/HDFEOS/SWATHS/', 0) ELSE swathname = dataname ENDIF msgtce='>>HandleAttribute traceback:' ;; set counter for number of attempted reads NPASS = 1 ;; if attrname is not a string type (i.e./attrname) then get attribute data IF SIZE(/TYPE, attrname) NE SIZE(/TYPE,"") THEN $ BEGIN attrname = dataname NPASS = 1 ;; group attribute END ELSE BEGIN IF attrname EQ dataname THEN $ BEGIN NPASS = 1 ;; group attribute END ELSE BEGIN NPASS = 5 ;; dataset attribute END END ;; on error jumps back to this line CATCH, error_statusa IF error_statusa NE 0 THEN $ BEGIN CATCH, error_statusa, /cancel NPASS = NPASS + 1 ENDIF ;; create HDF path to variable IF NPASS EQ 1 THEN GrpName = '/HDFEOS/ADDITIONAL/FILE_ATTRIBUTES/' IF NPASS EQ 2 THEN GrpName = '/HDFEOS/SWATHS/' + swathname + '/' IF NPASS EQ 3 THEN GrpName = '/HDFEOS/SWATHS/' IF NPASS EQ 4 THEN GrpName = '/HDFEOS/' IF NPASS EQ 5 THEN DsName = '/HDFEOS/SWATHS/' + swathname + '/' + geo_group + '/' + dataname +'/' IF NPASS EQ 6 THEN DsName = '/HDFEOS/SWATHS/' + swathname + '/' + dat_group + '/' + dataname +'/' IF NPASS GT 6 THEN $ BEGIN print, TRANSPOSE(msgtce) print, '>'+ attrname + ' not found.. Sorry!' CATCH,/cancel RETURN, -1 END CASE 1 OF NPASS LE 4: BEGIN ;; Group msgtce = [msgtce,">>>searched: " + GrpName + attrname] GrpId = h5g_open(FileId, GrpName) AtId = h5a_open_name(GrpId, attrname) data = h5a_read(AtId) h5a_close, AtId h5g_close, GrpId END ELSE :BEGIN ;; Dataset msgtce = [msgtce,">>>searched: " + DsName + attrname] DsId = h5d_open(fileid, DsName) AtId = h5a_open_name(DsId, attrname) data = h5a_read(AtId) h5a_close, AtId h5d_close, DsId END ENDCASE IF N_ELEMENTS(success) NE 0 THEN print, '>Located:'+msgtce(N_ELEMENTS(msgtce)-1) IF N_ELEMENTS(verbose) NE 0 THEN print, TRANSPOSE(msgtce) RETURN, 0 END Function HandleDataField, FileId, dataname, data, swathname=swathname, verbose=verbose, success=success ;; get named geo/data field geo_group = "Geolocation Fields" dat_group = "Data Fields" IF N_ELEMENTS(swathname) EQ 0 THEN $ BEGIN IF h5g_get_nmembers(FileId, '/HDFEOS/SWATHS/') EQ 1 THEN swathname = h5g_get_member_name(FileId, '/HDFEOS/SWATHS/', 0) ELSE swathname = dataname ENDIF msgtce='>>HandleDataField traceback:' ;; set counter for number of attempted reads NPASS = 1 ;; on error jumps back to this line CATCH, error_statusd IF error_statusd NE 0 THEN $ BEGIN CATCH, error_statusd, /cancel NPASS = NPASS + 1 ENDIF ;; create HDF path to variable IF NPASS EQ 1 THEN DsName ='/HDFEOS/SWATHS/' + swathname + '/' + geo_group + '/' + dataname IF NPASS EQ 2 THEN DsName ='/HDFEOS/SWATHS/' + swathname + '/' + dat_group + '/' + dataname IF NPASS GT 2 THEN $ BEGIN print, TRANSPOSE(msgtce) print, '>'+ dataname + ' not found.. Sorry!' CATCH,/cancel RETURN, -1 END msgtce = [msgtce,">>>searched: " + DsName] DsId = h5d_open(fileid, DsName) DspId = h5d_get_space(DsId) Dims = h5s_get_simple_extent_dims(DspId) h5s_close, DspId dspidm = h5s_create_simple(dims) data = h5d_read(dsid, FILE_SPACE=dspidm) h5s_close, DspIdM h5d_close, DsId data = reform(data) IF N_ELEMENTS(success) NE 0 THEN print, '>Located:'+msgtce(N_ELEMENTS(msgtce)-1) IF N_ELEMENTS(verbose) NE 0 THEN print, TRANSPOSE(msgtce) RETURN, 0 END FUNCTION get_aura, file, varname, data, swathname=swathname, attrname=attrname, verbose=verbose, success=success ;+ ; NAME: ; get_aura ; ; PURPOSE: ; extract data from Aura style HDF5-EOS file ; ; ; CATEGORY: ; HDF5-EOS file reader ; ; CALLING SEQUENCE: ; status = get_aura(file, varname, data) ; ; INPUTS: ; file is the file path ; varname (+attrname) is the HDF5-EOS object ; ; dafault is to first search varname as geo/data set then as group attribute ; ; KEYWORD PARAMETERS: ; attribute: ; may be set as /attr if varname is a group attribute object ; may be set as attr='' if attribute is attached ; to varname ; ; /verbose : ; produces printout of all searched locations ; ; /success : ; produces printout of sucessful search location ; ; ; OUTPUTS: ; data is the returned IDL data variable name ; returns status as 0 for success and -1 for failure ; ; sucessful location of requested data object is not notified ; unless keyword /success is set ; ; failure to find data object results in traceback of searched ; locations ; ; EXAMPLES: ; ; 1) extract datsets ; ; extract the HIRDLS 'Temperature' dataset and put into variable t and ; be quiet if successful ; status = get_aura('HIRDLS.he5','Temperature',t) ; ; extract the MLS 'Latitude' dataset and put into variable lats and ; report success ; status = get_aura('MLS.he5','Latitude',lats, /succ) ; ; 2) extract attributes associated with a particular dataset ; ; extract the 'Units' attribute from the 'Temperature' dataset and put into variable x ; status = get_aura('HIRDLS.he5','Temperature', x, attr='Units') ; ; 3) extract attributes associated with groups ; ; extract the 'InstrumentName' attribute and put into variable x ; status = get_aura('HIRDLS.he5','InstrumentName', x, /attr) ; ; extract the 'GranuleMonth' attribute and put into variable x and be verbose ; status = get_aura('HIRDLS.he5','GranuleMonth', x, /attr, /verb); ; ; ; MODIFICATION HISTORY: ; from original get_sw_data5 by K. Stone and J. McInerney UCB/CLAS ; A. Lambert NCAR ; AL 01-NOV-2003 revised version of get_sw_data5 ; AL 04-NOV-2003 added automatic swath name recognition ; AL 27-MAY-2004 added default of searching in group attributes ; if data/geo field not found; added verbose and ; success keywords ; ;- FileId = h5f_open(file) IF FileId EQ -1 THEN MESSAGE, "File does not exist." CASE N_ELEMENTS(attrname) OF 0: BEGIN status = HandleDataField(FileId, varname, data, swathname=swathname, verbose=verbose, success=success) IF status(0) EQ -1 THEN $ BEGIN print,'>Now searching as group attribute:' status = HandleAttribute(FileId, varname, varname, data, swathname=swathname, verbose=verbose, /success) ENDIF END ELSE: status = HandleAttribute(FileId, varname, attrname, data, swathname=swathname, verbose=verbose, success=success) ENDCASE h5f_close,FileId RETURN, status END