clear all

load ModisIRF
load Project1shis
load Project1Modis
load Project1shisSim
load simulatedModis


m=convolve2Modis(radiance(:,5));

figure(1) 
plot(wavenumber, radiance(:,5),'c')
for I = 1:12
   x = [wavenumberBandInterval(I,1):0.1:wavenumberBandInterval(I,2)];
   y1= m{17-I}.val;
   y2 = mradiances(I,5);
   mcradiances(I)=m{17-I}.val;
   hold on
   plot(x,y1,'b-',x,y2,'r-')
end
	xlabel('wavenumber [cm^-^1]')
    ylabel('radiance')
    legend('S-HIS','conv(S-HIS)','MODIS')
    title('Observations')
    
figure(2) 
plot(wavenumber,brightnessTemperature(:,5),'c')
for I = 1:12
   x = [wavenumberBandInterval(I,1):0.1:wavenumberBandInterval(I,2)];
   x2 = [m{17-I}.meanWn];
   y1=rad2bt(x2,m{17-I}.val);
   y2 =rad2bt(x2,mradiances(I,5));
   hold on
   plot(x,y1,'b-',x,y2,'r-')
end
    xlabel('wavenumber [cm^-^1]')
    ylabel('BTemperature')
    legend('S-HIS','conv(S-HIS)','MODIS')
    title('Observed temperature')
 ms=convolve2Modis(simulated.radiance(:,1));

figure(3) 
plot(simulated.wavenumber, simulated.radiance(:,1),'g')
for I = 1:12
   xs = [wavenumberBandInterval(I,1):0.1:wavenumberBandInterval(I,2)];
   y1s= ms{17-I}.val;
   y2s = smodis{17-I}.val;
   hold on
   plot(xs,y1s,'b-',xs,y2s,'r-')
end
xlabel('wavenumber [cm^-^1]')
    ylabel('radiance')
    legend('S-HIS','conv(S-HIS)','MODIS')
    title('Simulations')
    
figure(4) 
plot(simulated.wavenumber,simulated.bt(:,1),'g')
for I = 1:12
   xs = [wavenumberBandInterval(I,1):0.1:wavenumberBandInterval(I,2)];
   x2s = ms{17-I}.meanWn;
   y1s=rad2bt(x2s,ms{17-I}.val);
   y2s =rad2bt(x2s,smodis{17-I}.val);
   hold on
   plot(xs,y1s,'b-',xs,y2s,'r-')
end
xlabel('wavenumber [cm^-^1]')
    ylabel('BTemperature')
    legend('S-HIS','conv(S-HIS)','MODIS')
    title('Simulations')

figure(5) 
for I = 1:12
   x2s(I) = ms{17-I}.meanWn;
   diffH(I) = ms{17-I}.val - m{17-I}.val;
   diffm(I)= smodis{17-I}.val - mradiances(I,5);
end
   x=[600:0.1:2400];
   y = zeros(size(x)); 
   plot(x,y,'k',x2s,diffH,'b:.',x2s,diffm,'r:.')
xlabel('wavenumber [cm^-^1]')
    ylabel('Radiance')
    legend('conv(S-HIS)sim-conv(S-HIS)','MODISsim-MODIS')
    title('Differences')  

figure(6) 
for I = 1:12
   x2s(I) = ms{17-I}.meanWn;
   diffH(I) = rad2bt(x2s(I),ms{17-I}.val) - rad2bt(x2s(I),m{17-I}.val);
   diffm(I)= rad2bt(x2s(I),smodis{17-I}.val) - rad2bt(x2s(I),mradiances(I,5));
   diffHm(I)=-diffH(I)+diffm(I);
   diffObs(I)=rad2bt(x2s(I),mradiances(I,5))-rad2bt(x2s(I),m{17-I}.val);
end
   x=[600:0.1:2400];
   y = zeros(size(x)); 
   plot(x2s,diffH,'b:.',x2s,diffm,'r:.', x,y,'k')
   xlabel('wavenumber [cm^-^1]')
    ylabel('Temperature')
    legend('conv(S-HIS)sim-conv(S-HIS)','MODISsim-MODIS')
    title('Differences')
figure(7) 
   plot(x2s,diffHm,'m:.',x2s,diffObs,'b:.', x,y, 'k')
   xlabel('wavenumber [cm^-^1]')
    ylabel('Temperature')
    legend('corrected diff.', 'MODIS-conv(S-HIS)')
    title('Differences')
   