function [xma,xn] = ens2mean_noise(x)

[ny,nx,m,nt] = size(x);

%ensemble mean
xm  = mean(x,3);

%grand mean
xgm = mean(squeeze(xm),3);

%ensemble mean anomalies
xma = squeeze(xm) - xgm(:,:,ones(1,nt));

%ensemble noise
xn = x - xm(:,:,ones(1,m),:);

