clear all

% loads cdc amo climate index
%   get index, and index_date
%
% first data point (1) is supposed to start at:
% Jan 15, 1865 and the last (1602) ends at: 15th of....TBA.

%
% load indeces
%
  amo = load('amo_index_long_us.dat');
  amo_smooth = load('amo_index_long_sm.dat');
%
% Data Consists of:
% column 1: Year (yy)
% column 2-13: Month (mm)
%
% Flagged value = -99.9
%
iflag = -99.9;

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

year = amo(:,1);
year = (year*ones(1,12))';

amo = amo(:,2:13)';
amo_smooth = amo_smooth(:,2:13)';

[m,n]=size(amo);
amo = reshape(amo,m*n,1);
amo_smooth = reshape(amo, m*n,1);

year = reshape (year, m*n, 1);

months = (ones(n,1)*[1:12])';
months = reshape(months, m*n, 1);

days = ones(m*n,1)*15.;
days = reshape (days, m*n, 1);

amo_date = datenum(year, months, days);

clear year months days m n
clear iflag
clear ans

save amo_indices.mat
