Esempio n. 1
0
 def setUp(self):
     """Set up the blocks list, and put in a single
         block which reads in the data from a filterbank
         file."""
     self.blocks = []
     self.blocks.append(
         (SigprocReadBlock('./data/1chan8bitNoDM.fil'), [], [0]))
Esempio n. 2
0
 def setUp(self):
     """Assemble a basic pipeline with the FFT block"""
     self.logfile = '.log.txt'
     self.blocks = []
     self.blocks.append(
         (SigprocReadBlock('./data/1chan8bitNoDM.fil'), [], [0]))
     self.blocks.append((FFTBlock(gulp_size=4096 * 8 * 8 * 8), [0], [1]))
     self.blocks.append((WriteAsciiBlock(self.logfile), [1], []))
Esempio n. 3
0
 def test_many_channels(self):
     """See if many channels work with folding"""
     self.blocks[0] = (
         SigprocReadBlock('./data/simple_pulsar_DM0_128ch.fil'), [], [0])
     self.blocks.append((FoldBlock(bins=200), [0], [1]))
     histogram = self.dump_ring_and_read()
     self.assertTrue(np.min(histogram) > 1e-10)
     self.assertGreater(np.max(histogram) / np.min(histogram), 3)
Esempio n. 4
0
 def test_throughput(self):
     """Read in data with a small throughput size. Expect all to go through."""
     blocks = []
     blocks.append((SigprocReadBlock('./data/1chan8bitNoDM.fil',
                                     gulp_nframe=4096), [], [0]))
     blocks.append((WriteAsciiBlock('.log.txt'), [0], []))
     Pipeline(blocks).main()
     log_data = np.loadtxt('.log.txt')
     self.assertEqual(log_data.size, 12800)
Esempio n. 5
0
 def test_high_dispersion(self):
     """Test folding on a file with high DM"""
     self.blocks[0] = (
         SigprocReadBlock('./data/simple_pulsar_DM10_128ch.fil'), [], [0])
     self.blocks.append((FoldBlock(bins=200, dispersion_measure=10,
                                   core=0), [0], [1]))
     histogram = self.dump_ring_and_read()
     self.assertTrue(np.min(histogram) > 1e-10)
     self.assertGreater(np.max(histogram) / np.min(histogram), 3)
Esempio n. 6
0
 def test_show_pulse(self):
     """Test to see if a pulse is visible in the
         histogram from pulsar data"""
     self.blocks[0] = (SigprocReadBlock('./data/simple_pulsar_DM0.fil'), [],
                       [0])
     self.blocks.append((FoldBlock(bins=200), [0], [1]))
     histogram = self.dump_ring_and_read()
     self.assertTrue(np.min(histogram) > 1e-10)
     self.assertGreater(np.max(histogram) / np.average(histogram), 5)
Esempio n. 7
0
 def test_data_throughput(self):
     """Check that data is being put through the block
     (does this by checking consistency of shape/datatype)"""
     blocks = []
     blocks.append((SigprocReadBlock('./data/1chan8bitNoDM.fil'), [], [0]))
     blocks.append((KurtosisBlock(), [0], [1]))
     blocks.append((WriteAsciiBlock('.log.txt'), [1], []))
     Pipeline(blocks).main()
     test_byte = open('.log.txt', 'r').read().split(' ')
     test_nums = np.array([float(x) for x in test_byte])
     self.assertLess(np.max(test_nums), 256)
     self.assertEqual(test_nums.size, 12800)
Esempio n. 8
0
 def test_32bit_copy(self):
     """Perform a simple test to confirm that 32 bit
         copying has no information loss"""
     logfile = '.log.txt'
     self.blocks = []
     self.blocks.append(
         (SigprocReadBlock('./data/256chan32bitNoDM.fil'), [], [0]))
     self.blocks.append((CopyBlock(), [0], [1]))
     self.blocks.append((WriteAsciiBlock(logfile), [1], []))
     Pipeline(self.blocks).main()
     test_bytes = open(logfile, 'r').read(500).split(' ')
     self.assertAlmostEqual(np.float(test_bytes[0]), 0.72650784254)
Esempio n. 9
0
 def test_data_sizes(self):
     """Test that different number of bits give correct throughput size"""
     for iterate in range(5):
         nbit = 2**iterate
         if nbit == 8:
             continue
         self.blocks[0] = (SigprocReadBlock('./data/2chan' + str(nbit) +
                                            'bitNoDM.fil'), [], [0])
         open(self.logfile, 'w').close()
         Pipeline(self.blocks).main()
         number_fftd = np.loadtxt(self.logfile).astype(np.float32).view(
             np.complex64).size
         # Compare with simple copy
         self.blocks[1] = (CopyBlock(), [0], [1])
         open(self.logfile, 'w').close()
         Pipeline(self.blocks).main()
         number_copied = np.loadtxt(self.logfile).size
         self.assertEqual(number_fftd, number_copied)
         # Go back to FFT
         self.blocks[1] = (FFTBlock(gulp_size=4096 * 8 * 8 * 8), [0], [1])
Esempio n. 10
0
 def test_equivalent_data_to_copy(self):
     """Test that the data coming out of this pipeline is equivalent
     the initial read data"""
     self.logfile = '.log.txt'
     self.blocks = []
     self.blocks.append((
         SigprocReadBlock(
             './data/1chan8bitNoDM.fil'),
         [], [0]))
     self.blocks.append((FFTBlock(gulp_size=4096 * 8 * 8 * 8 * 8), [0], [1]))
     self.blocks.append((IFFTBlock(gulp_size=4096 * 8 * 8 * 8 * 8), [1], [2]))
     self.blocks.append((WriteAsciiBlock(self.logfile), [2], []))
     open(self.logfile, 'w').close()
     Pipeline(self.blocks).main()
     unfft_result = np.loadtxt(self.logfile).astype(np.float32).view(np.complex64)
     self.blocks[1] = (CopyBlock(), [0], [1])
     self.blocks[2] = (WriteAsciiBlock(self.logfile), [1], [])
     del self.blocks[3]
     open(self.logfile, 'w').close()
     Pipeline(self.blocks).main()
     untouched_result = np.loadtxt(self.logfile).astype(np.float32)
     np.testing.assert_almost_equal(unfft_result, untouched_result, 2)