Ejemplo n.º 1
0
 def test_areas_pi_n_pi_fwhm(self):
     """Test sech areas as multiples of pi given n_pi and fwhm args.
     """
     tlist = np.linspace(0., 1., 201)
     t_func = t_funcs.sech(1)
     FWHM = 0.1
     for n in np.linspace(1.0, 10.0, 10):
         t_args = {'n_pi_1': n, 'fwhm_1': FWHM, 'centre_1': 0.5}
         area = np.trapz(t_func(tlist, t_args), tlist) * 2 * np.pi
         fwhm_test = utility.full_width_at_half_max(tlist,
                                                    t_func(tlist, t_args))
         self.assertAlmostEqual(area, n * np.pi, places=3)
         self.assertAlmostEqual(fwhm_test, FWHM)
Ejemplo n.º 2
0
 def test_ampl_and_n_pi(self):
     """Test that KeyError is raised if both ampl and n_pi args set.
     """
     tlist = np.linspace(0., 1., 201)
     t_args = {
         'n_pi_1': 2.0,
         'ampl_1': 1.0,
         'width_1': 0.1,
         'centre_1': 0.5
     }
     t_func = t_funcs.sech(1)
     with self.assertRaises(KeyError):
         t_func(tlist, t_args)
Ejemplo n.º 3
0
 def test_areas_pi_n_pi(self):
     """Test sech areas as multiples of pi given n_pi arg.
     """
     SECH_FWHM_CONV = 1. / 2.6339157938
     FWHM = 0.1
     width = FWHM * SECH_FWHM_CONV  # [τ]
     tlist = np.linspace(0., 1., 201)
     t_func = t_funcs.sech(1)
     for n in np.linspace(1.0, 10.0, 10):
         t_args = {'n_pi_1': n, 'width_1': width, 'centre_1': 0.5}
         area = np.trapz(t_func(tlist, t_args), tlist) * 2 * np.pi
         fwhm_test = utility.full_width_at_half_max(tlist,
                                                    t_func(tlist, t_args))
         self.assertAlmostEqual(area, n * np.pi, places=3)
         self.assertAlmostEqual(fwhm_test, FWHM)
Ejemplo n.º 4
0
 def test_no_ampl_nor_n_pi(self):
     tlist = np.linspace(0., 1., 201)
     t_args = {'width_1': 0.1, 'centre_1': 0.5}
     t_func = t_funcs.sech(1)
     with self.assertRaises(KeyError):
         t_func(tlist, t_args)