コード例 #1
0
def test_GUPPI_INCO_64_backend():
    """
    A GUPPI INCO backend (GuppyBackend) test setup.
    """
    config = ConfigParser.ConfigParser()
    config.readfp(open(dibas_dir + "/etc/config/dibas.conf"))
    b = BankData()
    b.load_config(config, "BANKA")
    m = ModeData()
    m.load_config(config, "INCO_MODE_64")
    m.frequency = 800.0
    be = GuppiBackend(b, m, None, None, None, unit_test=True)
    be.set_obs_frequency(1500.0)
    be.prepare()

    print "Status memory:", be.status_mem_local
    print "Roach (int) registers:", be.roach_registers_local

    assert_equal(be.get_status('ACC_LEN'), '512')
    assert_equal(be.get_status('BLOCSIZE'), '33554432')
    assert_almost_equal(float(be.get_status('CHAN_DM')), 0.0)
    assert_almost_equal(float(be.get_status('CHAN_BW')), 12.5)
    assert_equal(be.get_status('DATADIR'), dibas_data)
    assert_equal(be.get_status('DS_TIME'), '1')

    assert_equal(be.get_status('FFTLEN'), '16384')

    assert_equal(be.get_status('NPOL'), '4')
    assert_equal(be.get_status('NRCVR'), '2')
    assert_equal(be.get_status('NBIN'), '256')
    assert_equal(be.get_status('NBITS'), '8')

    assert_almost_equal(float(be.get_status('OBSFREQ')), 1500.0)
    assert_almost_equal(float(be.get_status('OBSBW')), 800.0)
    assert_equal(be.get_status('OBSNCHAN'), '64')
    assert_equal(be.get_status('OBS_MODE'), 'SEARCH')
    assert_almost_equal(float(be.get_status('OFFSET0')), 0.0)
    assert_almost_equal(float(be.get_status('OFFSET1')), 0.0)
    assert_almost_equal(float(be.get_status('OFFSET2')), 0.0)
    assert_almost_equal(float(be.get_status('OFFSET3')), 0.0)
    assert_equal(be.get_status('ONLY_I'), '0')
    assert_equal(be.get_status('OVERLAP'), '0')

    assert_equal(be.get_status('POL_TYPE'), 'IQUV')
    assert_equal(be.get_status('PFB_OVER'), '12')
    assert_equal(be.get_status('PARFILE'),
                 os.getenv('DIBAS_DIR') + '/etc/config/example.par')
    assert_equal(be.get_status('PKTFMT'), '1SFA')

    assert_almost_equal(float(be.get_status('SCALE0')), 1.0)
    assert_almost_equal(float(be.get_status('SCALE1')), 1.0)
    assert_almost_equal(float(be.get_status('SCALE2')), 1.0)
    assert_almost_equal(float(be.get_status('SCALE3')), 1.0)
    assert_almost_equal(float(be.get_status('TBIN')), 4.096e-05)
    assert_almost_equal(float(be.get_status('TFOLD')), 1.0)

    be.set_param("only_i", 1)
    be.prepare()
    assert_equal(be.get_status('ONLY_I'), '1')
    assert_equal(be.get_status('NPOL'), '4')
