使用python在netcdf文件上写字符串

时间:2014-06-03 13:43:03

标签: python string netcdf

我试图写入NetCDF文件。 定义了两个变量,浮点类型没有问题但是我遇到了sting类型的错误。

NVal=cdms2.createVariable( (N.zeros((nvarmax,nlat, nlon)) ),
                             typecode = cdms2.MV2.float32,
                             id = "val",
                             attributes=att_nval)

NParam=cdms2.createVariable( (OPTIONS["VARS"]),
                             typecode = 'string',
                             id = "param",
                             attributes=att_nparam)

和文件:

fout = cdms2.open('NVar.nc','w')
fout.write( NVal )
fout.write( NParam )
fout.close()

最后,错误信息是:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: write() got an unexpected keyword argument 'type'
>>> fout.write( NParam,'string' )
cdunif: NetCDF: Not a valid data type or _FillValue type mismatch
cdunif: NetCDF: Not a valid data type or _FillValue type mismatch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/share/unix_files/cdat/versions/cdat_install_trunk_x86_64_gcc4_03/lib/python2.5/site-packages/cdms2/dataset.py", line 1459, in write
    id=varid, extend=extend, fill_value=fill_value, index=index)
  File "/home/share/unix_files/cdat/versions/cdat_install_trunk_x86_64_gcc4_03/lib/python2.5/site-packages/cdms2/dataset.py", line 1391, in createVariableCopy
    newvar = self.createVariable(newname, datatype, axislist)
  File "/home/share/unix_files/cdat/versions/cdat_install_trunk_x86_64_gcc4_03/lib/python2.5/site-packages/cdms2/dataset.py", line 1179, in createVariable
    raise CDMSError, "Creating variable "+name
cdms2.error.CDMSError: Creating variable param

提前谢谢

0 个答案:

没有答案