美文网首页
【python】读NC文件

【python】读NC文件

作者: 南谛走心 | 来源:发表于2020-04-20 15:42 被阅读0次

# -*- coding: utf-8 -*-

# NAN Yang

#2020-04-20

import netCDF4

from netCDF4import Dataset

nc_obj=Dataset('D:\\Pyhton_conda\\AQI_GRID_2020040708_024-048-072.nc')

#查看nc文件中有什么东西

print(nc_obj)

print('-----------------------------------------------------')

#查看nc文件中的变量

print(nc_obj.variables.keys())

for iin nc_obj.variables.keys():

print(i)

print('-----------------------------------------------------')

#查看每个变量的信息

'''

print(nc_obj.variables['lon'])

print(nc_obj.variables['lat'])

print(nc_obj.variables['Time'])

print(nc_obj.variables['PM25'])

print(nc_obj.variables['PM10'])

print(nc_obj.variables['O3'])

print(nc_obj.variables['AQI'])

print('------------------------------------------------------')

'''

#查看每个变量的属性

'''

print(nc_obj.variables['lon'].ncattrs())

print(nc_obj.variables['lat'].ncattrs())

print(nc_obj.variables['Time'].ncattrs())

print(nc_obj.variables['PM25'].ncattrs())

print(nc_obj.variables['PM10'].ncattrs())

print(nc_obj.variables['O3'].ncattrs())

print(nc_obj.variables['AQI'].ncattrs())

'''

#读取数据值

lon=(nc_obj.variables['lon'][:])

lat=(nc_obj.variables['lat'][:])

Time=(nc_obj.variables['Time'][:])

AQI=(nc_obj.variables['AQI'][:])

#print(lon)

#print(Time)

相关文章

网友评论

      本文标题:【python】读NC文件

      本文链接:https://www.haomeiwen.com/subject/ottmbhtx.html