我正在使用如下代码创建一个netCDF文件:
from netCDF4 import Dataset
outfile = Dataset('output.nc', 'w', format = 'NETCDF4')
level = outfile.createDimension('level', 1)
time = outfile.createDimension('t', None)
lats = outfile.createDimension('latitude', 141)
lons = outfile.createDimension('longitude', 121)
precips = outfile.createVariable('Precipitation', 'f4',('t','level','latitude','longitude'))
times = outfile.createVariable('t','f8',('t',))
levels = outfile.createVariable('level','i4',('level',))
latitudes = outfile.createVariable('latitude','f4',('latitude',))
longitudes = outfile.createVariable('longitude','f4',('longitude',))
latitudes.units = "degrees east"
longitudes.units = "degrees north"
levels.units = "surface"
precips.units = "mm/day"
times.calendar = "gregorian"这一切都很好(在用数据填充变量并调用outfile.close()之后),但是如何为变量分配一个短名称呢?我希望会有这样的东西:
precips.shortFieldName = "prec"但是,在尝试了许多变体,扫描了文档,并快速浏览了源代码后,我并没有更进一步的解决方案。
有什么想法吗?
发布于 2014-12-04 03:52:41
prec=precips ^^然后有指针指向这个,而不是两个对象=> 2的名字,它们都是可用的
https://stackoverflow.com/questions/27280297
复制相似问题