Example #1
0
    def generate_sequence(self, config):
         """Generate sequence by adding gates/pulses to waveforms"""

         frequency = config.get('Parameter #1')
         amplitude = config.get('Parameter #2')
         width = config.get('Parameter #3')
         plateau = config.get('Parameter #4')
         shapeID=config.get('Parameter #5') # (0) gaussian, (1) cosine
         waitTime=config.get('Parameter #10')
         self.add_gate_to_all(Gate.Xp)

         pulse12 = Pulse()
         pulse12.width = width
         pulse12.plateau = plateau
         pulse12.amplitude = amplitude
         pulse12.frequency = frequency
         if shapeID==0:
             pulse12.shape=PulseShape.GAUSSIAN
         if shapeID==1:
             pulse12.shape=PulseShape.COSINE
         pulse12.pulse_type=PulseType.XY
         pulse12.phase = 0
         gateP = CustomGate(pulse12)
         wait=Pulse()
         wait.shape=PulseShape.COSINE
         wait.width = 0
         wait.plateau = waitTime
         wait.amplitude = 0
         wait.frequency = 0
         gateWait=CustomGate(wait)
         self.add_gate_to_all(gateP)
         self.add_gate_to_all(gateWait)
         self.add_gate_to_all(gateP)
Example #2
0
    def __init__(self, n_qubit=5):
        self.n_qubit = n_qubit
        self.dt = 10E-9
        self.local_xy = True
        self.simultaneous_pulses = True

        # waveform parameter
        self.sample_rate = 1.2E9
        self.n_pts = 240E3
        self.first_delay = 100E-9
        self.trim_to_sequence = True
        self.align_to_end = False

        self.sequences = []
        self.qubits = [Qubit() for n in range(MAX_QUBIT)]

        # waveforms
        self._wave_xy = [
            np.zeros(0, dtype=np.complex) for n in range(MAX_QUBIT)
        ]
        self._wave_z = [np.zeros(0) for n in range(MAX_QUBIT)]
        self._wave_gate = [np.zeros(0) for n in range(MAX_QUBIT)]

        # waveform delays
        self.wave_xy_delays = np.zeros(MAX_QUBIT)
        self.wave_z_delays = np.zeros(MAX_QUBIT)

        # define pulses
        self.pulses_1qb_xy = [Pulse() for n in range(MAX_QUBIT)]
        self.pulses_1qb_z = [Pulse() for n in range(MAX_QUBIT)]
        self.pulses_2qb = [Pulse() for n in range(MAX_QUBIT - 1)]
        self.pulses_readout = [
            Pulse(pulse_type=PulseType.READOUT) for n in range(MAX_QUBIT)
        ]

        # cross-talk
        self.compensate_crosstalk = False
        self._crosstalk = Crosstalk()

        # predistortion
        self.perform_predistortion = False
        self._predistortions = [Predistortion(n) for n in range(MAX_QUBIT)]
        self._predistortions_z = [
            ExponentialPredistortion(n) for n in range(MAX_QUBIT)
        ]

        # gate switch waveform
        self.generate_gate_switch = False
        self.uniform_gate = False
        self.gate_delay = 0.0
        self.gate_overlap = 20E-9
        self.minimal_gate_time = 20E-9

        # readout trig settings
        self.readout_trig_generate = False

        # readout wave object and settings
        self.readout = Readout(max_qubit=MAX_QUBIT)
        self.readout_trig = np.array([], dtype=float)
        self.readout_iq = np.array([], dtype=np.complex)
Example #3
0
    def __init__(self, ems, gui):
        super(ReachModel, self).__init__()

        self.verbose = config.getboolean('Reach Control', 'console_stats')
        self.brake_channel = config.get("Extra EMS Channels", "brake_active")

        self.ems = ems
        self.gui = gui
        self.left = Pulse(1)
        self.right = Pulse(2)
        self.penup = Pulse(3)
        self.brake = Pulse(4)

        self.last_index = 0

        self.brake_zone = config.getint('Reach Control', 'brake_zone')
        self.fixed_delay = config.getfloat('Reach Control', 'fixed_delay')
        pulse_period = config.getfloat('EMS Machine', 'ems_period')
        self.reach_repetitions = int(self.fixed_delay / pulse_period)

        self.CONTROL_ON = False
        self.BRAKE_MODE = False
        """Establishes state transfer from execute_repetions
        """
        self.stats = ReachStats()
