def EOM_test(SpecAn):
    ##     SpecAn.write('LG 10')
    ##     pb.Sequence([(['ch2'], 1*ms)], loop=False)
    ##     sleep(3)
    ##     SpecAn.write('MKPK HI')
    ##     num = SpecAn.query('MKA?')
    ##     print num

    pb.Sequence([(['ch2', 'ch5'], 1 * ms)], loop=False)
    sleep(3)
    SpecAn.write("LG 2")
    h.run_offset(SpecAn, sweep=2)
    SpecAn.write('ST 2')
    filepath = h.create_file(SpecAn,
                             filename='EOM bias test',
                             compensated='Y',
                             n=1,
                             burn_time=0)
    pb.Sequence([(['ch1'], 4 * s)] + [(['ch2', 'ch4', 'ch5'], 3000 * ms)] +
                [(['ch2', 'ch5'], 1 * s)],
                loop=False)
    filepath = h.record_trace(SpecAn,
                              filepath,
                              compensated='Y',
                              n=1,
                              burn_time=0)
Exemplo n.º 2
0
def comb_background_abs(burn_f=1.1 * GHz, shots=1000, delay=0):
    ''' Idea: Spin pump crystal 
              Burn a narrow hole where the AFC will be (100 kHz)
              Send broad pulse through quickly after (>1ms after, MHz broad)
    What comes out should give a measurement of the background where the AFC will be
    before spin jumping.
    
    Turn WF on
    Set up PS for RAPID BLOCK mode'''

    mc.setWvfm(0)
    sleep(0.1)
    pb.Sequence([(['ch1', 'ch5'], 50 * ms), (['ch5'], 1 * ms)], loop=False)
    sleep(0.1)

    AWG_trig_out()
    ##     wf = wf_24_cw(burn_f + 19e6 + 460.99e6, -10)
    mc.setWvfm(1)
    sleep(0.1)

    arr = [(['ch5', 'ch6'], 10 * s), (['ch5'], 20 * ms)
           ]  #10s to spin pol. crystal, 20ms to let the mems switch switch.
    pb.Sequence(arr, loop=False)
    time.sleep(10.1)

    pb.ProbBurnLoop(shots=1000)
    time.sleep(shots * 7e-4)  #replace this is Wvfm time length

    mc.setWvfm(2)
    pb.ProbBurnLoop(shots=1000)
    time.sleep(shots * 5e-4)  #replace this is Wvfm time length
Exemplo n.º 3
0
def temp_func():

    for i in range(10):
        filepath = hb.create_file(SpecAn,
                                  compensated='Y',
                                  n=1,
                                  burn_time=0,
                                  filename=' 2nd background ' + str(i))
        sleep(100 * ms)
        pb.Sequence(
            [
                (['ch5'], 0.5 * s),
                (['ch5', 'ch6'], 20 * us),
                (['ch5'], 5 * ms),
                (['ch2', 'ch4', 'ch5'
                  ], 50 * ms),  #RF Switch, Trigger SpecAn, EOM Bias on 
                (['ch2', 'ch5'], 100 * ms),
            ],
            loop=False)
        hb.record_trace(SpecAn,
                        filepath,
                        filename=' 2nd background ' + str(i),
                        compensated='Y',
                        sweep_again='Y',
                        n=1,
                        burn_time='')
Exemplo n.º 4
0
def hardburn():
    freq = 1.04 * GHz
    span = 20 * MHz
    title_str = '20MHz, 2500ms, 1.8GHz'
    HP8560E_SpecAn_Trigger('FREE', 'CONTS', SpecAn)
    spin_pump_seq()
    mc.setWvfm(2)
    burn_sequence_AWG_cust(burn=50 * ms,
                           burn_freq=freq,
                           record='True',
                           rec_span=span,
                           f_name=' ' + title_str,
                           sa='N')  # ' + str(i))

    filepath = hb.create_file(SpecAn,
                              compensated='Y',
                              n=1,
                              burn_time=0,
                              filename=' Spin pumped after ' + title_str)
    sleep(100 * ms)
    pb.Sequence(
        [
            (['ch5'], 0.5 * s),
            (['ch2', 'ch4', 'ch5'
              ], 50 * ms),  #RF Switch, Trigger SpecAn, EOM Bias on 
            (['ch2', 'ch5'], 100 * ms),
        ],
        loop=False)
    hb.record_trace(SpecAn,
                    filepath,
                    filename=' Spin pumped after ' + title_str,
                    compensated='Y',
                    sweep_again='N',
                    n=1,
                    burn_time='')
Exemplo n.º 5
0
def spin_polarise(SpecAn, SpecAn_Bool, start_freq, pumps = 10, direction = 'backwards'):
    ''' Controls stanford plugged into VCO to spin pump ensomble by scanning over
    delta m = +/-1. 
    MIN FREQ: 1900MHz'''
    sweep_time = 50*ms
    sweep_array = np.array([[start_freq, start_freq + 800*MHz, sweep_time]]) 
    #Best time scale is 100ms sweep time - Milos
    print 'Sweep range: ' + str(np.min(sweep_array)) +', '+ str(np.max(sweep_array)/1e6)
    [Stanford_FG, Stanford_Bool] = stan.Initialise_Stanford_FG()
    
    #Tell me the Stanfords settings
    Stanford_FG.write('AMPL?')
    print 'Amplitude set to ' + Stanford_FG.read()    
    Stanford_FG.write('OFFS?')
    print 'Offset set to ' + Stanford_FG.read() 
    
    if direction == 'backwards':
        [num_array, waveform_length] = stan.VCO_Sweep_backwards(sweep_array, Stanford_FG, Stanford_Bool, 'op amp 3.7', SpecAn, SpecAn_Bool)
    elif direction == 'forwards':
        [num_array, waveform_length] = stan.VCO_Sweep(sweep_array, Stanford_FG, Stanford_Bool, 'op amp 3.7', SpecAn, SpecAn_Bool)
    else:
        raise error('direction must be either backwards or forwards')
        
    stan.Upload_to_Stanford_FG(num_array,waveform_length, Stanford_FG)
    
    #Sets pulseblaster to run VCO via ch3
    time = pumps*sweep_time
    print 'Spin polarizing for: ' + str(time) + ' seconds'
    
    array = create_sequence(time)
    pb.Sequence(array,loop=False) 
