%% Plot surface ocean Ekman spiral solution. See notes-friction.pdf
%% EPS131, 2012, Eli

delta=50; % meter
z=-(0:0.1:1500);
A=1;

u=A*exp(z/delta).*(cos(z/delta)-sin(z/delta));
v=A*exp(z/delta).*(cos(z/delta)+sin(z/delta));

fig1=figure(1); clf
subplot(1,2,1)
plot(u,v)
h1=xlabel('u');
h2=ylabel('v');
h3=title('Ekman spiral, zoom in to see details');
h4=text(0.9,0.95,'z=0');
h5=text(0.02,0,'z=-\infty');
set([gca,h1,h2,h3,h4,h5],'fontsize',14);
xlim([-0.25,1.1]);
ylim([-0.25,1.1]);
axis square

subplot(1,2,2)
plot(u,z,'r');
hold on
plot(v,z,'b');
ylim([-300,0]);
h1=xlabel('u,v');
h2=ylabel('z');
h3=legend('u','v','location','southeast');
h4=title('u,v');
set([gca,h1,h2,h3,h4],'fontsize',14);
axis square

if 1
  set(gcf, 'PaperUnits', 'inches'); set(gcf, 'PaperSize', [8 4]);
  set(gcf, 'PaperPosition', [0 0 8 4]); % [left, bottom, width, height];
  saveas(fig1,'Output/my_Ekman_spiral.pdf');
  saveas(fig1,'Output/my_Ekman_spiral.fig');
end
