def dd_sweep_LDE_DD_XYX_free_evolution_time(name):
    m = dd_msmt.DynamicalDecoupling('calibrate_xyx_fet_pi2phase_min90')
    dd_msmt.prepare(m)

    pts = 17
    m.params['pts'] = pts
    m.params['repetitions'] = 3000
    m.params_lt3['wait_for_AWG_done'] = 1

    #free evolutiona time is half the total evolution time!!! from centre to centre of pulses
    m.params_lt3['extra_ts_between_pulses'] = np.ones(
        pts) * m.params_lt3['dd_extra_t_between_pi_pulses']
    m.params_lt3['dd_spin_echo_times'] = np.ones(
        pts) * m.params_lt3['dd_spin_echo_time']
    #m.params_lt3['A_SP_amplitude'] = 0. #use LDE element SP.

    # sweep params
    m.params_lt3['pi2_pulse_phase'] = 0
    m.params_lt3['free_evolution_times'] = np.linspace(
        -1e-6, 1e-6, pts) + m.params_lt3['first_C_revival']

    m.params_lt3['DD_pi_phases'] = [90, 0, 90]
    m.dd_sweep_LDE_spin_echo_time_msmt()

    # for the autoanalysis
    m.params_lt3['sweep_name'] = 'free evolution time (us)'
    m.params_lt3['sweep_pts'] = m.params_lt3['dd_extra_t_between_pi_pulses'] * (len(m.params_lt3['DD_pi_phases']) -1) + \
        2 * len(m.params_lt3['DD_pi_phases']) * m.params_lt3['free_evolution_times'] / 1e-6

    dd_msmt.finish(m, upload=UPLOAD, debug=False)
def dd_sweep_LDE_DD_XYX_t_between_pulse(name):
    m = dd_msmt.DynamicalDecoupling('calibrate_xyx_t_between_pulses')
    dd_msmt.prepare(m)

    pts = 21
    m.params['pts'] = pts
    m.params['repetitions'] = 2000
    m.params_lt3['wait_for_AWG_done'] = 1
    m.params['dd_use_delay_reps'] = False

    #suppress optical pulses here
    m.params_lt3['eom_aom_on'] = False
    m.params_lt3['eom_pulse_amplitude'] = -0.26

    #free evolutiona time is half the total evolution time!!! from centre to centre of pulses
    m.params_lt3['free_evolution_times'] = np.ones(
        pts) * m.params_lt3['first_C_revival']
    m.params_lt3['dd_spin_echo_times'] = np.ones(
        pts) * m.params_lt3['dd_spin_echo_time']
    #m.params_lt3['A_SP_amplitude'] = 0. #use LDE element SP.

    # sweep params
    m.params_lt3['extra_ts_between_pulses'] = 400e-9 + np.linspace(
        -2e-6, 2e-6, pts)

    m.params_lt3['DD_pi_phases'] = [90, 0, 90]
    m.dd_sweep_LDE_spin_echo_time_msmt()

    # for the autoanalysis
    m.params_lt3['sweep_name'] = 'extra t between pi pulses (us)'
    m.params_lt3['sweep_pts'] = m.params_lt3['extra_ts_between_pulses'] / 1e-6

    dd_msmt.finish(m, upload=UPLOAD, debug=False)
def dd_calibrate_T2(name):
    m = dd_msmt.DynamicalDecoupling('calibrate_T2')
    funcs.prepare(m)

    m.params_lt3 = m.params
    m.params_lt3['pi2_pulse_phase'] = 0  #Y
    m.params_lt3['DD_pi_phases'] = [90, 0,
                                    90]  ## THIS DEFINES THE XYX SEQUENCE
    m.params_lt3['CORPSE_pi2_wait_length'] = 1300e-9
    m.params_lt3[
        'first_C_revival'] = 106.579e-6 / 2.  #C revival after CORPSE_pi2_wait_length
    m.params_lt3['dd_extra_t_between_pi_pulses'] = -0.111e-6  #0.470e-6
    m.params_lt3['dd_spin_echo_time'] = -83.5e-9
    m.params['dd_use_delay_reps'] = False
    m.params['EOM_trigger_length'] = 100e-9
    m.params['PLU_gate_duration'] = 100e-9
    m.params['Ex_SP_amplitude'] = 0
    m.update_definitions()

    m.params['dd_use_delay_reps'] = True

    pts_per_revival = 2
    revivals = 16
    pts = pts_per_revival * (revivals - 1)
    m.params['pts'] = pts
    m.params['repetitions'] = 750
    m.params_lt3['wait_for_AWG_done'] = 1

    # sweep params
    #free evolutiona time is half the total evolution time!!! from centre to centre of pulses

    sweep_array = m.params_lt3['first_C_revival'] + np.linspace(
        -1e-6, 1e-6, pts_per_revival)
    for r in range(2, revivals):
        sweep_array=np.append(sweep_array, \
            r * (m.params_lt3['first_C_revival'] \
            + m.params_lt3['CORPSE_pi2_wait_length'] \
            + m.params_lt3['dd_extra_t_between_pi_pulses'])
            + np.linspace(-1e-6, 1e-6, pts_per_revival))
    print sweep_array
    m.params_lt3['free_evolution_times'] = sweep_array

    m.params_lt3['DD_pi_phases'] = [0]
    m.dd_sweep_free_ev_time_msmt()

    # for the autoanalysis
    m.params_lt3['sweep_name'] = 'total free evolution time (us)'
    m.params_lt3['sweep_pts'] = 2 * m.params_lt3['free_evolution_times'] / 1e-6

    funcs.finish(m, upload=UPLOAD, debug=False)
def dd_calibrate_C13_revival(name):
    m = dd_msmt.DynamicalDecoupling('calibrate_first_revival')
    funcs.prepare(m)

    m.params_lt3 = m.params
    m.params_lt3['pi2_pulse_phase'] = 0  #Y
    m.params_lt3['DD_pi_phases'] = [90, 0,
                                    90]  ## THIS DEFINES THE XYX SEQUENCE
    m.params_lt3['CORPSE_pi2_wait_length'] = 1300e-9
    m.params_lt3[
        'first_C_revival'] = 106.579e-6 / 2.  #C revival after CORPSE_pi2_wait_length
    m.params_lt3['dd_extra_t_between_pi_pulses'] = -0.111e-6  #0.470e-6
    m.params_lt3['dd_spin_echo_time'] = -83.5e-9
    m.params['dd_use_delay_reps'] = False
    m.params['EOM_trigger_length'] = 100e-9
    m.params['PLU_gate_duration'] = 100e-9
    m.params['Ex_SP_amplitude'] = 0
    m.update_definitions()

    pts = 11
    m.params['pts'] = pts
    m.params['repetitions'] = 2000
    m.params_lt3['wait_for_AWG_done'] = 1

    # sweep params
    #free evolutiona time is half the total evolution time!!! from centre to centre of pulses
    m.params_lt3['free_evolution_times'] = 52.4e-6 + np.linspace(
        -5e-6, 5e-6, pts)  #m.params_lt3['first_C_revival'] #

    m.params_lt3['DD_pi_phases'] = [0]
    m.dd_sweep_free_ev_time_msmt()

    # for the autoanalysis
    m.params_lt3['sweep_name'] = 'total free evolution time (us)'
    m.params_lt3['sweep_pts'] = 2 * m.params_lt3['free_evolution_times'] / 1e-6

    funcs.finish(m, upload=UPLOAD, debug=False)