- 积分
- 3308
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2017-3-9
- 最后登录
- 1970-1-1
|
发表于 2023-6-28 17:22:38
|
显示全部楼层
import pandas as pd
import xarray as xr
import matplotlib.pyplot as plt
import numpy as np
import cartopy.crs as ccrs
import cartopy.feature as cfeat
from cartopy.io.shapereader import Reader
from cartopy.mpl.ticker import LongitudeFormatter,LatitudeFormatter
f=xr.open_dataset("c:/Users/Yagma/Desktop/ERA5-pr-0606.nc")
tp=f['tp'].loc['2023-06-06-15',50:10,80:140]*1000
lat=f['latitude'].loc[50:10]
lon=f['longitude'].loc[80:140]
fig=plt.figure(figsize=(8,8))
ax=fig.add_subplot(111,projection=ccrs.PlateCarree())
ax.add_feature(cfeat.OCEAN.with_scale('50m'), zorder=0)
ax.xaxis.set_major_formatter(LongitudeFormatter())
ax.yaxis.set_major_formatter(LatitudeFormatter())
ax.set_xticks(np.arange(80,141,20),crs=ccrs.PlateCarree())
ax.set_yticks(np.arange(10,51,20),crs=ccrs.PlateCarree())
ax.set_extent([80,140,10,50],crs=ccrs.PlateCarree())
les=[0.1,1,2,3,4,5,6,7,8]
cn=ax.contourf(lon,lat,tp, transform = ccrs.PlateCarree(),levels=les,cmap=plt.get_cmap('tab20'))
plt.colorbar(cn, cax=fig.add_axes([0.21, 0.05, 0.6, 0.02]),orientation='horizontal')
plt.show() |
|