问题描述
我正试图在喀麦隆上绘制降水,只遮盖喀麦隆边界的内部。
其他所有国家都将被屏蔽。
以下是我正在使用的脚本的情节和开头:
import numpy as np
from scipy import stats
from netCDF4 import Dataset
import cartopy.crs as ccrs
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER,LATITUDE_FORMATTER
import cartopy
import cartopy.io.shapereader as shapereader
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib.font_manager import FontProperties
ref_dat = Dataset("R95ptot_Kmer_chirps-v2.0.1981_2019.days_p05.nc",mode='r')
lat = ref_dat.variables["latitude"][:]
lon = ref_dat.variables["longitude"][:]
time = ref_dat.variables["time"]
pre0 = ref_dat.variables["precip"][:,:,:]
slope = np.zeros(pre0[0,:].shape)
intercept = np.zeros(pre0[0,:].shape)
r_value = np.zeros(pre0[0,:].shape)
p_value = np.zeros(pre0[0,:].shape)
std_err = np.zeros(pre0[0,:].shape)
for ilat in range(len(lat)):
for jlon in range(len(lon)):
slope[ilat,jlon],intercept[ilat,r_value[ilat,p_value[ilat,std_err[ilat,jlon] = stats.linregress(time,pre0[:,ilat,jlon])
[lons2d,lats2d] = np.meshgrid(lon,lat)
fig,ax = plt.subplots(1,1,sharex=True,sharey=True,figsize=(8.5,6.98),subplot_kw={'projection':ccrs.PlateCarree()})
mymap = ax.contourf(lons2d,lats2d,slope,transform=ccrs.PlateCarree(),cmap=plt.cm.Spectral_r,extend='both')
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)