Exemplo n.º 6
0
def test_pico():
    ''' Testing the picoscope runblock code. Plug CH7 into the picoscope'''

    shots = 5
    f_ext = 'TestRunIgnore'

    t_s = 10 * us
    r_l = 10 * ms
    ps, t_sample, res = pico.run_rapid_block(Vrange=5,
                                             n_captures=shots,
                                             t_sample=t_s,
                                             record_length=r_l)
    n_data = r_l / t_s

    for i in range(shots):
        storage_arr = [(['ch3', 'ch5'], 25 * us),
                       (['ch1', 'ch5', 'ch7'], 500 * us), (['ch5'], 1 * ms)]
        pb.Sequence(storage_arr, loop=False)

    data = pico.get_data_from_rapid_block(ps)
    t = np.arange(data.shape[1]) * t_s
    data_total = np.vstack([t, data])
    data_total = data_total.T

    #Save formatted data.
    file_name = time.strftime("C:\Users\Milos\Desktop\James\\" +
                              "%Y-%m-%d Pico " + f_ext + '.mat')

    sci.savemat(file_name, {'data': data_total})
    plt.plot(t, data[0, :])
    plt.show()
    ps.close()
Exemplo n.º 7
0
def spin_pump_seq(freq, pumps, record="False"):
    ''' Runs spin polarize sequence and allows for the ability to record the spectrum
        just after spin pumping.
    '''
    time = spin_polarise(SpecAn,
                         SpecAn_Bool,
                         freq,
                         pumps,
                         direction='forwards')
    sleep(time)  #Wait for spin polarize to take place.

    SpecAn.write('FA ' + str(0 * MHz))  #Start freq
    SpecAn.write('FB ' + str(2900 * MHz))  #Stop freq
    save_file = "C:\\Users\\Milos\Desktop\\Er_Experiment_Interface_Code\\amplitude_offset_full.csv"
    amplitude_offset = np.loadtxt(save_file, delimiter=",")

    #This if statement is a rewritten version of record_trace
    if record == 'True':
        filepath = create_file(SpecAn, compensated='N', n=1, burn_time=0)

        array = [([], 0.5 * s)] + [(['ch5'], 500 * ms),
                                   (['ch2', 'ch4', 'ch5'], 100 * ms)
                                   ] + [(['ch2', 'ch5'], 100 * ms)]
        pb.Sequence(array, loop=False)

        [x, y, f] = record_trace(SpecAn,
                                 filepath,
                                 filename='',
                                 compensated='Y',
                                 sweep_again='Y',
                                 n=1,
                                 burn_time=0)
Exemplo n.º 8
0
def reference_pulse(f_ext='', voltRange=0.2):
    ''' Spin polarize the crystal and send a pulse through at the freq where the AFC
    would be. Needs to know the number of teeth to know which bit of memory the pulse is stored at.'''

    mc.setWvfmKey('Pulse')
    AWG_trig_out(1)

    #Set picoscope up to collect data and wait for external trigger
    t_s = 4 * ns
    r_l = 20 * us
    t_sample, res = pico.run_rapid_block(ps,
                                         Vrange=voltRange,
                                         n_captures=1,
                                         t_sample=t_s,
                                         record_length=r_l)
    n_data = r_l / t_s

    print("Toggling MEMS switch high for 10 s")
    pb.Sequence(
        [
            (['ch5'], 0.5 * us),
            (['ch5', 'ch6'], 10),  #Spin polarise crystal
            (['ch5'], 0.5 * us, WAIT),
            (['ch5'], 49.5 * us),
            (['ch3', 'ch5'], 0.5 * us),
            (['ch1', 'ch5'], 50 * us),
            (['ch5'], 1 * ms)
        ],
        loop=False,
        bStart=False)
    sleep(11)

    #Old Sequence
    ##     pb.Sequence([(['ch5'], 0.5*us), (['ch5'], 0.5*us, WAIT), (['ch5'], 49.5*us),
    ##     (['ch3','ch5'], 0.5*us), (['ch1','ch5'],1*ms), (['ch5'], 1*ms)] ,loop=False,bStart=False)
    #CH3 to picoscope (start recording just before pulse arrives),
    #CH1 to open RF switch for AWG,
    #CH5 so carrier sideband beat on laser is strong
    sleep(0.1)
    #AWG_trig_out(0)

    #sleep(1)
    data = pico.get_data_from_rapid_block(ps)
    t = np.arange(data.shape[1]) * t_s
    data_total = np.vstack([t, data])
    data_total = data_total.T

    ##     for dat in data_total[0]:
    ##         if dat == "inf" or dat == "-inf":
    ##             raise RuntimeError, "Picoscope V range too small"

    #Save formatted data.
    file_name = time.strftime("C:\Users\Milos\Desktop\James\\" +
                              "%Y-%m-%d REFERNCE Pico " + f_ext + '.mat')

    sci.savemat(file_name, {
        'Vrange': voltRange,
        'sampleRate': t_s,
        'data': data_total
    })
Exemplo n.º 9
0
def spin_pump_seq(spintime=10 * s, SpecAnSweep='Y', rec='Y'):
    ''' For spin polarizing the crystal.
        Triggers pulseblaster CH6 on - off, changes the state of the mems switch 
        which lets the photonics laser to sweep over the dm = 1 & 2 for a given time, default 10s
        Then allows for the recording of the Spin pumped spectrum if rec 'Y'
    '''
    #Toggle the mems switch for n sec
    if rec == 'Y':
        HP8560E_SpecAn_Trigger('FREE', 'CONTS', SpecAn)
        SpecAn.write('CF ' + str(1.45 * GHz))
        SpecAn.write('SP ' + str(2.90 * GHz))

    pb.mems_switch_toggle(spintime, n=1, other_ch='', init_state=1)
    sleep(spintime)

    #Record full span spectrum, else: just toggle the mems switch again
    if rec == 'Y':
        filepath = hb.create_file(SpecAn,
                                  compensated='Y',
                                  n=1,
                                  burn_time=0,
                                  filename=' Spin pumped')
        sleep(100 * ms)
        pb.Sequence(
            [
                (['ch5'], 0.5 * s),
                (['ch5', 'ch6'], 20 * us),
                (['ch5'], 5 * ms),
                (['ch2', 'ch4', 'ch5'
                  ], 50 * ms),  #RF Switch, Trigger SpecAn, EOM Bias on 
                (['ch2', 'ch5'], 100 * ms),
            ],
            loop=False)
        hb.record_trace(SpecAn,
                        filepath,
                        filename=' Spin pumped',
                        compensated='Y',
                        sweep_again=SpecAnSweep,
                        n=1,
                        burn_time='')
    else:
        pb.Sequence([
            (['ch5', 'ch6'], 20 * us),
            (['ch5'], 5 * ms),
        ],
                    loop=False)
