Beispiel #1
0
 def test_unity_with_fft(self):
     ''' This tests the not only that apodization of no arguments has no effect
         on the spectrum, but also it makes sure the 'no_transpose' flag is
         correctly set and reset.
     '''
     spec2d = fromPipe(self.filename)
     apoded_2d = apod(spec2d)
     apoded_ffted_2d = fft1d(apoded_2d)
 
     spec2d = fromPipe(self.filename)
     ffted_2d = fft1d(apoded_2d)
     ts.assert_equal(ffted_2d, apoded_ffted_2d, '2D Apodization unity with FFT failed')
Beispiel #2
0
    def test_fft_command_2d(self):
        spec = fromPipe(self.d2_file)
        spec = self.command(spec, {})

        dic, data = ng.pipe.read(self.d2_file)

        # 2D FFT using pipe_proc functions
        dic3, data3 = ng.pipe_proc.ft(dic, data)
        dic3, data3 = ng.pipe_proc.tp(dic3, data3, auto=True)
        dic3, data3 = ng.pipe_proc.ft(dic3, data3)
        dic3, data3 = ng.pipe_proc.tp(dic3, data3, auto=True)

        ts.assert_equal(data3, spec,
                        '2D FFT command doesnt match pipe_proc.ft')

        self.assertEqual((spec.udic[0]['time'] or spec.udic[1]['time']), False,
                         'udic time paramter not set to False')
        self.assertEqual((spec.udic[0]['freq'] and spec.udic[1]['freq']), True,
                         'udic freq paramter not set to True')

        spec = self.command(spec, {})
        ts.assert_equal(data3, spec,
                        'Rpetitive 2D FFT command doesnt match pipe_proc.ft')

        self.assertEqual((spec.udic[0]['time'] or spec.udic[1]['time']), False,
                         'udic time paramter not set to False')
        self.assertEqual((spec.udic[0]['freq'] and spec.udic[1]['freq']), True,
                         'udic freq paramter not set to True')
Beispiel #3
0
 def test_apod_unity(self):
     dic, data = self.dic, self.data
     spec2d = fromPipe(self.filename)
     
     # test auto class implementation
     apoded = apod(spec2d)
     ts.assert_equal(data, apoded, '2D Apodization unity failed')
Beispiel #4
0
    def test_fft_pipe(self):
        dic, data = self.dic, self.data
        spec2d = fromPipe(self.filename)
        # testing hypercomplex
        fn = "FDF" + str(int(dic["FDDIMORDER"][0]))
        fn2 = "FDF" + str(int(dic["FDDIMORDER"][1]))
        self.assertEqual((dic[fn + "QUADFLAG"] != 1) and \
                         (dic[fn2 + "QUADFLAG"] != 1), True,
                         'QUADFLAGs Error: data is not complex')

        # testing hypercomplex transpose
        ts.assert_array_equal(
            ng.pipe_proc.tp(dic, data, auto=True)[1],
            array(ng.proc_base.tp_hyper(data), dtype="complex64"))

        dic2, data2 = ng.pipe_proc.tp(dic, data, auto=True)

        # test class implementation of tp with pipe_proc
        ts.assert_array_equal(data2, spec2d.tp(),
                              'class implementation of tp not matching pipe.')

        # test double transpose
        ts.assert_array_equal(
            ng.pipe_proc.tp(dic2, data2, auto=True)[1], data,
            'Pipe tp: double transpose not giving the original data')

        # test double transpose with class implementation
        ts.assert_array_equal(
            spec2d.tp().tp(), spec2d,
            'Double tp with class implementation not giving '
            'the original data')

        # test pipe_ft
        ts.assert_array_equal(
            ng.pipe_proc.ft(dic, data)[1], ng.proc_base.fft_positive(data),
            'pipe_proc.ft not equal to fft_positive')

        # 2D FFT using pipe_proc functions
        dic3, data3 = ng.pipe_proc.ft(dic, data)
        dic3, data3 = ng.pipe_proc.tp(dic3, data3, auto=True)
        dic3, data3 = ng.pipe_proc.ft(dic3, data3)
        dic3, data3 = ng.pipe_proc.tp(dic3, data3, auto=True)

        # test auto class implementation
        ffted = fft1d(spec2d)
        ts.assert_equal(data3, ffted, '2D FFT doesnt match pipe_proc.ft')

        self.assertEqual((ffted.udic[0]['time'] or ffted.udic[1]['time']),
                         False, 'udic time paramter not set to False')
        self.assertEqual((ffted.udic[0]['freq'] and ffted.udic[1]['freq']),
                         True, 'udic freq paramter not set to True')
