def test_memory_size_is_constant(self): ps100 = CircularPupil(100, 200, 1000) ps100_size = getsize(ps100) ps100a = CircularPupil(100, 200, 1000) ps100a_size = getsize(ps100a) ps1000 = CircularPupil(1000, 2000, 1) ps1000_size = getsize(ps1000) # magnitude of counts should not matter self.assertEqual(ps100_size, ps100a_size) # size of the decal should not matter self.assertEqual(ps100_size, ps1000_size) # size must not change if decal is generated decal = ps1000.decal self.assertEqual(ps1000_size, getsize(ps1000))
def test_decal_shape(self): """the decal is shaped on the outer_radius """ x, y, inner_radius, outer_radius, counts = 0, 0, 100, 200, 100 cp = CircularPupil(inner_radius, outer_radius, counts, x=x, y=y) expected_shape = (2 * outer_radius + 1, 2 * outer_radius + 1) self.assertEqual(expected_shape, cp.decal.shape) # also test source.half_with is correct self.assertEqual(outer_radius, cp.half_width)
def test_corner_values(self): """We're testing withing the decal, so x, y (the data coords) don't matter. """ x, y, inner_radius, outer_radius, counts = 0, 0, 100, 200, 100 cp = CircularPupil(inner_radius, outer_radius, counts, x=x, y=y) corner = 2 * outer_radius # corner of the decal self.assertEqual(0, cp.decal[0, 0]) self.assertEqual(0, cp.decal[0, corner]) self.assertEqual(0, cp.decal[corner, corner]) self.assertEqual(0, cp.decal[corner, 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])
def setUp(self): self.ppi = PupilPlateImage(shape=(1024, 1024)) self.cp = CircularPupil(100, 200, 1000.) self.ppi.add_source(self.cp, 512, 512)
def test_decal_sum(self): x, y, inner_radius, outer_radius, counts = 0, 0, 1, 2, 100 cp = CircularPupil(inner_radius, outer_radius, counts, x=x, y=y) expected_sum = (9 - 1) * counts # 9 from outer - 1 from inner self.assertEqual(expected_sum, cp.decal.sum())
def test_center_value(self): x, y, inner_radius, outer_radius, counts = 0, 0, 100, 200, 100 cp = CircularPupil(inner_radius, outer_radius, counts, x=x, y=y) ci = cj = outer_radius + 1 # the coords of the middle pixel self.assertEqual(0, cp.decal[ci, cj])
def test___init__(self): x, y, inner_radius, outer_radius, counts = 0, 0, 100, 200, 100 cp = CircularPupil(inner_radius, outer_radius, counts, x=x, y=y) self.assertIsInstance(cp, CircularPupil) print(cp)