function [acs_apcorr, acs_cp, acs_bp, acs_af, acs_cf] = Calc_ACS_apcp(acs_a, acs_c, minute1,minute2)

acs_af.time = [];
acs_af.mean = [];
acs_cf.time = [];
acs_cf.mean = [];
acs_af.wavel = acs_a.wavel;
acs_cf.wavel = acs_c.wavel;

tmp = datevec(acs_a.time);
tmp(:,[5 6]) = 0;
tmp = datenum(tmp);
unique_hr = unique(tmp);

for kh = 1:length(unique_hr)
	datestr(unique_hr(kh))
	ix = find( acs_a.time>=unique_hr(kh)+datenum(0,0,0,0,minute1,0) ...
                & acs_a.time<=unique_hr(kh)+datenum(0,0,0,0,minute2,0) );
    if ~isempty(ix)
        tmp_a = nanmean(acs_a.mean(ix,:));
        tmp_c = nanmean(acs_c.mean(ix,:));
        if all(isfinite(tmp_a)) && size(tmp_a,2)==length(acs_a.wavel)
            acs_af.time = [acs_af.time; unique_hr(kh)+datenum(0,0,0,0,minute1,0)];
            acs_af.mean = [acs_af.mean; tmp_a];
        end
        if all(isfinite(tmp_c)) && size(tmp_c,2)==length(acs_c.wavel)
            acs_cf.time = [acs_cf.time; unique_hr(kh)+datenum(0,0,0,0,minute1,0)];
            acs_cf.mean = [acs_cf.mean; tmp_c];
        end

        % acs_af.std = [acs_af.std;
        % acs_cf.std = [acs_cf.std; 
    end
end
    
% Calculate particle properties using simple linear interpolation between
% filtered measurements
acs_ap.time = acs_a.time;
acs_ap.wavel = acs_a.wavel;
acs_ap.mean = acs_a.mean - interp1(acs_af.time, acs_af.mean, acs_a.time);
acs_cp.time = acs_c.time;
acs_cp.wavel = acs_c.wavel;
acs_cp.mean = acs_c.mean - interp1(acs_cf.time, acs_cf.mean, acs_c.time);
tmp = datevec(acs_a.time);
tmp_min = tmp(:,5);
tmp_rm = tmp_min>=minute1 & tmp_min<=minute2;

acs_ap.time(tmp_rm) = [];
acs_ap.mean(tmp_rm,:) = [];
acs_cp.time(tmp_rm) = [];
acs_cp.mean(tmp_rm,:) = [];

% Deal with mismatch in spectral band positions between a and c channel.
% Interpolate a onto c, but exclude last two bins of c, since they're
% beyond range of a.
wavel = acs_c.wavel(1:(end-2))
acs_apcorr.time = acs_ap.time;
acs_apcorr.wavel = wavel;

ap_uncorr = interp1(acs_ap.wavel, acs_ap.mean', wavel, 'linear')';
cp = acs_cp.mean(:,1:(end-2));

acs_apcorr.mean = ACS_ResidTempScatCorr(ap_uncorr,cp, wavel);


acs_bp.time = acs_ap.time;
acs_bp.wavel = wavel;
acs_bp.mean = interp1(acs_cp.wavel,acs_cp.mean',wavel, 'linear')' - acs_apcorr.mean

