Exemplo n.º 1
0
    def test_fit_powerspectrum(self):
        model = self.model.copy()

        t0 = model.parameters
        _, res1 = fit_powerspectrum(self.ps, model)
        _, res2 = fit_powerspectrum(self.ps, model, t0)
        _, res3 = fit_crossspectrum(self.ps, model, t0, priors=self.priors)

        assert np.all(np.isclose(t0, res1.p_opt, rtol=0.5, atol=0.5))
        assert np.all(np.isclose(t0, res2.p_opt, rtol=0.5, atol=0.5))
        assert np.all(np.isclose(t0, res3.p_opt, rtol=0.5, atol=0.5))
Exemplo n.º 2
0
    def test_fit_powerspectrum(self):
        model = self.model.copy()

        t0 = model.parameters
        _, res1 = fit_powerspectrum(self.ps, model)
        _, res2 = fit_powerspectrum(self.ps, model, t0)
        _, res3 = fit_crossspectrum(self.ps, model, t0, priors=self.priors)

        assert np.all(np.isclose(t0, res1.p_opt, rtol=0.5, atol=0.5))
        assert np.all(np.isclose(t0, res2.p_opt, rtol=0.5, atol=0.5))
        assert np.all(np.isclose(t0, res3.p_opt, rtol=0.5, atol=0.5))
Exemplo n.º 3
0
    def test_fitting_with_tied_pars(self):
        double_f = lambda model: model.x_0_0 * 4
        triple_f = lambda model: model.x_0_0 * 15
        model = self.model.copy()
        model.x_0_1.tied = double_f
        model.x_0_2.tied = triple_f
        model.amplitude_0 = self.t0[0]
        # model.bounds = {}

        t0 = np.array([self.amplitude_0, self.x_0_0, self.fwhm_0,
                       self.amplitude_1, self.fwhm_1,
                       self.amplitude_2, self.fwhm_2,
                       self.whitenoise])

        parest, res = fit_powerspectrum(self.ps, model,
                                        np.random.normal(t0,
                                                         t0 / 10))

        true_pars = [self.amplitude_0,
                     self.x_0_0, self.fwhm_0,
                     self.amplitude_1, self.fwhm_1,
                     self.amplitude_2, self.fwhm_2,
                     self.whitenoise]

        assert np.all(np.isclose(true_pars, res.p_opt, rtol=0.5))
Exemplo n.º 4
0
    def test_fitting_with_fixed_pars(self):
        model = self.model.copy()
        model.amplitude_0 = self.t0[0]
        model.amplitude_0.fixed = True
        # model.bounds = {}

        parest, res = fit_powerspectrum(
            self.ps, model, np.random.normal(self.t0, self.t0 / 10))

        true_pars = [
            self.x_0_0, self.fwhm_0, self.amplitude_1, self.x_0_1, self.fwhm_1,
            self.amplitude_2, self.x_0_2, self.fwhm_2, self.whitenoise
        ]

        assert np.all(np.isclose(true_pars, res.p_opt, rtol=0.5))
Exemplo n.º 5
0
    def test_fitting_with_tied_pars(self):
        double_f = lambda model: model.x_0_0 * 4
        triple_f = lambda model: model.x_0_0 * 15
        model = self.model.copy()
        model.x_0_1.tied = double_f
        model.x_0_2.tied = triple_f
        model.amplitude_0 = self.t0[0]
        # model.bounds = {}

        parest, res = fit_powerspectrum(
            self.ps, model, np.random.normal(self.t0, self.t0 / 10))

        true_pars = [
            self.amplitude_0, self.x_0_0, self.fwhm_0, self.amplitude_1,
            self.fwhm_1, self.amplitude_2, self.fwhm_2, self.whitenoise
        ]

        assert np.all(np.isclose(true_pars, res.p_opt, rtol=0.5))
Exemplo n.º 6
0
    def test_fitting_with_fixed_pars(self):
        model = self.model.copy()
        model.amplitude_0 = self.t0[0]
        model.amplitude_0.fixed = True
        # model.bounds = {}

        t0 = np.array([self.x_0_0, self.fwhm_0,
                       self.amplitude_1, self.x_0_1, self.fwhm_1,
                       self.amplitude_2, self.x_0_2, self.fwhm_2,
                       self.whitenoise])

        parest, res = fit_powerspectrum(self.ps, model,
                                        np.random.normal(t0,
                                                         t0 / 10))

        true_pars = [self.x_0_0, self.fwhm_0,
                     self.amplitude_1, self.x_0_1, self.fwhm_1,
                     self.amplitude_2, self.x_0_2, self.fwhm_2,
                     self.whitenoise]

        assert np.all(np.isclose(true_pars, res.p_opt, rtol=0.5))