Skip to content
Snippets Groups Projects
Select Git revision
  • 0432dc9b15622997ba3176edbe2f9cd1ac90c09e
  • master default protected
  • L2SS-2407-swap-iers-caltable-monitoring-port
  • L2SS-2357-fix-ruff
  • sync-up-with-meta-pypcc
  • stabilise-landing-page
  • all-stations-lofar2
  • v0.39.7-backports
  • Move-sdptr-to-v1.5.0
  • fix-build-ubuntu
  • tokens-in-env-files
  • fix-build
  • L2SS-2214-deploy-cdb
  • fix-missing-init
  • add-power-hardware-apply
  • L2SS-2129-Add-Subrack-Routine
  • Also-listen-internal-to-rpc
  • fix-build-dind
  • L2SS-2153--Improve-Error-Handling
  • L2SS-2153-Add-Grpc-Gateway-support
  • L2SS-1970-apsct-lol
  • v0.55.5 protected
  • v0.55.4 protected
  • 0.55.2.dev0
  • 0.55.1.dev0
  • 0.55.0.dev0
  • v0.54.0 protected
  • 0.53.2.dev0
  • 0.53.1.dev0
  • v0.52.3-r2 protected
  • remove-snmp-client
  • v0.52.3 protected
  • v0.52.3dev0 protected
  • 0.53.1dev0
  • v0.52.2-rc3 protected
  • v0.52.2-rc2 protected
  • v0.52.2-rc1 protected
  • v0.52.1.1 protected
  • v0.52.1 protected
  • v0.52.1-rc1 protected
  • v0.51.9-6 protected
41 results

Dockerfile

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    test_sdp_device.py 2.99 KiB
    # Copyright (C) 2024 ASTRON (Netherlands Institute for Radio Astronomy)
    # SPDX-License-Identifier: Apache-2.0
    
    import numpy
    import numpy.testing
    
    # Internal test imports
    from test.devices import device_base
    
    from tangostationcontrol.common.constants import (
        CLK_160_MHZ,
        CLK_200_MHZ,
        N_pn,
        S_pn,
        N_subbands,
    )
    from tangostationcontrol.common.sdp import subband_frequency
    from tangostationcontrol.devices.sdp.sdp import SDP
    
    
    class TestSDPDevice(device_base.DeviceTestCase):
        def _verify_subband_frequencies(self, clock, nyquist_zone, spectral_inversion):
            subband_frequencies = SDP._subband_frequencies(
                clock, nyquist_zone, spectral_inversion
            )
    
            # explicitly construct expected output. We can count on the subband_frequency
            # to work as that is tested elsewhere.
            expected_frequencies = numpy.zeros(
                (N_pn, S_pn, N_subbands), dtype=numpy.float64
            )
            for sb in range(N_subbands):
                for fpga_nr in range(N_pn):
                    for antenna_nr in range(S_pn):
                        expected_frequencies[fpga_nr, antenna_nr, sb] = subband_frequency(
                            sb,
                            clock,
                            nyquist_zone[fpga_nr, antenna_nr],
                            spectral_inversion[fpga_nr, antenna_nr],
                        )
    
            numpy.testing.assert_array_almost_equal(
                subband_frequencies, expected_frequencies.reshape(subband_frequencies.shape)
            )
    
        def test_subband_frequencies_200mhz(self):
            clock = CLK_200_MHZ
            nyquist_zone = numpy.array([[1] * S_pn] * N_pn)
            spectral_inversion = numpy.array([[True] * S_pn] * N_pn)
    
            self._verify_subband_frequencies(clock, nyquist_zone, spectral_inversion)
    
        def test_subband_frequencies_160mhz(self):
            clock = CLK_160_MHZ
            nyquist_zone = numpy.array([[1] * S_pn] * N_pn)
            spectral_inversion = numpy.array([[True] * S_pn] * N_pn)
    
            self._verify_subband_frequencies(clock, nyquist_zone, spectral_inversion)
    
        def test_subband_frequencies_mixed_fpga_settings(self):
            """Test different settings for the FPGAs to verify the ordering."""
    
            clock = CLK_200_MHZ
            nyquist_zone = numpy.array([[1] * S_pn] * N_pn)
            spectral_inversion = numpy.array([[True] * S_pn] * N_pn)
    
            # change settings for FPGAs beyond 4
            nyquist_zone[4:, :] = 0
            spectral_inversion[4:, :] = False
    
            self._verify_subband_frequencies(clock, nyquist_zone, spectral_inversion)
    
        def test_subband_frequencies_mixed_input_settings(self):
            """Test different settings for the inputs of the FPGAs to verify the ordering."""
    
            clock = CLK_200_MHZ
            nyquist_zone = numpy.array([[1] * S_pn] * N_pn)
            spectral_inversion = numpy.array([[True] * S_pn] * N_pn)
    
            # change settings for inputs beyond 4
            nyquist_zone[:, 4:] = 0
            spectral_inversion[:, 4:] = False
    
            self._verify_subband_frequencies(clock, nyquist_zone, spectral_inversion)