爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 2529|回复: 0

[源代码] [求助]Python 使用ERA数据绘制风场、位势高度场图像

[复制链接]

新浪微博达人勋

发表于 2023-4-17 10:15:27 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 WOT 于 2023-4-17 11:16 编辑

我用的是ERA数据,数据时间为1961-2020年7~8月u、v、z数据,高度为1000-500hpa,想画1961-1965年7月的500hpa位势高度场和风场的图像.这个程序没报错,但是没有我要的数据填色图和线条,请各位老师帮我看看哪里需要改动
#风场图像
import os
import numpy as np
import netCDF4 as nc
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.io.shapereader import Reader
import warnings; warnings.filterwarnings('ignore')

##data_read
df1 = nc.Dataset(r'E:/GrADS/dataERA/Uwnd.nc')
df2 = nc.Dataset(r'E:/GrADS/dataERA/Vwnd.nc')
df3 = nc.Dataset(r'E:/GrADS/dataERA/Geopotential.nc')
## coordinate_info
lat = df2['latitude'][0:5:2]
lon = df2['longitude'][:]
lev = df2['level'][0]
times = df2['time'][0:5:2]
lon2d, lat2d = np.meshgrid(lon, lat)
#1961.7~1963.7 500hpa
u7 = df1['u'][0:5:2,0,:,:]
v7 = df2['v'][0:5:2,0,:,:]
h7 = df3['z'][0:5:2,0,:,:]
U7 = np.mean(u7,axis=1)
V7 = np.mean(v7,axis=1)
H7 = np.mean(h7,axis=1)
###plot
fig = plt.figure(figsize=(12,8))
ax = plt.axes(projection=ccrs.PlateCarree())
ax.set_extent([20, 150, 0, 70], crs=ccrs.PlateCarree())
ax.coastlines()

SHP = r'E:\python\shp'
projection = ccrs.PlateCarree()
# China boundary
ax.add_geometries(Reader(os.path.join(SHP, 'PRO.shp')).geometries(),
                  ccrs.PlateCarree(),facecolor='none',edgecolor='r', linewidth=1.5)

ax.coastlines(resolution='50m', linewidth=0.3, color='black')

ax.gridlines(draw_labels=True, linewidth=0.5, color='gray',
             xlocs=range(20,150,10), ylocs=range(0,70,10))
cnplot = ax.contourf(lon2d,
                      lat2d,
                      H7,
                      #levels=np.array(5000,5880,80),
                      extend='max',
                      cmap='Oranges',
                      transform=ccrs.PlateCarree()
                      )
cvf = ax.streamplot(lon2d,
                    lat2d,
                    U7,V7,
                    density=[1,5],
                    transform=ccrs.PlateCarree()
                    )

ax.set_title('1961', fontsize=15, fontweight='bold')
#plt.savefig('E:/Water vapor flux differnce at 500hPa between 1992-2020 and 1961-1985 (Jul-Aug).pdf', bbox_inches='tight', dpi=200)
plt.show()

1681701314010.png
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表