# -*- 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)