生活随笔
收集整理的這篇文章主要介紹了
ERA5再分析资料,绘制2020年7月13日0点(UTC)总降水全国分布图
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
添加南海小地圖,cartopy自帶地圖國境線有問題,大家務(wù)必注意。
代碼如下:
%matplotlib inline
import xarray
as xr
import numpy
as np
import cartopy
.crs
as ccrs
import cartopy
.feature
as cfeature
from cartopy
.mpl
.gridliner
import LONGITUDE_FORMATTER
, LATITUDE_FORMATTER
import cartopy
.io
.shapereader
as shpreader
import matplotlib
.ticker
as mticker
import matplotlib
.pyplot
as plt
ds
=xr
.open_dataset
("/home/kesci/work/assignment_1/2020071300.grib",engine
='pynio')
tp
=ds
['TP_GDS0_SFC_acc1h']*1000
tp
.attrs
['units']='mm'
proj
=ccrs
.PlateCarree
()
fig
=plt
.figure
(figsize
=(12,8))
ax
=fig
.subplots
(1,1,subplot_kw
={'projection':proj
})
region
= [70,140,15,55]
ax
.set_extent
(region
,crs
=proj
)
ax
.add_feature
(cfeature
.COASTLINE
.with_scale
('50m'), linewidth
=0.6, zorder
=1)
ax
.add_feature
(cfeature
.LAKES
.with_scale
('50m'), zorder
=1)
gl
= ax
.gridlines
(ylocs
=np
.arange
(region
[2],region
[3]+10,10),xlocs
=np
.arange
(region
[0],region
[1]+10,10),draw_labels
=True,linestyle
='--',alpha
=0.7)
gl
.xlabels_top
= False
gl
.ylabels_right
= False
gl
.xformatter
= LONGITUDE_FORMATTER
gl
.yformatter
= LATITUDE_FORMATTER
ax
.set_title
('Total Precipitation',loc
='left',fontsize
=12)
ax
.set_title
('Time:2020071300(UTC)',loc
='right',fontsize
=12)
cbar_kwargs
= {'orientation': 'horizontal','label': 'Total Precipitation (mm)','shrink': 0.8,'ticks': np
.arange
(0,20+5,5)
}
levels
=np
.arange
(0,20+0.5,0.5)
tp
.plot
.contourf
(ax
=ax
, levels
=levels
, cmap
='pink_r', cbar_kwargs
=cbar_kwargs
, transform
=ccrs
.PlateCarree
())
china
= shpreader
.Reader
('/home/kesci/work/assignment_1/China_basic_map/bou2_4l.dbf').geometries
()
ax
.add_geometries
(china
, proj
,facecolor
='none', edgecolor
='black',zorder
= 1)
sub_ax
= fig
.add_axes
([0.705, 0.351, 0.15, 0.15],projection
= proj
)
sub_ax
.set_extent
([105, 125, 0, 25], crs
=ccrs
.PlateCarree
())
sub_ax
.add_feature
(cfeature
.COASTLINE
.with_scale
('50m'))
china
= shpreader
.Reader
('/home/kesci/work/assignment_1/China_basic_map/bou2_4l.dbf').geometries
()
sub_ax
.add_geometries
(china
, ccrs
.PlateCarree
(),facecolor
='none', edgecolor
='black',zorder
= 1)
總結(jié)
以上是生活随笔為你收集整理的ERA5再分析资料,绘制2020年7月13日0点(UTC)总降水全国分布图的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。