Exemplo n.º 1
0
def speed_test(host, n_pts=1000):
    time_array = np.zeros(n_pts)
    client = load_instrument(host, instrument='oscillo')
    driver = Oscillo(client)
    driver.set_averaging(False)

    t0 = time.time()
    t_prev = t0

    for i in range(n_pts):
        if cmd == 'get_adc':
            driver.get_adc()
        elif cmd == 'get_num_average':
            driver.get_num_average()
        t = time.time()
        time_array[i] = t - t_prev
        print host, i, time_array[i]
        t_prev = t

    print np.median(time_array)

    plt.plot(time_array)
    driver.close()
def speed_test(host, n_pts=1000):
    time_array = np.zeros(n_pts)
    client = load_instrument(host, instrument='oscillo')
    driver = Oscillo(client)
    driver.set_averaging(False)

    t0 = time.time()
    t_prev = t0

    for i in range(n_pts):
        if cmd == 'get_adc':
            driver.get_adc()
        elif cmd == 'get_num_average':
            driver.get_num_average()
        t = time.time()
        time_array[i] = t - t_prev
        print host, i, time_array[i]
        t_prev = t
        
    print np.median(time_array)

    plt.plot(time_array)
    driver.close()
    time_total = np.zeros((n_pts, n_methods))    
    for j, method in enumerate(methods):
        t0 = time.time()
        t_prev = t0
        print j
        for i in range(n_pts):
            driver.get_adc(method)
            print i
            t = time.time()
            time_total[i,j] = t - t_prev
            t_prev = t
    return time_total


host = os.getenv('HOST','192.168.1.100')
client = load_instrument(host, instrument='oscillo')
driver = SpeedTest(client)


methods = ('read_zeros',
           'read_rambuf',
           'read_rambuf_memcpy',
           'read_rambuf_mycopy',
           'read_mmapbuf_nocopy',
           'read_rambuf_mmap_memcpy')

lineObjects = plt.plot(read(driver, methods, n_pts=1000))
plt.legend(iter(lineObjects), methods)
plt.ylabel('Time (s)')
plt.show()
Exemplo n.º 4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import initExample
import os
import time
import numpy as np
import matplotlib.pyplot as plt

from utilities import load_instrument
from ldk.drivers import Oscillo

host = os.getenv('HOST','192.168.1.100')
client = load_instrument(host, instrument='oscillo')
driver = Oscillo(client)

# Enable laser
driver.start_laser()

# Set laser current
current = 30  # mA
driver.set_laser_current(current)

# Modulation on DAC
amp_mod = 0.2
freq_mod = 1e6
driver.dac[1, :] = amp_mod*np.sin(2 * np.pi * freq_mod * driver.sampling.t)
driver.set_dac()

# Signal on ADC
driver.get_adc()
Exemplo n.º 5
0
# -*- coding: utf-8 -*-

import initExample
import os
import time
import numpy as np
import matplotlib
matplotlib.use('GTKAgg')
from matplotlib import pyplot as plt

from utilities import load_instrument
from ldk.drivers import Spectrum

# Load the spectrum instrument
host = os.getenv('HOST','192.168.1.100')
client = load_instrument(host, instrument='spectrum')
driver = Spectrum(client)

# Enable laser
driver.start_laser()

# Set laser current
current = 30  # mA
driver.set_laser_current(current)

# Plot parameters
fig = plt.figure()
ax = fig.add_subplot(111)
x = 1e-6 * np.fft.fftshift(driver.sampling.f_fft)
y = 10*np.log10(np.fft.fftshift(driver.spectrum))
li, = ax.plot(x, y)