Example #1
0
    def test_single_element_aperture_card2(self):
        # Two cards, single element aperture near left bofder of the second card aperture
        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=128),
            ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=64)
        ]

        # Run.
        probe = self._create_probe(hw_subapertures, 0)
        tx_aperture = Subaperture(128, 1)
        tx_delays = [1]
        carrier_frequency = 8e6
        n_periods = 1
        probe.transmit_and_record(tx_aperture=tx_aperture,
                                  tx_delays=tx_delays,
                                  carrier_frequency=carrier_frequency,
                                  n_tx_periods=n_periods)
        # Verify.
        self.assertIsNone(hw_subapertures[0].card.tx_aperture)
        self.assertEqual(Subaperture(0, 1),
                         hw_subapertures[1].card.tx_aperture)
        self._assert_card_delays([[0.0] * 128, [1] + [0.0] * 127],
                                 hw_subapertures)
        self.assertEqual(carrier_frequency,
                         hw_subapertures[1].card.tx_frequency)
        self.assertEqual(n_periods, hw_subapertures[1].card.tx_periods)
Example #2
0
    def test_probe_sets_tx_for_two_cards_complete_apertures(self):
        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=128),
            ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=128)
        ]

        # Run.
        probe = self._create_probe(hw_subapertures, 0)
        tx_aperture = Subaperture(0, 256)
        tx_delays = list(range(0, 256))
        carrier_frequency = 14e6
        n_periods = 1
        probe.transmit_and_record(tx_aperture=tx_aperture,
                                  tx_delays=tx_delays,
                                  carrier_frequency=carrier_frequency,
                                  n_tx_periods=n_periods)
        # Verify.
        self.assertEqual(Subaperture(0, 128),
                         hw_subapertures[0].card.tx_aperture)
        self.assertEqual(Subaperture(0, 128),
                         hw_subapertures[1].card.tx_aperture)
        self._assert_card_delays(
            [list(range(0, 128)), list(range(128, 256))], hw_subapertures)
        for hws in hw_subapertures:
            self.assertEqual(carrier_frequency, hws.card.tx_frequency)
            self.assertEqual(n_periods, hws.card.tx_periods)
Example #3
0
    def test_probe_sets_tx_for_single_card_offset_origin(self):
        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=64)
        ]

        # Run.
        probe = self._create_probe(hw_subapertures, 0)
        tx_aperture = Subaperture(14, 32)
        tx_delays = list(range(0, 32))
        carrier_frequency = 10e6
        n_periods = 2
        probe.transmit_and_record(tx_aperture=tx_aperture,
                                  tx_delays=tx_delays,
                                  carrier_frequency=carrier_frequency,
                                  n_tx_periods=n_periods)
        # Verify.
        self.assertEqual(tx_aperture, hw_subapertures[0].card.tx_aperture)
        self.assertEqual(carrier_frequency,
                         hw_subapertures[0].card.tx_frequency)
        self.assertEqual(n_periods, hw_subapertures[0].card.tx_periods)
        self._assert_card_delays([
            14 * [0.0] + tx_delays + [0.0] * (128 - (14 + len(tx_delays))),
        ], hw_subapertures)
Example #4
0
    def test_probe_sets_tx_for_single_card(self):
        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(
                card=Us4OEMCardMock(0, n_rx_channels=32, n_tx_channels=128),
                origin=0,
                size=32  # Determines the size of the probe's aperture.
            )
        ]
        # Run.
        probe = self._create_probe(hw_subapertures, 0)
        tx_aperture = Subaperture(0, 32)
        tx_delays = list(range(0, 32))
        carrier_frequency = 5e6
        n_periods = 1
        probe.transmit_and_record(tx_aperture=tx_aperture,
                                  tx_delays=tx_delays,
                                  carrier_frequency=carrier_frequency,
                                  n_tx_periods=n_periods)
        # Verify.
        self.assertEqual(tx_aperture, hw_subapertures[0].card.tx_aperture)
        self.assertEqual(carrier_frequency,
                         hw_subapertures[0].card.tx_frequency)
        self.assertEqual(n_periods, hw_subapertures[0].card.tx_periods)

        self._assert_card_delays([tx_delays + [0.0] * 96], hw_subapertures)