Example #4
0
    def __init__(self, n_qubit=5, period_1qb=30E-9, period_2qb=30E-9,
                 sample_rate=1.2E9, n_pts=240E3, first_delay=100E-9,
                 local_xy=True):
        # define parameters
        self.n_qubit = n_qubit
        self.period_1qb = period_1qb
        self.period_2qb = period_2qb
        self.local_xy = local_xy
        # waveform parameter
        self.sample_rate = sample_rate
        self.n_pts = n_pts
        self.first_delay = first_delay
        self.trim_to_sequence = True
        self.trim_start = False
        self.align_to_end = False
        # parameter for keeping track of current gate pulse time
        self.time_pulse = 0.0

        # waveforms
        self.wave_xy = [np.zeros(0, dtype=np.complex)
                        for n in range(MAX_QUBIT)]
        self.wave_z = [np.zeros(0) for n in range(MAX_QUBIT)]
        self.wave_gate = [np.zeros(0) for n in range(MAX_QUBIT)]
        # define pulses
        self.pulses_1qb = [Pulse() for n in range(MAX_QUBIT)]
        self.pulses_2qb = [Pulse() for n in range(MAX_QUBIT - 1)]

        # tomography
        self.perform_tomography = False
        self.tomography = Tomography()

        # cross-talk object
        self.compensate_crosstalk = False
        self.crosstalk = Crosstalk()

        # predistortion objects
        self.perform_predistortion = False
        self.predistortions = [Predistortion(n) for n in range(MAX_QUBIT)]

        # gate switch waveform
        self.generate_gate_switch = False
        self.uniform_gate = False
        self.gate_delay = 0.0
        self.gate_overlap = 20E-9
        self.minimal_gate_time = 20E-9

        # readout trig settings
        self.generate_readout_trig = False
        self.readout_delay = 0.0
        self.readout_amplitude = 1.0
        self.readout_duration = 20E-9

        # readout wave object and settings
        self.generate_readout_iq = False
        self.readout = Readout(max_qubit=MAX_QUBIT)
        self.readout_trig = np.array([], dtype=float)
        self.readout_iq = np.array([], dtype=np.complex)
Example #5
0
 def generate_sequence(self, config):
     """Generate sequence by adding gates/pulses to waveforms."""
     pulse1 = Pulse(shape=PulseShape.SQUARE)
     pulse1.amplitude = config['Parameter #1']
     pulse1.width = float(config['Number of points']) / float(
         config['Sample rate'])
     pulse3 = Pulse(shape=PulseShape.SQUARE)
     pulse3.amplitude = config['Parameter #1']
     pulse3.width = config['Readout duration'] + float(
         config['Parameter #2'])
     self.add_gate_to_all(CustomGate(pulse1), t0=0)
     self.add_gate_to_all(Gate.Xp, dt=0)
     self.add_gate_to_all(CustomGate(pulse3), dt=0)
Example #6
0
    def generate_sequence(self, config):
        """Generate sequence by adding gates/pulses to waveforms"""

        frequency = config.get('Parameter #1')
        amplitude = config.get('Parameter #2')
        width = config.get('Parameter #3')
        plateau = config.get('Parameter #4')
        drag_coeff = config.get('Parameter #5')  #(drag coefficient)
        shapeID = config.get('Parameter #6')  # (0) gaussian, (1) cosine
        pulse_train = config.get(
            'Parameter #7'
        )  #yes (1) or no (0) for multiple alternate pulses for optimizing drag and Pi pulse
        N_pulses = config.get('Parameter #8')  #ignored if pulse_train == 0
        self.add_gate_to_all(Gate.Xp)

        pulse12 = Pulse()
        pulse12n = Pulse()
        pulse12.width = width
        pulse12n.width = width
        pulse12.plateau = plateau
        pulse12n.plateau = plateau
        pulse12.amplitude = amplitude
        pulse12n.amplitude = amplitude
        pulse12.frequency = frequency
        pulse12n.frequency = frequency
        if shapeID == 0:
            pulse12.shape = PulseShape.GAUSSIAN
            pulse12n.shape = PulseShape.GAUSSIAN
        if shapeID == 1:
            pulse12.shape = PulseShape.COSINE
            pulse12n.shape = PulseShape.COSINE
        pulse12.use_drag = True
        pulse12n.use_drag = True
        pulse12.drag_coefficient = drag_coeff
        pulse12n.drag_coefficient = drag_coeff
        pulse12.pulse_type = PulseType.XY
        pulse12n.pulse_type = PulseType.XY
        pulse12.phase = 0
        pulse12n.phase = -np.pi
        gateP = CustomGate(pulse12)
        gateN = CustomGate(pulse12n)
        if pulse_train:
            for i in range(int(N_pulses)):
                if ((i % 2) == 0):
                    self.add_gate_to_all(gateP)
                else:
                    self.add_gate_to_all(gateN)
        else:
            self.add_gate_to_all(gateP)
