clear
close all


eval('! ls -1 Data/transport/XBT_newsal_stomlin_noyear_noint/ > files.txt');

lista = importdata('files.txt');


direc = {'XBT_newsal_annual_noyear_noint/' ,...
         'XBT_newsal_goes_noyear_noint/',...
         'XBT_newsal_thacker_noyear_noint/',...
         'XBT_newsal_stomlin_noyear_noint/'};

nl = length(direc);
nf = length(lista);

mht_all = zeros(nf,1);
mht_ekm = zeros(nf,1);
mht_geo = zeros(nf,1);
moc_all = zeros(nf,1);
moc_ekm = zeros(nf,1);
moc_geo = zeros(nf,1);
time    = zeros(nf,1);

for jj = 1:nl
  for ii = 1:nf
    filename = ['Data/transport/',direc{jj},lista{ii}];
    dados=load(filename);
    mht_all(ii,jj) = dados.mht;
    mht_ekm(ii,jj) = dados.mhte;
    mht_geo(ii,jj) = dados.mhtg;
    moc_all(ii,jj) = dados.moc;
    moc_ekm(ii,jj) = dados.moce;
    moc_geo(ii,jj) = dados.mocg;
    time(ii)       = dados.timev;
  end
end

[time,ii] = sort(time);
mht_all = mht_all(ii,:);
mht_ekm = mht_ekm(ii,:);
mht_geo = mht_geo(ii,:);
moc_all = moc_all(ii,:);
moc_ekm = moc_ekm(ii,:);
moc_geo = moc_geo(ii,:);

[mean(moc_geo);std(moc_geo)]
[mean(mht_geo);std(mht_geo)]

stop
seasonal_residual_from_MOC
