| 
 
	积分14贡献 精华在线时间 小时注册时间2021-12-5最后登录1970-1-1 
 | 
 
| 
现在我的问题是问什么这里画出来地转风和地转偏差是重合的呢?哪里有问题呢?感谢各位大佬
x
登录后查看更多精彩内容~您需要 登录 才可以下载或查看,没有帐号?立即注册 
  
  、import xarray as xr import matplotlib.pyplot as plt
 import metpy.calc as mpcalc
 from metpy.units import units
 import cartopy.crs as ccrs
 import numpy as np
 import scipy.ndimage as ndimage
 import cartopy.feature as cfeature
 from cartopy.mpl.ticker import LongitudeFormatter,LatitudeFormatter
 nc = r'C:\Users\MMMz\Desktop\adaptor.mars.internal-1639145498.7367666-26326-13-b07c601e-9a1e-466b-a946-cda3c21a9cae.nc'
 ds = xr.open_dataset(nc)
 
 hgt = ds.z.loc['2021-11-01T08:00:00',[700]].squeeze() * units.m
 u_wind= ds.u.loc['2021-11-01T08:00:00',[700]]* units('m/s')
 v_wind= ds.v.loc['2021-11-01T08:00:00',[700]]* units('m/s')
 
 lat = u_wind.latitude
 lon = u_wind.longitude
 lev = u_wind.level
 
 #平滑高度
 hgt = ndimage.gaussian_filter(hgt * units.m, sigma=5.0) / 9.80665*0.1
 
 
 lon_2d, lat_2d = np.meshgrid(lon,lat)
 
 dx,dy = mpcalc.lat_lon_grid_deltas(lon,lat)
 geo_wind_u, geo_wind_v = mpcalc.geostrophic_wind(hgt * units.m,dx,dy,lat_2d)
 
 
 
 # 绘制新画板
 fig = plt.figure(figsize=(15,7))
 
 # 添加地图并设置范围
 ax = plt.axes(projection=ccrs.PlateCarree())
 extent = [100,160,20,60]
 ax.set_extent(extent,crs=ccrs.PlateCarree())
 
 
 ax.add_feature(cfeature.COASTLINE)  # 画海岸线
 
 
 zoom_500 = ndimage.zoom(hgt, 5)
 zlon = ndimage.zoom(lon_2d, 5)
 zlat = ndimage.zoom(lat_2d, 5)
 clevs = np.arange(200,300,2.5)
 c = ax.contour(zlon, zlat,zoom_500,leves=clevs,
 colors='blue',
 linewidths=2,
 transform=ccrs.PlateCarree())
 ax.clabel(c, fontsize=12,inline=1, inline_spacing=3, fmt='%i',colors='blue')
 
 
 u_wind=u_wind[0]
 v_wind=v_wind[0]
 
 ageo_wind_u = u_wind - geo_wind_u
 ageo_wind_v = v_wind - geo_wind_v
 
 
 
 
 quiver_slices = (slice(None, None, 25), slice(None, None,25))
 quiver_kwargs1 = {'headlength': 6, 'headwidth': 4, 'angles': 'xy', 'scale_units': 'xy',
 'scale':0.5}
 quiver_kwargs2 = {'headlength': 6, 'headwidth': 4, 'angles': 'xy', 'scale_units': 'xy',
 'scale':5}
 #地转风
 geo = ax.quiver(lon_2d[quiver_slices], lat_2d[quiver_slices],
 geo_wind_u[quiver_slices], geo_wind_v[quiver_slices],
 color='black', **quiver_kwargs1)
 #地转偏差
 ageo = ax.quiver(lon_2d[quiver_slices], lat_2d[quiver_slices],
 ageo_wind_u[quiver_slices], ageo_wind_v[quiver_slices],
 color='red', **quiver_kwargs2)
 
 #
 dlon,dlat=10,10
 xticks = np.arange(100,150+dlon,dlon)
 yticks = np.arange(20,60+dlat,dlat)
 tick_proj = ccrs.PlateCarree()
 ax.set_xticks(xticks,crs=tick_proj)
 ax.set_yticks(yticks,crs=tick_proj)
 ax.xaxis.set_major_formatter(LongitudeFormatter()
 ax.yaxis.set_major_formatter(LatitudeFormatter())
 plt.show()
 
 | 
 
 
5001.py
 2.67 KB, 下载次数: 2, 下载积分: 金钱 -5  
 |