Example #7
0
 def activate_pulse(self):
     if (self.pulse_charge >= 1.0) and (self.power > 0.1):
         if (engine.key.get_mods()
                 & engine.KMOD_CTRL) or self.identity != 'Avatar':
             pulse_aim = self.pulse_aim
         else:
             pulse_aim = 'u'
         if pulse_aim == 'u':
             x = self.x
             y = self.y - (self.height / 2)
         if pulse_aim == 'd':
             x = self.x
             y = self.y + (self.height / 2)
         if pulse_aim == 'l':
             x = self.x - (self.width / 2)
             y = self.y
         if pulse_aim == 'r':
             x = self.x + (self.width / 2)
             y = self.y
         self.matrix.pulses.add(
             Pulse(self.matrix, x, y, pulse_aim, self.targets))
         self.power -= 0.01
         if env.sound:
             self.sound['pulse'].play()
         self.pulse_charge = 0.0
Example #8
0
    def generate_readout(self):
        """Create read-out trig and waveform signals

        """
        # get positon of readout
        if self.generate_readout_trig or self.generate_readout_iq:
            t = self.find_range_of_sequence()[1] + self.readout_delay
        # start with readout trig signal
        if self.generate_readout_trig:
            # create pulse object and insert into trig waveform
            trig = Pulse(amplitude=self.readout_amplitude,
                         width=0.0,
                         plateau=self.readout_duration,
                         shape=PulseShape.SQUARE)
            self.add_single_pulse(self.readout_trig, trig, t, align_left=True)

        # readout I/Q waveform
        if self.generate_readout_iq:
            wave = self.readout.create_waveform(t)
            # if not matching wave sizes, simply replace initialized waveform 
            if not self.readout.match_main_size:
                self.readout_iq = wave
            else:
                i0 = int(t * self.sample_rate)
                i1 = min(len(self.readout_iq), i0 + len(wave))
                self.readout_iq[i0:i1] = wave[:(i1 - i0)]
    def _add_pulse(self, element, offset, pulse, waveforms, 
            element_time_offset):
       
        chan_idx = self.find_channel(pulse['channel'])
        chan = self.channels[chan_idx]
        cable_delay = chan['cable_delay']
        AWG_chan_idx, AWG_subchan_idx = self._AWG_chan_indices(chan)
        
        # where we actually put the wfs depends on the cable delay
        # of the involved channels        
        sidx = int(self.start_index(pulse['name'], element['name']) + offset - \
            cable_delay)
        eidx = int(self.end_index(pulse['name'], element['name']) + offset - \
            cable_delay)
        
        stime = (sidx/self.clock + element_time_offset) if \
                pulse['element_phase'] else 0
        samples = eidx-sidx
        duration = samples/self.clock

        # print "pulse '%s' has offset %d (=%.3f us)" % (pulse['name'], sidx+of, stime*1e6)

        p = Pulse(pulse, samples, stime, self.clock)
        waveforms[AWG_chan_idx][AWG_subchan_idx][sidx:eidx] += p.wform()
        return waveforms
