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

Home » Public Forums » archive » Re: HDF viewer available?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: HDF viewer available? [message #4870] Wed, 16 August 1995 00:00
afl is currently offline  afl
Messages: 51
Registered: December 1994
Member
To view the contents of an HDF SDS one can use netCDF's ncdump utility,
or hdp which I believe is a new HDF dump utility from NCSA.

Here is something I wrote for specific HDF SDS files.
I must add that I have been very impressed with RSI's
new HDF interface. Good job!


;
; Function to obtain information on NASA Goddard's GEOS-1 HDF files.
;
; Originator: Andrew F. Loughe
;
; History: Written 4/28/95
;

FUNCTION GET_HDF_INFO, filename, varname, $
varnames=varnames, coordnames=coordnames, $
lons=lons, lats=lats, levels=levels, times=times, $
title=title, units=units, format=format, id=id, dims=dims

on_error, 2

; Help string
USAGE1='err = get_hdf_info(filename, varname, ' + $
'varnames=varnames, coordnames=coordnames,'
USAGE2=' lons=lons, lats=lats, levels=levels, times=times,'
USAGE3=' title=title, units=units, format=format, id=id, ' + $
'dims=dims)'

; Need at least one parameter passed in.
if (N_params() lt 1) then begin
print, ' '
print, USAGE1
print, USAGE2
print, USAGE3
return, -1
endif

; Supply nonsense varname.
if ( n_elements(varname) eq 0 ) then varname='ZxYzXy'
varname = strlowcase(varname)

; Assign dummy values to ERR and ID.
ERR = -1
ID = -9999

; Check that file is in HDF.
if HDF_ISHDF( filename ) ne 1 then $
message, "File " + filename + " is not an HDF file."

; Open HDF file and initialize the SD interface.
sd_id = HDF_SD_START( filename, /read )

;Get number of datasets and global attributes in this file.
HDF_SD_FILEINFO, sd_id, nmfsds, nglobatts

; Loop through all datasets until correct SDS_NAME (and SDS_ID) is found.
if nmfsds gt 0 then begin
varnames = ''
coordnames = ''
for i = 0, nmfsds-1 do begin
sds_id = HDF_SD_SELECT(sd_id, i)
HDF_SD_GETINFO, sds_id, name=n, ndims=r, type=t, $
natts=nats, dims=dimensions

; Collect all variable names.
if ( HDF_SD_ISCOORDVAR(sds_id) ne 1 ) then $
varnames = [varnames, n + ' ; ']

; If desired variable name is found, get more information.
if ( strpos( strlowcase(n) , varname) ge 0 ) then begin
ERR = 0
ID = sds_id
dims = dimensions
for j = 0, nats-1 do begin
HDF_SD_ATTRINFO, sds_id, j, name=n, data=d
if (n eq 'long_name') then title=d
if (n eq 'units') then units=d
if (n eq 'format') then format=d
endfor
endif


; Get information on coordinate variables.
if ( HDF_SD_ISCOORDVAR(sds_id) eq 1 ) then begin
coordnames = [coordnames, n + ' ; ']
if ( strpos(strlowcase(n), 'longitude') ge 0 ) then $
HDF_SD_GETDATA, sds_id, lons
if ( strpos(strlowcase(n), 'latitude') ge 0 ) then $
HDF_SD_GETDATA, sds_id, lats
if ( strpos(strlowcase(n), 'level') ge 0 ) then $
HDF_SD_GETDATA, sds_id, levels
if ( strpos(strlowcase(n), 'time') ge 0 ) then $
HDF_SD_GETDATA, sds_id, times
endif

HDF_SD_ENDACCESS, sds_id
endfor
endif

; Omit first varname and coordname which is set to a dummy value.
if ( N_elements(varnames) gt 0 ) then $
varnames=varnames( indgen(N_elements(varnames)-1) + 1 )

if ( N_elements(coordnames) gt 0 ) then $
coordnames=coordnames( indgen(N_elements(coordnames)-1) + 1 )


; Close the HDF file.
HDF_SD_END, sd_id


return, err
end
Re: HDF viewer available? [message #4880 is a reply to message #4870] Tue, 15 August 1995 00:00 Go to previous message
rivers is currently offline  rivers
Messages: 228
Registered: March 1991
Senior Member
In article <40qna9$pl3@lace.Colorado.EDU>, afl@cdc.noaa.gov (Andy Loughe) writes:
> In article <DDD2oC.2uH@midway.uchicago.edu>, rivers@cars3.uchicago.edu (Mark
> Rivers) writes:
> |>
> |> Has anyone written an IDL "generic" viewer for HDF files? For now I would
> |> be
> |> happy to just be able to view the "structure" of the HDF file (vgroups, SDs,
> |> etc.) rather than actually view the content as plots or images.
> |>
>
> I am also VERY interested in such a tool!

RSI pointed out to me that $IDL_DIR/examples/hdf_ncdf/hdf_info.pro
does a basic HDF file dump, showing the contents of the HDF file. Note that
there is a minor problem with that routine: the file name of the file is
hdf_info.pro (with underscore), while the name of the routine is hdfinfo
(without underscore). It is helpful for getting basic information on the file.

While on the subject of HDF, has anyone gotten the routine HDF_VG_ADDTR
to work? If so, please let me know. I think I am calling it correctly with
valid arguments, but I am getting an error.

____________________________________________________________
Mark Rivers (312) 702-2279 (office)
CARS (312) 702-9951 (secretary)
Univ. of Chicago (312) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars3.uchicago.edu (Internet)
Re: HDF viewer available? [message #4884 is a reply to message #4880] Tue, 15 August 1995 00:00 Go to previous message
afl is currently offline  afl
Messages: 51
Registered: December 1994
Member
In article <DDD2oC.2uH@midway.uchicago.edu>, rivers@cars3.uchicago.edu (Mark
Rivers) writes:
|>
|> Has anyone written an IDL "generic" viewer for HDF files? For now I would
|> be
|> happy to just be able to view the "structure" of the HDF file (vgroups, SDs,
|> etc.) rather than actually view the content as plots or images.
|>

I am also VERY interested in such a tool!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: VELOVECT problem
Next Topic: Re: PVWAVE - widgets

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

Current Time: Fri Oct 10 07:38:11 PDT 2025

Total time taken to generate the page: 1.67838 seconds