def sweep_meas_strength(lt1=False,
                        name=meas_name,
                        nr_of_MW_pulses=1,
                        nr_of_datapoints=2,
                        reps=1500,
                        RO_reps=1,
                        do_shel=False,
                        init_line='-1',
                        RO_line='-1'):
    datafolder = 'D:/measuring/data/'
    date = dtime.strftime('%Y') + dtime.strftime('%m') + dtime.strftime('%d')
    datapath = datafolder + date + '/'

    m = MBI.MBI(name)
    m.setup(lt1)

    reps_per_datap = reps
    m.nr_of_datapoints = nr_of_datapoints
    m.nr_of_RO_steps = RO_reps

    print m.nr_of_RO_steps

    strength = np.linspace(0, 90, nr_of_datapoints)
    m.do_shelv_pulse = do_shel
    m.do_incr_RO_steps = 0

    m.MBI_mod_freq = MBI.get_freq(m, init_line) * np.ones(nr_of_datapoints)
    m.MW_sel_mod_freq = MBI.get_freq(m, RO_line) * np.ones(nr_of_datapoints)
    m.MW_nsel_mod_freq = (MBI.get_freq(
        m, RO_line) - exp.sil9['hf_splitting'] / 2) * np.ones(nr_of_datapoints)

    m.MWdic = {}
    m.MWdic['meas_theta'] = strength * np.ones(nr_of_datapoints)
    m.MWdic['CORPSE_nsel_frabi'] = exp.pulses['CORPSE_nsel_frabi'] * np.ones(
        nr_of_datapoints)
    m.MWdic['CORPSE_nsel_amp'] = exp.pulses['CORPSE_nsel_amp'] * np.ones(
        nr_of_datapoints)
    m.MWdic['CORPSE_freq'] = m.MW_nsel_mod_freq * np.ones(nr_of_datapoints)
    m.MWdic['sel_amp'] = exp.pulses['sel_amp'] * np.ones(nr_of_datapoints)
    m.MWdic['sel_frabi'] = exp.pulses['sel_frabi'] * np.ones(nr_of_datapoints)
    m.MWdic['RO_line'] = m.MW_sel_mod_freq * np.ones(nr_of_datapoints)

    print 'init on mI = ', init_line, m.MBI_mod_freq
    print 'pulses on mI = ', RO_line, m.MWdic['RO_line']

    m.par['sweep_par'] = strength / 90.
    m.par['sweep_par_name'] = 'measurement strength A.U.'
    m.par['RO_repetitions'] = int(len(m.par['sweep_par']) * reps_per_datap)

    m.load_MWseq_func = MBIseq.add_weak_meas
    #    m.start_measurement (m.generate_MW_sweep_sequence)
    m.start_measurement(MBIseq.MW_sweep)
    dp = MBI.get_datapath()
    path = lde_calibration.find_newest_data(dp, string=name)
    spin_control.plot_data_MBI(path)