コード例 #2
0
def test_GUPPI_INCO_64_backend():
    """
    A GUPPI INCO backend (GuppyBackend) test setup.
    """
    config = ConfigParser.ConfigParser()
    config.readfp(open(dibas_dir + "/etc/config/dibas.conf"))
    b = BankData()
    b.load_config(config, "BANKA")
    m = ModeData()
    m.load_config(config, "INCO_MODE_64")
    m.frequency=800.0
    be = GuppiBackend(b, m, None, None, None, unit_test = True)
    be.set_obs_frequency(1500.0)
    be.prepare()

    print "Status memory:", be.status_mem_local
    print "Roach (int) registers:", be.roach_registers_local

    assert_equal(be.get_status('ACC_LEN'), '512')
    assert_equal(be.get_status('BLOCSIZE'), '33554432')
    assert_almost_equal(float(be.get_status('CHAN_DM')), 0.0)
    assert_almost_equal(float(be.get_status('CHAN_BW')), 12.5)
    assert_equal(be.get_status('DATADIR'), dibas_data)
    assert_equal(be.get_status('DS_TIME'), '1')

    assert_equal(be.get_status('FFTLEN'), '16384')

    assert_equal(be.get_status('NPOL'), '4')
    assert_equal(be.get_status('NRCVR'), '2')
    assert_equal(be.get_status('NBIN'), '256')
    assert_equal(be.get_status('NBITS'), '8')

    assert_almost_equal(float(be.get_status('OBSFREQ')), 1500.0)
    assert_almost_equal(float(be.get_status('OBSBW')), 800.0)
    assert_equal(be.get_status('OBSNCHAN'), '64')
    assert_equal(be.get_status('OBS_MODE'), 'SEARCH')
    assert_almost_equal(float(be.get_status('OFFSET0')), 0.0)
    assert_almost_equal(float(be.get_status('OFFSET1')), 0.0)
    assert_almost_equal(float(be.get_status('OFFSET2')), 0.0)
    assert_almost_equal(float(be.get_status('OFFSET3')), 0.0)
    assert_equal(be.get_status('ONLY_I'), '0')
    assert_equal(be.get_status('OVERLAP'), '0')

    assert_equal(be.get_status('POL_TYPE'), 'IQUV')
    assert_equal(be.get_status('PFB_OVER'), '12')
    assert_equal(be.get_status('PARFILE'), os.getenv('DIBAS_DIR') + '/etc/config/example.par')
    assert_equal(be.get_status('PKTFMT'), '1SFA')

    assert_almost_equal(float(be.get_status('SCALE0')), 1.0)
    assert_almost_equal(float(be.get_status('SCALE1')), 1.0)
    assert_almost_equal(float(be.get_status('SCALE2')), 1.0)
    assert_almost_equal(float(be.get_status('SCALE3')), 1.0)
    assert_almost_equal(float(be.get_status('TBIN')), 4.096e-05)
    assert_almost_equal(float(be.get_status('TFOLD')), 1.0)

    be.set_param("only_i", 1)
    be.prepare()
    assert_equal(be.get_status('ONLY_I'), '1')
    assert_equal(be.get_status('NPOL'), '4')
コード例 #3
0
def test_GUPPI_CODD_64_backend():
    """
    A GUPPI CODD backend (GuppyCODDBackend) test setup.
    """
    config = ConfigParser.ConfigParser()
    config.readfp(open(dibas_dir + "/etc/config/dibas.conf"))
    b = BankData()
    b.load_config(config, "BANKA")
    m = ModeData()
    m.load_config(config, "CODD_MODE_64")

    be = GuppiCODDBackend(b, m, None, None, None, unit_test=True)
    be.set_obs_frequency(1500.0)
    be.set_bandwidth(800.0)

    be.prepare()
    print "Status memory:", be.status_mem_local
    print "Roach (int) registers:", be.roach_registers_local

    assert_equal(be.get_status('NBITS'), '8')
    assert_equal(be.get_status('OFFSET0'), '0.0')
    assert_equal(be.get_status('OFFSET1'), '0.0')
    assert_equal(be.get_status('OFFSET2'), '0.0')
    assert_equal(be.get_status('OFFSET3'), '0.0')
    assert_equal(be.get_status('TFOLD'), '1.0')
    assert_equal(be.get_status('NRCVR'), '2')
    assert_equal(be.get_status('FFTLEN'), '32768')
    assert_equal(be.get_status('CHAN_BW'), '12.5')
    assert_equal(be.get_status('NBIN'), '256')
    assert_equal(be.get_status('OBSNCHAN'), '8')
    assert_equal(be.get_status('SCALE0'), '1.0')
    assert_equal(be.get_status('SCALE1'), '1.0')
    assert_equal(be.get_status('SCALE2'), '1.0')
    assert_equal(be.get_status('SCALE3'), '1.0')
    assert_equal(be.get_status('NPOL'), '4')
    assert_equal(be.get_status('POL_TYPE'), 'AABBCRCI')
    assert_equal(be.get_status('BANKNUM'), '0')
    assert_equal(be.get_status('ONLY_I'), '0')
    assert_equal(be.get_status('BLOCSIZE'), '134201344')
    assert_equal(be.get_status('ACC_LEN'), '1')
    assert_equal(be.get_status('OVERLAP'), '512')
    assert_equal(be.get_status('OBS_MODE'), 'COHERENT_SEARCH')
    assert_almost_equal(float(be.get_status('OBSFREQ')), 1143.75)
    assert_equal(be.get_status('PFB_OVER'), '12')
    assert_equal(be.get_status('PARFILE'),
                 os.getenv('DIBAS_DIR') + '/etc/config/example.par')
    assert_equal(be.get_status('OBSBW'), '100.0')
    assert_equal(be.get_status('DS_TIME'), '512')
    assert_equal(be.get_status('PKTFMT'), '1SFA')
    assert_equal(be.get_status('TBIN'), '8e-08')
    assert_equal(be.get_status('CHAN_DM'), '0.0')

    be.set_param("only_i", 1)
    be.prepare()
    assert_equal(be.get_status('ONLY_I'), '1')
    assert_equal(be.get_status('NPOL'), '4')
