예제 #1
0
 def test_simple_copy(self):
     """Test which performs a read of a sigproc file,
         copy to one ring, and then output as text."""
     logfile = '.log.txt'
     self.blocks.append((CopyBlock(), [0], [1]))
     self.blocks.append((WriteAsciiBlock(logfile), [1], []))
     Pipeline(self.blocks).main()
     test_byte = open(logfile, 'r').read(1)
     self.assertEqual(test_byte, '2')
예제 #2
0
 def test_fft_result(self):
     """Make sure that fft matches what it should!"""
     open(self.logfile, 'w').close()
     Pipeline(self.blocks).main()
     fft_block_result = np.loadtxt(self.logfile).astype(np.float32).view(np.complex64)
     self.blocks[1] = (CopyBlock(), [0], [1])
     open(self.logfile, 'w').close()
     Pipeline(self.blocks).main()
     normal_fft_result = np.fft.fft(np.loadtxt(self.logfile))
     np.testing.assert_almost_equal(fft_block_result, normal_fft_result, 2)
예제 #3
0
 def test_throughput_size(self):
     """Number of elements going out should be double that of basic copy"""
     Pipeline(self.blocks).main()
     number_fftd = len(open(self.logfile, 'r').read().split('\n'))
     number_fftd = np.loadtxt(self.logfile).size
     open(self.logfile, 'w').close()
     # Run pipeline again with simple copy
     self.blocks[1] = (CopyBlock(), [0], [1])
     Pipeline(self.blocks).main()
     number_copied = np.loadtxt(self.logfile).size
     self.assertAlmostEqual(number_fftd, 2 * number_copied)
예제 #4
0
 def test_multi_copy(self):
     """Test which performs a read of a sigproc file,
         copy between many rings, and then output as
         text."""
     logfile = '.log.txt'
     for i in range(10):
         self.blocks.append((CopyBlock(), [i], [i + 1]))
     self.blocks.append((WriteAsciiBlock(logfile), [10], []))
     Pipeline(self.blocks).main()
     test_byte = open(logfile, 'r').read(1)
     self.assertEqual(test_byte, '2')
예제 #5
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)
예제 #6
0
 def test_single_block_multi_copy(self):
     """Test which forces one block to do multiple
         copies at once, and then dumps to two files,
         checking them both."""
     logfiles = ['.log1.txt', '.log2.txt']
     self.blocks.append((CopyBlock(), [0], [1, 2]))
     self.blocks.append((WriteAsciiBlock(logfiles[0]), [1], []))
     self.blocks.append((WriteAsciiBlock(logfiles[1]), [2], []))
     Pipeline(self.blocks).main()
     test_bytes = int(open(logfiles[0], 'r').read(1)) + int(
         open(logfiles[1], 'r').read(1))
     self.assertEqual(test_bytes, 4)
예제 #7
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])
예제 #8
0
 def test_non_linear_multi_copy(self):
     """Test which reads in a sigproc file, and
         loads it between different rings in a
         nonlinear fashion, then outputs to file."""
     logfile = '.log.txt'
     self.blocks.append((CopyBlock(), [0], [1]))
     self.blocks.append((CopyBlock(), [0], [2]))
     self.blocks.append((CopyBlock(), [2], [5]))
     self.blocks.append((CopyBlock(), [0], [3]))
     self.blocks.append((CopyBlock(), [3], [4]))
     self.blocks.append((CopyBlock(), [5], [6]))
     self.blocks.append((WriteAsciiBlock(logfile), [6], []))
     Pipeline(self.blocks).main()
     log_nums = open(logfile, 'r').read(500).split(' ')
     test_num = np.float(log_nums[8])
     self.assertEqual(test_num, 3)
예제 #9
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)