Example #5
0
 def test_two_cards_second_card_end(self):
     # Set.
     hw_subapertures = [
         ProbeHardwareSubaperture(
             card=Us4OEMCardMock(0, n_rx_channels=32, n_tx_channels=128),
             origin=0,
             size=128  # Determines the size of the probe's aperture.
         ),
         ProbeHardwareSubaperture(
             card=Us4OEMCardMock(0, n_rx_channels=32, n_tx_channels=128),
             origin=0,
             size=64  # Determines the size of the probe's aperture.
         )
     ]
     # Run.
     probe = self._create_probe(hw_subapertures, 0)
     probe.set_tx_delay(channel_nr=191, delay=1)
     self._assert_card_delays(
         [[0.0] * 128, [0.0] * 63 + [1.0] + [0.0] * 64], hw_subapertures)
Example #6
0
    def test_probe_sets_tx_for_two_cards_only_second_card_aperture(self):
        # Two cards, tx aperture only on the second card

        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=128),
            ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=64)
        ]

        # Run.
        probe = self._create_probe(hw_subapertures, 0)
        tx_aperture = Subaperture(130, 32)
        tx_delays = list(range(0, 32))
        carrier_frequency = 8e6
        n_periods = 1
        probe.transmit_and_record(tx_aperture=tx_aperture,
                                  tx_delays=tx_delays,
                                  carrier_frequency=carrier_frequency,
                                  n_tx_periods=n_periods)
        # Verify.
        self.assertEqual(Subaperture(2, 32),
                         hw_subapertures[1].card.tx_aperture)
        self.assertIsNone(hw_subapertures[0].card.tx_aperture)
        self._assert_card_delays([
            [0.0] * 128,
            [0.0] * 2 + list(range(0, 32)) + [0.0] * (128 -
                                                      (2 + len(tx_delays))),
        ], hw_subapertures)
        self.assertEqual(carrier_frequency,
                         hw_subapertures[1].card.tx_frequency)
        self.assertEqual(n_periods, hw_subapertures[1].card.tx_periods)
Example #7
0
    def test_probe_sets_tx_apeture_two_cards_second_hw_offset(self):
        # Two cards, second one's aperture starts at origin > 0
        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=128),
            ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=14,
                                     size=64)
        ]

        # Run.
        probe = self._create_probe(hw_subapertures, 0)
        tx_aperture = Subaperture(0, 192)
        tx_delays = list(range(0, 192))
        carrier_frequency = 8e6
        n_periods = 1
        probe.transmit_and_record(tx_aperture=tx_aperture,
                                  tx_delays=tx_delays,
                                  carrier_frequency=carrier_frequency,
                                  n_tx_periods=n_periods)
        # Verify.
        self.assertEqual(Subaperture(0, 128),
                         hw_subapertures[0].card.tx_aperture)
        self.assertEqual(Subaperture(14, 64),
                         hw_subapertures[1].card.tx_aperture)
        self._assert_card_delays([
            list(range(0, 128)),
            [0.0] * 14 + list(range(128, 192)) + [0.0] * 50
        ], hw_subapertures)
        for hws in hw_subapertures:
            self.assertEqual(carrier_frequency, hws.card.tx_frequency)
            self.assertEqual(n_periods, hws.card.tx_periods)
Example #8
0
    def test_probe_sets_tx_delay_for_single_card(self):
        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(
                card=Us4OEMCardMock(0, n_rx_channels=32, n_tx_channels=128),
                origin=0,
                size=32  # Determines the size of the probe's aperture.
            )
        ]
        # Run.
        probe = self._create_probe(hw_subapertures, 0)

        probe.set_tx_delay(channel_nr=0, delay=1)
        self._assert_card_delays([[1.0] + [0.0] * 127], hw_subapertures)