コード例 #4
0
def test_GUPPI_CODD_64_backend():
    """
    A GUPPI CODD backend (GuppyCODDBackend) test setup.
    """
    config = ConfigParser.ConfigParser()
    config.readfp(open(dibas_dir + "/etc/config/dibas.conf"))
    b = BankData()
    b.load_config(config, "BANKA")
    m = ModeData()
    m.load_config(config, "CODD_MODE_64")

    be = GuppiCODDBackend(b, m, None, None, None, unit_test = True)
    be.set_obs_frequency(1500.0)
    be.set_bandwidth(800.0)

    be.prepare()
    print "Status memory:", be.status_mem_local
    print "Roach (int) registers:", be.roach_registers_local

    assert_equal(be.get_status('NBITS'), '8')
    assert_equal(be.get_status('OFFSET0'), '0.0')
    assert_equal(be.get_status('OFFSET1'), '0.0')
    assert_equal(be.get_status('OFFSET2'), '0.0')
    assert_equal(be.get_status('OFFSET3'), '0.0')
    assert_equal(be.get_status('TFOLD'), '1.0')
    assert_equal(be.get_status('NRCVR'), '2')
    assert_equal(be.get_status('FFTLEN'), '32768')
    assert_equal(be.get_status('CHAN_BW'), '12.5')
    assert_equal(be.get_status('NBIN'), '256')
    assert_equal(be.get_status('OBSNCHAN'), '8')
    assert_equal(be.get_status('SCALE0'), '1.0')
    assert_equal(be.get_status('SCALE1'), '1.0')
    assert_equal(be.get_status('SCALE2'), '1.0')
    assert_equal(be.get_status('SCALE3'), '1.0')
    assert_equal(be.get_status('NPOL'), '4')
    assert_equal(be.get_status('POL_TYPE'), 'AABBCRCI')
    assert_equal(be.get_status('BANKNUM'), '0')
    assert_equal(be.get_status('ONLY_I'), '0')
    assert_equal(be.get_status('BLOCSIZE'), '134201344')
    assert_equal(be.get_status('ACC_LEN'), '1')
    assert_equal(be.get_status('OVERLAP'), '512')
    assert_equal(be.get_status('OBS_MODE'), 'COHERENT_SEARCH')
    assert_almost_equal(float(be.get_status('OBSFREQ')), 1143.75)
    assert_equal(be.get_status('PFB_OVER'), '12')
    assert_equal(be.get_status('PARFILE'), os.getenv('DIBAS_DIR') + '/etc/config/example.par')
    assert_equal(be.get_status('OBSBW'), '100.0')
    assert_equal(be.get_status('DS_TIME'),'512')
    assert_equal(be.get_status('PKTFMT'), '1SFA')
    assert_equal(be.get_status('TBIN'), '8e-08')
    assert_equal(be.get_status('CHAN_DM'), '0.0')

    be.set_param("only_i", 1)
    be.prepare()
    assert_equal(be.get_status('ONLY_I'), '1')
    assert_equal(be.get_status('NPOL'), '4')
