Re: Netcdf output with non-numeric datatyep

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Fri May 02 2014 - 11:09:20 MDT

Liang,

We think this is a bug for NCL not being able to read string as coordinate variable.
I have filed a JIRA ticket, and we will try to fix this in the next release.

Thanks,

Wei

On May 2, 2014, at 5:28 AM, Liang Guo (Gmail) <liang.guo.81@gmail.com> wrote:

> Hi Wei,
>
> This is very interesting idea, but unfortunately, there is something wrong with it.
>
> First of all, the code you shown me can be ran errorlessly. However, the output "out.nc" cannot be recognised, i.g., when I try *ncdump out.nc*, the error message is:
> ncdump: out.nc: NetCDF: Unknown file format
>
> And, when I try to read *out.nc* in NCL using code like:
> fi = addfile ("out.nc","r")
> allmode = fi->allmode
>
> The error is *Memory fault*.
>
> This is bizarre as NCL can create the file, but the file cannot be recognised by itself.
>
> Any idea about it?
>
> Regards,
> Liang
>
>
> On 14 Apr 2014, at 21:00, Wei Huang <huangwei@ucar.edu> wrote:
>
>> 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 Fri May 02 11:09:48 2014

This archive was generated by hypermail 2.1.8 : Sun May 04 2014 - 12:38:56 MDT