



vp = wh.parameter.vp.values(2);
vb = wh.parameter.vb.values(1);
rop = wh.parameter.rop.values;


f=figure(1113);
tiledlayout(2,3)
for sir = [36,26]
    for lw = wh.parameter.laser_linewidth.values
        nexttile
        cols = linspecer(9);
        cnt = 1;
        for bias = wh.parameter.vb.values
            curber = [];
            curstd = [];
            rop_meas = [];
            txpow_meas = wh.getStoValue('mod_out_pow',sir,lw,1,vp,bias,rop(1));
            for pn_key = wh.parameter.pn_key.values
                curber(end+1,:)     = wh.getStoValue('ber',sir,lw,pn_key,vp,bias,rop);
                rop_meas(end+1,:)   = wh.getStoValue('rop_save',sir,lw,pn_key,vp,bias,rop);

                plot(rop_meas(end,:)-txpow_meas, curber(end,:) ,'LineStyle',':','Color',cols(cnt,:),'LineWidth',0.1,'Marker','o','MarkerEdgeColor',[1 1 1],'MarkerFaceColor',cols(cnt,:),'HandleVisibility','off','MarkerSize',1);
                hold on
            end
            [wrst,idx]=max(curber);
            for i = 1:numel(idx)
                rop_wrst(i)=rop_meas(idx(i),i);
            end
            plot( rop_wrst-txpow_meas, wrst ,'LineStyle',':','Color',cols(cnt,:),'LineWidth',1,'Marker','^','MarkerSize',5,'MarkerEdgeColor',[1 1 1],'MarkerFaceColor',cols(cnt,:),'HandleVisibility','off');
            plot(mean(rop_meas,1)-txpow_meas, mean(curber,1),'DisplayName',['Vbias: ',num2str(bias),' V'],'LineStyle','-','Color',cols(cnt,:),'LineWidth',1,'Marker','o','MarkerEdgeColor',[1 1 1],'MarkerFaceColor',cols(cnt,:));
            hold on
            cnt = cnt+1;
        end
        
        title(['SIR: ',num2str(sir),'; Lw: ',num2str(lw*1e-6),' MHz; Vpeakpeak: ',num2str(2*vp)])
        set(gca,'YScale','log');
        legend('Location','southwest')
        xlabel("measured ROP in dBm")
        ylabel("BER")
        yline(3.8e-3,'DisplayName','FEC');
        xlim([-5,3]);
        ylim([1e-4,3e-1]);
        drawnow
    end
end

