gpt4 book ai didi

python - 无法读取 netcdf 文件属性,因为属性名称包含括号

转载 作者:太空宇宙 更新时间:2023-11-04 03:16:28 25 4
gpt4 key购买 nike

我正在使用 python-2.7 和 NetCDF4 模块来读取 netcdf 文件。我需要从名称中包含括号的 netcdf 文件中读取全局属性 (Lat(Degrees.Cents_of_degrees)),但我无法读取它。我的工作:

from netCDF4 import Dataset as NetCDFFile
filename = 'DDE30.2002.RG300004.nc'
nc = NetCDFFile(filename)
lat = nc.Lat(Degrees.Cents_of_degrees)

但是我明白了:

AttributeError: NetCDF: Attribute not found

我试过在括号前使用反斜杠,但没有用。 Here是 netcdf 文件。

最佳答案

我想你想要 getncattr [docs] .可能最好不要依赖@M.T 建议的私有(private)方法。

lat = nc.getncattr('Lat(Degrees.Cents_of_degrees)')

关于python - 无法读取 netcdf 文件属性,因为属性名称包含括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36125769/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com