Exemplo n.º 10
0
def getTrace(SpecAn, t_space):
    pb.Sequence([(['ch2', 'ch4', 'ch5'], 100 * ms), (['ch5'], 10 * us)],
                loop=False)
    SpecAn.write('TRA?')
    time.sleep(t_space - 50 * ms)
    binary = SpecAn.read_raw()
    spec_data_temp = np.frombuffer(binary, '>u2')
    return spec_data_temp
Exemplo n.º 11
0
def save_offset_custom(SpecAn,
                       avg_num,
                       save_file,
                       freq,
                       span=40 * MHz,
                       res=30 * kHz,
                       sweep=50 * ms):
    SpecAn.write("CF " + str(freq))
    SpecAn.write("SP " + str(span))
    SpecAn.write("RB " + str(res))
    SpecAn.write("ST " + str(sweep))
    #Give time to let the SpecAn change span settings
    sleep(0.1)

    SpecAn.write("SRCPWR?")
    SpecAn_Power = SpecAn.read()
    print("Power is: " + str(SpecAn_Power))

    #Traces are made up of 601 points (x axis) with a value from 0 to 610
    #This can be converted into dB
    SpecAn.write('LG?')
    dB_div = float(SpecAn.read())
    entire_depth = 10 * dB_div  #how many dB in the entire display
    SpecAn.write('RL?')  #Get the reference level
    ref_level = float(SpecAn.read())

    lowest_point = ref_level - entire_depth
    #To convert Y data to dB -> y_data*entire_depth/610 + lowest_point

    offset_array = np.zeros((avg_num, 601), dtype=float)
    HP8560E_SpecAn_Trigger('EXT', 'CONTS', SpecAn)
    ##     pb.Sequence([(['ch2','ch5','ch4'], 1*ms)], loop=False)

    #Leave enough time for it sweep and store a new trace
    ##     sleep(0.4)
    ##     [SpecAn_track, SpecAn_Power] = HP8560E_SpecAn_RF(tracking_gen, RF_power, SpecAn)
    #now we collect the data trace
    for i in range(avg_num):

        pb.Sequence([(['ch2', 'ch5', 'ch4'], 1 * ms)], loop=False)
        sleep(sweep + 0.2)
        SpecAn.write("TRA?")
        binary_string = SpecAn.read_raw()
        hex_string = binascii.b2a_hex(binary_string)
        offset_data_temp = np.zeros(601)

        for j in range(601):

            offset_data_temp[j] = int('0x' + hex_string[j * 4:j * 4 + 4], 0)
        offset_array[i, :] = offset_data_temp[:]

        time.sleep(0.07)

    avg_offset_data = np.average(offset_array, 0)
    avg_offset_data = avg_offset_data * entire_depth / 610 + lowest_point  #Convert to dB
    np.savetxt(save_file, avg_offset_data, fmt='%.10e', delimiter=",")
Exemplo n.º 12
0
def spin_jump_record_repeat(burn_f, h_state, file_name, teeth=1, n=1):
    ''' Spin poliarises the crystal once. Then repeatedly spin jump's and records the anti-hole.'''
    HP8560E_SpecAn_Trigger('FREE', 'CONTS', SpecAn)
    spin_pump_seq(spintime=10 * s, SpecAnSweep='N', rec='N')
    rec_span = 20 * MHz

    ##     state_dict = {'3,2': 0,'1,2': 1,'-1,2': 2,'-3,2': 3,'-5,2': 4,'-7,2': 5}
    ##     num = state_dict[h_state]
    ##     bjt_ext = 5/num

    #Initial spin jump (longer Burn Jump Time)
    num_len = int(np.ceil(np.log10(n)))
    zero = '0'
    zeros = zero * num_len
    spin_jump(burn_f,
              state=h_state,
              rec='True',
              span=rec_span,
              teeth=teeth,
              f_ext=file_name + ' ' + zeros,
              bjt=50)  #*bjt_ext)
    for i in range(n - 1):
        #Each subsequent spin jump should need a much shorter Burn Jump Time
        spin_jump(burn_f,
                  state=h_state,
                  rec='False',
                  span=rec_span,
                  teeth=teeth,
                  f_ext=file_name + ' ' + str(i + 1).zfill(num_len),
                  bjt=50,
                  rec_offs=False)

    #Records the 2.9GHz span after all measurements
    filepath = hb.create_file(SpecAn,
                              compensated='Y',
                              n=1,
                              burn_time=0,
                              filename=' Spin pumped after spinjump ' +
                              h_state)
    sleep(100 * ms)
    pb.Sequence(
        [
            (['ch5'], 0.5 * s),
            (['ch2', 'ch4', 'ch5'
              ], 50 * ms),  #RF Switch, Trigger SpecAn, EOM Bias on 
            (['ch2', 'ch5'], 100 * ms),
        ],
        loop=False)
    hb.record_trace(SpecAn,
                    filepath,
                    filename=' Spin pumped after spinjump ' + h_state,
                    compensated='Y',
                    sweep_again='N',
                    n=1,
                    burn_time='')
Exemplo n.º 13
0
def makeNpulse_AFC(burnf,
                   AFCparameters,
                   recComb=False,
                   shots,
                   f_ext='',
                   pico_f_ext=''):
    '''
    Uses make_AFC to create the AFC comb and then set the AWG and Picoscope to store and retrieve pulses from the AFC
    '''
    make_AFC(burnf, AFCparameters, recComb=False, f_ext='')

    wf_24_cw(burn_f + 15e6 + 460.99e6, -26)  #input into the IQ modulator
    #Set AWG to output storage pulse
    mc.setWvfmKey('Pulse')
    AWG_trig_out(1)

    #Set picoscope to wait for ext trig
    t_s = 8 * ns
    t_r = 100 * us
    pico.setRapidBlock(ps,
                       ch=['A', 'B'],
                       Vrange=0.2,
                       nCaptures=shots,
                       t_sample=t_s,
                       t_record=t_r,
                       trig='External',
                       res='15')

    #AWG will trigger Pulse blaster
    #CH3 trigger picoscope.
    #CH5 suppress carrier EOM.
    #CH1 Open RF switch for AWG.
    #CH9 Bypass the AMP going to the EOM for low light level measurements
    pb.Sequence(
        [
            (['ch5', 'ch9'], 0.5 * us, LOOP, shots),  #loop shots times
            (['ch5', 'ch9'
              ], 0.5 * us, WAIT),  #50us of 'silence' then have the pulse
            (['ch5', 'ch9'], 49.5 * us),
            (['ch3', 'ch5', 'ch9'
              ], 0.5 * us),  #Record just before the pulse comes in 
            (['ch1', 'ch5', 'ch9'
              ], t_r + 10 * us),  #Leave enough time for the recording
            (['ch5', 'ch9'], 10 * us, END_LOOP),
            (['ch5'], 1 * us)
        ],
        loop=False,
        bStart=False)

    sleep(0.1)

    picoData = pico.getRapidBlock(ps)
    AWG_trig_out(0)

    return picoData