def sweep_meas_strength(
    lt1=False,
    name=meas_name,
    nr_of_MW_pulses=1,
    nr_of_datapoints=2,
    reps=1500,
    RO_reps=1,
    do_shel=False,
    init_line="-1",
    RO_line="-1",
):
    datafolder = "D:/measuring/data/"
    date = dtime.strftime("%Y") + dtime.strftime("%m") + dtime.strftime("%d")
    datapath = datafolder + date + "/"

    m = MBI.MBI(name)
    m.setup(lt1)

    reps_per_datap = reps
    m.nr_of_datapoints = nr_of_datapoints
    m.nr_of_RO_steps = RO_reps

    print m.nr_of_RO_steps

    strength = np.linspace(0, 90, nr_of_datapoints)
    m.do_shelv_pulse = do_shel
    m.do_incr_RO_steps = 0

    m.MBI_mod_freq = MBI.get_freq(m, init_line) * np.ones(nr_of_datapoints)
    m.MW_sel_mod_freq = MBI.get_freq(m, RO_line) * np.ones(nr_of_datapoints)
    m.MW_nsel_mod_freq = (MBI.get_freq(m, RO_line) - exp.sil9["hf_splitting"] / 2) * np.ones(nr_of_datapoints)

    m.MWdic = {}
    m.MWdic["meas_theta"] = strength * np.ones(nr_of_datapoints)
    m.MWdic["CORPSE_nsel_frabi"] = exp.pulses["CORPSE_nsel_frabi"] * np.ones(nr_of_datapoints)
    m.MWdic["CORPSE_nsel_amp"] = exp.pulses["CORPSE_nsel_amp"] * np.ones(nr_of_datapoints)
    m.MWdic["CORPSE_freq"] = m.MW_nsel_mod_freq * np.ones(nr_of_datapoints)
    m.MWdic["sel_amp"] = exp.pulses["sel_amp"] * np.ones(nr_of_datapoints)
    m.MWdic["sel_frabi"] = exp.pulses["sel_frabi"] * np.ones(nr_of_datapoints)
    m.MWdic["RO_line"] = m.MW_sel_mod_freq * np.ones(nr_of_datapoints)

    print "init on mI = ", init_line, m.MBI_mod_freq
    print "pulses on mI = ", RO_line, m.MWdic["RO_line"]

    m.par["sweep_par"] = strength / 90.0
    m.par["sweep_par_name"] = "measurement strength A.U."
    m.par["RO_repetitions"] = int(len(m.par["sweep_par"]) * reps_per_datap)

    m.load_MWseq_func = MBIseq.add_weak_meas
    #    m.start_measurement (m.generate_MW_sweep_sequence)
    m.start_measurement(MBIseq.MW_sweep)
    dp = MBI.get_datapath()
    path = lde_calibration.find_newest_data(dp, string=name)
    spin_control.plot_data_MBI(path)
def sweep_meas_strength (lt1 = False, name = meas_name,nr_of_MW_pulses=1,nr_of_datapoints = 2,
        reps=1500,RO_reps=1,do_shel=False,init_line='-1',RO_line='-1'):
    datafolder= 'D:/measuring/data/'
    date = dtime.strftime('%Y') + dtime.strftime('%m') + dtime.strftime('%d')
    datapath = datafolder+date + '/'

    m = MBI.MBI(name)
    m.setup (lt1)

    reps_per_datap = reps
    m.nr_of_datapoints = nr_of_datapoints
    m.nr_of_RO_steps = RO_reps

    print m.nr_of_RO_steps

    strength=np.linspace(0,90,nr_of_datapoints)
    m.do_shelv_pulse = do_shel
    m.do_incr_RO_steps = 0

    m.MBI_mod_freq = MBI.get_freq(m,init_line)*np.ones(nr_of_datapoints)
    m.MW_sel_mod_freq = MBI.get_freq(m,RO_line)*np.ones(nr_of_datapoints)
    m.MW_nsel_mod_freq = (MBI.get_freq(m,RO_line)-exp.sil9['hf_splitting']/2)*np.ones(nr_of_datapoints)

    m.MWdic={}
    m.MWdic['meas_theta']=strength*np.ones(nr_of_datapoints)
    m.MWdic['CORPSE_nsel_frabi']=exp.pulses['CORPSE_nsel_frabi']*np.ones(nr_of_datapoints)
    m.MWdic['CORPSE_nsel_amp']=exp.pulses['CORPSE_nsel_amp']*np.ones(nr_of_datapoints)
    m.MWdic['CORPSE_freq'] = m.MW_nsel_mod_freq*np.ones(nr_of_datapoints)
    m.MWdic['sel_amp']=exp.pulses['sel_amp']*np.ones(nr_of_datapoints)
    m.MWdic['sel_frabi']=exp.pulses['sel_frabi']*np.ones(nr_of_datapoints)
    m.MWdic['RO_line'] = m.MW_sel_mod_freq*np.ones(nr_of_datapoints)


    print 'init on mI = ', init_line, m.MBI_mod_freq
    print 'pulses on mI = ', RO_line,  m.MWdic['RO_line']

    m.par['sweep_par'] = strength/90.
    m.par['sweep_par_name'] = 'measurement strength A.U.'
    m.par['RO_repetitions'] = int(len(m.par['sweep_par'])*reps_per_datap)

    m.load_MWseq_func = MBIseq.add_weak_meas
#    m.start_measurement (m.generate_MW_sweep_sequence)
    m.start_measurement (MBIseq.MW_sweep)
    dp = MBI.get_datapath()
    path = lde_calibration.find_newest_data (dp, string=name)
    spin_control.plot_data_MBI(path)
