コード例 #1
0
ファイル: test_gaussian.py プロジェクト: ajstewart/tkp
 def test_tiny_pixel_offset(self):
     pixel_noise = 0.0001
     self.mygauss[self.xbar+30, self.ybar] += pixel_noise
     self.fit = fitgaussian(self.mygauss, self.moments)
     for param in FIT_PARAMS:
         self.assertAlmostEqual(getattr(self,param), self.fit[param],
                                places=6)
コード例 #2
0
 def test_tiny_pixel_offset(self):
     pixel_noise = 0.0001
     self.mygauss[self.xbar + 30, self.ybar] += pixel_noise
     self.fit = fitgaussian(self.mygauss, self.moments)
     for param in FIT_PARAMS:
         self.assertAlmostEqual(getattr(self, param),
                                self.fit[param],
                                places=6)
コード例 #3
0
ファイル: test_gaussian.py プロジェクト: hughbg/tkp
 def setUp(self):
     Xin, Yin = numpy.indices((500, 500))
     self.height = 10
     self.x = 250
     self.y = 250
     self.maj = 40
     self.min = 40
     self.theta = 0
     self.mygauss = numpy.ma.array(gaussian(self.height, self.x, self.y, self.maj, self.min, self.theta)(Xin, Yin))
     self.moments = moments(self.mygauss, beam, 0)
     self.fit = fitgaussian(self.mygauss, self.moments)
コード例 #4
0
ファイル: test_gaussian.py プロジェクト: ajstewart/tkp
    def test_small_pixel_offset(self):
        pixel_noise = 0.001
        n_noisy_pix = 2
        # Place noisy pix symmetrically about centre to avoid position offset
        self.mygauss[self.xbar+30, self.ybar] += pixel_noise
        self.mygauss[self.xbar-30, self.ybar] += pixel_noise
        self.fit = fitgaussian(self.mygauss, self.moments)

        for param in FIT_PARAMS:
            self.assertAlmostEqual(getattr(self,param), self.fit[param],
                                   places=5)
コード例 #5
0
    def test_small_pixel_offset(self):
        pixel_noise = 0.001
        n_noisy_pix = 2
        # Place noisy pix symmetrically about centre to avoid position offset
        self.mygauss[self.xbar + 30, self.ybar] += pixel_noise
        self.mygauss[self.xbar - 30, self.ybar] += pixel_noise
        self.fit = fitgaussian(self.mygauss, self.moments)

        for param in FIT_PARAMS:
            self.assertAlmostEqual(getattr(self, param),
                                   self.fit[param],
                                   places=5)
コード例 #6
0
 def setUp(self):
     Xin, Yin = numpy.indices((500, 500))
     self.height = 10
     self.x = 250
     self.y = 250
     self.maj = 40
     self.min = 40
     self.theta = 0
     self.mygauss = numpy.ma.array(
         gaussian(self.height, self.x, self.y, self.maj, self.min,
                  self.theta)(Xin, Yin))
     self.moments = moments(self.mygauss, beam, 0)
     self.fit = fitgaussian(self.mygauss, self.moments)
コード例 #7
0
    def test_noisy_background(self):
        #Use a fixed random state seed, so unit-test is reproducible:
        rstate = numpy.random.RandomState(42)
        pixel_noise = 0.5
        self.mygauss += rstate.normal(scale=pixel_noise,
                                      size=len(self.mygauss.ravel())).reshape(
                                          self.mygauss.shape)
        self.fit = fitgaussian(self.mygauss, self.moments)
        self.longMessage = True  #Show assertion fail values + given message

        # First, let's check we've converged to a reasonable fit in the
        # presence of noise:
        # print
        for param in FIT_PARAMS:
            # print param, getattr(self,param), self.fit[param]
            self.assertAlmostEqual(
                getattr(self, param),
                self.fit[param],
                places=1,
                msg=param + " misfit (bad random noise seed?)",
            )

        # Now we run the full error-profiling routine and check the chi-sq
        # calculations:
        self.fit_w_errs, _ = source_profile_and_errors(
            data=self.mygauss,
            threshold=0.,
            noise=pixel_noise,
            beam=(self.semimajor, self.semiminor, self.theta),
        )

        npix = len(self.mygauss.ravel())
        # print "CHISQ", npix, self.fit_w_errs.chisq

        # NB: this is the calculation for reduced chisq in presence of
        # independent pixels, i.e. uncorrelated noise.
        # For real data, we try to take the noise-correlation into account.
        # print "Reduced chisq", self.fit_w_errs.chisq / npix
        self.assertTrue(0.9 < self.fit_w_errs.chisq / npix < 1.1)
コード例 #8
0
ファイル: test_gaussian.py プロジェクト: ajstewart/tkp
    def test_noisy_background(self):
        #Use a fixed random state seed, so unit-test is reproducible:
        rstate = numpy.random.RandomState(42)
        pixel_noise = 0.5
        self.mygauss += rstate.normal(scale = pixel_noise,
                  size=len(self.mygauss.ravel())).reshape(self.mygauss.shape)
        self.fit = fitgaussian(self.mygauss, self.moments)
        self.longMessage = True #Show assertion fail values + given message

        # First, let's check we've converged to a reasonable fit in the
        # presence of noise:
        # print
        for param in FIT_PARAMS:
            # print param, getattr(self,param), self.fit[param]
            self.assertAlmostEqual(getattr(self,param), self.fit[param],
                               places=1,
                               msg = param +" misfit (bad random noise seed?)",
                               )

        # Now we run the full error-profiling routine and check the chi-sq
        # calculations:
        self.fit_w_errs, _ = source_profile_and_errors(
            data = self.mygauss,
            threshold=0.,
            noise=pixel_noise,
            beam = (self.semimajor, self.semiminor, self.theta),
            )


        npix = len(self.mygauss.ravel())
        # print "CHISQ", npix, self.fit_w_errs.chisq

        # NB: this is the calculation for reduced chisq in presence of
        # independent pixels, i.e. uncorrelated noise.
        # For real data, we try to take the noise-correlation into account.
        # print "Reduced chisq", self.fit_w_errs.chisq / npix
        self.assertTrue( 0.9 < self.fit_w_errs.chisq / npix < 1.1)