Exemplo n.º 14
0
def multi_record(SpecAn, d_time, n, filepath):
    '''Takes 'n' scans on the HP Spectrum Analyzer at ~d_time intervals.
       This is an augmented version of record_trace from holeburn_james.
       Also records the times for each data recording event.'''
    #Run the following first to set up the text file.
    #hb.create_file(SpecAn, filename = '', compensated = 'N', sweep_again = 'Y', n=1, burn_time = '')

    SpecAn.write('SP?')
    span = float(SpecAn.read())
    SpecAn.write('CF?')
    center = float(SpecAn.read())

    file = open(filepath, 'a')
    x = np.linspace(center - span / 2, center + span / 2, 601)
    spec_data_db = np.zeros((601, n))

    record_time = []
    for i in range(n):
        SpecAn.write('TS')
        #Waits for Spectrum Analyser to finish Data sweep
        SpecAn.wait_for_srq(timeout=30000)

        #Gets the trace from the SpecAn
        SpecAn.write('TRA?')
        binary = SpecAn.read_raw()
        spec_data_temp = np.frombuffer(
            binary, '>u2')  # Data format is big-endian unsigned integers

        record_time.append(datetime.now().strftime("%H:%M:%S.%f"))

        spec_data_db[:, i] = SIH.convert2db(SpecAn, spec_data_temp)

        if compensated == 'Y':
            spec_data_db[:, i] = compensate(spec_data_temp, span)

        SpecAn.write("CLEAR; RQS 4")
        pb.Sequence([(['ch2', 'ch5'], d_time)],
                    [(['ch2', 'ch5', 'ch4'], 1 * ms)],
                    loop=False)

    #Conjoins both x and spec_data_temp vectors and saves them to file
    data = np.vstack([x, spec_data_db]).T
    np.savetxt(file, data, fmt='%.10e')

    file.close()
    pylab.ion()

    if sweep_again == 'Y':
        HP8560E_SpecAn_Trigger("FREE", 'CONTS', SpecAn)

    return x, spec_data_db, filepath
Exemplo n.º 15
0
def SpinpumpSite2BurnSite1(f_name='Spinpump site2 burn site1', freq=195.162):
    fg = rigolfg.RigolFG()  #Open the Rigol FG
    ITLA = ITLA_Wrap.ITLA_Class(port="COM6",
                                baudrate=9600)  #Open the Photonics Laser

    #Probe laser and check it's happy
    ITLA.ProbeLaser()
    #Disable laser to change parameters
    ITLA.EnableLaser(False)

    #Set Laser to usual parameters for Spin Pumping
    ITLA.SetFrequency(194.9412)  #THz
    ITLA.SetPower(1600)  #dBm * 100
    fg.setOutputState(bOn=0)
    ITLA.EnableLaser(True)
    ITLA.EnableWhisperMode(True)
    fg.setOutputState(bOn=1)

    spin_pump_seq(spintime=10 * s, SpecAnSweep='Y', rec='Y')  #Spin pump site 2
    HP8560E_SpecAn_Trigger('EXT', 'SNGLS', SpecAn)
    fg.setOutputState(bOn=0)  #Turn off Rigol CH2 (sweeping photonics)
    print("Turning Rigol FG off (stop photonics laser sweeping).")

    #Turn off laser
    #Change photonics laser freq to 195.162 THz
    ITLA.EnableWhisperMode(False)
    ITLA.EnableLaser(False)
    ##     ITLA.SetFrequency(195.162) #THz site 1
    ##     ITLA.SetFrequency(194.9437) #THz magnetic sub group
    ITLA.SetFrequency(freq)  #THz site 2 main peak

    ITLA.SetPower(1600)  #dBm * 100
    ITLA.EnableLaser(True)
    ITLA.EnableWhisperMode(True)

    #Burn site 1 for 5 s
    pb.Sequence([(['ch6'], 5 * s), (['ch5'], 5 * ms)], loop=False)
    sleep(5)
    filepath = hb.create_file(
        SpecAn, n=1, burn_time=0,
        filename=f_name)  #Record spin pumping after site 1 burn
    pb.hole_burn(1)
    filepath = hb.record_trace(SpecAn,
                               filepath,
                               compensated='Y',
                               sweep_again='Y',
                               burn_time=1)

    fg.setOutputState(
        bOn=1)  #Turns Channel 2 back on so we can spin pump again
    print("Turning Rigol FG on.")
Exemplo n.º 16
0
def save_offset(avg_num, full_span='N'):

    #Allows for two offsets, one dedicated as a fully span off set and the other
    #for various spans/frequencies
    if full_span == 'N':
        save_file = "C:\\Users\\Milos\Desktop\\Er_Experiment_Interface_Code\\amplitude_offset.csv"
    elif full_span == 'Y':
        save_file = "C:\\Users\\Milos\Desktop\\Er_Experiment_Interface_Code\\amplitude_offset_full.csv"
    else:
        save_file = full_span

    [SpecAn, SpecAn_Bool] = Initialise_HP8560E_SpecAn()
    SpecAn.write("SRCPWR?")
    SpecAn_Power = SpecAn.read()
    print "Power is: " + str(SpecAn_Power)
    sweep = float(SpecAn.query('ST?'))

    #Traces are made up of 601 points (x axis) with a value from 0 to 610
    #This can be converted into dB
    SpecAn.write('LG?')
    dB_div = float(SpecAn.read())
    entire_depth = 10 * dB_div  #how many dB in the entire display
    SpecAn.write('RL?')  #Get the reference level
    ref_level = float(SpecAn.read())

    lowest_point = ref_level - entire_depth
    #To convert Y data to dB -> y_data*entire_depth/610 + lowest_point

    offset_array = np.zeros((avg_num, 601), dtype=float)
    HP8560E_SpecAn_Trigger('EXT', 'CONTS', SpecAn)
    ##     [SpecAn_track, SpecAn_Power] = HP8560E_SpecAn_RF(tracking_gen, RF_power, SpecAn)
    #now we collect the data trace
    for i in range(avg_num):

        pb.Sequence([(['ch2', 'ch5', 'ch4'], 1 * ms)], loop=False)
        sleep(sweep + 0.05)
        SpecAn.write("TRA?")
        binary_string = SpecAn.read_raw()
        hex_string = binascii.b2a_hex(binary_string)
        offset_data_temp = np.zeros(601)

        for j in range(601):

            offset_data_temp[j] = int('0x' + hex_string[j * 4:j * 4 + 4], 0)
        offset_array[i, :] = offset_data_temp[:]

        time.sleep(0.07)
    avg_offset_data = np.average(offset_array, 0)
    avg_offset_data = avg_offset_data * entire_depth / 610 + lowest_point  #Convert to dB
    np.savetxt(save_file, avg_offset_data, fmt='%.10e', delimiter=",")
