我想制作一个hovmoller图,计算整个非洲的纵向平均值,并绘制每个月和每个纬度的每月总降水量。
我有以下netcdf文件:
afr = readOGR("F:/Africultures/shps/TM_WORLD_BORDERS-0.3.shp")
#
model1= stack("F:/Africultures/cordex/pr/model1.nc")
r2 = crop(model1, extent(afr))
r3 = mask(r2, afr)
model1= stack(r3)
#
> model1
class : RasterStack
dimensions : 168, 148, 24864, 12 (nrow, ncol, ncell, nlayers)
resolution : 0.5, 0.5 (x, y)
extent : -17.5, 56.5, -46.5, 37.5 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
names : X2008.01.16, X2008.02.15, X2008.03.16, X2008.04.16, X2008.05.16, X2008.06.16, X2008.07.16, X2008.08.16, X2008.09.16, X2008.10.16, X2008.11.16, X2008.12.16
min values : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
max values : 1202.7720, 988.6817, 1112.4779, 1798.5912, 2003.0107, 1738.6660, 1509.1978, 1570.9318, 1471.7200, 1593.1401, 657.7618, 774.1619
所以,我计算区域平均值如下(每月值):
#
idx <- seq(as.Date('2008-01-01'), as.Date('2008-12-31'), 'month')
#
SISmm <- setZ(rca4, idx)
dirLayer <- init(SISmm, v='y')
#
z <- zonal(SISmm, dirLayer, FUN='mean', digits=2)
dat <- expand.grid(y=z[,1], x=idx)
dat$z <- as.vector(z[,-1], mode='numeric')
levelplot(z ~ x*y, data=dat, col.regions=cr2,
xlab='Time', ylab='Latitude',
panel=panel.levelplot.raster,
interpolate=TRUE,
par.settings=RdBuTheme(), main="Model Precipitation", at=seq(0,260,10))
我得到的结果如下。如您所见,它非常模糊,我想纠正这一点。我已经进行了许多试验(尝试使用颜色限制,颜色增量等),以防万一这与色阶有关,但事实并非如此。