addpath(genpath('../../code'))
addpath(genpath('../../utilities'))
vers='1_13_1';
visual=false;
[S,year,proxy_ann,proxy_djf,proxy_jja,proxy_ama] = pages2k_phase2_db_unpack_AMA_1_13_1(vers,visual);

outfile = ['proxy_ama_',vers];
save(outfile,'proxy_ama');

outfile = ['proxy_data_',vers];
save(outfile,'year','proxy_ann','proxy_djf','proxy_jja','proxy_ama');

% x=[{S.dataSetName};{S.geo_latitude};{S.geo_longitude};{S.archiveType};{S.resMed};{S.paleoData_TSid}];
% %metadata=table(x,'RowNames',{'dataSetName','geo_latitude','geo_longitude','archiveType','resMed','paleoData_TSid'});
% metanames ={'dataSetName','geo_latitude','geo_longitude','archiveType','resMed','paleoData_TSid'};
% metadata=[metanames' x];
% metatable=cell2table(metadata);
% outname=['metadata_',vers,'.txt'];
% %dlmwrite(outname,cell2mat(metadata), '\t');
% %metadata=table(names',p_lat',p_lon',archive',resMed,{S.paleoData_TSid}','VariableNames',{'dataSetName','geo_latitude','geo_longitude','archiveType','resMed','paleoData_TSid'});
% writetable(metatable,outname,'WriteVariableNames',false,'Delimiter','\t');
