clear all

% loads NCEP CDC data and manipulates to get arrays of
% index, and index_date
%
% first data point (1) is supposed to start at:
% Jan 15, 1865 and the last (1602) ends at: June 15, 1998.

%
% load NCEP indeces
%
%  indeces = load('ncep_cdc_tele_index.nh');
  indeces = load('ncep_indices.dat');
%
% Data Consists of:
% column 1: Year (yy)
% column 2: Month (mm)
% column 3: North Atlantic Oscillation (NAO)
% column 4: East Atlantic Pattern (EA)
% column 5: West Pacific Pattern (WP)
% column 6: EastPacific/ North Pacific Pattern (EP/NP)
% column 7: Pacific/ North American Pattern (PNA)
% column 8: East Atlantic/West Russia Pattern (EA/WR)
% column 9: Scandinavia Pattern (SCA)
% column 10: Tropical/ Northern Hemisphere Pattern (TNH)
% column 11: Polar/ Eurasia Pattern (POL)
% column 12: Pacific Transition Pattern (PT)
% column 13: Explained Variance (%) of leading 10 modes
%
% Flagged value = -99.9
iflag = -99.9;

%
% fill missing values with Nans
%
indeces = fillmiss(indeces, iflag, 1., NaN);

%
% Assign some indeces I know/care about
%
% North atlantic oscillation
nao=indeces(:,3);
indeces_date = datenum(indeces(:,1), indeces(:,2), 15.*ones(size(indeces,1),1));

%  East Atlantic Pattern (EA)
ea=indeces(:,8);

%  East Atlantic /West Russina Jet Pattern (EA/WR)
ea_wr=indeces(:,5);

% Pacific/ North American Pattern (PNA)
pna = indeces(:,7);

% Tropical/ Northern Hemisphere Pattern (TNH)
tropical_northern_hem = indeces(:,12);

%
% save as a mat file
%
clear ans
clear iflag
clear indeces

save ncep_indeces.mat
