예제 #1
0
    def test_add_point_source(self):
        ppi = PupilPlateImage()  # defaults to (4096, 4096)
        ppi.add_poisson_noise = False
        ppi.sky_level = 0
        ppi.read_noise = 0

        radius, counts = 10, 1000
        ps = FlatSource(radius, counts)
        image = ppi.render()

        # add the pupil to the center of the plate
        cx = cy = int(image.shape[0] / 2)
        ppi.add_source(ps, cx, cy)

        # must re-render the image if a ppi parameter (like sources[]) has changed
        image = ppi.render()

        # check that the plate knows about it's new Source
        self.assertTrue(ps in ppi.sources)

        # check that the Source now knows where it is on the plate
        self.assertEqual((cx, cy), ppi.sources[0].position)

        # check that the Source is actually there.
        self.assertEqual(ps.counts, image[ps.x, ps.y])
예제 #2
0
    def test_add_circular_pupil(self):
        ppi = PupilPlateImage()  # defaults to (4096, 4096)
        ppi.add_poisson_noise = False
        ppi.sky_level = 0
        ppi.read_noise = 0

        inner_radius, outer_radius, counts = 100, 200, 1000
        cp = CircularPupil(inner_radius, outer_radius, counts)

        # add the pupil to the center of the plate
        cx = cy = int(ppi.render().shape[0] / 2)
        ppi.add_source(cp, cx, cy)

        # check that the plate knows about it's new Source
        self.assertTrue(cp in ppi.sources)

        # check that the Source now knows where it is on the plate
        self.assertEqual((cx, cy), ppi.sources[0].position)

        # check that the Source is actually there.
        annulus_px = cp.x + cp.inner_radius + 10
        self.assertEqual(0, ppi.render()[cx, cy])  # center is 0
        self.assertEqual(cp.counts, ppi.render()[annulus_px, annulus_px])
예제 #3
0
    def test_pixel_perfect_placement(self):
        ppi = PupilPlateImage((4, 4))  # typical even number of pixels/edge
        ppi.add_poisson_noise = False
        ppi.sky_level = 0
        ppi.read_noise = 0

        radius, counts = 1, 99  # radius 0 gives single pixel decal
        ps = FlatSource(radius, counts)

        # add the single pixel point source to the plate
        cx = 2
        cy = 1
        ppi.add_source(ps, cx, cy)

        image = ppi.render()

        # check that source is where we placed it
        for y in range(image.shape[0]):
            for x in range(image.shape[1]):
                if not ((y == cx) and (x == cy)):
                    self.assertEqual(0, image[y, x],
                                     '({x:}, {y:})'.format(x=y, y=x))
        self.assertEqual(counts, image[cx, cy], '({x:}, {y:})'.format(x=cx,
                                                                      y=cy))