function METout=QC_MET(MET,savefile)
%QC MET:

% (1) Time-series plot
% This is used to manually NaN data, for example, if the MET atm pressure
%  sensor started reporting bad data. Typical range for atm pressure is 
%  1000 - 1030 hPa (or mbar).

dn = datenum([1970 1 1]);

 figMET = figure('Name','MET','Units','inches','Position',[0 0 11 8.5],...
     'CloseRequestFcn', @(h,e) fprintf(1, 'Not allowed, use "close MET force"\n.'));
 ha = tight_subplot(2,1,0.075,0.2,0.1);
 g = get(ha,'Position');
 set(ha,'Box','on','NextPlot','add');
 axes(ha(1));
   plot(MET(:,1),MET(:,2),'.-');
   ylabel(['[mbar]']);
   title('Atmospheric Pressure');
   fUnNaN=@qcWG_UnNaNcb;
   fNaN=@qcWG_NaNcb;
   ha(1).UserData=zeros(length(MET(:,2)),1);
   
   uicontrol('Units','normalized','Style','pushbutton','String','NaN',...
     'Position',[g{1}(1)+g{1}(3)-0.08 g{1}(2)+g{1}(4)+0.003 .08 .03],...
     'Callback',{fNaN,MET(:,1),MET(:,2),ha(1)});
 
   uicontrol('Units','normalized','Style','pushbutton','String','Un-NaN',...
     'Position',[g{1}(1)+g{1}(3)-0.16 g{1}(2)+g{1}(4)+0.003 .08 .03],...
     'Callback',{fUnNaN,MET(:,1),MET(:,2),ha(1)});
 
 axes(ha(2));
   plot(MET(:,1),MET(:,3),'.-');
   ylabel(['[' char(186) 'C]']);
   title('Air Temperature');
   ha(2).UserData=zeros(length(MET(:,2)),1);
   
   uicontrol('Units','normalized','Style','pushbutton','String','NaN',...
     'Position',[g{2}(1)+g{2}(3)-0.08 g{2}(2)+g{2}(4)+0.003 .08 .03],...
     'Callback',{fNaN,MET(:,1),MET(:,3),ha(2)});
 
   uicontrol('Units','normalized','Style','pushbutton','String','Un-NaN',...
     'Position',[g{2}(1)+g{2}(3)-0.16 g{2}(2)+g{2}(4)+0.003 .08 .03],...
     'Callback',{fUnNaN,MET(:,1),MET(:,3),ha(2)});
 
 set(ha,'XLim',[min(MET(:,1)) max(MET(:,1))] + [-1 1]*0.1);
 linkaxes(ha,'x');
 
 sprintf('Paused, Hit any key to save data and continue')
 pause;
 for n1=1:2
     bool=zeros(size(MET,1),1);
     for n=1:size(MET,1)
         samp=ha(n1).UserData(n,:);
         f=samp>0;
         if sum(f)==0
             bool(n)=0;
             continue
         end
         samp=samp(f);
         if samp(end)==2
             bool(n)=0;
         else
             bool(n)=1;
         end
     end
     filtered=MET(:,n1+1);
     filtered(bool==1)=NaN;
     MET(:,n1+1)=filtered;
 end

 close MET force
 
 METout=MET;

%save QC'd .csv file
 time = (MET(:,1) - dn) * 86400*1000;
 fid = fopen(savefile,'w');
 fprintf(fid, ['Time[GMT/Unix*1000],airPress[hPa],airTemp[C]']);
 for n=1:size(MET,1)
   fprintf(fid, '\n%.0f,%.1f,%.1f', [time(n) MET(n,2:3)]);
 end
 fclose(fid);
 clear time fid n;

 clear ha figMET g;