我使用import netCDF4
file = r"C:\netcdf_files\data*.nc" #wildcarded NetCDF files
with netCDF4.MFDataset(file) as src:
for name, variable in src.variables.items():
for attrname in variable.ncattrs():
print("{} -- {}".format(attrname, variable.getncattr(attrname)))
当上面的代码段运行时,我会得到以下异常:
^{pr2}$
对于单个文件NetCDF文件,加载了数据集:import netCDF4
file = r"C:\netcdf_files\data1.nc" #single, explicit file
with netCDF4.Dataset(file) as src:
for name, variable in src.variables.items():
for attrname in variable.ncattrs():
print("{} -- {}".format(attrname, variable.getncattr(attrname)))
上面的代码运行得很好,可以根据需要打印出变量属性。在
我对使用NetCDF文件还是很陌生的-有没有办法在使用MFDataset加载数据时访问变量属性?
谢谢!在