

files = ["imdd_simulation\projects\MPI_April\wh_pam4_dienstag.mat","imdd_simulation\projects\MPI_April\wh_pam6_dienstag.mat"];
linesstyles = ["-","--"];

vp = wh.parameter.vp.values;
vb = wh.parameter.vb.values;
sir = wh.parameter.sir.values(4);
rop = wh.parameter.rop.values(end);
lw = wh.parameter.laser_linewidth.values(1);
pn_key = wh.parameter.pn_key.values;
bias = wh.parameter.vb.values(1:end-3);

figure()
tiledlayout(2,3)
cols = flip(cbrewer2("RdYlBu",32));

for d = 1:2
    load(files(d));

    for lw = wh.parameter.laser_linewidth.values
        nexttile

        curber = [];
        meanber = [];
        for v = 1:numel(wh.parameter.vp.values)
            vp_ = wh.parameter.vp.values(v);
            for b = 1:numel(bias)
                for k = pn_key
                    curber(k,b) = wh.getStoValue('ber',sir,lw,k,vp_,bias(b),rop);
                end
            end
            meanber(v,:) =  mean(curber,1);
        end
        
        levels = [1e-4, reshape([1e-4; 1e-3; 1e-2]*[2:2:10],1,[])];
        contourf(2-bias,wh.parameter.vp.values*100, meanber,levels,'DisplayName',"BER","EdgeAlpha",0.5,'LineStyle','--');
        colormap(cols)
        set(gca,'ColorScale','log');
        xlabel('bias ')
        ylabel('vpp in %')
        clim([1e-4 3e-1]);

        if d == 1
            title(['PAM4 - SIR: ',num2str(sir),'; Lw: ',num2str(lw*1e-6),' MHz'])
        elseif d == 2
            title(['PAM6 - SIR: ',num2str(sir),'; Lw: ',num2str(lw*1e-6),' MHz'])
        end

    end
end