Exemplo n.º 17
0
def burn_sequence_AWG_cust(burn,
                           burn_freq,
                           record='True',
                           rec_freq='',
                           rec_span=10 * MHz,
                           f_name='',
                           nu=2,
                           sa='Y',
                           rec_offs=True,
                           opt_bac='offs1.txt'):
    ''' Same as burn_sequence_AWG, but uses save custom offset rather than hb.run_offset '''

    filepath = ''
    if rec_freq == '':
        rec_freq = burn_freq

    if record == 'True':
        filepath = hb.create_file(SpecAn, n=1, burn_time=burn, filename=f_name)
        if rec_offs:
            save_offset_custom(SpecAn,
                               5,
                               'offs1.txt',
                               freq=rec_freq,
                               span=rec_span,
                               res=30 * kHz,
                               sweep=50 * ms)
        else:
            SpecAn.write("CF " + str(rec_freq))
            SpecAn.write("SP " + str(rec_span))

    arr1 = [([], 0.5 * s), (['ch1'], burn)] + [
        (['ch5'], 100 * us), (['ch2', 'ch4', 'ch5'], 100 * ms)
    ] + [(['ch2', 'ch5'], 100 * ms)]
    pb.Sequence(arr1, loop=False)
    ##     pb.hole_burn(burn)

    if record == 'True':
        filepath = hb.record_trace(SpecAn,
                                   filepath,
                                   compensated='Y',
                                   sweep_again=sa,
                                   burn_time=burn,
                                   opt_bac=opt_bac)
    sleep(0.5 * s)

    hb.full_sweep(SpecAn)
Exemplo n.º 18
0
def record_dm_1(freq, f_ext='', tn=3):
    ''' Set up to record the anti-holes made by spin jumping by looking at three places
    on the Delta m = 1 '''
    if freq > 1210 * MHz:
        print(
            'WARNING: Freq set too high, might not be able to see the |5/2> on the Delta m = 1'
        )

    rec_freq = np.array([1557 * MHz, 1472 * MHz, 1529 * MHz]) + freq
    span = np.array([270, 20, 20]) * MHz
    f_name = [
        ' ' + f_ext + ' dm1', ' ' + f_ext + ' dm 12', ' ' + f_ext + ' dm13'
    ]
    opt = [
        "C:\\Users\\Milos\Desktop\\Er_Experiment_Interface_Code\\1.txt",
        "C:\\Users\\Milos\Desktop\\Er_Experiment_Interface_Code\\2.txt",
        "C:\\Users\\Milos\Desktop\\Er_Experiment_Interface_Code\\3.txt"
    ]

    for i in range(1):
        SpecAn.write('SP ' + str(span[i]))
        SpecAn.write('CF ' + str(rec_freq[i]))
        sleep(0.01)
        filepath = hb.create_file(SpecAn,
                                  n=1,
                                  burn_time=1 * ms,
                                  filename=f_name[i])
        pb.Sequence([([], 0.5 * s)] + [(['ch5'], 1000 * ms),
                                       (['ch2', 'ch4', 'ch5'], 100 * ms)] +
                    [(['ch2', 'ch5'], 100 * ms)],
                    loop=False)
        filepath = hb.record_trace(SpecAn,
                                   filepath,
                                   compensated='Y',
                                   sweep_again='N',
                                   burn_time=1 * ms,
                                   opt_bac=opt[i])
        sleep(0.05)
Exemplo n.º 19
0
def run_offset(SpecAn,
               freq=1.45 * GHz,
               span=2.9 * GHz,
               res=30 * kHz,
               sweep=50 * ms,
               full_span='Y',
               show_window='N',
               n=20):
    ''' Sets desired SpecAn settings and runs Milos's background and free run
        programs.'''
    SpecAn.write("CF " + str(freq))
    SpecAn.write("SP " + str(span))
    SpecAn.write("RB " + str(res))
    SpecAn.write("ST " + str(sweep))

    #This sequence ensures that atleast one sweep is taken once the Span and Center
    #Frequecies are changed, before the offsets are saved
    pb.Sequence([(['ch2', 'ch4', 'ch5'], 50 * ms), ([], 0.4 * s)], loop=False)
    sleep(0.5)
    SIH.save_offset(n, full_span)

    if show_window == 'Y':
        SIH.free_run_plot_window('Y', freq, span, full_span)
