Re: Netcdf output with non-numeric datatyep

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Mon Apr 14 2014 - 14:00:39 MDT

Liang,

You may try something like:

 fout = "out.nc"
 system("/bin/rm -f "+fout)
 setfileoption( "nc", "format", "netcdf4" )
 ncdf = addfile(fout,"c")

 mode = (/"Original value","Component 1","Component 2","Component 3","Component 4"/)
 time = (/0, 1, 2/)

 mode@long_name = "mode"
 mode@units = "M"

 mode!0 = "mode"
 mode&mode = mode

 time!0 = "time"
 time&time = time

 time@long_name = "time"
 time@units = "day"

 print("mode=" + mode)
 print("time=" + time)

 allmode = new((/dimsizes(mode), dimsizes(time)/), float)
 allmode = 9.9

 allmode@long_name = "allmode"
 allmode@units = "mode/day"

 allmode!0 = "mode"
 allmode!1 = "time"
 allmode&mode = mode
 allmode&time = time

 ncdf->allmode = allmode

 delete(ncdf)

Wei

On Apr 7, 2014, at 8:18 AM, Liang Guo (Gmail) <liang.guo.81@gmail.com> wrote:

> Dear NCL,
>
> I have a variable named *allmode(mode,time)*. For the dimension *mode*, I'd like to assign string value (/"Original value","Component 1","Component 2","Component 3","Component 4"/) instead of numeric value (/0,1,2,3,4/). Then, I try to write this variable into a Netcdf file. I wrote:
> > fout = "out.nc"
> > system("/bin/rm -f "+fout)
> > setfileoption( "nc", "format", "netcdf4" )
> > ncdf = addfile(fout,"c")
> > ncdf->mode = allmode
>
> However, file can not be created successfully, with error information as:
> warning:FileReadVarAtt: _FillValue attribute type differs from variable (mode) type in file (out), forcing type conversion; may result in overflow and/or loss of precision
> ncclose: ncid 393216: NetCDF: Can't open HDF5 attribute
>
> Does any has ideas how to write this file out?
>
> Regards,
> Liang
>
> _______________________________________________
> 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 Mon Apr 14 14:00:52 2014

This archive was generated by hypermail 2.1.8 : Tue Apr 15 2014 - 10:45:19 MDT