コード例 #5
0
    def read_config_file(self, filename):
        """
        read_config_file(filename)

        Reads the config file 'filename' and loads the values into data
        structures in memory. 'filename' should be a fully qualified
        filename. The config file contains a 'bank' section of interest to
        this bank; in addition, it contains any number of 'MODEX' sections,
        where 'X' is a mode name/number.
        """

        try:
            config = ConfigParser.ConfigParser()
            config.readfp(open(filename))

            if not self.bank_name:
                self.bank_name = self.get_bank_name(config)

                if not self.bank_name:
                    sys.exit(0)

            bank = self.bank_name
            print "bank =", bank, "filename =", filename

            # Read general stuff:
            telescope = config.get(
                'DEFAULTS',
                'telescope').lstrip().rstrip().lstrip('"').rstrip('"')
            self.set_status(TELESCOP=telescope)

            # Read the HPC MAC addresses
            macs = config.items('HPCMACS')
            self.hpc_macs = {}

            for i in macs:
                #key = _ip_string_to_int(_hostname_to_ip(i[0])) & 0xFF
                #self.hpc_macs[key] = int(i[1], 16)
                # Change made due to different python version (At least I think that is the problem). Debugging was done with these lines in ipython - Mark R.
                key = _ip_string_to_int(i[0]) & 0xFF
                self.hpc_macs[key] = int(i[1], 16)

            # Get all bank data and store it. This is needed by any mode
            # where there is 1 ROACH and N Players & HPC programs
            banks = [s for s in config.sections() if 'BANK' in s]

            for bank in banks:
                b = BankData()
                b.load_config(config, bank)
                self.banks[bank] = b

            # Get config info on this bank's ROACH2. Normally there is 1
            # ROACH per Player/HPC node, so this is it.
            self.bank_data = self.banks[self.bank_name]
            self.instance_id = self.bank2inst(
                self.bank_name)  #self.bank_data.instance_id

            # Get config info on all modes
            modes = [s for s in config.sections() if 'MODE' in s]

            for mode in modes:
                m = ModeData()

                try:
                    m.load_config(config, mode)
                except Exception, e:
                    if self.simulate:
                        pass
                    else:
                        raise e

                self.mode_data[mode] = m

        except ConfigParser.NoSectionError as e:
            print str(e)
            return str(e)

        # Now that all the configuration data is loaded, set up some
        # basic things: KATCP, Valon, etc.  Not all backends will
        # have/need katcp & valon, so it config data says no roach &
        # valon, these steps will not happen.
        self.valon = None
        self.roach = None

        if not self.simulate and self.bank_data.has_roach:
            self.roach = katcp_wrapper.FpgaClient(self.bank_data.katcp_ip,
                                                  self.bank_data.katcp_port,
                                                  timeout=30.0)
            time.sleep(
                1
            )  # It takes the KATCP interface a little while to get ready. It's used below
            # by the Valon interface, so we must wait a little.

            # The Valon can be on this host ('local') or on the ROACH
            # ('katcp'), or None. Create accordingly.
            if self.bank_data.synth == 'local':
                import valon_synth
                self.valon = valon_synth.Synthesizer(self.bank_data.synth_port)
            elif self.bank_data.synth == 'katcp':
                from valon_katcp import ValonKATCP
                self.valon = ValonKATCP(self.roach, self.bank_data.synth_port)

            # Valon is now assumed to be working
            if self.valon:
                self.valon.set_ref_select(self.bank_data.synth_ref)
                self.valon.set_reference(self.bank_data.synth_ref_freq)
                self.valon.set_vco_range(0, *self.bank_data.synth_vco_range)
                self.valon.set_rf_level(0, self.bank_data.synth_rf_level)
                self.valon.set_options(0, *self.bank_data.synth_options)

            print "connecting to %s, port %i" % (self.bank_data.katcp_ip,
                                                 self.bank_data.katcp_port)
        print self.bank_data
        return "config file loaded."
