Documentation of regress_taux_hanom2


Global Index (short | long) | Local contents | Local Index (short | long)


Help text

  Set up coefficients for centered difference

Cross-Reference Information

This script calls

Listing of script regress_taux_hanom2


clear
lims = [180 270 -6 6];
tim = 1:1000;
[lat, lon, depth] = getll('temp', lims);
[lat, lon, depthw] = getll('wl', lims);
ttop = getnc('temp', lims, 4:6, tim);
ttop = squeeze(mean(mean(ttop, 3), 4));
ttop = ttop';

dx = diff(depth(4:6));
alpha = dx(1)/mean(dx);
beta = dx(2)/mean(dx);

coefs = [1 1 1; alpha 0 -beta; alpha^2/2 0 beta^2/2];
abc = inv(coefs) * [0; 1/mean(dx); 0];

dtdz = -abc'*ttop;

%  Get h' by t = tmean + dtdz*h'

t4 = ttop(2,:);
hprime = (t4-mean(t4))./dtdz;

ct = getct(tim);
corr(ct, hprime)
ans =

   -0.8655


lims2 = [165 210 -5 5];
tx = getnc('taux', lims2, 1, tim);
tx = mean(mean(tx, 2), 3);

corr(tx, hprime)

ans =

   -0.8010

h = hprime;
h = detrend(h);
tx = detrend(tx);

%  convert to cm:

h = 100*h;
h = -6e-3*h;
h = h';

subplot(2,1,1)
plot(h, tx, '.');
axis('square')
axis([-15 15 -.20 .20]);
line([-15 15], reg_coef*[-15 15]);
grid on

reg_coef = (h'*tx) ./ (length(tx) * std(h)^2);
reg_coef =

    0.0105

cor_coef = corr(tx, h);
%[beta, expv, fval, fitted] = regress(h,tx);
[B,BINT,R,RINT,STATS] = regress(tx, [h h.^3], .01);

subplot(2,1,1);
hold on;
  plot(h, reg_coef*h, 'r.')
hold off

resid = tx - reg_coef*h;

subplot(2,1,2);
plot(h, resid, '.r')
axis('square')
axis([-15 15 -.20 .20]);
hold on;
  plot(h, reg_coef*h, '.')
hold off;
grid on

%  Check fit of tanh(h) with tx

scale = 1/2;
reg_coef2 = (tanh(scale*h/std(h))'*tx) ./ (length(tx) * std(tanh(scale*h/std(h)))^2);

subplot(2,1,2);
plot(h, tx, '.b');
hold on
  plot(h, reg_coef2*tanh(scale*h/std(h)), '.g');
hold off
axis('square')
axis([-15 15 -.20 .20]);
grid on

[2*std(h) reg_coef2]
ans =

    7.8223    0.0974

%  scale = 3
ans =

   11.7334    0.1344

fitted = reg_coef2*tanh(scale*h/std(h));

[std(tx) std(fitted) std(tx-fitted)]
ans =

    0.0501    0.0409    0.0289

% (linear regression):
ans =

    0.0501    0.0410    0.0288

[max(tx) max(fitted) max(tx-fitted)]
ans =

    0.1750    0.1024    0.0962

% (linear regression):
ans =

    0.1750    0.1231    0.0923

[min(tx) min(fitted) min(tx-fitted)]
ans =

   -0.1255   -0.1041   -0.0882

% (linear regression):
ans =

   -0.1255   -0.1270   -0.0866

[std(h) max(h) min(h)]
ans =

    3.9111   11.7320  -12.1093