Example #10
0
def init_db():
    connection = SQLEngine.connect()
    context = MigrationContext.configure(connection)
    current_revision = context.get_current_revision()
    logger.boot('Database revision: %s', current_revision)
    if current_revision is None:
        DataBase.metadata.create_all(SQLEngine)

    config = Config(ALEMBIC_CONFIG)
    script = ScriptDirectory.from_config(config)
    head_revision = script.get_current_head()
    if current_revision is None or current_revision != head_revision:
        logger.boot('Upgrading database to version %s.', head_revision)
        command.upgrade(config, 'head')
        from option import Option
        session = Session()
        options = session.query(Option).first()
        if options is None:
            options = Option()
        options.version = head_revision
        session.add(options)
        from pulse import Pulse
        pulse = session.query(Pulse).first()
        if pulse is None:
            pulse = Pulse()
        session.add(pulse)
        session.commit()
Example #11
0
 def __init__(self, sz=270, fs=30, bs=30, size=256):
     print('init')
     self.stop = False
     self.masked_batches = []
     self.batch_mean = []
     self.signal_size = sz
     self.batch_size = bs
     self.signal = np.zeros((sz, 3))
     self.pulse = Pulse(fs, sz, bs, size)
     self.hrs = []
     self.save_results = True
Example #12
0
 def __init__(self, sz=270, fs=30, bs=30, save_key=None, size=256):
     print('init')
     self.stop = False
     self.masked_batches = []
     self.batch_mean = []
     self.signal_size = sz
     self.batch_size = bs
     self.signal = np.zeros((sz, 3))
     self.pulse = Pulse(fs, sz, bs, size)
     self.hrs = []
     self.save_key = save_key
     self.save_root = '/data2/datasets_origin/'
     self.save_results = True
    def __init__(self):
        self.node_name = rospy.get_name()
        rospy.loginfo("[%s] Initializing " % (self.node_name))

        self.config_path = rospy.get_param("~config_path")
        self.veh_name = rospy.get_param("~veh_name")

        self.ps = Pulse([5, 6, 13, 19])
        self.fname = None
        self.v = 0
        self.omega = 0
        self.readParamFromFile()
        self.shutdown = False

        self.kRadius = self.setup_parameter('~kRadius', 8.5)
        self.kEncRes = self.setup_parameter('~kEncRes', 1024)
        self.kSmpTime = self.setup_parameter('~kSmpTime', 10)
        self.kMaxVel = self.setup_parameter('~kMaxVel', 40)
        self.updatekMaxPPMS()

        #Publisher
        self.pub_wheelcmd = rospy.Publisher("~wheel_cmd",
                                            WheelsCmdStamped,
                                            queue_size=1)

        #open new thread
        self.thread = threading.Thread(target=self.counter)
        self.thread.start()
        time.sleep(0.2)

        self.srv_kRadius = rospy.Service("~set_kRadius", SetValue,
                                         self.cbSrvSetkRadius)
        self.srv_kEncRes = rospy.Service("~set_kEncRes", SetValue,
                                         self.cbSrvSetkEncRes)
        self.srv_kSmpTime = rospy.Service('~set_kSmpTime', SetValue,
                                          self.cbSrvSetkSmpTime)
        self.srv_kMaxVel = rospy.Service('~set_kMaxVel', SetValue,
                                         self.cbSrvSetkMaxVel)
        self.srv_save_param = rospy.Service('~save_param', Empty,
                                            self.cbSrvSaveParam)

        #Subsriber
        self.sub_carcmd = rospy.Subscriber("~car_cmd",
                                           Twist2DStamped,
                                           self.cbCarcmd,
                                           queue_size=1)
Example #14
0
    def generate_sequence(self, config):
        """Generate sequence by adding gates/pulses to waveforms"""

        frequency = config.get('Parameter #1')
        amplitude = config.get('Parameter #2')
        width = config.get('Parameter #3')
        plateau = config.get('Parameter #4')
        self.add_gate_to_all(Gate.Xp)

        pulse12 = Pulse()
        pulse12.truncation_range = 3
        pulse12.width = width
        pulse12.plateau = plateau
        pulse12.amplitude = amplitude
        pulse12.frequency = frequency
        gate = CustomGate(pulse12)
        self.add_gate_to_all(gate)