コード例 #6
0
def dibas_vals(mode, expo):
    """Helper function, computes values for HBW modes to be used for test
    purposes. Assumes a switching signal with 4 phases and 4 blankings,
    and that the blanking is always 2 mS.

    * *mode:* The mode, a string; i.e. 'MODE1'
    * *expo:* The requested exposure

    Returns:

    A tuple:

    (b, m, freq, exposure, expoclks, ssg_bl_times[0], spec_tick, efsampfr, \
     hwexposr, chan_bw, bw_mode, obs_mode, fpga_clk)

    """
    modenum = int(mode[4:])
    config = ConfigParser.ConfigParser()
    config.readfp(open(dibas_dir + "/etc/config/dibas.conf"))
    b = BankData()
    b.load_config(config, "BANKA")
    m = ModeData()
    m.load_config(config, mode)
    freq = m.frequency * 1e6
    bl_init_val = 0.002
    ssg_init = [expo / 4 - bl_init_val] * 4
    bl_init = [bl_init_val] * 4

    if modenum < 4:
        efsampfr = freq * 2
        bw_mode = "high"
        obs_mode = "HBW"
        spec_tick = m.nchan / freq
    elif modenum > 3 and modenum < 10:
        efsampfr = freq / 4
        bw_mode = "low"
        obs_mode = "LBW"
        spec_tick = 1024.0 / freq
    elif modenum > 9 and modenum < 30:
        efsampfr = freq / 32
        bw_mode = "low"
        obs_mode = "LBW"
        spec_tick = 1024.0 / freq

    chan_bw = efsampfr / (m.nchan * 2)
    fpga_clk = freq / 8
    fpart, ipart = math.modf(m.hwexposr / spec_tick)

    if fpart >= 0.5:
        ipart = int(ipart) + 1

    hwexposr = spec_tick * ipart

    ssg_expoclks, ssg_times = compute_phases(ssg_init, hwexposr, spec_tick)

    if modenum < 4:
        ssg_bl_ticks, ssg_bl_times = compute_hbw_blanking(bl_init, hwexposr, spec_tick)
        exposure = compute_exposure(ssg_times, ssg_bl_times)
        expoclks = compute_expoclks(ssg_expoclks, ssg_bl_ticks, m.nchan / 8)
    else:
        ssg_bl_ticks, ssg_bl_times = compute_lbw_blanking(bl_init, chan_bw, spec_tick)
        exposure = compute_exposure(ssg_times, ssg_bl_times)
        expoclks = compute_expoclks(ssg_expoclks, ssg_bl_ticks, 128)

    return (b, m, freq, exposure, expoclks, ssg_bl_times[0], spec_tick, efsampfr, \
            hwexposr, chan_bw, bw_mode, obs_mode, fpga_clk)
コード例 #7
0
    def read_config_file(self, filename):
        """
        read_config_file(filename)

        Reads the config file 'filename' and loads the values into data
        structures in memory. 'filename' should be a fully qualified
        filename. The config file contains a 'bank' section of interest to
        this bank; in addition, it contains any number of 'MODEX' sections,
        where 'X' is a mode name/number.
        """

        try:
            config = ConfigParser.ConfigParser()
            config.readfp(open(filename))

            if not self.bank_name:
                self.bank_name = self.get_bank_name(config)

                if not self.bank_name:
                    sys.exit(0)

            bank = self.bank_name
            print "bank =", bank, "filename =", filename

            # Read general stuff:
            telescope = config.get('DEFAULTS', 'telescope').lstrip().rstrip().lstrip('"').rstrip('"')
            self.set_status(TELESCOP=telescope)

            # Read the HPC MAC addresses
            macs = config.items('HPCMACS')
            self.hpc_macs = {}

            for i in macs:
                key = _ip_string_to_int(_hostname_to_ip(i[0])) & 0xFF
                self.hpc_macs[key] = int(i[1], 16)

            # Get all bank data and store it. This is needed by any mode
            # where there is 1 ROACH and N Players & HPC programs
            banks = [s for s in config.sections() if 'BANK' in s]

            for bank in banks:
                b = BankData()
                b.load_config(config, bank)
                self.banks[bank] = b

            # Get config info on this bank's ROACH2. Normally there is 1
            # ROACH per Player/HPC node, so this is it.
            self.bank_data = self.banks[self.bank_name]

            # Get config info on all modes
            modes = [s for s in config.sections() if 'MODE' in s]

            for mode in modes:
                m = ModeData()

                try:
                    m.load_config(config, mode)
                except Exception, e:
                    if self.simulate:
                        pass
                    else:
                        raise e

                self.mode_data[mode] = m

        except ConfigParser.NoSectionError as e:
            print str(e)
            return str(e)

        # Now that all the configuration data is loaded, set up some
        # basic things: KATCP, Valon, etc.  Not all backends will
        # have/need katcp & valon, so it config data says no roach &
        # valon, these steps will not happen.
        self.valon = None
        self.roach = None

        if not self.simulate and self.bank_data.has_roach:
            self.roach = katcp_wrapper.FpgaClient(self.bank_data.katcp_ip,
                                                  self.bank_data.katcp_port,
                                                  timeout = 30.0)
            time.sleep(1) # It takes the KATCP interface a little while to get ready. It's used below
                          # by the Valon interface, so we must wait a little.

            # The Valon can be on this host ('local') or on the ROACH
            # ('katcp'), or None. Create accordingly.
            if self.bank_data.synth == 'local':
                import valon_synth
                self.valon = valon_synth.Synthesizer(self.bank_data.synth_port)
            elif self.bank_data.synth == 'katcp':
                from valon_katcp import ValonKATCP
                self.valon = ValonKATCP(self.roach, self.bank_data.synth_port)

            # Valon is now assumed to be working
            if self.valon:
                self.valon.set_ref_select(self.bank_data.synth_ref)
                self.valon.set_reference(self.bank_data.synth_ref_freq)
                self.valon.set_vco_range(0, *self.bank_data.synth_vco_range)
                self.valon.set_rf_level(0, self.bank_data.synth_rf_level)
                self.valon.set_options(0, *self.bank_data.synth_options)

            print "connecting to %s, port %i" % (self.bank_data.katcp_ip, self.bank_data.katcp_port)
        print self.bank_data
        return "config file loaded."