Exemplo n.º 20
0
def spin_jump_time_measurement_faster(times, burn_f, state='5,2'):
    ''' Spin polarizes and spin jumps the ensemble to a given [state].
        Then it records the anti-hole after a certain amount of time given by [times]
        This one is faster because it spin polarizes every n recordings rather than
        every recording.'''
    freq = burn_f
    count = 4
    sp = 20 * MHz
    ##     sp = 2.9*GHz

    state_dict = {
        '5,2': 0,
        '3,2': 1,
        '1,2': 2,
        '-1,2': 3,
        '-3,2': 4,
        '-5,2': 5,
        '-7,2': 6
    }
    if state not in state_dict:  #Check if variable state is valid
        print('Error, variable state must be in [5,2, 3,2... -5,2]')

    p = state_dict[state]
    e_gap = np.array([
        -107.60, -218.09, -323.2, -415.50, -488.20, -535.89, 1453.5
    ]) * MHz  #Gaps in hyperfine energy levels

    pl.ioff()
    for i in range(len(times)):
        count += 1

        if count == 5:
            count = 0

            HP8560E_SpecAn_Trigger("FREE", 'CONTS', SpecAn)

            SpecAn.write('CF ' + str(1.45 * GHz))
            SpecAn.write('SP ' + str(2.9 * GHz))
            spin_pump_seq(spintime=10 * s, SpecAnSweep='Y', rec='N')

            #Record background measurements
            HP8560E_SpecAn_Trigger("FREE", 'CONTS', SpecAn)
            pb.Sequence([(['ch2', 'ch5'], 1 * ms)], loop=False)
            hb.run_offset(SpecAn,
                          freq=freq + e_gap[p],
                          span=sp,
                          res=30 * kHz,
                          sweep=50 * ms,
                          full_span='N',
                          show_window='N',
                          n=5)
            ##             hb.run_offset(SpecAn, freq = 1.45*GHz, span = 2.9*GHz, res = 30*kHz, sweep = 50*ms, full_span = 'N', show_window = 'N',n = 5)

            #Stop SpecAn sweeping over anti hole, burn final anti-hole and then suppresses carrier
            HP8560E_SpecAn_Trigger('EXT', 'SNGLS', SpecAn)

            #Spin Jump
            spin_jump(freq, state, rec='False', span=sp, teeth=1)

            #Take spectra at time '0'
            SpecAn.write("CF " + str(freq + e_gap[p]))
            SpecAn.write("SP " + str(sp))
            ##             SpecAn.write("CF " + str(1.45*GHz))
            ##             SpecAn.write("SP " + str(2.9*GHz))
            f_name = ' ' + state + ' zero ' + str(times[i]) + 's'
            filepath = hb.create_file(SpecAn, compensated='Y', filename=f_name)
            pb.Sequence(
                [
                    (['ch5'], 1 * s),
                    (['ch2', 'ch4', 'ch5'
                      ], 70 * ms),  #RF Switch, Trigger SpecAn, EOM Bias on 
                    ([], 100 * ms),  #turn off ch2,ch5, suppress carrier/RF
                ],
                loop=False)
            hb.record_trace(SpecAn,
                            filepath,
                            compensated='Y',
                            sweep_again='N',
                            n=1,
                            burn_time='')
            HP8560E_SpecAn_Trigger('EXT', 'SNGLS', SpecAn)

            print 'Waiting ' + str(times[i]) + ' seconds.'
            sleep(times[i])  #wait

        else:
            t = times[i] - times[i - 1]
            print 'Waiting ' + str(t) + ' seconds.'
            sleep(t)

        #Record
        f_name = ' ' + state + ' ' + str(times[i]) + 's'
        filepath = hb.create_file(SpecAn, compensated='Y', filename=f_name)
        pb.Sequence(
            [
                (['ch5'], 1 * s),
                (['ch2', 'ch4', 'ch5'
                  ], 70 * ms),  #RF Switch, Trigger SpecAn, EOM Bias on 
                ([], 100 * ms),
            ],
            loop=False)
        fName = hb.record_trace(SpecAn,
                                filepath,
                                compensated='Y',
                                sweep_again='N',
                                n=1,
                                burn_time='')
        dat = np.loadtxt(fName, skiprows=10)
        pl.plot(*dat.T)
        #pl.draw()
        plt.pause(0.1)

    pl.show()
    sleep(1)

    HP8560E_SpecAn_Trigger("FREE", 'CONTS', SpecAn)
Exemplo n.º 21
0
## rec_f = 1*GHz

AFC.spin_pump_seq(spintime=10 * s, SpecAnSweep='Y', rec='Y')
## SIH.free_run_plot_window('Y', full_span = 'Y')

## burn_sequence_AWG(burn = burn_time, burn_freq, record = 'True', rec_freq = rec_f, rec_span = 50*MHz, f_name = 'ASE burn', nu = 2, sa = 'Y'):

## array = [([], 0.5*s),(['ch1'], burn_time)] + [(['ch5'], 1000*ms), (['ch2','ch4','ch5'], 100*ms)] + [(['ch2','ch5'], 100*ms)]
## pb.Sequence(array,loop=False)

if __name__ == "__main__":

    # ============== WITHOUT SPEC AN =====================================
    #pi = range(20)
    pi = 22 * us
    delay = 150 * us
    #array = [(['ch1','ch3'], pi/2)] + [([''], delay)] + [(['ch1'], pi)]
    #for i in range()
    from __builtin__ import sum
    arr = [(['ch1', 'ch3'], pi / 2), ([], delay), (['ch1'], pi), ([], 10 * ms)]

    pb.Sequence(arr, loop=True)
    ## AFC.spin_pump_seq(spintime = 10*s,SpecAnSweep = 'N',rec ='N') #Run first

    ## for i in range(1):
    ##     AFC.spin_pump_seq(spintime = 0.5*s,SpecAnSweep = 'N',rec ='N')
    ##     burn_time = 1*us

    ##     array = [(['ch1','ch3'], burn_time) + ([], 100*ms)]
    ##     pb.Sequence(array,loop=False)
Exemplo n.º 22
0
def spin_jump_time_measurement(freq, times, state='5,2'):
    ''' OLDER SLOWER VERSION, USE ONLY IF NEW ONE BROKE
        Preforms spin jump to a certain hyperfine and then records the anti-hole a give time
        after the hole was originally burnt '''
    HP8560E_SpecAn_Trigger('EXT', 'SNGLS', SpecAn)
    sp = 10 * MHz

    state_dict = {
        '5,2': 0,
        '3,2': 1,
        '1,2': 2,
        '-1,2': 3,
        '-3,2': 4,
        '-5,2': 5
    }
    if state not in state_dict:  #Check if variable state is valid
        print('Error, variable state must be in [5/2, 3/2... -5/2]')

    p = state_dict[state]
    e_gap = np.array([-107.64, -217.98, -323.19, -415.47, -488.22, -536.46
                      ]) * MHz  #Gaps in hyperfine energy levels

    #Record background measurements
    HP8560E_SpecAn_Trigger("FREE", 'CONTS', SpecAn)
    pb.Sequence([(['ch2', 'ch5'], 1 * ms)], loop=False)
    hb.run_offset(SpecAn,
                  freq=freq + e_gap[p],
                  span=sp,
                  res=30 * kHz,
                  sweep=50 * ms,
                  full_span='N',
                  show_window='N',
                  n=5)

    #Spin Jump
    HP8560E_SpecAn_Trigger('EXT', 'SNGLS', SpecAn)
    spin_jump(freq, state, rec='False', span=sp)

    #Stop SpecAn sweeping over anti hole, burn final anti-hole and then suppresses carrier
    #Take spectra at time '0'
    HP8560E_SpecAn_Trigger("FREE", 'CONTS', SpecAn)  #Record
    SpecAn.write("CF " + str(freq + e_gap[p]))
    SpecAn.write("SP " + str(sp))
    filepath = hb.create_file(SpecAn,
                              compensated='Y',
                              n=1,
                              burn_time=0,
                              filename=' ' + state + ' zero ' + str(time[i]) +
                              's')
    pb.Sequence(
        [
            (['ch5'], 1 * s),
            (['ch2', 'ch4', 'ch5'
              ], 70 * ms),  #RF Switch, Trigger SpecAn, EOM Bias on 
            ([], 100 * ms),  #turn off ch2,ch5, suppress carrier/RF
        ],
        loop=False)
    hb.record_trace(SpecAn,
                    filepath,
                    compensated='Y',
                    sweep_again='Y',
                    n=1,
                    burn_time='')
    HP8560E_SpecAn_Trigger('EXT', 'SNGLS', SpecAn)

    sleep(times[i])  #wait
    HP8560E_SpecAn_Trigger("FREE", 'CONTS', SpecAn)  #Record
    filepath = hb.create_file(SpecAn,
                              compensated='Y',
                              n=1,
                              burn_time=0,
                              filename=' ' + state + ' ' + str(time[i]) + 's')
    pb.Sequence(
        [
            (['ch5'], 1 * s),
            (['ch2', 'ch4', 'ch5'
              ], 70 * ms),  #RF Switch, Trigger SpecAn, EOM Bias on 
            (['ch2', 'ch5'], 100 * ms),
        ],
        loop=False)
    hb.record_trace(SpecAn,
                    filepath,
                    compensated='Y',
                    sweep_again='Y',
                    n=1,
                    burn_time='')
    HP8560E_SpecAn_Trigger('EXT', 'SNGLS', SpecAn)