Example #15
0
xmax = 500
gridsize = 250
x0 = np.linspace(-xmax, xmax, gridsize)
y0 = np.linspace(-xmax, xmax, gridsize)

z0 = 1e3

x, y = np.meshgrid(x0, y0)

phi0 = np.linspace(0, 2 * np.pi, gridsize)
r0 = np.linspace(0, xmax, gridsize)
phi, r = np.meshgrid(phi0, r0)

surface = [np.zeros(x.size), np.zeros(x.size), np.zeros(x.size)]
pulse = Pulse(surface, 'Ku', x=x0, y=y0, r0=[0, 0, z0])
theta0 = pulse.main()

plt.figure()
plt.contourf(x, y, theta0.reshape(x.shape))
plt.colorbar()

fig, ax = plt.subplots(subplot_kw=dict(projection='polar'))
pulse = Pulse(surface,
              'Ku',
              x=r * np.cos(phi),
              y=r * np.sin(phi),
              r0=[0, 0, z0])
theta0 = pulse.main()
im = ax.contourf(phi, r, theta0.reshape(x.shape))
fig.colorbar(im)
Example #16
0
kernel_ku[blockspergrid, threadsperblock](band_ku, x, y, k, offset, phi, A, F,
                                          psi)

x0 = x0 - offsetx
y0 = y0 - offsety

z0 = 3e6
c = 3e8
omega = 2 * np.pi * 12e9
k = omega / c
timp = 3e-9
T0 = z0 / c
T = np.linspace(T0 - timp, np.sqrt(z0**2 + Xmax**2) / c, 200)
P = np.zeros(T.size)

pulse = Pulse(band_c, 'C', x0, y0, [0, 0, z0], timp=timp)
theta0_c = pulse.main()
theta0_c = theta0_c.reshape((x.size, y.size))
pulse = Pulse(band_ku, 'Ku', x0, y0, [0, 0, z0], timp=timp)
theta0_ku = pulse.main()
theta0_ku = theta0_c.reshape((x.size, y.size))

data.export(x0,
            y0,
            surface,
            ku_band=band_ku,
            c_band=band_c,
            theta0_c=theta0_c,
            theta0_ku=theta0_ku)

# print(surface.U10)
Example #17
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

from pulse import Pulse
from koheron import connect

host = os.getenv('HOST', '192.168.1.7')
client = connect(host, name='pulse-generator')
driver = Pulse(client)

pulse_width = 256
n_pulse = 64
pulse_frequency = 2000

pulse_period = np.uint32(driver.fs / pulse_frequency)

# Send Gaussian pulses to DACs
t = np.arange(driver.n_pts) / driver.fs # time grid (s)
driver.dac[0,:] = 0.6 * np.exp(-(t - 500e-9)**2/(150e-9)**2)
driver.dac[1,:] = 0.6 * np.exp(-(t - 500e-9)**2/(150e-9)**2)
driver.set_dac()

driver.set_pulse_width(pulse_width)
driver.set_pulse_period(pulse_period)
Example #18
0
timp = 40e-6
T0 = z0 / c

T = np.linspace(0.0199, np.sqrt(z0**2 + Xmax**2) / c, 256)

count = 0
while count < 100:
    x0 = np.random.uniform(-Xmax, Xmax, size=25)
    y0 = np.random.uniform(-Xmax, Xmax, size=25)
    x, y = np.meshgrid(x0, y0)
    band_c, band_ku = surface.surfaces_band([x, y], 0)

    pulse = Pulse(band_ku,
                  'Ku',
                  x0,
                  y0, [0, 0, z0],
                  timp=timp,
                  c=c,
                  projection='polar')
    theta0 = pulse.main()
    index = pulse.index[0]

    count += index.size
    print(count)
    P = np.zeros(T.size)

    for i in range(T.size):
        P[i] += pulse.power(T[i], omega, timp, pulse.Rabs, pulse.theta)
    plt.ion()
    plt.clf()
    plt.plot(T, P)
