Example #1
0
 def test_apod_tri(self):
     spec = fromBruker(self.filename, False, False)        
     # Loc < 1 results in dimension reduction of the apodization vector
     with self.assertRaises(NMRShapeError):
         apod(spec, w=lambda s: TRI(s, 0.5, 0.7, 0.5))
     
     spec = fromBruker(self.filename, False, False)
     spec = apod(spec, w=lambda s: TRI(s, 5000, 0.7, 0.5))
     C = converter()
     u = guess_udic(self.dic,self.data)
     C.from_bruker(self.dic, self.data, u)
     
     pipe_dic, pipe_data = C.to_pipe()
     test_data = pipep.tri(pipe_dic, pipe_data, loc=5000, lHi=0.7, rHi=0.5)[1]
     ts.assert_allclose(spec, test_data, 1e-7,1e-3, 'TRI apodization not equal to NMRPipe processed one.')
Example #2
0
    def test_fft_object_overwrite(self):
        spec = fromBruker(self.filename, False, False)
        fft1d(spec, 'fft')

        ts.assert_array_equal(spec, ng.process.proc_base.fft(self.data),
                              'Simple FFT falied')
        self.assertEqual(spec.udic[0]['freq'], True,
                         'Spec udic not modified to freq=True')
Example #3
0
    def test_fft_norm(self):
        spec = fromBruker(self.filename, False, False)
        spec = fft1d(spec, 'norm')

        ts.assert_array_equal(spec, ng.process.proc_base.fft_norm(self.data),
                              'FFT_norm failed')
        self.assertEqual(spec.udic[0]['freq'], True,
                         'Spec udic not modified to freq=True')
Example #4
0
 def test_zf_object_overwrite(self):
     spec = fromBruker(self.filename, False, False)
     zf1d(spec, size = 2**15)
     
     ts.assert_array_equal(spec, zf_size(self.data, 2**15), 'Simple Zero filling falied (see zf_size)')
     self.assertEqual(spec.shape[-1], 2**15, 'Spec size is not correct')
     self.assertEqual("ZF" in spec.history._stepnames, True, 'ZF not added to Spec history')
     self.assertEqual(spec.udic[0]['size'], 2**15, 'udic size not set correctly')
Example #5
0
 def test_apod_with_fft(self):
     spec = fromBruker(self.filename, False, False)
     spec = fft1d(spec, 'fft')
     spec = apod(spec, w=lambda s: EM(s, 0.))
     
     test_data = ngp.fft( ngp.em(self.data) )
     ts.assert_array_equal(spec, test_data, 'Apodization with zero filling and FFT failed.')
     self.assertEqual("apodization" in spec.history._stepnames, True, 'Apodization not added to Spec history')
     self.assertEqual(spec.history._stepnames, ['apodization', 'FFT'], 'Spec history not in the correct order (See fapplyBefore)')
Example #6
0
 def test_apod_multiple(self):
     spec = fromBruker(self.filename, False, False)
     spec = apod(spec, w=lambda s: EM(s, 0.), w2=lambda s: GM(s))
     
     test_data = ngp.em(self.data)
     test_data = ngp.gm(test_data)
     
     ts.assert_array_equal(spec, test_data, 'Multiple apodization (EM + GM) failed')
     self.assertEqual("apodization" in spec.history._stepnames, True, 'Apodization not added to Spec history')
Example #7
0
 def test_apod_gmb(self):
     spec = fromBruker(self.filename, False, False)
     spec = apod(spec, w=lambda s: GMB(s, 2, 0.5))
     C = converter()
     u = guess_udic(self.dic,self.data)
     C.from_bruker(self.dic, self.data, u)
     
     pipe_dic, pipe_data = C.to_pipe()
     test_data = pipep.gmb(pipe_dic, pipe_data, lb=2, gb=0.5)[1]
     ts.assert_allclose(spec, test_data, 1e-7,1e-3, 'GBM apodization not equal to NMRPipe processed one.')
Example #8
0
 def test_apod_gm(self):
     spec = fromBruker(self.filename, False, False)
     spec = apod(spec, w=lambda s: GM(s, 1, 10, 5))
     C = converter()
     u = guess_udic(self.dic,self.data)
     C.from_bruker(self.dic, self.data, u)
     
     pipe_dic, pipe_data = C.to_pipe()
     test_data = pipep.gm(pipe_dic, pipe_data, g1=1, g2=10, g3=5)[1]        
     ts.assert_allclose(spec, test_data, 1e-7,1e-3, 'GM apodization not equal to NMRPipe processed one.')
Example #9
0
 def test_apod_sp(self):
     spec = fromBruker(self.filename, False, False)
     spec = apod(spec, w=lambda s: SP(s, off=0.5, power=2))
     C = converter()
     u = guess_udic(self.dic,self.data)
     C.from_bruker(self.dic, self.data, u)
     
     pipe_dic, pipe_data = C.to_pipe()
     test_data = pipep.sp(pipe_dic, pipe_data, off=0.5, pow=2)[1]        
     ts.assert_allclose(spec, test_data, 1e-7,1e-3, 'SP apodization not equal to NMRPipe processed one.')
Example #10
0
 def test_apod_jmod(self):
     spec = fromBruker(self.filename, False, False)
     spec = apod(spec, w=lambda s: JMOD(s, 0.5, 5, 1))
     C = converter()
     u = guess_udic(self.dic,self.data)
     C.from_bruker(self.dic, self.data, u)
     
     pipe_dic, pipe_data = C.to_pipe()
     test_data = pipep.jmod(pipe_dic, pipe_data, off=0.5, j=5, lb=1)[1]        
     ts.assert_allclose(spec, test_data, 1e-7,1e-3, 'JMOD apodization not equal to NMRPipe processed one.')
Example #11
0
 def test_zf_with_fft(self):
     spec = fromBruker(self.filename, False, False)
     spec = fft1d(spec, 'fft')
     spec = zf1d(spec, size = 2**15)
     
     test_data = fft(zf_size(self.data, 2**15))
     self.assertEqual(spec.shape[-1], 2**15, 'Spec size is not correct')
     self.assertEqual("ZF" in spec.history._stepnames, True, 'ZF not added to Spec history')
     self.assertEqual(spec.history._stepnames, ['ZF','FFT'], 'Spec history not in the correct order (See fapplyBefore)')
     ts.assert_array_equal(spec, test_data, 'Simple Zero filling falied (see zf_size)')
     self.assertEqual(spec.udic[0]['size'], 2**15, 'udic size not set correctly')        
Example #12
0
    def test_fft_command_1d(self):
        spec = fromBruker(self.d1_file, False, False)
        spec = self.command(spec, {})

        dic, data = ng.bruker.read(self.d1_file, read_pulseprogram=False)
        ts.assert_array_equal(spec, ng.process.proc_base.fft_positive(data),
                              '1D FFT command failed')
        self.assertEqual(spec.udic[0]['freq'], True,
                         'Spec udic not modified to freq=True')

        spec = self.command(spec, {})
        ts.assert_array_equal(spec, ng.process.proc_base.fft_positive(data),
                              'Repetitive 1D FFT command failed')
Example #13
0
 def test_apod(self):
     spec = fromBruker(self.filename, False, False)
     spec = apod(spec, w=lambda s: EM(s, 0.))
     
     ts.assert_array_equal(spec, ngp.em(self.data), 'Simple EM apodization failed')
     self.assertEqual("apodization" in spec.history._stepnames, True, 'Apodization not added to Spec history %s' %str(spec.history._stepnames))