clear all; close all;
%make zonal and annual mean planetary albedo partitioning for David Klein

load ('C:\Users\Aaron Donohoe\Desktop\research\radiation\ceres_ebaf\4.0\CERES_4p0_planetary_albedo_partition_climatolgy.mat')
INSOL=squeeze(mean(squeeze(mean(CDT))'));
PALB = squeeze(mean(squeeze(mean(CUT))'))./INSOL;
ATMOS_PALB = squeeze(mean(squeeze(nansum(cATM))'))./(12*INSOL);
SURF_PALB = squeeze(mean(squeeze(nansum(cSURF))'))./(12*INSOL);
SURF_ALB = squeeze(mean( squeeze(mean(CUS))' ))./squeeze(mean( squeeze(mean(CDS))' ));
ATTENUATION = 1-SURF_PALB./SURF_ALB;

LW=2.5; FSz=32;
FN='Arial';
LWA=3;

figure(1); clf;

hold on; plot(lat, PALB, 'k-', 'LineWidth', LW);
hold on; plot(lat, ATMOS_PALB, 'r-', 'LineWidth', LW);
hold on; plot(lat, SURF_PALB, 'b-', 'LineWidth', LW);
%hold on; plot(lat, SURF_PALB+ATMOS_PALB, 'k--', 'LineWidth', LW)

xmn=-90; xmx=90;
ymn=0; ymx=0.9;
axis([xmn xmx ymn ymx]); grid on; box on;
xlabel('Latitude', 'FontSize', FSz, 'FontName', FN)
ylabel('Planetary Albedo', 'FontSize', FSz, 'FontName', FN)
set(gca, 'FontSize', FSz, 'FontName', FN, 'LineWidth', LWA);
legend('Total', 'Atmospheric contribution','Surface contribution')



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(2); clf;

hold on; plot(lat, SURF_ALB, 'k-', 'LineWidth', LW);
hold on; plot(lat, SURF_PALB, 'b-', 'LineWidth', LW);
%hold on; plot(lat, SURF_PALB+ATMOS_PALB, 'k--', 'LineWidth', LW)

xmn=-90; xmx=90;
ymn=0; ymx=0.9;
axis([xmn xmx ymn ymx]); grid on; box on;
xlabel('Latitude', 'FontSize', FSz, 'FontName', FN)
ylabel('Albedo', 'FontSize', FSz, 'FontName', FN)
set(gca, 'FontSize', FSz, 'FontName', FN, 'LineWidth', LWA);
legend('Surface Albedo', 'Surface contribution to planetary albedo')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


figure(3); clf;

hold on; plot(lat, ATTENUATION, 'k-', 'LineWidth', LW);


xmn=-90; xmx=90;
ymn=0; ymx=0.95;
axis([xmn xmx ymn ymx]); grid on; box on;
xlabel('Latitude', 'FontSize', FSz, 'FontName', FN)
ylabel('Atmopsheric Attenuation', 'FontSize', FSz, 'FontName', FN);

set(gca, 'FontSize', FSz, 'FontName', FN, 'LineWidth', LWA);

%save annual mean calculations

save('CERES_4p0_planetary_albedo_partition_annual.mat', 'lat', 'ATTENUATION', 'ATMOS_PALB', 'SURF_PALB', 'SURF_ALB', 'PALB')