Example #19
0
            p.set_parameters(config)

        # crosstalk
        self.compensate_crosstalk = config.get('Compensate cross-talk', False)
        self.crosstalk.set_parameters(config)

        # gate switch waveform
        self.generate_gate_switch = config.get('Generate gate')
        self.uniform_gate = config.get('Uniform gate')
        self.gate_delay = config.get('Gate delay')
        self.gate_overlap = config.get('Gate overlap')
        self.minimal_gate_time = config.get('Minimal gate time')

        # readout, trig settings
        self.generate_readout_trig = config.get('Generate readout trig')
        self.readout_delay = config.get('Readout delay')
        self.readout_amplitude = config.get('Readout trig amplitude')
        self.readout_duration = config.get('Readout trig duration')
        self.iq_skew = config.get('Readout IQ skew')
        self.i_offset = config.get('Readout offset - I')
        self.q_offset = config.get('Readout offset - Q')

        # readout, wave settings
        self.generate_readout_iq = config.get('Generate readout waveform')
        self.readout.set_parameters(config)


if __name__ == '__main__':
    pass
    Pulse()
Example #20
0
import matplotlib.pyplot as plt
from SSFM import SSFM
from fiber import Fiber
from pulse import Pulse


plt.close('all')

dz = 1e-3
steps = 500
range1 = np.arange(steps)

centerwl = 835.0
fiber_length = 0.15

init = Pulse(n = 2**13)
init.gen_sech(1e4, 28.4e-3, centerwl)

fiber1 = Fiber()
fiber1.load_from_db( fiber_length, 'dudley')

evoladv  = SSFM(dz = 1e-6, local_error = 0.001, USE_SIMPLE_RAMAN = False)
yadv = np.zeros(steps)
AWadv = np.zeros((init.n, steps))
ATadv = np.copy(AWadv)

yadv, AWadv, ATadv, pulse1adv = evoladv.propagate(pulse_in = init,
                                                        fiber = fiber1,
                                                        n_steps = steps)
                                         
evolsimp = SSFM(dz = 1e-6, local_error = 0.001, USE_SIMPLE_RAMAN = True)
Example #21
0
fiber1 = Fiber()

steps = 250

centerwl = 1550.0
gamma = 2e-3
fiber_length = 100.0
T0 = 50e-3
D = 4  # ps / km / nm
beta2 = -2 * np.pi * fiber1.c / centerwl**2 * D
beta3 = 0.1
betas = [beta2, beta3]
print betas
P0 = abs(betas[0] * 1e-3) / gamma / T0**2
init = Pulse(n=2**14)
init.gen_sech(P0, T0, centerwl, time_window=25)
fiber1.generate_fiber(fiber_length, centerwl, betas, gamma, 0, "ps^n/km")

evol = SSFM(disable_Raman=False,
            disable_self_steepening=False,
            local_error=0.001,
            suppress_iteration=True,
            USE_SIMPLE_RAMAN=True)

y = np.zeros(steps)
AW = np.complex64(np.zeros((init.n, steps)))
AT = np.complex64(np.copy(AW))
wl = 2 * np.pi * init.c / (init.W)

shift = np.zeros((len(y), 3))
Example #22
0
    process[j] = Process(target=srf.init_kernel,
                         args=(kernel, arr[j], X0[j], Y0[j], host_constants))
    process[j].start()

data_p = pd.Series(dtype='object')
data_m = pd.Series(dtype='object')

fig_p, ax_p = plt.subplots()
fig_m, ax_m = plt.subplots()
for i in range(len(kernels)):
    # wait until process funished
    process[i].join()
    surf = arr[i]
    x = X0[i]
    y = Y0[i]
    pulse = Pulse(surf, x, y, const)
    # Calculate Probality Dencity Function of mirrored dots
    Z, W, f = pulse.pdf(surf)

    P = np.zeros(T.size)
    # Calculate impulse form
    for j in range(T.size):
        P[j] += pulse.power1(T[j])

    ax_p.plot(T, P, label=labels[i])
    dT = pd.Series(T - z0 / c, name='t_%s' % (labels[i]))
    dP = pd.Series(P / P.max(), name='P_%s' % (labels[i]))
    data_p = pd.concat([data_p, dT, dP], axis=1)

    Z = pd.Series(Z, name='Z_%s' % (labels[i]))
    W = pd.Series(W, name='W_%s' % (labels[i]))