;------------------------------------------------------------- ;+ ; NAME: ; hdf_read_structure ; PURPOSE: ; Reads a hdf file into a structure ; Caution: it puts every thing into main memory ; If no keyword is set nothing happens!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ; ; This program is very usefull together with shelp (help for structures) ; ; CATEGORY:In/Output ; ; CALLING SEQUENCE: ; ; hdf_read_structure, structure ; ; KEYWORDS: ; ; filename file to read, if not set pickfile is used ; eos_and_hdf since eos is an combination of different hdf types, ; you can read eos as hdf-files but then the structure is ; very difficult. Set it only if you know, what you are doing ; info prints all information about the hdf file WITHOUT WITHOUT ; WITHOUT WITHOUT WITHOUT WITHOUT WITHOUT WITHOUT reading ; data (info=2 --> xdisplay, info="filename" --> into file) ; ; all If this keyword is set ALL data is read into the structure. ; Be careful with large files and small computers. It overrides ; the following keywords. ; pointer instead adding data to the structure it adds a pointer ; ; annotations If this keyword is set hdf_annotations are read into the structure ; ; eos_grids_ok If this keyword is set ALL eos grid data is read into the structure. ; IF IT IS A STRING VECTOR THAN ONLY THE DATASETS CONTAINING AT LEAST ONE ; OF THE STRINGS OF EOS_GRIDS_OK IN IT NAMES WILL BE READ. (SEE EXAMPLE!!) ; eos_grids_not This keyword excludes all datafields containing at least one ; of the strings of eos_grids_not (see modis example!!). ; eos_grids_an If this keyword is set the global eos_grid anotations are read ; ; eos_swaths_ok see eos_grids_ok, but for eos swaths ; eos_points_ok see eos_grids_ok, but for eos points (if a point is selected, all levels and fields will be read) ; sci_data_ok see eos_grids_ok, but for scientific (multidimensional) data ; sd_data_ok see eos_grids_ok, synonym of sci_data ; gen_ras_ok see eos_grids_ok, but for generic raster ; vdata_ok see eos_grids_ok, but for vdata ; vd_fields_ok see eos_grids_ok, but for the fields within a valid vdata ; vgroups_ok see eos_grids_ok, but for vgroups (take care: vgroups can be recursive) ; eos_swaths_not see eos_grids_not ; eos_points_not see eos_grids_not ; sci_data_not see eos_grids_not ; sd_data_not see eos_grids_not ; gen_ras_not see eos_grids_not ; vdata_not see eos_grids_not ; vgroups_not see eos_grids_not ; vd_fields_not see eos_grids_not, but for the fields within a valid vdata ; sci_data_an If is set the global sd anotations are read ; sd_data_an see sci_data_an ; gen_ras_an see sci_data_an ; vg_recursive vgroups can be entries of each other. If you read vgroups recursive, ; you can optain very deep trees even for low number of vgroups. This ; can only happen if this keyword is set. ; start ; count start and count can be passed through to the "hdf_sd_getdata" routine in case of SD datasets ; channel if a SD dataset is 3-dimensional (e.g. MODIS radiances), one channel can be specified through the ; "channel" keyword. Attention: this keword has nothing to do with MODIS channel numbers, it is just ; the third index for the SD dataset specified by "sci_data_ok" ; varnum if set only the varnum dataset is with a given name is read (sd_names dont have to be ; uniq, if you have 3 times the name "radiance" and set varnum to 2 the second is read, ; if you don't set it, the first is read ... This is especially usefull if you use hdf_sd_read_matrix ; ; USAGE/EXAMPLE: ; IDL> hdf_read_structure,outstr,file="bla.hdf",/info ; gives: ; File has no annotation data ; File has no generic raster images ; File has no vgroups ; File has no single vds ; File has no EOS data ; because neither ALL nor the other data-keywords have been set ; ; IDL> hdf_read_structure,outstr,file="eos_point_data.hdf",/info,/all ; or ; IDL> hdf_read_structure,outstr,file="eos_point_data.hdf",info=2,/all ; ; gives for example: ; File has EOS data ; File has EOS point data ; FixedBuoy_Point ; FixedBuoy_Point_attributes: ; Viscosity: 11 ; FixedBuoy_Point_n_levels: 2 ; FixedBuoy_Point level 0: ; nfields: 5 ; nrecs: 3 ; fieldlist:Label,Longitude,Latitude,DeployDate,ID ; FixedBuoy_Point level 1: ; nfields: 4 ; nrecs: 20 ; fieldlist:Time,Rainfall,Temperature,ID ; Simple_Point ; Simple_Point_n_levels: 1 ; Simple_Point level 0: ; nfields: 3 ; nrecs: 15 ; fieldlist:Time,Concentration,Species ; FloatBuoy_Point ; FloatBuoy_Point_n_levels: 2 ; FloatBuoy_Point level 0: ; nfields: 4 ; nrecs: 3 ; fieldlist:Label,DeployDate,Weight,ID ; FloatBuoy_Point level 1: ; nfields: 6 ; nrecs: 25 ; fieldlist:Time,Longitude,Latitude,Rainfall,Temperature,ID ; File has no EOS grid data ; File has no EOS swath data ; ; now you can isolate the data you like: ; IDL> hdf_read_structure,outstr,file="eos_point_data.hdf",/info,eos_points_ok=["simple","float"] ; gives: ; File has EOS data ; File has EOS point data ; Simple_Point ; Simple_Point_n_levels: 1 ; Simple_Point level 0: ; nfields: 3 ; nrecs: 15 ; fieldlist:Time,Concentration,Species ; FloatBuoy_Point ; FloatBuoy_Point_n_levels: 2 ; FloatBuoy_Point level 0: ; nfields: 4 ; nrecs: 3 ; fieldlist:Label,DeployDate,Weight,ID ; FloatBuoy_Point level 1: ; nfields: 6 ; nrecs: 25 ; fieldlist:Time,Longitude,Latitude,Rainfall,Temperature,ID ; or: ; IDL> hdf_read_structure,outstr,file="eos_point_data.hdf",/info,/eos_points_ok,eos_points_not=["Buoy"] ; gives: ; File has EOS data ; File has EOS point data ; Simple_Point ; Simple_Point_n_levels: 1 ; Simple_Point level 0: ; nfields: 3 ; nrecs: 15 ; fieldlist:Time,Concentration,Species ; File has no EOS grid data ; File has no EOS swath data ; ; finaly you can read the data into outstr by omiting the /info keyword: ; ; IDL> hdf_read_structure,outstr,file="eos_point_data.hdf",eos_points_ok=["simple","float"] ; ; To write a subroutine that reads modis level 2b cloud top pressure ; (not "night", "day", "tempeature", "ratios" ...) you have to: ; ; function read_modis_cloud_top_pressure,file,swathname ; hdf_read_structure,d,file=file $ ; ,eos_swaths_ok=[swathname,"lat","lon","top","pressure"] $ ; ,eos_swaths_not=["day","night","infrared","ratios","temp","surface"] ; ; return,{ctp:D.EOS_SWATH_DATA.MOD06.DATAFIELDS.CLOUD_TOP_PRESSURE $ ; ,lon:D.EOS_SWATH_DATA.MOD06.GEOFIELDS.LONGITUDE $ ; ,lat:D.EOS_SWATH_DATA.MOD06.GEOFIELDS.LATITUDE} ; end ; ; ; MODIFICATION HISTORY: ; Written by R. Preusker, Nov, 2000. ; + added data keywords Apr, 2001. ; + added all _not keywords May 2001 ; + added some temporary() to save memory ; + cleared some bugs in vdata/vgroups ; ; 20.11.2001 ; Added keywords "count", "start" and "channel" (PA) ; Added keyword "exact" to "valid_name" ; Added function "hdf_sd_read_matrix" (RP/PA) ; ; 29.01.2002 ; When keyword info is set, a bunch of information is put into ; the return structure anyway ; Added option to set keyword info to "quiet", then there is no output ; on the screen, but the information is in the output structure ; (PA) ; ; 11.03.2002 ; Reorganization of the vdata/vgroups ; 1. All vdata are read directly without diving into ; the directory structure of the vgroups ; 2. vd_fields_ok/vd_fields_not keywords added. ; To read a vdata you have to specify the name ; of the field or to set /vd_fields_ok ; 3. within vgroups real data will not be read ; any longer, instead only the tag/reference pairs and ; some aditional information is put into the ; vgroup structure (actually I don't have a ; good and usefull example of vgroups) ; (RP) ; ; ; Copyright (C) 2000, Freie Universitaet Berlin ; This software may be used, copied, or redistributed as long ; as it is not sold and this copyright notice is reproduced on ; each copy made. This routine is provided as is without any ; express or implied warranties whatsoever. ; ; This software is still alpha !!! ; Feel free to test and to improve it. If you found ; a bug email me. (rene.preusker@wew.fu-berlin.de) ;- function add_stru,alt,name,add if (shift(size(add),2))[0] eq 0 then return,alt if (shift(size(alt),2))[0] ne 8 then return,create_struct(name,add) $ else begin names=tag_names(alt) check_it: if total(STRUPCASE(names) eq replicate(strupcase(name),n_tags(alt))) ge 1 then begin name=name+"_" goto,check_it endif return,create_struct(alt,name,add) endelse end pro my_hdf_close,id ; somtimes hdf_close does not work ; (or a bug in my code?) catch,error ;if error eq -865 then return if error ne 0 then return hdf_close,id end function replace_string,in,was,womit out=in while 1 do begin res= STRPOS(out,was) if res eq -1 then return,out strput,out,womit,res endwhile end function strjoin_1,str,del ; <= 5.2 don't have it if not is_defined(del) then del =" " if !version.release gt 5.2 then return,strjoin(str,del) s=size(str) if s(0) lt 1 then return,str out = reform(str(0,*)) if s(1) gt 0 then begin for i=1,s(1)-1 do out =out +del+reform(str(i,*)) endif return,out end function replace_space,in out=in while 1 do begin res= STRPOS(out," ") if res eq -1 then return,out strput,out,"_",res endwhile end function hdf_type,tag ht=[ $ '30 ',' Version Identifier ' , $ '100 ',' File Identifier ' , $ '101 ',' File Description ' , $ '102 ',' Tag Identifier ' , $ '103 ',' Tag Description ' , $ '104 ',' Data Identifier ' , $ '105 ',' Data Description ' , $ '106 ',' Number Type ' , $ '107 ',' Machine Type ' , $ '300 ',' RIG Image Dimension ' , $ '301 ',' Raster Image Look Up Table (LUT)' , $ '302 ',' Raster Image ' , $ '303 ',' Compressed Raster Image ' , $ '306 ',' Raster Image Group (RIG) ' , $ '307 ',' RIG LUT Dimension ' , $ '308 ',' RIG Matte Dimension ' , $ '309 ',' Raster Image Matte Data ' , $ '310 ',' Raster Image Color Correction ' , $ '311 ',' Raster Image Color Format ' , $ '312 ',' Raster Image Aspect Ratio ' , $ '400 ',' Composite Image Descriptor ' , $ '500 ',' XY Position ' , $ '602 ',' Vector Image - Tek4014 Stream ' , $ '603 ',' Vector Image - Tek4105 Stream ' , $ '701 ',' SD Dimension Record ' , $ '702 ',' SD Data ' , $ '703 ',' SD Scales ' , $ '704 ',' SD Labels ' , $ '705 ',' SD Units ' , $ '706 ',' SD Formats ' , $ '707 ',' SD Max/Min ' , $ '708 ',' SD Coordinates ' , $ '710 ',' SD Link ' , $ '720 ',' SD Descriptor (NDG) ' , $ '731 ',' SD Calibration Information ' , $ '732 ',' SD Fill Value ' , $ '1962 ',' Vdata Description ' , $ '1963 ',' Vdata ' , $ '1965 ',' Vgroup '] ht=strtrim(ht,2) ht=reform(ht,2,n_elements(ht)/2) index=where(ht(0,*) eq strcompress(string(tag),/rem)) if index[0] eq -1 then return,"unknown" return,ht(1,index) end function reference_name,file,tag,reference,class=class,name=name $ ,nentries=nentries,nfields=nfields $ ,fields=fields,count=count $ ,dims=dims,type=typ name=string(reference) case tag of 300: begin ; raster images end 720: begin ; sd data sd_id=hdf_sd_start(file) index=hdf_sd_reftoindex(sd_id,reference) if index ge 0l then begin sds_id=hdf_sd_select(sd_id,index) hdf_sd_getinfo,sds_id,name=name $ ,dims=dims,type=typ hdf_sd_endaccess, sds_id endif hdf_sd_end, sd_id end 1962:begin ; Vdata hdf_id=hdf_open(file) vd_handle = hdf_vd_attach(hdf_id,reference, /READ) hdf_vd_get,vd_handle,class=class,name=name $ ,nfields=nfields,fields=fields,count=count my_hdf_close,hdf_id end 1965:begin ; Vgroups hdf_id=hdf_open(file) vg_handle = hdf_vg_attach(hdf_id,reference, /READ) hdf_vg_getinfo,vg_handle,class=class,name=name,nentries=nentries my_hdf_close,hdf_id end else: endcase return,string(name) end function good_name,in out=in verboten=["#",":",".","/","+","-","*","!","$",";",'"',"&",":",",","?","@","\","(",")","{","}","[","]","%"] out=strtrim(out,2) out=replace_space(out) for i=0,n_elements(verboten)-1 do out=replace_string(out,verboten(i),"_") verboten=string(indgen(10),format="(i1.1)") for i=0,n_elements(verboten)-1 do begin if strmid(out,0,1) eq verboten(i) then out="a"+out endfor return,out end function valid_name,name,nmc=nmc,nmnc=nmnc,exact=exact ;name is valid if it contains nmc ("name must contain") ;and not nmnc ("name must not contain") s=size(nmc) if (shift(s,2))[0] eq 7 then begin ok=0 for i=0,n_elements(nmc)-1 do begin if strpos(strlowcase(name),strlowcase(nmc(i)),0) ne -1 then begin if keyword_set(exact) then begin if strlowcase(name) eq strlowcase(nmc(i)) then ok = 1 endif else ok = 1 endif endfor endif else ok=1 if keyword_set(nmnc) then begin for i=0,n_elements(nmnc)-1 do begin if strpos(strlowcase(name),strlowcase(nmnc(i)),0) ne -1 then ok = 0 endfor endif return,ok end pro print_info,info,text,str case info of 1: begin case (shift(size(text),2))[0] of 7: text=[text,string(str)] else:print,str endcase end else: endcase end function hdf_read_an, an_id,info,text,n_ano ; reads a full hdf_an into a structure ; an_id is the lun of the already opened hdf-file ; info and text are needed for some information-print-out an_out=0 Result = hdf_an_fileinfo(an_id, n_file_labels, n_file_descs, n_data_labels, n_data_descs) n_ano=n_file_labels+n_file_descs+n_data_labels+n_data_descs if n_data_labels gt 0 then begin data_labels=strarr(n_data_labels) if not info then begin for i=0l, n_data_labels -1l do begin ann_id= hdf_an_select(an_id,i,0) dummy= hdf_an_readann(ann_id,dumstr) HDF_AN_ENDACCESS, ann_id data_labels(i)=dumstr endfor an_out=add_stru(an_out,"data_labels",data_labels) endif else print_info, info, text,string(n_data_labels)+" data_labels" endif if n_data_descs gt 0 then begin data_descs=strarr(n_data_descs) if not info then begin for i=0l, n_data_descs -1l do begin ann_id= hdf_an_select(an_id,i,1) dummy= hdf_an_readann(ann_id,dumstr) HDF_AN_ENDACCESS, ann_id data_descs(i)=dumstr endfor an_out=add_stru(an_out,"data_descs",data_descs) endif else print_info, info, text,string(n_data_descs)+" data_descs" endif if n_file_labels gt 0 then begin file_labels=strarr(n_file_labels) if not info then begin for i=0l, n_file_labels -1l do begin ann_id= hdf_an_select(an_id,i,2) dummy=hdf_an_readann(ann_id,dumstr) HDF_AN_ENDACCESS, ann_id file_labels(i)=dumstr endfor an_out=add_stru(an_out,"file_labels",file_labels) endif else print_info, info, text,string(n_file_labels)+" file_labels" endif if n_file_descs gt 0 then begin file_descs=strarr(n_file_descs) if info then begin for i=0l, n_file_descs -1l do begin ann_id= hdf_an_select(an_id,i,3) dummy= hdf_an_readann(ann_id,dumstr) HDF_AN_ENDACCESS, ann_id file_descs(i)=dumstr endfor an_out=add_stru(an_out,"file_descs",file_descs) endif else print_info, info, text,string(n_file_descs)+" file_descs" endif return,an_out end function hdf_read_gr, gr_id, gdnr,info,text,im_name,ok=ok,gen_ras_ok=gen_ras_ok,pointer=pointer ; reads a full hdf_gr into a structure ; gr_id is the lun of the already opened hdf-file ; info and text are needed for some information-print-out image_stru=0 gr_im_id=hdf_gr_select(gr_id,gdnr) result= HDF_GR_GETIMINFO(gr_im_id,im_name,ncomp,data_type,in_mode,dims,num_atts) ok=valid_name(im_name,nmc=gen_ras_ok,nmnc=gen_ras_not) if not ok then goto,ende print_info, info, text," "+im_name print_info, info, text," "+im_name+"_dimensions: "+strjoin_1(string(dims),",") if num_atts gt 0 then begin att_stru=0 for j=0l,num_atts do begin result = hdf_gr_attrinfo(gr_im_id,j, name,type,count) if info then print_info, info, text," "+im_name+"_attribut: "+name else begin result = hdf_gr_getattr(gr_im_id,j, value) att_stru=add_stru(att_stru,good_name(name),value) endelse endfor endif if not info then result=HDF_GR_READIMAGE(gr_im_id, image, interlace=in_mod) pal_id=HDF_GR_GETLUTID(gr_im_id,0) if pal_id ge 0 then begin if info then print_info, info, text," "+im_name+"_palette: exist" else begin result = HDF_GR_GETLUTINFO(pal_id, ncomp, data_type, interlace, num_entries) if num_entries ge 1 then $ result = HDF_GR_READLUT( pal_id, pal_data, interlace=interlace) endelse endif if not(info) and keyword_set(pointer) then begin image = ptr_new( image,/no_copy) att_stru = ptr_new( att_stru,/no_copy) pal_data = ptr_new( pal_data,/no_copy) endif image_stru=add_stru(image_stru,"image",image) image_stru=add_stru(image_stru,"attributes",att_stru) image_stru=add_stru(image_stru,"lut",pal_data) ende: return,image_stru end function hdf_read_sd, sd_id, sdnr,info,text,pointer=pointer $ ,start = start, count = count $ ,channel = channel ; reads a full hdf_sd into a structure ; sd_id is the lun of the already opened hdf-file ; info and text are needed for some information-print-out sd_stru=0 ii=strcompress(string(sdnr),/rem) sds_id=hdf_sd_select(sd_id,sdnr) hdf_sd_getinfo,sds_id,caldata=caldata,coordsys=coordsys $ ,dims=dims,format=format,label=label,name=name,natts=natts $ ,ndims=ndims,unit=unit if info ne 0 then begin if info ne 2 then begin print_info, info, text," "+name print_info, info, text," "+name+"_dimensions : "+strjoin_1(string(dims),",") print_info, info, text," "+name+"_label : "+string(label) print_info, info, text," "+name+"_unit : "+string(unit) print_info, info, text," "+name+"_coordsys : "+string(coordsys) print_info, info, text," "+name+"_format : "+string(format) endif sd_stru=add_stru(sd_stru,"dimensions",dims) sd_stru=add_stru(sd_stru,"label",label) sd_stru=add_stru(sd_stru,"unit",unit) sd_stru=add_stru(sd_stru,"coordsys",coordsys) sd_stru=add_stru(sd_stru,"format",format) endif else begin ; Only read slices from the full SD dataset if keyword_set(channel) then begin if ndims ne 3 then begin print, 'The "channel" keyword is only useful for three-dimensional SD datasets!' goto, ende endif start = [0, 0, channel] count = [dims[0:1], 1] endif dummy = keyword_set(start) + 2 * keyword_set(count) if dummy eq 0 then hdf_sd_getdata,sds_id,data if dummy eq 1 then hdf_sd_getdata,sds_id,data, start = start if dummy eq 2 then hdf_sd_getdata,sds_id,data, start = count * 0., count = count if dummy eq 3 then hdf_sd_getdata,sds_id,data, start = start, count = count if name eq "" then name="sd_dataset_"+ii sd_stru=add_stru(sd_stru,"data",data) sd_stru=add_stru(sd_stru,"caldata",caldata) sd_stru=add_stru(sd_stru,"label",label) sd_stru=add_stru(sd_stru,"unit",unit) sd_stru=add_stru(sd_stru,"coordsys",coordsys) endelse if natts gt 0 then begin att_stru=0 print_info, info, text," "+name+"_attributtes: " for j=0,natts-1l do begin HDF_SD_ATTRINFO, sds_id, j,name=atname,data=data if info then print_info, info, text," : "+atname else $ att_stru=add_stru(att_stru,good_name(atname),data) endfor endif sd_stru=add_stru(sd_stru,"attributes",att_stru) if keyword_set(pointer) then begin sd_stru = ptr_new(sd_stru,/no_copy) endif ende: return,sd_stru end function hdf_read_vd,hdf_id,vd_id,info,text,vd_name,nspace $ ,vdata_ok=vdata_ok,vdata_not=vdata_not $ ,vd_fields_ok=vd_fields_ok $ ,vd_fields_not=vd_fields_not $ ,ok=ok,pointer=pointer ; reads a full vdata into a structure ; vd_id is the handle of the data ; info,text,nspace are needed for some information-print-out vd_str=0 vdd_id = hdf_vd_attach(hdf_id, vd_id,/READ) hdf_vd_get,vdd_id,class=class,count=count,fields=fields $ ,interlace=interlace,name=vd_name,nfields=nfields $ ,ref=ref,size=rec_size,tag=tag ok=valid_name(vd_name,nmc=vdata_ok,nmnc=vdata_not) if not ok then goto,ende ;print,"tag",tag,"ref",ref vd_str=add_stru(vd_str,"name",vd_name) vd_str=add_stru(vd_str,"class",class) vd_str=add_stru(vd_str,"nfields",nfields) vd_str=add_stru(vd_str,"fields",fields) vd_str=add_stru(vd_str,"tag",tag) vd_str=add_stru(vd_str,"ref",ref) vd_str=add_stru(vd_str,"interlace",interlace) vd_str=add_stru(vd_str,"record_size",rec_size) print_info, info, text,strjoin_1(replicate(" ",nspace))+"vd_name:"+string(vd_name) print_info, info, text,strjoin_1(replicate(" ",nspace))+"vd_class:"+string(class) print_info, info, text,strjoin_1(replicate(" ",nspace))+"vd_fields:"+string(fields) print_info, info, text,strjoin_1(replicate(" ",nspace))+"vd_nfields:"+string(nfields) print_info, info, text,strjoin_1(replicate(" ",nspace))+"vd_tag:"+string(tag) print_info, info, text,strjoin_1(replicate(" ",nspace))+"vd_ref:"+string(ref) print_info, info, text,strjoin_1(replicate(" ",nspace))+"vd_interlace:"+string(interlace) print_info, info, text,strjoin_1(replicate(" ",nspace))+"vd_record_size:"+string(rec_size) fields=str_sep(fields,",") for i=0l,nfields-1l do begin field_str=0 field_ok=valid_name(fields(i),nmc=vd_fields_ok,nmnc=vd_fields_not) and keyword_set(vd_fields_ok) if field_ok then begin if not(info) then result=hdf_vd_read(vdd_id,data,fields=fields(i)) field_str=add_stru(field_str,"name",fields(i)) field_str=add_stru(field_str,"data",data) hdf_vd_getinfo,vdd_id,fields(i),order=order,size=size,type=type field_str=add_stru(field_str,"order",order) field_str=add_stru(field_str,"size",size) field_str=add_stru(field_str,"type",type) print_info, info, text,strjoin_1(replicate(" ",nspace))+" "+fields(i)+"_order:"+string(order) print_info, info, text,strjoin_1(replicate(" ",nspace))+" "+fields(i)+"_size:"+string(size) print_info, info, text,strjoin_1(replicate(" ",nspace))+" "+fields(i)+"_type:"+string(type) if keyword_set(pointer) then begin field_str= ptr_new(field_str,/no_copy) endif vd_str=add_stru(vd_str,good_name("field_"+fields(i)),field_str) endif endfor ende: hdf_vd_detach,vdd_id return,vd_str end function hdf_read_vg,hdf_id,vg_id,info,text,vg_name,nspace $ ,vgroups_ok=vgroups_ok,vgroups_not=vgroups_not,ok=ok,number=number $ ,vdata_ok=vdata_ok,vdata_not=vdata_not,filename=filename $ ,pointer=pointer,vg_recursive=vg_recursive ; reads a full vgroup (recursive, if set) into a structure ; vg_id is the handle of the group ; info,text,nspace are needed for some information-print-out if not keyword_set(number) then number="" vg_str=0 nspace_add=2 vgg_id = hdf_vg_attach(hdf_id, vg_id, /READ) hdf_vg_getinfo,vgg_id,class=class,name=vg_name,nentries=nentries ok=valid_name(vg_name,nmc=vgroups_ok,nmnc=vgroups_not) ;if not ok then goto, ende vg_str=add_stru(vg_str,"type",hdf_type(1965)) vg_str=add_stru(vg_str,"name",reference_name(filename,1965,vg_id)) vg_str=add_stru(vg_str,"tag",1965) vg_str=add_stru(vg_str,"reference",vg_id) vg_str=add_stru(vg_str,"class",class) vg_str=add_stru(vg_str,"n_entries",nentries) print_info, info, text,strjoin_1(replicate(" ",nspace))+"vgroup_name:"+string(vg_name) print_info, info, text,strjoin_1(replicate(" ",nspace))+"vgroup_class:"+string(class) print_info, info, text,strjoin_1(replicate(" ",nspace))+"vgroup_nentries:"+string(nentries) idid=-1 for i=0l, nentries-1l do begin num=number+"_"+strcompress(string(i+1),/rem) hdf_vg_gettr, vgg_id,i,tag,ref idid=hdf_vg_getnext(vgg_id,idid) case tag of 1965: begin ; tag 1965 = vgroups if keyword_set(vg_recursive) then begin nspace=nspace+nspace_add dum=hdf_read_vg(hdf_id,idid,info,text,vg_name,nspace $ ,vgroups_ok=vgroups_ok,vgroups_not=vgroups_not,ok=ok $ ,vdata_ok=vdata_ok,vdata_not=vdata_not,number=num $ ,filename=filename,pointer=pointer $ ,vg_recursive=vg_recursive) nspace=nspace-nspace_add if ok then begin vg_str=add_stru(vg_str,good_name("vg_entrie"+num),dum) endif endif else begin vg_obj_str=0 vg_obj_str=add_stru(vg_obj_str,"type",hdf_type(tag)) vg_obj_str=add_stru(vg_obj_str,"name" $ ,reference_name(filename,tag,ref,class=class,name=name,nentries=nentries)) vg_obj_str=add_stru(vg_obj_str,"tag",tag) vg_obj_str=add_stru(vg_obj_str,"reference",ref) vg_obj_str=add_stru(vg_obj_str,"class",class) vg_obj_str=add_stru(vg_obj_str,"n_entries",nentries) vg_str=add_stru(vg_str,good_name("vg_entrie"+num),vg_obj_str) endelse end 720: begin vg_obj_str=0 vg_obj_str=add_stru(vg_obj_str,"type",hdf_type(tag)) vg_obj_str=add_stru(vg_obj_str,"name" $ ,reference_name(filename,tag,ref,dims=dims,type=typ)) vg_obj_str=add_stru(vg_obj_str,"tag",tag) vg_obj_str=add_stru(vg_obj_str,"reference",ref) vg_obj_str=add_stru(vg_obj_str,"data_dims",strcompress("("+strjoin_1(string(dims),",")+")",/rem)) vg_obj_str=add_stru(vg_obj_str,"data_type",typ) vg_str=add_stru(vg_str,good_name("vg_entrie"+num),vg_obj_str) end 1962: begin vg_obj_str=0 vg_obj_str=add_stru(vg_obj_str,"type",hdf_type(tag)) vg_obj_str=add_stru(vg_obj_str,"name" $ ,reference_name(filename,tag,ref,nfields=nfields,fields=fields,count=count)) vg_obj_str=add_stru(vg_obj_str,"tag",tag) vg_obj_str=add_stru(vg_obj_str,"reference",ref) vg_obj_str=add_stru(vg_obj_str,"n_records",count) vg_obj_str=add_stru(vg_obj_str,"n_fields",nfields) vg_obj_str=add_stru(vg_obj_str,"fields",fields) vg_str=add_stru(vg_str,good_name("vg_entrie"+num),vg_obj_str) end else: begin vg_obj_str=0 vg_obj_str=add_stru(vg_obj_str,"type",hdf_type(tag)) vg_obj_str=add_stru(vg_obj_str,"tag",tag) vg_obj_str=add_stru(vg_obj_str,"reference",ref) vg_str=add_stru(vg_str,good_name("vg_entrie"+num),vg_obj_str) end endcase endfor return,vg_str end function eos_read_point, pt_file_id, pointname,info,text,pointer=pointer ; reads a full eos_point into a structure ; pt_file_id is the lun of the already opened eos-file ; info and text are needed for some information-print-out pt_id=eos_pt_attach(pt_file_id,pointname) n_att=eos_pt_inqattrs(pt_id,attlist) print_info, info, text,""+pointname pt_str=0 if n_att gt 0 then begin attlist=str_sep(attlist,",") att_str=0 print_info, info, text," "+pointname+"_attributes:" for j=0l,n_att-1l do begin dum=eos_pt_readattr(pt_id,attlist(j),value) att_str=add_stru(att_str,good_name(attlist(j)),value) print_info, info, text," "+attlist(j)+ ": "+strcompress(string(value)) endfor endif pt_str=add_stru(pt_str,"attributes",att_str) nlevels=eos_pt_nlevels(pt_id) print_info, info, text," "+pointname+"_n_levels:"+string(nlevels) if nlevels gt 0 then begin for j=0l,nlevels-1l do begin nfields=eos_pt_nfields(pt_id,j) Result = eos_pt_levelinfo(pt_id, j, fieldlist,hdf_typ,hdf_order) nrecs=eos_pt_nrecs(pt_id,j) fieldlist=str_sep(fieldlist,",") lev_str=0 lev_str=add_stru(lev_str,"fieldlist",fieldlist) lev_str=add_stru(lev_str,"nfields",nfields) lev_str=add_stru(lev_str,"nrec",nrecs) print_info, info, text," "+pointname+" level"+strcompress(string(j))+":" print_info, info, text," nfields: "+strcompress(string(nfields)) print_info, info, text," nrecs: "+strcompress(string(nrecs)) print_info, info, text," fieldlist:"+strjoin_1(fieldlist,",") if nfields gt 0 and not info then begin for k=0l, nfields -1l do begin dum = eos_pt_readlevel(pt_id, j, fieldlist(k), nrecs, findgen(nrecs), buffer) hdf_unpackdata,buffer,data,hdf_order=hdf_order(k),hdf_type=hdf_typ(k),nrec=nrecs lev_str=add_stru(lev_str,good_name(fieldlist(k)),data) endfor endif if j gt 0 then lev_str=[lev_str,lev_str] endfor endif if keyword_set(pointer) then begin lev_str = ptr_new(lev_str,/no_copy) endif pt_str=add_stru(pt_str,"levels",lev_str) dum=eos_pt_detach(pt_id) return,pt_str end function eos_read_grid, gd_file_id, gridname,info,text,eos_grids_ok,eos_grids_not,pointer=pointer ; reads a full eos_grid into a structure ; ge_file_id is the lun of the already opened eos-file ; info and text are needed for some information-print-out gd_id=eos_gd_attach(gd_file_id,gridname) n_att=eos_gd_inqattrs(gd_id,attlist) n_dims=eos_gd_gridinfo(gd_id,xdimsize, ydimsize, upleft, lowright) print_info, info, text,""+gridname print_info, info, text," "+gridname+" xdimsize: "+string(xdimsize) print_info, info, text," "+gridname+" ydimsize: "+string(ydimsize) print_info, info, text," "+gridname+" upleft: "+string(upleft) print_info, info, text," "+gridname+" lowright: "+string(lowright) if n_dims gt 0 then begin dimnames=str_sep(dimnames,",") print_info, info, text," "+gridname+" dimnames: "+string(dimnames) endif gd_str=0 if n_att gt 0 then begin attlist=str_sep(attlist,",") att_str=0 for j=0l,n_att-1l do begin dum=eos_gd_readattr(gd_id,attlist(j),value) att_str=add_stru(att_str,good_name(attlist(j)),value) print_info, info, text," "+gridname+"_attribut_"+string(attlist(j))+": "+string(value) endfor endif nfields=eos_gd_inqfields(gd_id,fieldlist,rank,type) fieldlist=str_sep(fieldlist,",") if nfields gt 0 then begin field_str=0 for j=0,nfields-1 do begin if valid_name(fieldlist(j),nmc=eos_grids_ok,nmnc=eos_grids_not) then begin print_info, info, text," "+gridname+"_field_"+fieldlist(j) if not info then result=eos_gd_readfield(gd_id,fieldlist(j),buffer) field_str=add_stru(field_str,good_name(fieldlist(j)),buffer) result=eos_gd_getfillvalue(gd_id,fieldlist(j),value) field_str=add_stru(field_str,good_name(fieldlist(j))+"_fillvalue",value) print_info, info, text," "+gridname+"_field_"+fieldlist(j)+"_fillvalue "+string(float(value)) result=eos_gd_fieldinfo(gd_id, fieldlist(j), rank, dims, numbertype, dimlist) field_str=add_stru(field_str,good_name(fieldlist(j))+"_rank",rank) field_str=add_stru(field_str,good_name(fieldlist(j))+"_dims",dims) field_str=add_stru(field_str,good_name(fieldlist(j))+"_numbertype",numbertype) field_str=add_stru(field_str,good_name(fieldlist(j))+"_dimlist",dimlist) print_info, info, text," "+gridname+"_field_"+fieldlist(j)+"_rank "+string(rank) print_info, info, text," "+gridname+"_field_"+fieldlist(j)+"_dims "+string(dims) print_info, info, text," "+gridname+"_field_"+fieldlist(j)+"_numbertype "+string(numbertype) print_info, info, text," "+gridname+"_field_"+fieldlist(j)+"_dimlist "+string(dimlist) endif endfor endif ;stop result=eos_gd_origininfo(gd_id,ocode) result=eos_gd_projinfo(gd_id,pcode,zcode,spcode,projparm) proj_str=0 proj_str=add_stru(proj_str,"proj_code",pcode) proj_str=add_stru(proj_str,"origin_code",ocode) proj_str=add_stru(proj_str,"zone",zcode) proj_str=add_stru(proj_str,"sphere",spcode) proj_str=add_stru(proj_str,"parameter",projparm) print_info, info, text," "+gridname+"_projection_"+"proj_code"+string(pcode) print_info, info, text," "+gridname+"_projection_"+"origin_code"+string(ocode) print_info, info, text," "+gridname+"_projection_"+"zone"+string(zcode) print_info, info, text," "+gridname+"_projection_"+"sphere"+string(spcode) print_info, info, text," "+gridname+"_projection_"+"parameter"+strjoin_1(string(projparm),",") gd_str=add_stru(gd_str,"fields",field_str) gd_str=add_stru(gd_str,"attributes",att_str) gd_str=add_stru(gd_str,"xdimsize",xdimsize) gd_str=add_stru(gd_str,"ydimsize",ydimsize) gd_str=add_stru(gd_str,"upleft",upleft) gd_str=add_stru(gd_str,"lowright",lowright) gd_str=add_stru(gd_str,"projection",proj_str) dum=eos_gd_detach(gd_id) if keyword_set(pointer) then begin gd_str = ptr_new(gd_str,/no_copy) endif return,gd_str end function eos_read_swath, sw_file_id, swathname,info,text,eos_swaths_ok,eos_swaths_not,pointer=pointer ; reads a full eos_swath into a structure ; sw_file_id is the lun of the already opened eos-file ; info and text are needed for some information-print-out sw_id=eos_sw_attach(sw_file_id,swathname) n_att=eos_sw_inqattrs(sw_id,attlist) n_dims=eos_sw_inqdims(sw_id,dimnames, dims) n_geofields=eos_sw_inqgeofields(sw_id,geofieldlist,geofieldrank,geofieldtype) n_datafields=eos_sw_inqdatafields(sw_id,datafieldlist,datafieldrank,datafieldtype) n_idxmaps=eos_sw_inqidxmaps(sw_id,idxmaplist,idxmapsizes) n_maps=eos_sw_inqmaps(sw_id,maplist,offset,increment) print_info, info, text,""+swathname ;print_info, info, text," "+swathname+"_dims: "+dimnames+strjoin_1(string(dims),",") if n_dims gt 0 then begin dimnames=str_sep(dimnames,",") for i=0, n_dims -1 do print_info, info, text," "+swathname+" dimnames: "+dimnames(i)+string(dims(i)) endif print_info, info, text," "+swathname+"_idxmaplist: "+idxmaplist print_info, info, text," "+swathname+"_maplist: "+maplist geofieldlist=str_sep(geofieldlist,",") datafieldlist=str_sep(datafieldlist,",") idxmaplist=str_sep(idxmaplist,",") maplist=str_sep(maplist,",") sw_str=0 if n_att gt 0 then begin attlist=str_sep(attlist,",") att_str=0 for j=0l,n_att-1l do begin dum=eos_sw_readattr(sw_id,attlist(j),value) att_str=add_stru(att_str,good_name(attlist(j)),value) print_info, info, text," "+swathname+"_attribut_"+string(attlist(j))+": "+value endfor endif if n_geofields gt 0 then begin geofield_str=0 for j=0,n_geofields-1 do begin if valid_name(geofieldlist(j),nmc=eos_swaths_ok,nmnc=eos_swaths_not) then begin print_info, info, text," "+swathname+"_geofield "+string(j,format="(i3)")+" "+geofieldlist(j) if not info then result=eos_sw_readfield(sw_id,geofieldlist(j),buffer) geofield_str=add_stru(geofield_str,good_name(geofieldlist(j)),buffer) endif endfor endif if n_datafields gt 0 then begin datafield_str=0 for j=0,n_datafields-1 do begin if valid_name(datafieldlist(j),nmc=eos_swaths_ok,nmnc=eos_swaths_not) then begin print_info, info, text," "+swathname+"_datafield "+string(j,format="(i3)")+" "+datafieldlist(j) if not info then result=eos_sw_readfield(sw_id,datafieldlist(j),buffer) datafield_str=add_stru(datafield_str,good_name(datafieldlist(j)),buffer) endif endfor endif if n_elements(maplist) gt 0 then begin map_str=0 for j=0l, n_elements(maplist)-1l do begin pair=str_sep(maplist(j),"/") if n_elements(pair) eq 2 then begin result=eos_sw_mapinfo(sw_id,pair(0),pair(1),offset,increment) map_str=add_stru(map_str,good_name(maplist(j))+"_offset",offset) map_str=add_stru(map_str,good_name(maplist(j))+"_increment",increment) print_info, info, text," "+swathname+"_"+maplist(j)+"_offset: "+string(long(offset)) print_info, info, text," "+swathname+"_"+maplist(j)+"_increment: "+string(long(increment)) endif endfor endif if n_elements(idxmaplist) gt 0 then begin idxmap_str=0 for j=0l, n_elements(idxmaplist)-1l do begin pair=str_sep(idxmaplist(j),"/") if n_elements(pair) eq 2 then begin result=eos_sw_idxmapinfo(sw_id,pair(0),pair(1),index) idxmap_str=add_stru(map_str,good_name(maplist(j))+"_index",index) endif endfor endif ;stop sw_str=add_stru(sw_str,"datafields",temporary(datafield_str)) sw_str=add_stru(sw_str,"geofields",temporary(geofield_str)) sw_str=add_stru(sw_str,"map",map_str) sw_str=add_stru(sw_str,"index_map",idxmap_str) sw_str=add_stru(sw_str,"attributes",att_str) dum=eos_sw_detach(sw_id) if keyword_set(pointer) then begin sw_str = ptr_new(sw_str,/no_copy) endif return,sw_str end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; pro read_all_all,filename,pointer=pointer,info,text,out,eos_and_hdf=eos_and_hdf $ ,eos_grids_ok=eos_grids_ok,eos_grids_not=eos_grids_not $ ,eos_swaths_ok=eos_swaths_ok,eos_swaths_not=eos_swaths_not $ ,eos_points_ok=eos_points_ok,eos_points_not=eos_points_not $ ,gen_ras_ok=gen_ras_ok,gen_ras_not=gen_ras_not,gen_ras_an=gen_ras_an $ ,sci_data_ok=sci_data_ok,sci_data_not=sci_data_not,sci_data_an=sci_data_an $ ,vgroups_ok=vgroups_ok,vgroups_not=vgroups_not,vg_recursive=vg_recursive $ ,vdata_ok=vdata_ok,vdata_not=vdata_not $ ,vd_fields_ok=vd_fields_ok,vd_fields_not=vd_fields_not $ ,annotations=annotations $ ,start = start, count = count, varnum=varnum $ ,channel = channel ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;on_ioerror, some_io_error ; go directly to eos if it is a eos file and eos_and_hdf is NOT set if !version.release lt 5.3 then todo=0 else todo=(eos_query(filename)) and (not keyword_set(eos_and_hdf)) case todo of ;classic hdf 0:begin if not hdf_ishdf(filename) then begin goto,hdf_classic_ende endif ;all annotations hdf_id=hdf_open(filename) an_id=hdf_an_start(hdf_id) if (an_id ne -1) and keyword_set(annotations) then begin an_out=hdf_read_an(an_id,info,text,n_ano) if n_ano ge 1 then print_info, info, text,"File has annotation data" $ else print_info, info, text,"File has no annotation data" HDF_AN_END, an_id endif else print_info, info, text,"File has no annotation data" my_hdf_close,hdf_id ;all generic raster hdf_id=hdf_open(filename) gr_id = hdf_gr_start(hdf_id) result = hdf_gr_fileinfo(gr_id, n_images, n_file_attrs) if (n_images gt 0) and keyword_set(gen_ras_ok) then begin print_info, info, text,"File has generic raster images" for i=0l,n_images-1l do begin image_str=hdf_read_gr(gr_id,i,info,text,im_name,ok=ok,gen_ras_ok=gen_ras_ok,pointer=pointer) if ok then gr_out=add_stru(gr_out,good_name(im_name),image_str) endfor endif else print_info, info, text,"File has no generic raster images" if (n_file_attrs gt 0) and keyword_set(gen_ras_an) then begin att_stru=0 print_info, info, text,"generic raster global attributes:" for i=0l,n_file_attrs-1l do begin result = hdf_gr_attrinfo(gr_id,i, name,type,count) if info then print_info, info, text," "+name else begin result = hdf_gr_getattr(gr_id,i, value) att_stru=add_stru(att_stru,good_name(name),value) endelse endfor gr_out=add_stru(gr_out,"global_attributes",att_stru) endif HDF_GR_END, gr_id my_hdf_close,hdf_id ;all vgroups and vdata hdf_id=hdf_open(filename) vg_idx=hdf_vg_lone(hdf_id) vg_out=0 nspace=2 ; if (size(vg_idx))[0] gt 0 then begin if ((vg_idx)[0] gt 0) and keyword_set(vgroups_ok) then begin print_info, info, text,"File has vgroups" case keyword_set(vg_recursive) of 1:begin for i=0l, n_elements(vg_idx)-1l do begin vg_str=hdf_read_vg(hdf_id,vg_idx(i),info,text,vg_name,nspace $ ,vgroups_ok=vgroups_ok,vgroups_not=vgroups_not $ ,vdata_ok=vdata_ok,vdata_not=vdata_not,ok=ok $ ,filename=filename,vg_recursive=vg_recursive) if ok then vg_out=add_stru(vg_out,good_name(vg_name),vg_str) endfor end else: begin vg_idx=hdf_number(hdf_id,tag=1965) ; vgroups idx=-1 for i=0l, vg_idx-1l do begin idx=HDF_VG_GETID(hdf_id,idx) vg_str=hdf_read_vg(hdf_id,idx,info,text,vg_name,nspace $ ,vgroups_ok=vgroups_ok,vgroups_not=vgroups_not $ ,vdata_ok=vdata_ok,vdata_not=vdata_not,ok=ok $ ,filename=filename,vg_recursive=vg_recursive) if ok then vg_out=add_stru(vg_out,good_name(vg_name),vg_str) endfor end endcase endif else print_info, info, text,"File has no vgroups" my_hdf_close,hdf_id hdf_id=hdf_open(filename) vd_idx=hdf_number(hdf_id,tag=1963) ; vdata vd_out=0 nspace=2 if vd_idx gt 0 and keyword_set(vdata_ok) then begin print_info, info, text,"File has vdata" idx=-1 for i=0l, vd_idx-1l do begin idx=HDF_VD_GETID(hdf_id, idx) vd_str=hdf_read_vd(hdf_id,idx,info,text,vd_name,nspace $ ,vdata_ok=vdata_ok,vdata_not=vdata_not $ ,vd_fields_ok=vd_fields_ok $ ,vd_fields_not=vd_fields_not $ ,ok=ok,pointer=pointer) if ok then vd_out=add_stru(vd_out,good_name(vd_name),vd_str) endfor endif else print_info, info, text,"File has no vdata" my_hdf_close,hdf_id hdf_classic_ende: ; it could be a ncdf ; all sd_data sd_id=hdf_sd_start(filename,/read) if (sd_id ne -1) and keyword_set(sci_data_ok) then begin hdf_sd_fileinfo, sd_id, n_sd, n_file_attr if n_sd gt 0 then begin print_info, info, text,"File has scientific (multidimensional) data" if not !quiet then print,"File has scientific (multidimensional) data" only_one = is_defined(start) or is_defined(count) or is_defined(channel) or is_defined(varnum) varcount=0 for i=0l, n_sd-1l do begin sds_id=hdf_sd_select(sd_id,i) hdf_sd_getinfo,sds_id,name=name ok=valid_name(name,nmc=sci_data_ok,nmnc=sci_data_not, exact=only_one) if only_one and ok then begin if not is_defined((varnum)) then varnum=0 varcount=varcount+1 ok=ok and (varcount gt varnum) endif if ok then begin sd_str=hdf_read_sd(sd_id,i,info,text,pointer=pointer $ , start=start, count=count, channel=channel) sd_out=add_stru(sd_out,good_name(name),sd_str) if only_one then goto, weiter endif endfor weiter: endif else print_info, info, text,"File has no scientific (multidimensional) data" ; Die nächsten drei Zeilen sorgen dafür, dass man globale Attribute auch ohne ; setzen von sci_data_ok einlesen kann ; PA 12.11.01 endif if (sd_id ne -1) and keyword_set(sci_data_an) then begin hdf_sd_fileinfo, sd_id, n_sd, n_file_attr if n_file_attr gt 0 and keyword_set(sci_data_an) then begin att_stru=0 print_info, info, text," scientific data global attributes: " for i=0,n_file_attr-1l do begin HDF_SD_ATTRINFO, sd_id, i,name=atname,data=data att_stru=add_stru(att_stru,good_name(atname),data) print_info, info, text,"+ "+atname+" : "+string(data) endfor sd_out=add_stru(sd_out,"global_attributes",att_stru) endif endif HDF_SD_END, sd_id ;if not eos_query(filename) then print_info, info, text,"File has no EOS data" end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;eos hdf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1:begin dum=eos_query(filename,eos_info) print_info, info, text,"File has EOS data" if (eos_info.num_points gt 0) and keyword_set(eos_points_ok) then begin print_info, info, text,"File has EOS point data" pt_file_id=eos_pt_open(filename,/read) dum=eos_pt_inqpoint(filename,pointlist) pointlist=str_sep(pointlist,",") pt_out=0 for i=0l,eos_info.num_points-1l do begin ok=valid_name(pointlist(i),nmc=eos_points_ok,nmnc=eos_points_not) if ok then pt_str=eos_read_point(pt_file_id, pointlist(i),info,text,pointer=pointer) if ok then pt_out=add_stru(pt_out,pointlist(i),pt_str) endfor result=eos_pt_close(pt_file_id) endif else print_info, info, text,"File has no EOS Point data" if (eos_info.num_grids gt 0) and keyword_set(eos_grids_ok) then begin print_info, info, text,"File has EOS grid data" gd_file_id=eos_gd_open(filename,/read) dum=eos_gd_inqgrid(filename,gridlist) gridlist=str_sep(gridlist,",") gd_out=0 for i=0l,eos_info.num_grids-1l do begin ok=valid_name(gridlist(i),nmc=eos_grids_ok,nmnc=eos_grids_not) if ok then gd_str=eos_read_grid(gd_file_id, gridlist(i),info,text,eos_grids_ok,eos_grids_not,pointer=pointer) if ok then gd_out=add_stru(gd_out,gridlist(i),gd_str) endfor result=eos_gd_close(gd_file_id) endif else print_info, info, text,"File has no EOS grid data" if (eos_info.num_swaths gt 0) and keyword_set(eos_swaths_ok) then begin print_info, info, text,"File has EOS swath data" sw_file_id=eos_sw_open(filename,/read) dum=eos_sw_inqswath(filename,swathlist) swathlist=str_sep(swathlist,",") sw_out=0 for i=0l,eos_info.num_swaths-1l do begin ok=valid_name(swathlist(i),nmc=eos_swaths_ok,nmnc=eos_swaths_not) if ok then sw_str=eos_read_swath(sw_file_id, swathlist(i),info,text,eos_swaths_ok,eos_swaths_not,pointer=pointer) if ok then sw_out=add_stru(sw_out,swathlist(i),sw_str) endfor result=eos_sw_close(sw_file_id) endif else print_info, info, text,"File has no EOS swath data" end endcase out=0 if (shift(size(an_out),2))[0] eq 8 then out=add_stru(out,"annotations",an_out) if (shift(size(gr_out),2))[0] eq 8 then out=add_stru(out,"generic_raster",gr_out) if (shift(size(vg_out),2))[0] eq 8 then out=add_stru(out,"vgroups",vg_out) if (shift(size(vd_out),2))[0] eq 8 then out=add_stru(out,"vdata",vd_out) if (shift(size(sd_out),2))[0] eq 8 then out=add_stru(out,"scientific_data",sd_out) if (shift(size(pt_out),2))[0] eq 8 then out=add_stru(out,"eos_point_data",pt_out) if (shift(size(gd_out),2))[0] eq 8 then out=add_stru(out,"eos_grid_data",gd_out) if (shift(size(sw_out),2))[0] eq 8 then out=add_stru(out,"eos_swath_data",sw_out) return some_io_error: print, "An input error occurs !!" print, "Probably "+filename+" is corrupted or not a valid hdf/eos/ncdf file" end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;MAIN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;MAIN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;MAIN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;MAIN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; pro hdf_read_structure, out ,filename=filename,pointer=pointer,eos_and_hdf=eos_and_hdf $ ,eos_grids_ok=eos_grids_ok,eos_grids_not=eos_grids_not $ ,eos_swaths_ok=eos_swaths_ok,eos_swaths_not=eos_swaths_not $ ,eos_points_ok=eos_points_ok,eos_points_not=eos_points_not $ ,gen_ras_ok=gen_ras_ok,gen_ras_not=gen_ras_not,gen_ras_an=gen_ras_an $ ,sci_data_ok=sci_data_ok,sci_data_not=sci_data_not,sci_data_an=sci_data_an $ ,sd_data_ok=sd_data_ok,sd_data_not=sd_data_not,sd_data_an=sd_data_an $ ,vgroups_ok=vgroups_ok,vgroups_not=vgroups_not,vg_recursive=vg_recursive $ ,vdata_ok=vdata_ok,vdata_not=vdata_not $ ,vd_fields_ok=vd_fields_ok,vd_fields_not=vd_fields_not $ ,annotations=annotations $ ,all=all,help=help,info=info $ ,start = start, count = count ,varnum=varnum $ ,channel = channel ;catch,error error=0 if error or keyword_set(help) or (n_params() ne 1) then begin print_help,"hdf_read_structure" return endif if !version.os_family eq "unix" then filter='*[he.][don][fsc]' $ else filter="*.hdf" if not keyword_set(filename) then begin ; undefinend filename=pickfile(title='Select File',filter=filter) if filename eq "" then goto,ende endif result=findfile(filename, count=c) if c ne 1 then begin print, 'File does not exist: ', filename filename=pickfile(title='File does not exist: select new!',filter=filter) if filename eq '' then goto,ende endif test = hdf_open(filename) if test eq -1 then begin print, 'Something is wrong with the file' out = -1 goto,ende endif my_hdf_close, test text=" " if not keyword_set(info) then begin info=0 text=0 endif else begin if (byte(info))[0] eq 1 then begin text=0 endif if string(info) eq 'quiet' then begin text = 0 info = 2 endif else begin infofile=info info=1 endelse endelse if !version.release lt 5.3 and $ (keyword_set(eos_grids_ok) or keyword_set(eos_swaths_ok) or keyword_set(eos_points_ok)) $ then begin print, "EOS is not suported with this version of idl" endif if keyword_set(sd_data_ok) then sci_data_ok=sd_data_ok if keyword_set(sd_data_not) then sci_data_ok=sd_data_not if keyword_set(sd_data_an) then sci_data_ok=sd_data_an if keyword_set(all) then begin eos_grids_ok=1 eos_swaths_ok=1 eos_points_ok=1 annotations=1 gen_ras_ok=1 gen_ras_an=1 sci_data_ok=1 sci_data_an=1 vgroups_ok=1 vdata_ok=1 vd_fields_ok=1 if keyword_set(eos_grids_not) then dum=temporary(eos_grids_not) if keyword_set(eos_swaths_not) then dum=temporary(eos_swaths_not) if keyword_set(eos_points_not) then dum=temporary(eos_points_not) if keyword_set(gen_ras_not) then dum=temporary(gen_ras_not) if keyword_set(sci_data_not) then dum=temporary(sci_data_not) if keyword_set(vgroups_not) then dum=temporary(vgroups_not) if keyword_set(vdata_not) then dum=temporary(vdata_not) if keyword_set(vd_fields_not) then dum=temporary(vd_fields_not) endif read_all_all,filename,pointer=pointer,info,text,out,eos_and_hdf=eos_and_hdf $ ,eos_grids_ok=eos_grids_ok,eos_grids_not=eos_grids_not $ ,eos_swaths_ok=eos_swaths_ok,eos_swaths_not=eos_swaths_not $ ,eos_points_ok=eos_points_ok,eos_points_not=eos_points_not $ ,gen_ras_ok=gen_ras_ok,gen_ras_not=gen_ras_not,gen_ras_an=gen_ras_an $ ,sci_data_ok=sci_data_ok,sci_data_not=sci_data_not,sci_data_an=sci_data_an $ ,vgroups_ok=vgroups_ok,vgroups_not=vgroups_not,vg_recursive=vg_recursive $ ,vdata_ok=vdata_ok,vdata_not=vdata_not $ ,vd_fields_ok=vd_fields_ok,vd_fields_not=vd_fields_not $ ,annotations=annotations $ ,start = start, count = count ,varnum=varnum $ ,channel = channel if (shift(size(text),2))[0] eq 7 then begin if (shift(size(infofile),2))[0] eq 7 then begin dum=findfile(infofile,count=count) if count gt 0 then $ openu,lun,infofile,/get_lun $ else openw,lun,infofile,/get_lun printf,lun,transpose(text) free_lun,lun xdisplayfile,"/dev/null",text=text endif else xdisplayfile,"/dev/null",text=text endif ende: end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; pro hdf_sd_read_matrix $ ,filename $ ,var $ ,varname=varname $ ,varnum=varnum $ ,count=count $ ,start=start $ ,attributes=attributes $ ,all=all error = 0 if not is_defined(start) then start = 0 ;print,start hdf_read_structure,struc $ ,file=filename $ ,sci_data_ok=[varname] ,/eos_and_hdf $ ,varnum=varnum $ ,count=count $ ,start=start s = size(struc, /type) if s ne 8 then var = 0 $ else begin if keyword_set(all) then var = struc $ else var = struc.(0).(0).data catch, error if error eq 0 then $ attributes =struc.(0).(0).attributes $ else attributes = 'sd data has no attributes' endelse end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;