Deviations from the Mean
dev_1.ncl: Creates panel plot of TS data
and TS deviations from a zonal mean.
TS is dimensioned (/"time","lat","lon"/)
dim_rmvmean is the intrinsic NCL function that will calculate deviations from a mean. This function first calculates the mean of the data using dim_avg, and then subtracts that mean from the original data. Since dim_avg operates on the right most dimension, dim_rmvmean results in the deviation from the zonal mean.
dev_2.ncl: Reorders the TS data so
that time is the right most dimension, which produces a deviation from
time plot.
The NCL syntax |: is called named subscripting, and it can be used to efficiently reorder a data array:
anom = dim_rmvmean(ts(lat|:,lon|:,time|:))
The zonal average plot is modified by using gsnZonalMeanXMinF, gsnZonalMeanXMaxF, and gsnZonalMeanYRefLine to set the minimum X-axis value, the maximum X-axis value, and the X-axis value where the reference line will be drawn.