Re: how to convert TRMM hdf data to nc files

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri, 12 Jan 2007 09:41:17 -0700 (MST)

On Fri, 12 Jan 2007, Lawrence wrote:

> Hi NCL users,
>
> I am attempting to read TRMM 3B42 datasets (HDF format) from
> http://disc.sci.gsfc.nasa.gov/data/datapool/TRMM/01_Data_Products/02_Gridded/06_3-hour_Gpi_Cal_3B_42/index.html
> ,
> the original data is divided by 8 files per day, and I want to convert them
> to netcdf format and write out dayly files, my NCL scripts is something
> like:
>
> do nyr = 0,5
> day = systemfunc("ls "+path+year(nyr))
> nday = dimsizes(day)
> do n = 0,364
> files = systemfunc("ls "+path+year(nyr)+"/"+day(n)+"/*.HDF")
> nfiles = dimsizes(files)
> fin=addfiles(files,"r")
> ListSetType (fin, "cat")
> pr_in = addfiles_GetVar(fin,files,"precipitation")
> delete(pr_in!0)
> pr_in!0 = "time"
> pr_in&time = (/time/)
> pr_in&time_at_units = "hours since 1998-01-01 00:00:0.0"
> pr_in_at_delta_t = "0000-00-00 03:00:00"
> pr_in_at_avg_period = "0000-00-00 01:00:00"
> delete(pr_in!1)
> delete(pr_in!2)
> pr_in!1 = "lon"
> pr_in&lon = (/lon/)
> pr_in&lon_at_units = "degrees_east"
> pr_in!2 = "lat"
> pr_in@_FillValue = -9999.9
> pr_in&lat = (/lat/)
> pr_in&lat_at_units = "degrees_north"
> precip = pr_in(time|:,lat|:,lon|:)
> printVarSummary(precip)
> dirout = "./"
> filout = year(nyr)+day(n)+".nc"
> system("/bin/rm -f " + dirout + filout)
> fout = addfile (dirout + filout, "c")
> copy_VarAtts(fin, fout)
> fout->precip = precip
> end do
> end do
>
> However, I always get the folllowing warning message:
> warning:VarVarWrite: Dimension names for dimension number (0) don't match,
> assigning name of rhs dimension to lhs and overwriting coordinate variable,
> use "(/../)" if this change is not desired
> warning:VarVarWrite: Dimension names for dimension number (1) don't match,
> assigning name of rhs dimension to lhs and overwriting coordinate variable,
> use "(/../)" if this change is not desired
> warning:VarVarWrite: Dimension names for dimension number (2) don't match,
> assigning name of rhs dimension to lhs and overwriting coordinate variable,
> use "(/../)" if this change is not desired
>
> Could anyone give some suggestions? Your help is appreciated.
>
> Thank you!
> Lawrence

Hi Lawrence,

Since you are reading data into the same variable (pr_in) inside
the loop, anytime you then try to read more data into it, it's going to
try to rectify the attributes and coordinate information for both
sides of the "=" sign.

I suggest deleting pr_in before the end of the loop, so you
are starting with a brand new variable everytime.

Also, you have several of these:

> delete(pr_in!0)

This is just deleting the name of the dimension, and not the actual
values themselves, so this isn't really necessary. If you are
trying to delete the values, try this instead, before you redefine the
values:

   delete(pr_in&$pr_in!0$)

You really only need to delete the coordinate values if the new ones
you want to assign are of a different type than the original ones.

Otherwise, just go ahead and do:

   pr_in!0 = "time"
   pr_in&time = (/time/)

without any deletions beforehand.

--Mary
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jan 12 2007 - 09:41:17 MST

This archive was generated by hypermail 2.2.0 : Tue Jan 16 2007 - 14:49:45 MST