Re: About netcdf output

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Tue Feb 25 2014 - 16:51:30 MST

Guilong,

We'll take a look at this and get back to you.

Thanks,

Wei

huangwei@ucar.edu
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924

On Feb 25, 2014, at 3:27 PM, "Li,Guilong [Ontario]" <Guilong.Li@ec.gc.ca> wrote:

> Hi,
>
> I am using ncl to calculate standardized precipitation index, and I want
> to output the result in netcdf format which can be read be some graph
> software, such as GrADS. I use the following program but it seems I have
> something wrong on the program
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> f = addfile("pr_mon.nc", "r")
> prc = f->pr ; PREC(time,lat,lon)
> lon = f->lon ; Longitude(lon)
> lat = f->lat ; Latitude(lat)
> time = f->time ; Time(time)
> printVarSummary(prc)
>
> dimp = dimsizes(prc) ; # monthly precipitation values
> ntim = dimp(0)
> nlat = dimp(1)
> mlon = dimp(2)
>
> lev = (/3, 6, 12, 24, 36, 48 /)
> klev = dimsizes(lev)
> spi = new((/klev,ntim,nlat,mlon/) ,float,prc@_FillValue)
>
> do k=0,klev-1
> spi(k,:,:,:) = dim_spi_n(prc, lev(k), False, 0)
> end do
>
> printVarSummary(lev)
> copy_VarCoords(prc,spi(0,:,:,:))
> spi@long_name = "SPI"
> lev@long_name = "Levels"
> lev@units = "months"
> lev@axis = "Z"
> spi!0 = "lev"
> spi&lev = lev
> spi!1 = "time"
> spi&time = time
> spi!2 = "lat"
> spi&lat = lat
> spi!3 = "lon"
> spi&lon = lon
> printVarSummary(spi)
>
> setfileoption("nc","Format","NetCDF4")
> fout = addfile("out1.nc","c")
> fout->spi = spi ; spi(lev,time,lat,lon)
> fout->lon = lon ; longitude(lon)
> fout->lat = lat ; latitude(lat)
> fout->lev = lev ; levels(lev)
> fout->time = time ; time(time)
>
> As I am new in ncl group, I just wonder whether someone can help me on
> this problem. If I don't output the lon, lat, lev, and time, I can write
> a control file to read the output. But I still want to know how to write
> it in netcdf format which can be read by GrADS directly.
>
> Thanks,
>
> Guilong
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Feb 25 16:51:41 2014

This archive was generated by hypermail 2.1.8 : Mon Mar 03 2014 - 14:26:18 MST