Beispiel #5
0
 def test_di(self):
     dic, data = ng.pipe.read(self.fid_file)
     spec2d = fromPipe(self.fid_file)
     
     
     self.assertEqual(data.dtype, spec2d.dtype, 'Initial dtype dont match')
     self.assertEqual(data.shape, spec2d.shape, 'Initial data shapes dont match')
     for i in range(0,spec2d.ndim):
         spec2d = spec2d.di().tp()
         dic, data = ng.pipe_proc.di(dic, data)
         dic, data = ng.pipe_proc.tp(dic, data, auto=True)
         self.assertEqual(data.dtype, spec2d.dtype, 'dtype dont match for dimension '+str(i))
         self.assertEqual(data.shape, spec2d.shape, 'data shapes dont match for dimension '+str(i))
         
Beispiel #6
0
 def test_apod_different_F1F2(self):
     dic, data = self.dic, self.data
     spec2d = fromPipe(self.filename)
     
     
     # 2D FFT using pipe_proc functions
     dic3, data3 = pipep.em(dic, data, 0.2)
     dic3, data3 = pipep.tp(dic3, data3, auto=True)
     dic3, data3 = pipep.gm(dic3, data3, 1, 0.5, 0.5)
     dic3, data3 = pipep.tp(dic3, data3, auto=True)
     
     # test auto class implementation
     apoded = apod(spec2d, F2_w1=lambda s: EM(s, 0.2), F1_w2=lambda s: GM(s, 1, 0.5, 0.5))
     ts.assert_equal(data3, apoded, '2D Apodized spectrum doesnt match pipe_proc.em and gm on F1 and F2')
Beispiel #7
0
 def test_apod_pipe(self):
     dic, data = self.dic, self.data
     spec2d = fromPipe(self.filename)
     
     
     # 2D FFT using pipe_proc functions
     dic3, data3 = pipep.em(dic, data, 0.2)
     dic3, data3 = pipep.tp(dic3, data3, auto=True)
     dic3, data3 = pipep.em(dic3, data3, 0.2)
     dic3, data3 = pipep.tp(dic3, data3, auto=True)
     
     # test auto class implementation
     apoded = apod(spec2d, w=lambda s: EM(s))
     ts.assert_equal(data3, apoded, '2D Apodized spectrum doesnt match pipe_proc.em')
Beispiel #8
0
    def test_di(self):
        dic, data = ng.pipe.read(self.fid_file)
        spec2d = fromPipe(self.fid_file)

        self.assertEqual(data.dtype, spec2d.dtype, 'Initial dtype dont match')
        self.assertEqual(data.shape, spec2d.shape,
                         'Initial data shapes dont match')
        for i in range(0, spec2d.ndim):
            spec2d = spec2d.di().tp()
            dic, data = ng.pipe_proc.di(dic, data)
            dic, data = ng.pipe_proc.tp(dic, data, auto=True)
            self.assertEqual(data.dtype, spec2d.dtype,
                             'dtype dont match for dimension ' + str(i))
            self.assertEqual(data.shape, spec2d.shape,
                             'data shapes dont match for dimension ' + str(i))
Beispiel #9
0
 def test_zf_pipe(self):
     dic, data = self.dic, self.data
     spec2d = fromPipe(self.filename)
     
     def zf2d_pipe(dic, data, size, size2):
         dic2, data2 = ng.pipe_proc.zf(dic,data, size=size)
         dic2, data2 = ng.pipe_proc.tp(dic2, data2, nohyper=True)
         dic2, data2 = ng.pipe_proc.zf(dic2, data2, size=size2)
         dic2, data2 = ng.pipe_proc.tp(dic2, data2, nohyper=True)    
         return dic2, data2
         
     pipe_zf = zf2d_pipe(dic, data, 2048, 512)[1]
     spec2d = zf2d(spec2d, size = 2048, size2=512)
     self.assertEqual(spec2d.shape, (512, 2048), 'Zero filled 2D spectrum has incorrect shape')
     ts.assert_array_equal(spec2d, pipe_zf, 'Zero filled 2D spectrum not equal to pipe_proc spectrum')
Beispiel #10
0
 def test_zf_auto(self):
     dic, data = self.dic, self.data
     spec2d = fromPipe(self.filename)
     
     spec2d = zf2d(spec2d)
     self.assertEqual(spec2d.shape, (512, 1900), 'Incorrect size in zero filling with size=auto')