def Weak_strong_meas(lt1 = False, name = 'SIL9_lt2_weak_value',
        tau = np.array([1., 90.]), nr_of_pulses=1,nr_of_datapoints = 16, reps=500,RO_reps=2,
        do_shel=True,CORPSE=True,init_line='-1',MW_line='0-1',RO_basis='X',init_rot=1):

    datafolder= 'D:/measuring/data/'
    date = dtime.strftime('%Y') + dtime.strftime('%m') + dtime.strftime('%d')
    datapath = datafolder+date + '/'

    m = MBI.MBI(name)
    m.setup (lt1)

    reps_per_datap = reps
    m.nr_of_datapoints = nr_of_datapoints
    m.nr_of_RO_steps = RO_reps
    print m.nr_of_RO_steps

    #min_tau = 1.
    #max_tau = 217.
    #tau=np.linspace(min_tau,max_tau,nr_of_datapoints)


    m.do_shelv_pulse = do_shel*np.ones(RO_reps)
    m.do_shelv_pulse[RO_reps-1]=1
    print m.do_shelv_pulse
    postselect_pulse=True
    m.do_incr_RO_steps = 0

    m.MBI_mod_freq = MBI.get_freq(m,init_line)*np.ones(nr_of_datapoints)
    if RO_basis=='Z':
        do_rot=0
    else:
        do_rot=1
    if RO_basis=='Y':
        RO_phase=90
    else:
        RO_phase=0

    tauF =30.*np.ones(nr_of_datapoints)
    #tauF = tau

    # first pi/2 pulse
    m.MWdic_last={}
    m.MWdic={}
    m.MWdic_last['nr_of_MW_pulses'] = 1*np.ones(nr_of_datapoints)
    m.MWdic_last['MW_pulse_amp'] = m.pulsedic['pi2_amp']*np.ones(nr_of_datapoints)
    m.MWdic_last['MW_pulse_len'] = m.pulsedic['pi2_len']*np.ones(nr_of_datapoints)
    m.MWdic_last['tau'] = tauF
    m.MWdic_last['weak']=True*np.ones(nr_of_datapoints)
    m.MWdic_last['phase']=90.*np.ones(nr_of_datapoints)
    m.MWdic_last['finalwait_dur']=2000.*np.ones(nr_of_datapoints) #MBIcfg['wait_time_before_MBI_pulse']
    m.MWdic_last['MW_mod_freq'] = MBI.get_freq(m,MW_line)*np.ones(nr_of_datapoints)

    #RF
    m.MWdic_last['RF_pulse_amp'] = init_rot*m.pulsedic['RF_pi2_amp']*np.ones(nr_of_datapoints)
    m.MWdic_last['RF_pulse_len'] = m.pulsedic['RF_pi2_len']*np.ones(nr_of_datapoints)
    m.MWdic_last['RF_phase'] = 0*np.ones(nr_of_datapoints)
    m.MWdic_last['RF_freq'] = exp.sil9['mI_m1_freq']*np.ones(nr_of_datapoints)
    m.MWdic['RF_pulse_amp'] = 0*np.ones(nr_of_datapoints)
    m.MWdic['RF_pulse_len'] = 0*np.ones(nr_of_datapoints)
    m.MWdic['RF_freq'] = 0*exp.sil9['mI_m1_freq']*np.ones(nr_of_datapoints)
    m.MWdic['RF_phase'] = 0*np.ones(nr_of_datapoints)
    #m.MWdic_last['final_shelving']=True*np.ones(nr_of_datapoints)
    #basisrot=m.pulsedic['RF_pi2_len']*np.ones(nr_of_datapoints)

   #WM postselection
    #min_theta=6
    #minTau = 10.
    # get from ramsey contrast at tau=0 ns
    #rot_angle = 2*0.5*np.arcsin (np.cos(np.pi*exp.sil9['hf_splitting']*1e-9*(tau+minTau)))#0.5
    #rot_angle = (np.pi/2.)*np.ones(nr_of_datapoints)
    #basisrot = rot_angle*exp.pulses['RF_pi2_len']/(np.pi/2.)
    basisrot = (tau/90.)*exp.pulses['RF_pi2_len']
    #basisrot = exp.pulses['RF_pi2_len']*np.ones(nr_of_datapoints)




    #m.pulsedic['RF_pi2_len'] = basisrot
    # second RF (basis rot)
    m.MWdic_last['RF2_pulse_amp'] = do_rot*m.pulsedic['RF_pi2_amp']*np.ones(nr_of_datapoints)
    m.MWdic_last['RF2_pulse_len'] = basisrot#m.pulsedic['RF_pi2_len']*np.ones(nr_of_datapoints)
    m.MWdic_last['RF2_freq'] = exp.sil9['mI_m1_freq']*np.ones(nr_of_datapoints)
    #m.MWdic_last['RF2_phase'] =102*np.ones(nr_of_datapoints)#(RO_phase+85)-tau*180*exp.sil9['hf_splitting']*1e-9 #
    m.MWdic_last['RF2_phase'] =(102.-tauF*180*exp.sil9['hf_splitting']*1e-9)#*np.ones(nr_of_datapoints)
    # third RF (other basis rot)
    m.MWdic_last['RF3_pulse_amp'] = do_rot*m.pulsedic['RF_pi2_amp']*np.ones(nr_of_datapoints)
    m.MWdic_last['RF3_pulse_len'] = basisrot#m.pulsedic['RF_pi2_len']*np.ones(nr_of_datapoints)#basisrot
    m.MWdic_last['RF3_freq'] = exp.sil9['mI_m1_freq']*np.ones(nr_of_datapoints)
    #m.MWdic_last['RF3_phase'] = RO_phase+10-tau*180*exp.sil9['hf_splitting']*1e-9#0*np.ones(nr_of_datapoints)
    #phase offset for non pi/2 pulse RF1
    m.MWdic_last['RF3_phase'] = np.fmod(30.-tauF*180*exp.sil9['hf_splitting']*1e-9-2*180*exp.sil9['hf_splitting']*(basisrot-m.pulsedic['RF_pi2_len'])*1e-9, 360)





    # Second pi/2 pulse
    m.MWdic['nr_of_MW_pulses'] = 1*np.ones(nr_of_datapoints)
    m.MWdic['MW_pulse_amp'] = m.pulsedic['pi2_amp']*np.ones(nr_of_datapoints)
    m.MWdic['MW_pulse_len'] = m.pulsedic['pi2_len']*np.ones(nr_of_datapoints)
    m.MWdic['tau'] = 217*np.ones(nr_of_datapoints)
    m.MWdic['phase']=90.*np.ones(nr_of_datapoints)
    m.MWdic['finalwait_dur']=2000.*np.ones(nr_of_datapoints) #MBIcfg['wait_time_before_MBI_pulse']
    m.MWdic['MW_mod_freq'] = MBI.get_freq(m,MW_line)*np.ones(nr_of_datapoints)
    m.MBI_mod_freq = MBI.get_freq(m,init_line)*np.ones(nr_of_datapoints)

    # in case of CORPSE pulses
    m.MWdic['CORPSE_amp'] = m.pulsedic['CORPSE_nsel_amp']*np.ones(nr_of_datapoints)
    m.MWdic['CORPSE_frabi']=m.pulsedic['CORPSE_nsel_frabi']*np.ones(nr_of_datapoints)
    m.MWdic_last['CORPSE_amp']= m.MWdic['CORPSE_amp']
    m.MWdic_last['CORPSE_frabi'] =  m.MWdic['CORPSE_frabi']
    m.MWdic['freq']=m.MWdic_last['MW_mod_freq']
    m.MWdic_last['freq']=m.MWdic['freq']
    #set laser powers
    m.Ex_final_RO_amplitude = m.ssrodic['Ex_RO_amplitude']
    m.A_final_RO_amplitude = 0.
    m.Ex_RO_amplitude = m.ssrodic['Ex_RO_amplitude']
    m.A_RO_amplitude = 0.
    m.RO_duration = m.MBIdic['weak_RO_duration']
    m.final_RO_duration = m.ssrodic['RO_duration']

    print 'init on mI = ', init_line, m.MBI_mod_freq
    print 'RO on mI = ', MW_line, m.MWdic['MW_mod_freq']

    m.par['sweep_par'] = tau
    m.par['sweep_par_name'] = 'phase (degree)'
    m.par['RO_repetitions'] = int(len(m.par['sweep_par'])*reps_per_datap)

    #STRONG READOUT!!!!
    # second RF (basis rot)
    m.MWdic['RF2_pulse_amp'] = 0*m.pulsedic['RF_pi2_amp']*np.ones(nr_of_datapoints)
    m.MWdic['RF2_pulse_len'] = m.pulsedic['RF_pi2_len']*np.ones(nr_of_datapoints)
    m.MWdic['RF2_freq'] = exp.sil9['mI_m1_freq']*np.ones(nr_of_datapoints)
    m.MWdic['RF2_phase'] = np.ones(nr_of_datapoints)
    # third RF (other basis rot)
    #If RF3 is commented out: no pi pulses after strong readout
    #m.MWdic['RF3_pulse_amp'] = 0*m.pulsedic['RF_pi2_amp']*np.ones(nr_of_datapoints)
    m.MWdic['RF3_pulse_len'] = m.pulsedic['RF_pi2_len']*np.ones(nr_of_datapoints)
    m.MWdic['RF3_freq'] = exp.sil9['mI_m1_freq']*np.ones(nr_of_datapoints)
    m.MWdic['RF3_phase'] = np.ones(nr_of_datapoints)

    if CORPSE:
        m.load_MWseq_func=MBIseq.ramsey_CORPSE
        m.load_MWseq_func_last=MBIseq.ramsey_CORPSE

