def add_fill(awg_element, tag, channels=None, refpulse=None, fillperiod=1e-7, start=0, refpoint='start', verbose=0): """ Add filling period to an element Args: awgelement (element): tag (str): name for the pulses to use ... """ if channels is None: # just select the first channel channels = [list(awg_element.pulsar.channels.keys())[0]] if channels == 'all': channels = list(awg_element.pulsar.channels.keys()) sq_pulse = pulse.SquarePulse( channel=channels[0], name='A dummy square pulse') for ii, ch in enumerate(channels): R = 0 px = pulse.cp(sq_pulse, amplitude=R, length=fillperiod, channel=ch, channels=[]) name = str(tag) + '%s' % ch awg_element.add(px, name=name, start=start, refpulse=refpulse, refpoint=refpoint) if verbose: print('add_fill: channel %s: name %s: amplitude %s, length %.6f [ms]' % (ch, name, px.amplitude, 1e3 * fillperiod)) if refpulse is None: refpulse = name
def generate_T1_element(tau, amp=1, sigma=5e-9, mod_frequency=10e6, meas_pulse_delay=20e-9, RO_pulse_duration=2e-6): # make sure tau is a multiple of 1 ns, if it is not the fixed point will # not be able to be computed. T1_element = element.Element(name=('T1_element %s' % tau), pulsar=qt.pulsar) Drag_pulse = pl.SSB_DRAG_pulse(name='DRAG', I_channel='I', Q_channel='Q') T1_element.add(pulse.cp(Drag_pulse, mod_frequency=mod_frequency, amplitude=amp, motzoi=.1, sigma=sigma), name='initial_pi', start=50e-9) T1_element.add(pulse.SquarePulse( channel='RF-marker', amplitude=1, length=RO_pulse_duration), name='Readout tone', start=(meas_pulse_delay+tau), refpulse='initial_pi', fixed_point_freq=100e6) T1_element.add(pulse.SquarePulse(name='ATS-marker', channel='ATS-marker', amplitude=1, length=100e-9), start=ATS_trig_delay, refpoint='start', refpulse='Readout tone') return T1_element
def ttrace2waveform(ttrace, pulsars, name='ttrace', verbose=1, awg_map=None, markeridx=1): """ Create a Toivo trace Args: ttrace (ttrace_t) pulsars (list): list of Pulsar objects markeridx (int): index of Pular to use for marker Returns: ttraces (waveforms) ttrace """ fillperiod = ttrace['fillperiod'] period = ttrace['period'] alpha = ttrace['alpha'] fpga_delay = ttrace['fpga_delay'] awg_delay = ttrace['awg_delay'] period0 = ttrace.get('period0', None) if period0 is None: period0 = fillperiod traces = ttrace['traces'] ntraces = len(traces) ttraces = [] # start with empty space for pi, pulsar in enumerate(pulsars): pulsar._clock_prequeried(True) ttrace_element = element.Element(name + '%d' % pi, pulsar=pulsar) ttraces += [ttrace_element] for pi, ttrace_element in enumerate(ttraces): add_fill(ttrace_element, fillperiod=period0, channels='all', tag='fillx', verbose=0) pulsar = pulsars[markeridx] ch = 1 lp = lastpulse(ttrace_element) # ttrace_element.pulses[lp].effective_stop() endtime = lasttime(ttrace_element) lpm = lastpulse(ttrace_element) # add marker markerperiod = ttrace['markerperiod'] try: pi, ci, mi = awg_map['fpga_mk'] except: pi, ci, mi = awg_map['m4i_mk'] pulsar = pulsars[pi] ttrace_element = ttraces[pi] ttrace_element.add(pulse.cp(sq_pulse, amplitude=.1, length=markerperiod, channel='ch%d_marker%d' % (ci, mi), channels=[]), name='marker%d' % ch, start=fpga_delay, refpulse=None, refpoint='end') # refpulse=refpulse if verbose: print('ttrace2waveform: %d traces, %d pulsars' % (ntraces, len(ttraces))) print('time after first till: %e' % endtime) ttrace['tracedata'] = [] for ii, tt in enumerate(traces): pass gg = [ga[0] for ga in tt] if verbose: print('trace %d: gates %s' % (ii, gg)) start_time = endtime ttrace['tracedata'] += [{ 'start_time': start_time + alpha * period, 'end_time': start_time + (1 - alpha) * period, 'start_time0': start_time, 'end_time0': start_time + period }] for g, a in tt: if isinstance(g, int): ch = g ci = g pi = 0 else: pi, ci = awg_map[g] ch = ci R = a print(' awg %d: channel %s: amplitude %.2f (%s)' % (pi, ch, R, g)) #lp = lastpulse(filler_element) start_time = endtime ttrace_element = ttraces[pi] if 1: tag = 'trace%dch%d' % (ii, ch) print('tag %s, start_time %f' % (tag, start_time)) ttrace_element.add(pulse.cp(lin_pulse, amplitude=.2, start_value=0, end_value=-R, length=alpha * period, channel='ch%d' % ch), name=tag + 'a', start=start_time + 0 * 1e-6, refpulse=None, refpoint='end') # refpulse=refpulse ttrace_element.add(pulse.cp(lin_pulse, start_value=-R, end_value=R, length=(1 - 2 * alpha) * period, channel='ch%d' % ch), name=tag + 'b', refpulse=tag + 'a', refpoint='end') # refpulse=refpulse ttrace_element.add(pulse.cp(lin_pulse, start_value=R, end_value=0, length=alpha * period, channel='ch%d' % ch), name=tag + 'c', refpoint='end', refpulse=tag + 'b') # refpulse=refpulse # endtime lp = lastpulse(ttrace_element) add_fill(ttrace_element, refpulse=lp, tag='fill%d' % ii, fillperiod=fillperiod, refpoint='end') lp = lastpulse(ttrace_element) endtime = lasttime(ttrace_element) # endtime startx = lasttime(ttrace_element) for pi, ttrace_element in enumerate(ttraces): add_fill(ttrace_element, fillperiod=period0, start=startx, tag='lastfill') for awgmk in ['awg_mk', 'awg_mk2']: if awgmk in awg_map: print('adding awg marker %s at %s' % ( awgmk, awg_map[awgmk], )) pi, ci, mi = awg_map[awgmk] pulsar = pulsars[pi] ttrace_element = ttraces[pi] ttrace_element.add(pulse.cp(sq_pulse, amplitude=.1, length=markerperiod - awg_delay, channel='ch%d_marker%d' % (ci, mi), channels=[]), name='%sci%dpost' % (awgmk, ci), start=0, refpulse=None, refpoint='end') # refpulse=refpulse ttrace_element.add(pulse.cp(sq_pulse, amplitude=.1, length=awg_delay, channel='ch%d_marker%d' % (ci, mi), channels=[]), name='%sci%dpre' % (awgmk, ci), start=lasttime(ttrace_element) - awg_delay, refpulse=None, refpoint='end') # refpulse=refpulse if verbose: lt = lasttime(ttraces[0]) print('ttrace2waveform: last time on waveform 0: %.1f [ms]' % (1e3 * lt)) return ttraces, ttrace
VT_channel = 5 VLP_channel = 8 base_amplitude = 0.25 # some safe value for the sample sin_pulse = pulse.CosPulse(channel='ch%d' % basechannel, name='A cosine pulse on RF') sq_pulse = pulse.SquarePulse(channel='ch%d' % basechannel, name='A square pulse on MW pmod1') sq_pulse_marker = pulse.SquarePulse(channel='ch%d_marker1' % basechannel, name='A square pulse on MW pmod2') sq_pulse1 = pulse.SquarePulse(channel='ch%d' % VT_channel, name='A square pulse on MW pmod3') sin_pulse_marker = pulse.CosPulse(channel='ch%d' % VLP_channel, name='A cosine pulse on RF1') test_element.add(pulse.cp(sin_pulse, frequency=1e6, amplitude=0.5, length=5e-6), name='first pulse') test_element.add(pulse.cp(sq_pulse1, amplitude=0.2, length=5e-6), name='second pulse marker', refpulse='first pulse', refpoint='start') test_element.add(pulse.cp(sq_pulse, amplitude=0.3, length=1e-6), name='second pulse', refpulse='first pulse', refpoint='end') test_element.add(pulse.cp(sq_pulse1, amplitude=0.6, length=1e-6), name='second pulse1', refpulse='first pulse',
pprint.pprint(test_element._channels) print() # define some bogus pulses. sin_pulse = pulse.SinePulse(channel='RF', name='A sine pulse on RF') sq_pulse = pulse.SquarePulse(channel='MW_pulsemod', name='A square pulse on MW pmod') special_pulse = pulse.SinePulse(channel='RF', name='special pulse') special_pulse.amplitude = 0.2 special_pulse.length = 2e-6 special_pulse.frequency = 10e6 special_pulse.phase = 0 # create a few of those test_element.add(pulse.cp(sin_pulse, frequency=1e6, amplitude=1, length=1e-6), name='first pulse') test_element.add(pulse.cp(sq_pulse, amplitude=1, length=1e-6), name='second pulse', refpulse='first pulse', refpoint='end') test_element.add(pulse.cp(sin_pulse, frequency=2e6, amplitude=0.5, length=1e-6), name='third pulse', refpulse='second pulse', refpoint='end') print('Element overview:') # test_element.print_overview() print() special_element = element.Element('Another_element', pulsar=qt.pulsar) special_element.add(special_pulse) # create the sequnce # note that we re-use the same waveforms (just with different identifier
sin_pulse = pulse.CosPulse(channel='ch%d' % basechannel, name='A cosine pulse on RF') #sq_pulse = pulse.SquarePulse(channels=['ch%d' %VT_channel, 'ch%d' %VLP_channel] , name='A square pulse on MW pmod') sq_pulse = pulse.SquarePulse(channel='ch%d' % basechannel, name='A square pulse on MW pmod1') sq_pulse_marker = pulse.SquarePulse(channel='ch%d_marker1' % basechannel, name='A square pulse on MW pmod2') sq_pulse1 = pulse.SquarePulse(channel='ch%d' % VT_channel, name='A square pulse on MW pmod3') sin_pulse_marker = pulse.CosPulse(channel='ch%d_marker2' % basechannel, name='A cosine pulse on RF1') #special_pulse = pulse.CosPulse(channel='ch%d' % basechannel, name='special pulse') #special_pulse.amplitude = base_amplitude #special_pulse.length = 2e-6 #special_pulse.frequency = 10e6 #special_pulse.phase = 0 # create a few of those test_element.add(pulse.cp(sin_pulse, frequency=1e6, amplitude=base_amplitude / np.sqrt(2), length=1e-6), name='first pulse') test_element.add(pulse.cp(sq_pulse1, amplitude=.5 * base_amplitude, length=2e-6), name='second pulse marker', refpulse='first pulse', refpoint='start') test_element.add(pulse.cp(sq_pulse, amplitude=0.3, length=1e-6), name='second pulse', refpulse='first pulse', refpoint='end') test_element.add(pulse.cp(sq_pulse1, amplitude=0.2, length=1e-6), name='second pulse1', refpulse='first pulse', refpoint='end') test_element.add(pulse.cp(sin_pulse, frequency=2e6, amplitude=0.25 / np.sqrt(2), length=1e-6), name='third pulse', refpulse='second pulse', refpoint='end') # #my_element = element.Element('my_element', pulsar=pulsar) #dd = [0, 0, 1, 2, 3, 4, 0] #my_element.add(pulse.cp(sq_pulse, amplitude=0.35, length=1e-6), name='d0', )