amo2 = load( 'amo_short_unsmoothed.txt');
% loads 59x13 array
% each row is a year labelled in amo(:,1)
% each month of that year in amo(:,2:13)

year = amo2(:,1);
amo_year2 = (year*ones(1,12))';
clear year;

amo2=amo2(:,2:13)';

[m,n]=size(amo2);

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

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

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

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

amo_date2 = datenum(amo_year2, amo_mos2, amo_day2);

amo2 = fillmiss(amo2, -99, 10, NaN);

%shorten the series to get rid of trailing NaN's
I = find(isnan(amo2));
amo2(I) = [];
amo_date2(I) = [];
amo_year2(I) = [];
amo_mos2(I) = [];
amo_day2(I) = [];

clear n m I

amo = amo2;
amo_date = amo_date2;
amo_day = amo_day2;
amo_mos = amo_mos2;
amo_year = amo_year2;

clear amo2 amo_date2 amo_day2 amo_mos2 amo_year2

save amo2.mat

