
function spectral2broad_cell
%%  This m-file converts spectral MODIS albedo data, converts it into 
%Broad Band albedo, and exports the resulting matrix back into the work
%place.  It is assumed that the input variables are already in the
%workspace.
%Version 1.0
%Author: Bruce Corliss

%% Algorithm ----------------------------------------------------------
%     Liang et al weighted corefficients visible to broadband
%
% Band ----------------  Wavelength  ----------------------------------
% Blue = 0.4364       % 0.459- 0.479
% Green = 0.5366      % 0.545- 0.565
% Red = 0.3265        % 0.620- 0.670
% NIR = 0             % 1.230- 1.250
% LW1 = 0             % 1.230- 1.250
% LW2 = 0             % 1.628- 1.652
% LW3 = 0             % 2.105- 2.115


display('************************************************************');
display(' ');
display('Spectral Albedo (Visible) to Broadband Converter for MODIS data');
display(' Version 1.0 ');
display('Specify the variables for each of the Bands');
display(' ');

% Produce prompt for user input
prompt = {'Enter cellvariable for BlueSky Albedo'};
title = 'Specify Spectral Variable';
lines = 1;
def = {'BlueS_Albedo'};
answer = inputdlg(prompt,title,lines,def);
BlueS_Albedo= evalin('caller', answer{1});

%Take user input, assign to local variables
Red = BlueS_Albedo{1};
NIR =BlueS_Albedo{2};
Blue = BlueS_Albedo{3};
Green = BlueS_Albedo{4};
LW1 = BlueS_Albedo{5};
LW2 = BlueS_Albedo{6};
LW3 = BlueS_Albedo{7};

%Evaluate Broadband albedo
BroadBand_a = 0.4364.*Blue + 0.2366.*Green + 0.3265.*Red +...
               0.*NIR + 0.*LW1 + 0.*LW2 + 0.*LW3;
     
%Export to workspace
assignin('base','VisibleBS_Albedo',BroadBand_a);

%Notify user of completion
display('=> BroadBand albedo exported to workspace.');
display(' ');
