def test_daofind_multiple_stars(self): size = (512, 512) number = 15 low = 2000 high = 30000 sky = 800 rdnoise = 20 fwhm = 5 sigma = fwhm * gaussian_fwhm_to_sigma theta = 0 threshold = 10 x, y, f = gen_position_flux(size, number, low, high, rng_seed=456) im = gen_image(size, x, y, f, sky, rdnoise, model='gaussian', sigma=sigma, theta=theta) sources = daofind(im, threshold, sky, rdnoise, fwhm) x, y, f = self.resort_sources(x, y, f) assert_equal(len(sources), number) assert_almost_equal(sources['x'], x, decimal=0) assert_almost_equal(sources['y'], y, decimal=0)
def test_daofind_four_stars_fixed_position(self): size = (128, 128) posx = (45, 90, 45, 90) posy = (45, 50, 90, 100) sky = 800 rdnoise = 20 flux = (15000, 3000, 5000, 35000) fwhm = 3 sigma = fwhm * gaussian_fwhm_to_sigma theta = 0 threshold = 10 im = gen_image(size, posx, posy, flux, sky, rdnoise, model='gaussian', sigma=sigma, theta=theta) sources = daofind(im, threshold, sky, rdnoise, fwhm) assert_equal(len(sources), 4) assert_almost_equal(sources['x'], posx, decimal=0) assert_almost_equal(sources['y'], posy, decimal=0)
def test_daofind_strong_and_weak(self): size = (128, 128) posx = (45, 90) posy = (45, 90) sky = 800 rdnoise = 20 flux = (32000, 16000) fwhm = 3 sigma = fwhm * gaussian_fwhm_to_sigma theta = 0 im = gen_image(size, posx, posy, flux, sky, rdnoise, model='gaussian', sigma=sigma, theta=theta) threshold = 10 sources = daofind(im, threshold, sky, rdnoise, fwhm) assert_equal(len(sources), 2) assert_almost_equal(sources['x'], posx, decimal=0) assert_almost_equal(sources['y'], posy, decimal=0)
def test_daofind_one_star_subpixel(self): size = (128, 128) pos = (54.32, 47.86) im = gen_image(size, [pos[0]], [pos[1]], [45000], 800, 0, sigma=[5 * gaussian_fwhm_to_sigma], skip_poisson=True) sources = daofind(im, 5, 800, 10, 5) assert_equal(len(sources), 1) # no error, 2 decimals ok! assert_almost_equal(sources[0]['x'], pos[0], decimal=2) assert_almost_equal(sources[0]['y'], pos[1], decimal=2)
def test_daofind_roundness(self): # compare my implementation with D.Jones PythonPhot # without filtering, both have to output the same round/sharp and # the same coordinates for all stars, because use the same algorithm image_size = (200, 525) xpos = np.arange(10) * 50 + 25 ypos = np.ones_like(xpos) * 30 + np.arange(len(xpos)) * 10 sky = 800 rdnoise = 50 threshold = 50 e = (np.arange(len(xpos))) * 0.1 flux = np.sqrt(np.arange(len(xpos)) + 1) * 80000 sigma_x = np.sqrt(1 / (1 - e**2)) * 2 sigma_y = np.ones_like(xpos) * 2 fwhm = 5 theta = np.zeros_like(xpos) sky = 800 rdnoise = 20 # very low noise expect_round = np.array( [0.0, 0.02, 0.03, 0.08, 0.15, 0.25, 0.39, 0.59, 0.88, 1.39]) im = gen_image(image_size, xpos, ypos, flux, sky, rdnoise, model='gaussian', sigma=(sigma_x, sigma_y), theta=theta) sources = daofind(im, threshold, sky, rdnoise, fwhm, sharp_limit=None, round_limit=None) assert_equal(len(sources), len(xpos)) assert_almost_equal(sources['x'], xpos, decimal=0) assert_almost_equal(sources['y'], ypos, decimal=0) assert_almost_equal(sources['round'], -expect_round, decimal=1)
def test_daofind_sharpness(self): # compare my implementation with D.Jones PythonPhot # without filtering, both have to output the same round/sharp and # the same coordinates for all stars, because use the same algorithm image_size = (200, 525) xpos = np.arange(10) * 50 + 25 ypos = np.ones_like(xpos) * 30 + np.arange(len(xpos)) * 10 sky = 800 rdnoise = 50 threshold = 50 fwhm = 5 sigma = np.array([0.1, 0.5, 0.8, 1.0, 1.2, 1.5, 2.0, 3.5, 3.0, 3.5]) sigma *= fwhm * gaussian_fwhm_to_sigma flux = (np.ones_like(xpos) * sigma) * 80000 expect_sharp = [ 3.55, 0.76, 0.50, 0.45, 0.43, 0.41, 0.39, 0.39, 0.39, 0.39 ] im = gen_image(image_size, xpos, ypos, flux, sky, rdnoise, model='gaussian', sigma=sigma) sources = daofind(im, threshold, sky, rdnoise, fwhm, sharp_limit=None, round_limit=None) assert_equal(len(sources), len(xpos)) assert_almost_equal(sources['x'], xpos, decimal=1) assert_almost_equal(sources['y'], ypos, decimal=1) assert_almost_equal(sources['sharp'], expect_sharp, decimal=1)
def test_daofind_reject_roundness(self): size = (128, 128) pos_x = [20, 60, 100, 40, 80] pos_y = [20, 30, 40, 50, 60] sky = 70 rdnoise = 20 flux = [30000] * 5 theta = 0 fwhm = 3 sigma_x = np.array([1, 0.5, 1, 2.0, 0.1 ]) * gaussian_fwhm_to_sigma * fwhm sigma_y = np.array([1, 1.0, 1, 0.5, 0.1 ]) * gaussian_fwhm_to_sigma * fwhm threshold = 10 # stars 0, 2 -> passed # star 4 -> rejected by sharpness # stars 1, 3 -> rejected by roundness im = gen_image(size, pos_x, pos_y, flux, sky, rdnoise, model='gaussian', sigma=(sigma_x, sigma_y), theta=theta) sources = daofind(im, threshold, sky, rdnoise, fwhm, sharp_limit=(0.3, 0.6), round_limit=(-0.5, 0.5)) assert_equal(len(sources), 2) assert_almost_equal(sources['x'], [20, 100], decimal=0) assert_almost_equal(sources['y'], [20, 40], decimal=0)
def test_daofind_one_star(self): size = (128, 128) pos = (64, 64) sky = 70 rdnoise = 20 flux = 32000 theta = 0 fwhm = 3 sigma = fwhm * gaussian_fwhm_to_sigma threshold = 10 im = gen_image(size, [pos[0]], [pos[1]], [flux], sky, rdnoise, model='gaussian', sigma=sigma, theta=theta) sources = daofind(im, threshold, sky, rdnoise, fwhm) assert_equal(len(sources), 1) assert_almost_equal(sources['x'][0], pos[0], decimal=1) assert_almost_equal(sources['y'][0], pos[1], decimal=1)