load ncep_indeces;
%
% loads the ncep cdc indeces
% created from make_ncep_indeces.m
%
% File contains
%  ea                        663x1                     5304  double array
%  ea_jet                    663x1                     5304  double array
%  indeces_date              663x1                     5304  double array
%  nao                       663x1                     5304  double array
%  pna                       663x1                     5304  double array
%  subtropical_zonal         663x1                     5304  double array
%  tropical_northern_hem     663x1                     5304  double array
%

%
% rename the ncep nao index so I can load the hurrel index with the same name.
%
ncep_nao = nao;

% 
% load hurrell data
%
load hurrell_monthly.mat
%
% file contains:
%  nao         1659x1                    13272  double array
%  nao_date    1659x1                    13272  double array
%  nao_day     1659x1                    13272  double array
%  nao_mos     1659x1                    13272  double array
%  nao_time    1659x1                    13272  double array
%  nao_year    1659x1                    13272  double array
%

%
% ncep index starts later than hurrell index and ends later, so look only at the same time periods
%
Istart = find(nao_date == indeces_date(1));
Jend = find(indeces_date == nao_date(end));

figure;
plot(nao_date(Istart:end), nao(Istart:end))
hold on
plot(indeces_date(1:Jend), ncep_nao(1:Jend),'r')
datetick
legend ('Hurrell', 'Ncep')


%
% Do cross correlation
%
check_corr3(nao(Istart:end),ncep_nao(1:Jend),['Hurrell vs. NCEP'],['months'],20)


clear all

load ncep_nao_filtered
% starts jan 15 1950
% ends 15 dec 2005

load filtered_nao
% starts jan 15 1865
% ends Mar 15 2003


nao_date=datenum(nao_year, nao_mos, nao_day);

Istart = find(nao_date == indeces_date(1));
Jend = find(indeces_date == nao_date(end));

figure;
plot(nao_date(Istart:end), nao_butter_bia(Istart:end))
hold on
plot(indeces_date(1:Jend), ncep_nao_butter_bia(1:Jend),'r')
datetick
legend ('Hurrell', 'Ncep')

%
% Do cross correlation
%
check_corr3(nao_butter_bia(Istart:end),ncep_nao_butter_bia(1:Jend),['Hurrell vs. NCEP'],['months'],20)

%
% Now what about since 1995?
%
Istart_nao = find(nao_date == datenum(1995,1,15));
Istart_ncep = find(indeces_date == datenum(1995,1,15));

figure;
plot(nao_date(Istart_nao:end), nao_butter_bia(Istart_nao:end))
hold on
plot(indeces_date(Istart_ncep:Jend), ncep_nao_butter_bia(Istart_ncep:Jend),'r')
datetick
legend ('Hurrell', 'Ncep')

%
% Do cross correlation
%
check_corr3(nao_butter_bia(Istart_nao:end),ncep_nao_butter_bia(Istart_ncep:Jend),['Hurrell vs. NCEP'],['months'],20)
check_corr3(nao(Istart_nao:end),ncep_nao(Istart_ncep:Jend),['Hurrell vs. NCEP'],['months'],20)


% Things look ok for the complete time series (except for a small phase shift 
% using long time scale butter filters.
% However since 1995 things do *NOT* look ok for longer and longer time averaging
%
