Re: HDF to NCDF

From: Dennis Shea (shea AT XXXXXX)
Date: Mon Mar 08 2004 - 16:58:52 MST


Before answering, a suggestion for new users...

(1) Download the Language and Graphics Mini-Reference Manuals (pdf).

     http://www.cgd.ucar.edu/csm/support/NCL/mini-refman.shtml
     http://www.cgd.ucar.edu/csm/support/CSM_Graphics/graphics_man.shtml

     Here at NCAR we print these on color printers in duplex mode.
     Black-and-white is also fine. It just looks nicer in color.

(2) Become familiar with: http://www.cgd.ucar.edu/csm/support/

(3) Step-by-step tutorial (Examples section):
     http://ngwww.ucar.edu/ngdoc/ng/ug/ncl/gsun/
============================
Yes, NCL can do that.
Note: NCL handles HDF's Scientific Data Set (SDS) *only*.

Since NCL can read HDF-SDS there is no need
to create netCDF. However, if you must create a netCDF file,
the crudest/slowest way is:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
begin
  fili = "input.hdf"
  filo = "output.nc"
  
  hdf = addfile (fili, "r")
  system ("/bin/rm "+filo)
  ncf = addfile (filo, "c")
  
  copy_VarAtts(hdf, ncf) ; copy file attributes
  
  vnames = getfilevarnames(hdf) ; all variables on hdf
  nvar = dimsizes(vnames)
  print (vnames)

  do i=0,nvar-1 ; this could be SLOW
     ncf->$vnames(i)$ = hdf->$vnames(i)$
  end do
  
end

The above could be modified to select only a subset of variables.

>
>Hello,
>
>I would like to convert a HDF file to NCDF format. I just installed NCL
>but I an not really usual with it. Could you eventually indicate how to
>proceed?
>
>Thank you very much,
>
>Vincent
>
>_______________________________________________
>ncl-talk mailing list
>ncl-talk AT ucar.edu
>http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk AT ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk



This archive was generated by hypermail 2b29 : Mon Mar 08 2004 - 16:37:32 MST