Example #9
0
 def test_single_element_aperture_card1(self):
     # Two cards, single element aperture near right border of the first card aperture
     # Set.
     hw_subapertures = [
         ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=128),
         ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=64)
     ]
     # Run.
     probe = self._create_probe(hw_subapertures, 0)
     tx_aperture = Subaperture(127, 1)
     probe.set_tx_aperture(tx_aperture=tx_aperture)
     # Verify.
     self.assertEqual(Subaperture(127, 1),
                      hw_subapertures[0].card.tx_aperture)
     self.assertIsNone(hw_subapertures[1].card.tx_aperture)
Example #10
0
 def test_probe_sets_tx_for_two_cards_only_first_card_aperture(self):
     # Two cards, tx aperture only on the first card
     # Set.
     hw_subapertures = [
         ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=128),
         ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=64)
     ]
     # Run.
     probe = self._create_probe(hw_subapertures, 0)
     tx_aperture = Subaperture(16, 64)
     probe.set_tx_aperture(tx_aperture=tx_aperture)
     # Verify.
     self.assertEqual(Subaperture(16, 64),
                      hw_subapertures[0].card.tx_aperture)
     self.assertIsNone(hw_subapertures[1].card.tx_aperture)
Example #11
0
 def test_probe_sets_tx_for_two_cards_complete_apertures(self):
     # Set.
     hw_subapertures = [
         ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=128),
         ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=128)
     ]
     # Run.
     probe = self._create_probe(hw_subapertures, 0)
     tx_aperture = Subaperture(0, 256)
     probe.set_tx_aperture(tx_aperture=tx_aperture)
     # Verify.
     self.assertEqual(Subaperture(0, 128),
                      hw_subapertures[0].card.tx_aperture)
     self.assertEqual(Subaperture(0, 128),
                      hw_subapertures[1].card.tx_aperture)
Example #12
0
 def test_probe_sets_tx_apeture_two_cards_second_hw_offset(self):
     # Two cards, second one's aperture starts at origin > 0
     # Set.
     hw_subapertures = [
         ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=128),
         ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=14,
                                  size=64)
     ]
     # Run.
     probe = self._create_probe(hw_subapertures, 0)
     tx_aperture = Subaperture(0, 192)
     probe.set_tx_aperture(tx_aperture=tx_aperture)
     # Verify.
     self.assertEqual(Subaperture(0, 128),
                      hw_subapertures[0].card.tx_aperture)
     self.assertEqual(Subaperture(14, 64),
                      hw_subapertures[1].card.tx_aperture)
Example #13
0
 def test_probe_sets_tx_for_single_card_offset_origin(self):
     # Set.
     hw_subapertures = [
         ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=64)
     ]
     # Run.
     probe = self._create_probe(hw_subapertures, 0)
     tx_aperture = Subaperture(14, 32)
     probe.set_tx_aperture(tx_aperture=tx_aperture)
     # Verify.
     self.assertEqual(tx_aperture, hw_subapertures[0].card.tx_aperture)
Example #14
0
    def test_set_multiple(self):
        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(
                card=Us4OEMCardMock(0, n_rx_channels=32, n_tx_channels=128),
                origin=0,
                size=128  # Determines the size of the probe's aperture.
            )
        ]
        # Run.
        probe = self._create_probe(hw_subapertures, 0)

        probe.set_tx_delay(channel_nr=42, delay=1)
        probe.set_tx_delay(channel_nr=0, delay=2)
        probe.set_tx_delay(channel_nr=127, delay=4)
        self._assert_card_delays(
            [[2.0] + [0.0] * 41 + [1.0] + [0.0] * 84 + [4.0]], hw_subapertures)