コード例 #8
0
def dibas_vals(mode, expo):
    """Helper function, computes values for HBW modes to be used for test
    purposes. Assumes a switching signal with 4 phases and 4 blankings,
    and that the blanking is always 2 mS.

    * *mode:* The mode, a string; i.e. 'MODE1'
    * *expo:* The requested exposure

    Returns:

    A tuple:

    (b, m, freq, exposure, expoclks, ssg_bl_times[0], spec_tick, efsampfr, \
     hwexposr, chan_bw, bw_mode, obs_mode, fpga_clk)

    """
    modenum = int(mode[4:])
    config = ConfigParser.ConfigParser()
    config.readfp(open(dibas_dir + "/etc/config/dibas.conf"))
    b = BankData()
    b.load_config(config, "BANKA")
    m = ModeData()
    m.load_config(config, mode)
    freq = m.frequency * 1e6
    bl_init_val = 0.002
    ssg_init = [expo / 4 - bl_init_val] * 4
    bl_init = [bl_init_val] * 4

    if modenum < 4:
        efsampfr = freq * 2
        bw_mode = "high"
        obs_mode = "HBW"
        spec_tick = m.nchan / freq
    elif modenum > 3 and modenum < 10:
        efsampfr = freq / 4
        bw_mode = "low"
        obs_mode = "LBW"
        spec_tick = 1024.0 / freq
    elif modenum > 9 and modenum < 30:
        efsampfr = freq / 32
        bw_mode = "low"
        obs_mode = "LBW"
        spec_tick = 1024.0 / freq

    chan_bw = efsampfr / (m.nchan * 2)
    fpga_clk = freq / 8
    fpart, ipart = math.modf(m.hwexposr / spec_tick)

    if fpart >= 0.5:
        ipart = int(ipart) + 1

    hwexposr = spec_tick * ipart

    ssg_expoclks, ssg_times = compute_phases(ssg_init, hwexposr, spec_tick)

    if modenum < 4:
        ssg_bl_ticks, ssg_bl_times = compute_hbw_blanking(
            bl_init, hwexposr, spec_tick)
        exposure = compute_exposure(ssg_times, ssg_bl_times)
        expoclks = compute_expoclks(ssg_expoclks, ssg_bl_ticks, m.nchan / 8)
    else:
        ssg_bl_ticks, ssg_bl_times = compute_lbw_blanking(
            bl_init, chan_bw, spec_tick)
        exposure = compute_exposure(ssg_times, ssg_bl_times)
        expoclks = compute_expoclks(ssg_expoclks, ssg_bl_ticks, 128)

    return (b, m, freq, exposure, expoclks, ssg_bl_times[0], spec_tick, efsampfr, \
            hwexposr, chan_bw, bw_mode, obs_mode, fpga_clk)