Perturbation align with vector field

example figure

Code

% domain size
m = 50;
n = 50;

% grid resolution
dx = 200e3/(m-1);
dy = dx;
[x,y] = ndgrid(dx*[0:m-1],dy*[0:n-1]);

% land-sea mask (true: sea, false: land)
mask = true(m,n);

% metric
pm = ones(m,n)/dx;
pn = ones(m,n)/dy;

% number of ensemble perturbations
Nens = 1;

% number of EOFs retained
k = 100;

% correlation length
len =  20e03;

% velocity field
a = 10 / (dx*(m-1));
u =  a * y;
v = -a * x;

% create ensemble perturbations
[Ep] = wce_simple(mask,{pm,pn},len,Nens,k,'velocity',{u,v});

hold on
contourf(x/1e3,y/1e3,Ep,50)
shading flat
l = 5;
quiver(x(1:l:end,1:l:end)/1e3,y(1:l:end,1:l:end)/1e3,...
       u(1:l:end,1:l:end),v(1:l:end,1:l:end),10 / max(u(:)),'k')
xlabel('x (km)');
ylabel('y (km)');
axis([min(x(:)) max(x(:)) min(y(:)) max(y(:))]/1e3)
title('Perturbation align with vector field');
hold off

Download wce_example_simple_advection.m