%Before running this, in ./reduc_makeaps.m > make_aps1d, remove the fiels {'ac'} from coaddopt, using coaddopt = rmfield(coaddopt, {'ac'}) before saving. 
%Number of pairs in B3
a = 1:1240;
%Shuffling of the array
stream0 = RandStream('mlfg6331_64', 'Seed', 0);
RandStream.setDefaultStream(stream0);

a1 = a(randperm(length(a)));
%Divide into 10 groups of equal len
tile_combos = mat2cell(a1,1,[155,155,155,155,155,155,155,155]);
apsopt.coaddrx=1;
ukpv = get_ukpervolt('2017','bicep3');
for i = 1:8
    b = tile_combos{1};
    if i>1
        b = cat(1,b,tile_combos{2:i})
    end
    b1 = reshape(b,1,[])
    length(b1)
    apsopt.ukpervolt = NaN*ones(1, length(a));
    apsopt.ukpervolt(b1) = ukpv;
    apsopt.daughter = sprintf('%dpairs', length(b1));
    mapname = sprintf('5901/0??6_g_filtp3_weight3_gs_dp1100_jack02_overrx_%dpairs.mat',length(b1))
    reduc_makeaps('maps/5901/0??6_g_filtp3_weight3_gs_dp1100_jack02.mat',apsopt);
    reduc_makesimset(mapname)
end
