def make_marker(period, uptime=0.2, offset=0.0, repetitions=1, name='marker'): """ Creates a marker block waveforms of the type qupulse template. Args: period (float): The period of the waveform in seconds. uptime (float): The marker up period in seconds. offset (float): The marker delay in seconds. repetitions (int): The number of oscillations in the sequence. name (str): The name of the returned sequence. Returns: Dict: *NAME*, *TYPE*, *WAVE* keys containing values; sequence name, sequence data type and the actual qupulse sequencePT respectively. """ if abs(offset) > period: raise ValueError('Invalid argument value for offset: |{}| > {}!'.format(offset, period)) if not 0 < uptime < period: raise ValueError("Invalid argument value for uptime '{}'!".format(uptime)) updated_offset = period + offset if offset < 0 else offset input_variables = {'period': period * Sequencer.__sec_to_ns, 'uptime': uptime * Sequencer.__sec_to_ns, 'offset': updated_offset * Sequencer.__sec_to_ns} rollover = updated_offset + uptime > period if rollover: warnings.warn('Marker rolls over to subsequent period.') pulse_template = Templates.rollover_marker(name) if rollover else Templates.marker(name) sequence_data = (pulse_template, input_variables) return {'name': name, 'wave': SequencePT(*((sequence_data,) * repetitions)), 'type': DataTypes.QU_PULSE, 'uptime': uptime, 'offset': offset}
def make_pulse_table(amplitudes, waiting_times, repetitions=1, name='pulse_table'): """ Creates a sequence of pulses from a list of amplitudes and waiting times. Note that the initial voltage level will be given by the last element in amplitudes. Args: amplitudes (list of floats): List with voltage amplitudes of the pulses. waiting_times (list of float): List with durations containing the waiting time of each pulse. repetitions (int): The number of oscillations in the sequence. name (str): The name of the returned sequence. Returns: Dict: *NAME*, *TYPE*, *WAVE* keys containing values; sequence name, sequence data type and the actual qupulse sequencePT respectively. """ if len(amplitudes) != len(waiting_times): raise ValueError( 'Arguments have invalid lengths! (amplitudes={}, waiting_times={}' .format(len(amplitudes), len(waiting_times))) time_in_ns = 0.0 entry_list = list() for waiting_time, amplitude in zip(waiting_times, amplitudes): time_in_ns += waiting_time * Sequencer.__sec_to_ns entry_list.append((time_in_ns, amplitude, 'jump')) sequence_data = Templates.pulse_table(name, entry_list) return { 'name': name, 'wave': SequencePT(*(sequence_data, ) * repetitions), 'type': DataTypes.QU_PULSE }
def make_sawtooth_wave(amplitude, period, width=0.95, repetitions=1, name='sawtooth'): """ Creates a sawtooth waveform of the type qupulse template. Args: amplitude (float): The peak-to-peak voltage of the waveform. width (float): The width of the rising ramp as a proportion of the total cycle. period (float): The period of the waveform in seconds. repetitions (int): The number of oscillations in the sequence. name (str): The name of the returned sequence. Returns: Dict: *NAME*, *TYPE*, *WAVE* keys containing values; sequence name, sequence data type and the actual qupulse sequencePT respectively. """ if width <= 0 or width >= 1: raise ValueError('Invalid argument value (0 < width < 1)!') input_variables = { 'period': period * Sequencer.__sec_to_ns, 'amplitude': amplitude / 2.0, 'width': width } sequence_data = (Templates.sawtooth(name), input_variables) return { 'name': name, 'wave': SequencePT(*((sequence_data, ) * repetitions)), 'type': DataTypes.QU_PULSE }
def make_square_wave(amplitude, period, repetitions=1, name='pulse'): """ Creates a block waveforms of the type qupulse template. Args: amplitude (float): The peak-to-peak voltage of the waveform. period (float): The period of the waveform in seconds. repetitions (int): The number of oscillations in the sequence. name (str): The name of the returned sequence. Returns: Dict: *NAME*, *TYPE*, *WAVE* keys containing values; sequence name, sequence data type and the actual qupulse sequencePT respectively. """ input_variables = {'period': period * Sequencer.__sec_to_ns, 'amplitude': amplitude / 2.0} sequence_data = (Templates.square(name), input_variables) return {'name': name, 'wave': SequencePT(*(sequence_data,) * repetitions), 'type': DataTypes.QU_PULSE}