读FY3D的海面风场数据(HDF格式)

文件下载

注册了中国气象数据网的账号(教育科研级别),然后登陆风云卫星遥感数据服务网,找到相应的数据,然后申请,然后得到下载文件的目录,用页面提示的使用*.bat的批量下载的方式进行下载(需要预先在电脑上安装wget)。

HDFVIEW

安装HDFVIEW,我装的是HDFView-3.1.0-win10vs14_64。

FengYunToolkit

在风云卫星遥感数据服务网的工具页面可以找到风云卫星数据处理包。

文件读取

用hdfview看到文件是HDF5的,所以用python库h5py读取。

import h5py
data = h5py.File(r'E:\download\down\FY3D_MWRIX_GBAL_L2_SWS_MLT_GLL_20200101_POAD_025KM_MS.HDF')
#得到HDF文件的参数
print(data.filename,":")
print([key for key in data.keys()],"\n")
print(data)
#拿出数据
for key in data.keys():
    print(key)
    print(data[key].name)
    print(data[key].shape)
    #print(data[key].value)
aa=data['SWS_Ascending'][:]
#画图
collev= ['#ffffff','#E6E6FA','#C1FFC1', '#9AFF9A', '#00FF7F', '#00CD66','#00FF00','#00CD00', '#7FFF00', '#FFFF00', '#FFD700', '#FFC125','#FFB90F','#CD950C', '#FF4500','#FF0000','#CD0000','#8B0000','#8B0A50','#828282']
levels = [-9999, 0, 2.5, 5,7.5,10,12.5, 15,17.5,20,22.5,25,27.5,30,32.5,35,37.5,40,42.5,45,47.5]
cmaps = colors.ListedColormap(collev, 'indexed')
norm = colors.BoundaryNorm(levels, cmaps.N)
  
proj = ccrs.PlateCarree()
  
fig, ax = plt.subplots(figsize=(16, 9), subplot_kw=dict(projection=proj))
lon = np.linspace(-180, 180,1440)
lat = np.linspace(90, -90,720)
  
LON, LAT= np.meshgrid(lon[:], lat[:])
  
con = ax.contourf(LON, LAT, aa, cmap=cmaps, norm=norm, levels=levels, extend='max')
  
cb = fig.colorbar(con, shrink=0.75, pad=0.02)
cb.cmap.set_over('#000000')
cb.ax.tick_params(direction='in', length=5)
  
ax.coastlines()
  
ax.set_xticks(np.linspace(-180, 180,9), crs=proj)
ax.set_yticks(np.linspace(-90, 90,9), crs=proj)
  
lon_formatter= LongitudeFormatter(zero_direction_label=True)
lat_formatter= LatitudeFormatter()
  
ax.xaxis.set_major_formatter(lon_formatter)
ax.yaxis.set_major_formatter(lat_formatter)

plt.savefig('./test2.jpg')

你可能感兴趣的:(python)