% Load and plot GMD radiometer data for U Mass period
% converts UTC to local

%                         Visitor           Tower
 %  Year Mn Dy Hr Mi    D_GLOBAL  D_IR  D_GLOBAL  D_IR  U_GLOBAL  U_IR
%   2007  8 13  7  1    0.00  367.74    0.00  347.01    0.00  455.11
%   2007  8 13  7  2    0.00  367.85    0.00  347.07    0.00  454.69

clear
close all
pltit = 1;

cd z:/bao/tower/umass

load GMD_rad_2007.dat
tt(:,1) = GMD_rad_2007(:,1);
tt(:,2) = GMD_rad_2007(:,2);
tt(:,3) = GMD_rad_2007(:,3);
tt(:,4) = GMD_rad_2007(:,4);
tt(:,5) = GMD_rad_2007(:,5);

rad(:,2) = GMD_rad_2007(:,6);
rad(:,3) = GMD_rad_2007(:,7);
rad(:,4) = GMD_rad_2007(:,8);
rad(:,5) = GMD_rad_2007(:,9);
rad(:,6) = GMD_rad_2007(:,10);
rad(:,7) = GMD_rad_2007(:,11);

%convert time to local fm GMT
t(:,4) = tt(:,4) - 7;
r = find(t(:,4) < 0);
t(:,3) = tt(:,3);
t(r,3) = tt(r,3) -1;
t(r,4) = t(r,4) + 24;
 
rad(:,1) = datenum(tt(:,1),tt(:,2),tt(:,3),tt(:,4),tt(:,5),0)-datenum(tt(:,1)-1,12,31) -212;
radLT(:,1) = datenum(tt(:,1),tt(:,2),t(:,3),t(:,4),tt(:,5),0)-datenum(tt(:,1)-1,12,31) -212;

figure
plot(radLT(:,1),rad(:,2))
hold
plot(radLT(:,1),rad(:,4),'r')
title('BAO 2007')
xlabel('August (MST)')
ylabel('Incoming SW (w/m^2)')
axis([13,28,0,1300])
legend('Visitor','Tower','Location','Best')

figure
plot(radLT(:,1),rad(:,3))
hold
plot(radLT(:,1),rad(:,5),'r')
title('BAO 2007')
xlabel('August (MST)')
ylabel('Incoming LW (w/m^2)')
axis([13,28,250,500])
legend('Visitor','Tower','Location','Best')

figure
plot(radLT(:,1),rad(:,5)./rad(:,3))
title('BAO 2007')
xlabel('August (MST)')
ylabel('Albedo')
axis([13,28,0,1])


figure
subplot(2,1,1),plot(radLT(:,1),rad(:,2))
hold
subplot(2,1,1),plot(radLT(:,1),rad(:,4),'r')
title('BAO 2007')
ylabel('Incoming SW (w/m^2)')
axis([17,18,0,1300])
legend('Visitor','Tower','Location','Best')
fl = ['Z:\BAO\Tower\UMASS\'];

subplot(2,1,2),plot(radLT(:,1),rad(:,3))
hold
subplot(2,1,2),plot(radLT(:,1),rad(:,5),'r')
xlabel('August (MST)')
ylabel('Incoming LW (w/m^2)')
axis([17,18,250,500])
fl = ['Z:\BAO\Tower\UMASS\'];
    if pltit
        print_buffer = [fl 'GMD_rad_Aug17.png'];
        print('-dpng ', print_buffer);
    end


figure
subplot(2,1,1),plot(radLT(:,1),rad(:,2))
hold
subplot(2,1,1),plot(radLT(:,1),rad(:,4),'r')
title('BAO 2007')
ylabel('Incoming SW (w/m^2)')
axis([19,20,0,1300])
legend('Visitor','Tower','Location','Best')

figure
subplot(2,1,2),plot(radLT(:,1),rad(:,3))
hold
subplot(2,1,2),plot(radLT(:,1),rad(:,5),'r')
xlabel('August (MST)')
ylabel('Incoming LW (w/m^2)')
axis([19,20,250,500])
legend('Visitor','Tower','Location','Best')
    if pltit
        print_buffer = [fl 'GMD_rad_Aug19.png'];
        print('-dpng ', print_buffer);
    end

