
% Remove NaN proxies in trees and re-save data

%ensnm={'001','002','003','004','005','006','007','008','009','010','011','012','013'};
%Edit Jul 2020: only do the ensemble members for my recons
ensnm={'007','008','009','010'};

% The union of missing trees among the models
trnn=[];%trnn=[171 172 238 240 241];
for i=1:length(ensnm)
   %load(['PSM_trees_cesm_lme' ensnm{i} '_v0.mat'],'tr_nanids')
   load(['PSM_trees_cesm_lme' ensnm{i} '_v0_Jul2020.mat'],'tr_nanids')
   trnn=union(trnn,tr_nanids);
end

timestp=datestr(now);
timestp=strrep(timestp,' ','_'); % remove space

for i=1:length(ensnm)

   load(['PSM_trees_cesm_lme' ensnm{i} '_v0_Jul2020.mat'])

   t_lat(trnn)=[];              
   t_lon(trnn)=[];
   tree_psms(trnn,:)=[];
   tree_snr(trnn)=[];
   trw_names(trnn)=[];

   save(['PSM_trees_cesm_lme' ensnm{i} '_updtd_' timestp '.mat'])
end