Exemplo n.º 23
0
def gatePump(gateFreq=30):
    t = 1. / (2 * gateFreq)
    pb.Sequence([(['ch6', 'ch7'], t), ([], t)], loop=True)
Exemplo n.º 24
0
def laser_stability_measure(freq,
                            t_space=100 * ms,
                            t=4 * s,
                            f_name='',
                            show='Y'):
    [SpecAn, SpecAn_Bool] = Initialise_HP8560E_SpecAn()
    SpecAn.write('ST 0.05')  #Sweep Time 50ms
    n = int(t / t_space)  #Amount of times scans needed
    ##     mc.setup(centerFreqL = freq, widthL = 10e4, sweepTimeL = 1e-4)

    if t_space < 50 * ms:
        raise RuntimeError, "SpecAn's fastest sweep time & reset is 100ms, t_space cannot be faster."
    file = make_file(f_name)

    span = 5 * MHz
    freq_sit = freq
    SpecAn.write('CF ' + str(freq_sit))
    SpecAn.write('SP ' + str(span))
    time.sleep(0.5)

    #Take Background measurement
    SIH.save_offset(10, 'n')

    #Burn a hole
    pb.Sequence([(['ch1'], 50 * ms), (['ch2', 'ch4', 'ch5'], 1 * ms)],
                loop=False)
    HP8560E_SpecAn_Trigger('EXT', 'CONTS', SpecAn)

    print "Recording for {}s at {} Hz".format(t, 1 / t_space)

    #Get raw data
    l = []
    for k in range(n):
        l.append([time.time(), getTrace(SpecAn, t_space)])

    HP8560E_SpecAn_Trigger('FREE', 'CONTS', SpecAn)

    t_init = l[0][0]
    t_arr = []
    center = []
    freq_arr = np.linspace(freq_sit - span / 2, freq_sit + span / 2, 601)

    for i in range(n):
        #Convert to dB and background subtract post data collection
        dat = SIH.convert2db(SpecAn, l[i][1])
        dat = hb.compensate(dat, span)
        #Make time and freq peak array
        t_arr.append(l[i][0] - t_init)
        index = np.argmax(
            dat[50:])  #The carrier also makes a hole, this should ignore it
        center.append(freq_arr[index])

    data = np.vstack([t_arr, center]).T
    np.savetxt(file, data, fmt='%.10e')

    ##
    pb.Sequence([(['ch2', 'ch5', 'ch4'], 1 * ms)], loop=False)
    #Plot
    if show == 'Y':
        plt.plot(t_arr, center)
        plt.show()

    return l, t_arr, center, data
Exemplo n.º 25
0
def SpecAnUnfreeze():
    pb.Sequence([(['ch4'], 2.5 * ms), (['ch2', 'ch5'], 2.5 * ms)], loop=False)
    HP8560E_SpecAn_Trigger('FREE', 'CONTS', SpecAn)
Exemplo n.º 26
0
def burn_scan_image_VCO(sweep_array, direction):

    global Agilent_OSA
    global Agilent_OSA_bool
    global SpecAn
    global SpecAn_Bool
    global Stanford_Bool
    global Stanford_FG

    #initialise the equiptment
    #Arduino = Initialise_Arduino(arduino_comport)
    #[Burleigh_WM, Burleigh_WM_bool] = Initialise_Burleigh_WM()
    [Agilent_OSA, Agilent_OSA_bool] = Initialise_OSA()
    [SpecAn, SpecAn_Bool] = Initialise_HP8560E_SpecAn()
    #[Stanford_FG, Stanford_Bool] = Initialise_Stanford_FG()

    #get the laser wavelength
    #Burleigh_WM.write("FETC:SCAL:WAV?")
    #laser_wavelength = np.float(Burleigh_WM.read())
    laser_wavelength = OSA_measure_wavelength(Agilent_OSA)
    #generate and upload the burn sweep to the Stanford and VCO
    #[num_array, waveform_length] = VCO_Sweep_backwards(sweep_array, Stanford_FG, Stanford_Bool)
    #Upload_to_Stanford_FG(num_array,waveform_length, Stanford_FG)

    #Arduino.write('0')
    #print Arduino.read()
    #wait some time for the arduino to start the pulse program before setting trigger on SpecAn
    #time.sleep(1)

    #upload pulse sequence to Pulse Blaster (Burn, wait, Trigger SpecAn)

    pb.Sequence([(['ch1'], 3 * s), ([], 100 * ms),
                 (['ch1', 'ch2', 'ch3'], 50 * ms), (['ch5'], 1 * ms)],
                loop=False)
    #sends necessary pre-data collection settings to the Spectrum Analyser

    [SpecAn_BW, SpecAn_Sweeptime
     ] = HP8560E_SpecAn_Resbandwidth_Sweeptime(10 * kHz, sweeptime, SpecAn)
    [SpecAn_track, SpecAn_Power] = HP8560E_SpecAn_RF(tracking_gen, RF_power,
                                                     SpecAn)
    [SpecAn_Centre,
     SpecAn_Span] = HP8560E_SpecAn_Centre_Span(centre, span, SpecAn)

    HP8560E_SpecAn_Trigger('EXT', 'SNGLS', SpecAn)
    #sets up registers to return interupt when sweep is complete
    SpecAn.write("CLEAR; RQS 4")
    #triggers spectrum analyser for data reading. it will no longer process input
    #untill the sweep has been triggered and completed
    SpecAn.write('TS')

    #Waits for Spectrum Analyser to finish Data sweep
    SpecAn.wait_for_srq(timeout=30000)

    #generate the array to compensate for the RF and Detector response
    amplitude_offset = np.loadtxt(
        "C:\\Users\\Milos\Desktop\\Er_Experiment_Interface_Code\\amplitude_offset.csv",
        delimiter=",")

    #collect trace data off spectrum analyser
    SpecAn.write("TRA?")

    binary_string = SpecAn.read_raw()
    hex_string = binascii.b2a_hex(binary_string)
    y_axis_data = np.zeros(601)

    for i in range(601):

        y_axis_data[i] = int('0x' + hex_string[i * 4:i * 4 + 4], 0)

    #divide by offset to compensate and generate an x_axis array
    y_axis_data = np.subtract(y_axis_data, amplitude_offset)
    x_axis_data = np.arange(centre - span / 2, centre + span / 2, span / 601)
    #speed of light
    c = 299792453

    #generate absolute wavelength and frequency information based on direction of scan
    if direction == 'pos':
        wavelength_values = x_axis_data * ((laser_wavelength**2) /
                                           (c * 10**9)) + laser_wavelength

        frequency_values = -x_axis_data + (c * 10**9) / laser_wavelength
    else:
        wavelength_values = -x_axis_data * ((laser_wavelength**2) /
                                            (c * 10**9)) + laser_wavelength
        frequency_values = x_axis_data + (c * 10**9) / laser_wavelength

    filename = "blank"

    save_data(filename, folder_name, laser_wavelength, y_axis_data,
              wavelength_values, frequency_values)

    #turns off the RF and returns the spectrum analyser back to normal state.
    HP8560E_SpecAn_Trigger('FREE', 'CONTS', SpecAn)
    #[SpecAn_track, SpecAn_Power] = HP8560E_SpecAn_RF('OFF', RF_power, SpecAn)

    display_start = 1
    display_end = 601
    data_plot_window(x_axis_data, y_axis_data, display_start, display_end)
