Пример #1
0
    def test_init_with_stddev_mean_amplitude(self):
        gauss = models.GaussianModel1D(amplitude=1., mean=1.5, stddev=0.5)

        # check variables are correct
        self.assertEqual(gauss.amplitude, 1.)
        self.assertEqual(gauss.mean, 1.5)
        self.assertEqual(gauss.stddev, 0.5)

        # check the model works on a couple of points (evaluating astropy code here)
        self.assertEqual(gauss(1.5), 1.)
        self.assertAlmostEqual(gauss(1.75), 0.8825, 4)
Пример #2
0
    def test_changing_stddev_recalculates_amp_from_flux(self):
        """ The reason for this test is if you initialise a gaussian with flux, then change the stddev after you may
        expect flux to be preserved. It is not (as amplitude is calculated from flux when set, not on the fly). Im
        unsure if i should change this, raise a warning or leave it. For now im writing this test that will fail. And
        raising an issue on github (issue #1)
        """

        gauss = models.GaussianModel1D(mean=1.5, flux=1., stddev=0.5)

        gauss.stddev = 0.6

        self.assertEqual(gauss.flux, 1.)
Пример #3
0
    def test_init_with_fwhm_mean_flux(self):
        gauss = models.GaussianModel1D(flux=1., mean=1.5, fwhm=0.5)

        # check variables are correct
        self.assertEqual(gauss.flux, 1.)
        self.assertAlmostEqual(gauss.amplitude, 1.879, 3)
        self.assertEqual(gauss.mean, 1.5)
        self.assertEqual(gauss.fwhm, 0.5)
        self.assertAlmostEqual(gauss.stddev, 0.2123, 4)

        # check the model works on a couple of points (evaluating astropy code here)
        self.assertAlmostEqual(gauss(1.5), 1.879, 3)
        self.assertAlmostEqual(gauss(1.75), 0.9394, 4)
Пример #4
0
 def test_init_fails_with_stdev_mean_amplitude_flux(self):
     with self.assertRaises(ValueError):
         models.GaussianModel1D(amplitude=1., mean=1.5, flux=1., stddev=0.5)
Пример #5
0
 def test_init_raises_Valueerror_with_stdev_fwhm_mean_amplitude(self):
     with self.assertRaises(ValueError):
         models.GaussianModel1D(amplitude=1.,
                                mean=1.5,
                                fwhm=0.5,
                                stddev=0.5)
Пример #6
0
    def test_integrate(self):
        gauss = models.GaussianModel1D(mean=5, flux=3, stddev=0.5)

        np.testing.assert_almost_equal(
            gauss.integrate(np.array([4.3, 4.7, 5.2, 6.])),
            np.array([0.5805, 1.1435, 0.9655]), 4)