#if postselect_pulse:
#            m.load_MWseq_func_last=MBIseq.MBI_element
    else:
        m.load_MWseq_func=MBIseq.ramsey
        m.load_MWseq_func_last=MBIseq.ramsey
    m.start_measurement (MBIseq.MW_sweep)
    dp = MBI.get_datapath()
    path = lde_calibration.find_newest_data (dp, string=name)
    spin_control.plot_data_MBI(path)
def Weak_strong_meas(lt1=False,
                     name='SIL9_lt2_weak_value',
                     tau=np.array([1., 90.]),
                     nr_of_pulses=1,
                     nr_of_datapoints=16,
                     reps=500,
                     RO_reps=2,
                     do_shel=True,
                     CORPSE=True,
                     init_line='-1',
                     MW_line='0-1',
                     RO_basis='X',
                     init_rot=1):

    datafolder = 'D:/measuring/data/'
    date = dtime.strftime('%Y') + dtime.strftime('%m') + dtime.strftime('%d')
    datapath = datafolder + date + '/'

    m = MBI.MBI(name)
    m.setup(lt1)

    reps_per_datap = reps
    m.nr_of_datapoints = nr_of_datapoints
    m.nr_of_RO_steps = RO_reps
    print m.nr_of_RO_steps

    #min_tau = 1.
    #max_tau = 217.
    #tau=np.linspace(min_tau,max_tau,nr_of_datapoints)

    m.do_shelv_pulse = do_shel * np.ones(RO_reps)
    m.do_shelv_pulse[RO_reps - 1] = 1
    print m.do_shelv_pulse
    postselect_pulse = True
    m.do_incr_RO_steps = 0

    m.MBI_mod_freq = MBI.get_freq(m, init_line) * np.ones(nr_of_datapoints)
    if RO_basis == 'Z':
        do_rot = 0
    else:
        do_rot = 1
    if RO_basis == 'Y':
        RO_phase = 90
    else:
        RO_phase = 0

    #tauF =100.*np.ones(nr_of_datapoints)
    tauF = tau

    # first pi/2 pulse
    m.MWdic_last = {}
    m.MWdic = {}
    m.MWdic_last['nr_of_MW_pulses'] = 1 * np.ones(nr_of_datapoints)
    m.MWdic_last['MW_pulse_amp'] = m.pulsedic['pi2_amp'] * np.ones(
        nr_of_datapoints)
    m.MWdic_last['MW_pulse_len'] = m.pulsedic['pi2_len'] * np.ones(
        nr_of_datapoints)
    m.MWdic_last['tau'] = tauF
    m.MWdic_last['weak'] = True * np.ones(nr_of_datapoints)
    m.MWdic_last['phase'] = 90. * np.ones(nr_of_datapoints)
    m.MWdic_last['finalwait_dur'] = 2000. * np.ones(
        nr_of_datapoints)  #MBIcfg['wait_time_before_MBI_pulse']
    m.MWdic_last['MW_mod_freq'] = MBI.get_freq(
        m, MW_line) * np.ones(nr_of_datapoints)

    #RF
    m.MWdic_last['RF_pulse_amp'] = init_rot * m.pulsedic[
        'RF_pi2_amp'] * np.ones(nr_of_datapoints)
    m.MWdic_last['RF_pulse_len'] = m.pulsedic['RF_pi2_len'] * np.ones(
        nr_of_datapoints)
    m.MWdic_last['RF_phase'] = 0 * np.ones(nr_of_datapoints)
    m.MWdic_last['RF_freq'] = exp.sil9['mI_m1_freq'] * np.ones(
        nr_of_datapoints)
    m.MWdic['RF_pulse_amp'] = 0 * np.ones(nr_of_datapoints)
    m.MWdic['RF_pulse_len'] = 0 * np.ones(nr_of_datapoints)
    m.MWdic['RF_freq'] = 0 * exp.sil9['mI_m1_freq'] * np.ones(nr_of_datapoints)
    m.MWdic['RF_phase'] = 0 * np.ones(nr_of_datapoints)
    #m.MWdic_last['final_shelving']=True*np.ones(nr_of_datapoints)
    #basisrot=m.pulsedic['RF_pi2_len']*np.ones(nr_of_datapoints)

    #WM postselection
    #min_theta=6
    minTau = 12.
    # get from ramsey contrast at tau=0 ns
    rot_angle = np.mod(2 * 0.5 * np.arcsin(
        np.cos(np.pi * exp.sil9['hf_splitting'] * 1e-9 * (tau + minTau))),
                       2 * np.pi)  #0.5
    #rot_angle = (np.pi/2.)*np.ones(nr_of_datapoints)
    basisrot = rot_angle * exp.pulses['RF_pi2_len'] / (np.pi / 2.)
    #basisrot = (tau/90.)*exp.pulses['RF_pi2_len']
    #basisrot = exp.pulses['RF_pi2_len']*np.ones(nr_of_datapoints)

    #m.pulsedic['RF_pi2_len'] = basisrot
    # second RF (basis rot)
    m.MWdic_last['RF2_pulse_amp'] = do_rot * m.pulsedic[
        'RF_pi2_amp'] * np.ones(nr_of_datapoints)
    m.MWdic_last[
        'RF2_pulse_len'] = basisrot  #m.pulsedic['RF_pi2_len']*np.ones(nr_of_datapoints)
    m.MWdic_last['RF2_freq'] = exp.sil9['mI_m1_freq'] * np.ones(
        nr_of_datapoints)
    #m.MWdic_last['RF2_phase'] =102*np.ones(nr_of_datapoints)#(RO_phase+85)-tau*180*exp.sil9['hf_splitting']*1e-9 #
    m.MWdic_last['RF2_phase'] = (102. -
                                 tauF * 180 * exp.sil9['hf_splitting'] * 1e-9
                                 )  #*np.ones(nr_of_datapoints)
    # third RF (other basis rot)
    m.MWdic_last['RF3_pulse_amp'] = do_rot * m.pulsedic[
        'RF_pi2_amp'] * np.ones(nr_of_datapoints)
    m.MWdic_last[
        'RF3_pulse_len'] = basisrot  #m.pulsedic['RF_pi2_len']*np.ones(nr_of_datapoints)#basisrot
    m.MWdic_last['RF3_freq'] = exp.sil9['mI_m1_freq'] * np.ones(
        nr_of_datapoints)
    #m.MWdic_last['RF3_phase'] = RO_phase+10-tau*180*exp.sil9['hf_splitting']*1e-9#0*np.ones(nr_of_datapoints)
    #phase offset for non pi/2 pulse RF1
    m.MWdic_last['RF3_phase'] = np.fmod(
        30. - tauF * 180 * exp.sil9['hf_splitting'] * 1e-9 -
        2 * 180 * exp.sil9['hf_splitting'] *
        (basisrot - m.pulsedic['RF_pi2_len']) * 1e-9, 360)

    # Second pi/2 pulse
    m.MWdic['nr_of_MW_pulses'] = 1 * np.ones(nr_of_datapoints)
    m.MWdic['MW_pulse_amp'] = m.pulsedic['pi2_amp'] * np.ones(nr_of_datapoints)
    m.MWdic['MW_pulse_len'] = m.pulsedic['pi2_len'] * np.ones(nr_of_datapoints)
    m.MWdic['tau'] = 217 * np.ones(nr_of_datapoints)
    m.MWdic['phase'] = 90. * np.ones(nr_of_datapoints)
    m.MWdic['finalwait_dur'] = 2000. * np.ones(
        nr_of_datapoints)  #MBIcfg['wait_time_before_MBI_pulse']
    m.MWdic['MW_mod_freq'] = MBI.get_freq(m,
                                          MW_line) * np.ones(nr_of_datapoints)
    m.MBI_mod_freq = MBI.get_freq(m, init_line) * np.ones(nr_of_datapoints)

    # in case of CORPSE pulses
    m.MWdic['CORPSE_amp'] = m.pulsedic['CORPSE_nsel_amp'] * np.ones(
        nr_of_datapoints)
    m.MWdic['CORPSE_frabi'] = m.pulsedic['CORPSE_nsel_frabi'] * np.ones(
        nr_of_datapoints)
    m.MWdic_last['CORPSE_amp'] = m.MWdic['CORPSE_amp']
    m.MWdic_last['CORPSE_frabi'] = m.MWdic['CORPSE_frabi']
    m.MWdic['freq'] = m.MWdic_last['MW_mod_freq']
    m.MWdic_last['freq'] = m.MWdic['freq']
    #set laser powers
    m.Ex_final_RO_amplitude = m.ssrodic['Ex_RO_amplitude']
    m.A_final_RO_amplitude = 0.
    m.Ex_RO_amplitude = m.ssrodic['Ex_RO_amplitude']
    m.A_RO_amplitude = 0.
    m.RO_duration = m.MBIdic['weak_RO_duration']
    m.final_RO_duration = m.ssrodic['RO_duration']

    print 'init on mI = ', init_line, m.MBI_mod_freq
    print 'RO on mI = ', MW_line, m.MWdic['MW_mod_freq']

    m.par['sweep_par'] = tau
    m.par['sweep_par_name'] = 'phase (degree)'
    m.par['RO_repetitions'] = int(len(m.par['sweep_par']) * reps_per_datap)

    #STRONG READOUT!!!!
    # second RF (basis rot)
    m.MWdic['RF2_pulse_amp'] = 0 * m.pulsedic['RF_pi2_amp'] * np.ones(
        nr_of_datapoints)
    m.MWdic['RF2_pulse_len'] = m.pulsedic['RF_pi2_len'] * np.ones(
        nr_of_datapoints)
    m.MWdic['RF2_freq'] = exp.sil9['mI_m1_freq'] * np.ones(nr_of_datapoints)
    m.MWdic['RF2_phase'] = np.ones(nr_of_datapoints)
    # third RF (other basis rot)
    #If RF3 is commented out: no pi pulses after strong readout
    #m.MWdic['RF3_pulse_amp'] = 0*m.pulsedic['RF_pi2_amp']*np.ones(nr_of_datapoints)
    m.MWdic['RF3_pulse_len'] = m.pulsedic['RF_pi2_len'] * np.ones(
        nr_of_datapoints)
    m.MWdic['RF3_freq'] = exp.sil9['mI_m1_freq'] * np.ones(nr_of_datapoints)
    m.MWdic['RF3_phase'] = np.ones(nr_of_datapoints)

    if CORPSE:
        m.load_MWseq_func = MBIseq.ramsey_CORPSE
        m.load_MWseq_func_last = MBIseq.ramsey_CORPSE

#if postselect_pulse:
#            m.load_MWseq_func_last=MBIseq.MBI_element
    else:
        m.load_MWseq_func = MBIseq.ramsey
        m.load_MWseq_func_last = MBIseq.ramsey
    m.start_measurement(MBIseq.MW_sweep)
    dp = MBI.get_datapath()
    path = lde_calibration.find_newest_data(dp, string=name)
    spin_control.plot_data_MBI(path)