Exemplo n.º 27
0
def view():
    ##     pb.Sequence([(['ch2','ch5'], 1*ms)], loop=False)
    pb.Sequence([(['ch2'], 1 * ms)], loop=False)
    SpecAn.write('LG 10')
    SIH.free_run_plot_window('N', full_span='Y')
Exemplo n.º 28
0
def make_AFC(n, bjt, burn_f, hyperfine, f_ext='', record="False", shots=1):
    '''
    Runs functions to make AFC and store / read out pulse
    n = number of teeth in comb
    bjt = burn jump time, time spent burning at each hyperfine (usually 500ms)
    hyperfine = hyperfine level to spin to (-7,2 for AFC)
    f_ext = end of each file name for data recording
    '''

    #Prepare instruments pre-storage.
    #Write to the wf the freq and power needed,
    wf_24_cw(burn_f + 10e6 + 460.99e6, -10)  #Freq offset from the pulses freq.

    #Spin pol crystal and record a refence pulse (through the non-existant AFC)
    spin_pump_seq(spintime=10 * s, SpecAnSweep='N', rec='Y')
    ##     reference_pulse(f_ext)

    ##     if record == "True":
    ##         save_offset_custom(SpecAn, 5, "1.txt",freq = burn_f + 1443*MHz, span = 40*MHz, res = 30*kHz, sweep = 50*ms)
    ##
    ##     #Make the AFC and record AFC at dm = 1 and 0. Also record initial comb holes
    ##     spin_jump(burn_f,state = hyperfine,rec = record, span = 20*MHz, teeth = n)

    ##     if record == "True":
    ##         record_dm_1(burn_f, hyperfine, tn=n)

    ##     save_offset_custom(SpecAn, 5, "1.txt",freq = burn_f + 1443*MHz, span = 40*MHz)
    ##     spin_jump(burn_f,state = hyperfine ,rec = 'True', span = 20*MHz, teeth = teeth, f_ext = file_suff, bjt = 500)
    ##     record_dm_1(burn_f, hyperfine + ' ' + file_suff, tn = teeth)

    #Set AWG to output storage pulse
    mc.setWvfmKey('Pulse')
    AWG_trig_out(1)

    #Set picoscope up to collect data and wait for external trigger
    t_s = 4 * ns
    r_l = 50 * us
    t_sample, res = pico.run_rapid_block(ps,
                                         Vrange=0.5,
                                         n_captures=shots,
                                         t_sample=t_s,
                                         record_length=r_l)
    n_data = r_l / t_s
    sleep(0.1)

    #CH3 trigger picoscope.
    #CH5 suppress carrier EOM.
    #CH1 Open RF switch for AWG.
    for i in range(shots):
        #1ms allows for a time gap between each shot
        pb.Sequence([(['ch5'], 0.5 * us), (['ch5'], 0.5 * us, WAIT),
                     (['ch5'], 49.5 * us), (['ch3', 'ch5'], 0.5 * us),
                     (['ch1', 'ch5'], 50 * us), (['ch5'], 1 * ms)],
                    loop=False,
                    bStart=False)

    sleep(0.1)

    #Get data from picoscope
    data = pico.get_data_from_rapid_block(ps)
    t = np.arange(data.shape[1]) * t_s
    data_total = np.vstack([t, data])
    data_total = data_total.T

    AWG_trig_out(0)
    #Save formatted data.
    file_name = time.strftime("C:\Users\Milos\Desktop\James\\" +
                              "%Y-%m-%d Pico " + f_ext + '.mat')

    sci.savemat(file_name, {'data': data_total})
    plt.plot(t, data[0, :])
    plt.show()
Exemplo n.º 29
0
		t = np.arange(data.size)*t_sample
		plt.plot(t , data)
		plt.show()
	else:
		#t = np.linspace(0,(len(data[:,1])-1)*t_sample,len(data[:,1])-1)
		t = np.arange(data.size)*t_sample
		#plt.imshow(data)
		#pdb.set_trace()
		#plt.plot(t,data[0,:])
		plt.show()
	


if __name__ == "__main__":
	import pulse_blaster as pb
        import scipy.io as sio
	try: 
                ps = open_pico()
		data,t_sample = run_rapid_block(ps, Vrange = 1, n_captures = 2, t_sample = 1e-8, record_length = 10e-6, chB=[False,False])
		pb.Sequence([([],1e-3),(['ch3'],1e-6),([],1e-3)],loop = False)
		data = get_data_from_rapid_block(ps)
# =============================================================================
# 		pico_plot(data,t_sample)
# =============================================================================
                filenameMat = "C:\Users\Milos\Desktop\James\\test2ch.mat"
                sio.savemat(filenameMat,{'DataPico':data})

	finally:
		ps.close()

Exemplo n.º 30
0
def SpecAnUnfreeze():
    ''' Triggers the Spectrum Analyser and sets it to continuous mode.'''
    pb.Sequence([(['ch4'], 2.5 * ms), (['ch2', 'ch5'], 2.5 * ms)], loop=False)
    HP8560E_SpecAn_Trigger('FREE', 'CONTS', SpecAn)