def __init__(self,
                 condition,
                 branches: List[segment_container],
                 name=None,
                 sample_rate=None):
        """
        initialize a container for segments.
        Args:
            channel_names (list<str>) : list with names of physical output channels on the AWG
            markers (list<str>) : declaration which of these channels are markers
            virtual_gates_objs (list<virtual_gates_constructor>) : list of object that define virtual gates
            IQ_channels_objs (list<IQ_channel_constructor>) : list of objects that define virtual IQ channels.
            Name (str): Optional name of segment container
            sample_rate (float): Optional sample rate of segment container. This sample rate overrules the default set on the sequence.
        """

        # create N segment_container
        self.condition = condition
        self.branches = branches

        # software markers and measurements stay empty
        self._software_markers = segment_HVI_variables("HVI_markers")
        self._segment_measurements = segment_measurements()

        # sample_rate must be equal

        # set sample rate (for all)

        self.name = name
        self.sample_rate = sample_rate

        # setpoints?
        self._setpoints = setpoint_mgr()
    def __init__(self,
                 channel_names,
                 markers=[],
                 virtual_gate_matrices=None,
                 IQ_channels_objs=[],
                 digitizer_channels=[],
                 name=None,
                 sample_rate=None):
        """
        initialize a container for segments.
        Args:
            channel_names (list<str>) : list with names of physical output channels on the AWG
            markers (list<str>) : declaration which of these channels are markers
            virtual_gate_matrices (VirtualGateMatrices) : object with all virtual gates matrices
            IQ_channels_objs (list<IQ_channel_constructor>) : list of objects that define virtual IQ channels.
            Name (str): Optional name of segment container
            sample_rate (float): Optional sample rate of segment container. This sample rate overrules the default set on the sequence.
        """
        # physical + virtual channels + digitizer channels
        self.channels = []
        self.render_mode = False
        self._total_times = None
        self.id = uuid.uuid4()
        self._Vmin_max_data = dict()
        self._software_markers = segment_HVI_variables("HVI_markers")
        self._segment_measurements = segment_measurements()

        self._virtual_gate_matrices = virtual_gate_matrices
        self._IQ_channel_objs = IQ_channels_objs
        self._digitizer_channels = digitizer_channels
        self.name = name
        self.sample_rate = sample_rate

        for name in channel_names:
            self._Vmin_max_data[name] = {"v_min": None, "v_max": None}

        self.prev_upload = datetime.datetime.utcfromtimestamp(0)

        # define real channels (+ markers)
        for name in channel_names:
            setattr(self, name, segment_pulse(name, self._software_markers))
            self.channels.append(name)
        for name in markers:
            setattr(self, name, segment_marker(name, self._software_markers))
            self.channels.append(name)

        # define virtual gates
        if self._virtual_gate_matrices:
            # make segments for virtual gates.
            for virtual_gate_name in self._virtual_gate_matrices.virtual_gate_names:
                setattr(
                    self, virtual_gate_name,
                    segment_pulse(virtual_gate_name, self._software_markers,
                                  'virtual_baseband'))
                self.channels.append(virtual_gate_name)

        # define virtual IQ channels
        for IQ_channels_obj in IQ_channels_objs:
            for qubit_channel in IQ_channels_obj.qubit_channels:
                setattr(
                    self, qubit_channel.channel_name,
                    segment_IQ(qubit_channel.channel_name,
                               self._software_markers))
                self.channels.append(qubit_channel.channel_name)

        # add the reference between channels for baseband pulses (->virtual gates) and IQ channels.
        add_reference_channels(self, self._virtual_gate_matrices,
                               self._IQ_channel_objs)

        for digitizer_channel in self._digitizer_channels:
            name = digitizer_channel.name
            setattr(self, name,
                    segment_acquisition(name, self._segment_measurements))
            self.channels.append(name)

        self._setpoints = setpoint_mgr()
    def __copy__(self):
        cpy = segment_pulse(self.name)
        return self._copy(cpy)



if __name__ == '__main__':
    # @@@ test timing of 200 * 200 2D loop with 100 pulse segments
    # a) adding pulses
    # b) rendering pulse segments

#    import matplotlib.pyplot as plt

    from pulse_lib.segments.segment_HVI_variables import segment_HVI_variables
    test_HVI_marker = segment_HVI_variables("name")

    s = segment_pulse("test", test_HVI_marker)
    from pulse_lib.segments.utility.looping import linspace

    a = tuple()
    b = tuple()
    print(a, b, a+b)
    t2 = linspace(100,500, 20, axis= 0)
    t = linspace(1,50, 10000, name = "test", unit = "test", axis= 0)

    # s.data_tmp = s.data[0]
    s.add_block(20, 50, 20)
    print(s.data[0].total_time)
    s.add_HVI_marker("test", 15)
    # s.reset_time()
Exemple #4
0
    def __init__(self,
                 channel_names,
                 markers=[],
                 virtual_gates_objs=[],
                 IQ_channels_objs=[]):
        """
        initialize a container for segments.
        Args:
            channel_names (list<str>) : list with names of physical output channels on the AWG
            markers (list<str>) : declaration which of these channels are markers
            virtual_gates_objs (list<virtual_gates_constructor>) : list of object that define virtual gates
            IQ_channels_objs (list<IQ_channel_constructor>) : list of objects that define virtual IQ channels.
        """
        # physical + virtual channels
        self.channels = []
        self.render_mode = False
        self.id = uuid.uuid4()
        self._Vmin_max_data = dict()
        self._software_markers = segment_HVI_variables("HVI_markers")

        self._virtual_gates_objs = virtual_gates_objs
        self._IQ_channel_objs = IQ_channels_objs

        for name in channel_names:
            self._Vmin_max_data[name] = {"v_min": None, "v_max": None}

        self.prev_upload = datetime.datetime.utcfromtimestamp(0)

        # define real channels (+ markers)
        for name in channel_names:
            if name in markers:
                setattr(self, name, segment_marker(name,
                                                   self._software_markers))
            else:
                setattr(self, name, segment_pulse(name,
                                                  self._software_markers))
            self.channels.append(name)

        # define virtual gates
        for virtual_gates in virtual_gates_objs:
            # make segments for virtual gates.
            for virtual_gate_name in virtual_gates.virtual_gate_names:
                setattr(
                    self, virtual_gate_name,
                    segment_pulse(virtual_gate_name, self._software_markers,
                                  'virtual_baseband'))
                self.channels.append(virtual_gate_name)

        # define virtual IQ channels
        for IQ_channels_obj in IQ_channels_objs:
            for virtual_channel_name in IQ_channels_obj.virtual_channel_map:
                setattr(
                    self, virtual_channel_name.channel_name,
                    segment_IQ(virtual_channel_name.channel_name,
                               self._software_markers))
                self.channels.append(virtual_channel_name.channel_name)

        # add the reference between channels for baseband pulses (->virtual gates) and IQ channels.
        add_reference_channels(self, self._virtual_gates_objs,
                               self._IQ_channel_objs)

        self._setpoints = setpoint_mgr()