def test_starfind_blind_fwhm(self): size = (512, 512) number = 12 low, high = (15000, 60000) sky = 800 rdnoise = 20 sigma = 2 theta = 0 threshold = 8 x, y, f = gen_position_flux(size, number, low, high, rng_seed=456) x, y, f = self.resort_sources(x, y, f) im = gen_image(size, x, y, f, sky, rdnoise, model='gaussian', sigma=sigma, theta=theta) sources = starfind(im, threshold, sky, rdnoise) assert_equal(len(sources), number) assert_almost_equal(sources['x'], x, decimal=1) assert_almost_equal(sources['y'], y, decimal=1) assert_almost_equal(sources.meta['astropop fwhm'], sigma * 2.355, decimal=2)
def test_starfind_strong_weak(self): size = (100, 200) posx = (50, 150) posy = (40, 60) sky = 800 rdnoise = 20 flux = (64000, 6000) theta = 0 fwhm = 3 sigma = fwhm * gaussian_fwhm_to_sigma threshold = 10 im = gen_image(size, posx, posy, flux, sky, rdnoise, model='gaussian', sigma=sigma, theta=theta) sources = starfind(im, threshold, sky, rdnoise, fwhm) assert_equal(len(sources), 2) assert_almost_equal(sources['x'], posx, decimal=1) assert_almost_equal(sources['y'], posy, decimal=1) assert_almost_equal(sources.meta['astropop fwhm'], sigma * 2.355, decimal=1)
def test_starfind_one_star(self): size = (128, 128) x, y = (64, 64) f = 80000 sky = 70 rdnoise = 20 sigma = 5 theta = 0 fwhm = 5 # dummy low value threshold = 10 im = gen_image(size, [x], [y], [f], sky, rdnoise, model='gaussian', sigma=sigma, theta=theta) sources = starfind(im, threshold, sky, rdnoise, fwhm) assert_equal(len(sources), 1) assert_almost_equal(sources['x'], x, decimal=0) assert_almost_equal(sources['y'], y, decimal=0) assert_almost_equal(sources.meta['astropop fwhm'], sigma * 2.355, decimal=1)
def test_starfind_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 = starfind(im, 5, 800, 10) 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_starfind_rejection(self): size = (128, 128) pos_x = [20, 60, 100, 40, 80, 50] pos_y = [20, 30, 40, 50, 60, 85] sky = 70 rdnoise = 20 flux = [30000] * 6 theta = 0 fwhm = 3 sig_base = gaussian_fwhm_to_sigma * fwhm sigma_x = np.array([1, 0.5, 1, 2.0, 0.1, 1]) * sig_base sigma_y = np.array([1, 1.0, 1, 0.5, 0.1, 1]) * sig_base 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 = starfind(im, threshold, sky, rdnoise, sharp_limit=(0.3, 0.6), round_limit=(-0.5, 0.5)) assert_equal(len(sources), 3) assert_almost_equal(sources['x'], [20, 100, 50], decimal=0) assert_almost_equal(sources['y'], [20, 40, 85], decimal=0) assert_almost_equal(sources.meta['astropop fwhm'], fwhm, decimal=1)