def inner(): # These imports are necessary to be able to execute in a forkserver context; it does not copy the full memory space, so # we'd have to rely on the target to know the imports from thesis_lib.testdata.recipes import scopesim_grid from thesis_lib.testdata.helpers import lowpass import numpy as np return scopesim_grid(seed=seed, N1d=25, perturbation=2., psf_transform=lowpass(), magnitude=lambda N: np.random.uniform(18, 24, N))
def test_lowpass(xsize, ysize): img = np.ones((ysize, xsize)) transform = lowpass(5) assert np.all(np.isclose(centroid(transform(img)), center_of_image(img)))
def test_single_star_image_scopesim_shift(single_star): """This test should not fail after scopesim fixes the coordinate transformation""" img, table = single_star xcenter, ycenter = center_of_image(img) xref, yref = table[INPUT_TABLE_NAMES[X]][0], table[INPUT_TABLE_NAMES[Y]][0] assert np.abs(xcenter-xref) < 0.01 assert np.abs(ycenter-yref) < 0.01 @pytest.mark.parametrize( 'generator_args', [{'N1d':3, 'border':128, 'perturbation':0}, {'N1d':3, 'border':128, 'perturbation':2}, {'N1d':3, 'border':128, 'perturbation':2, 'psf_transform': lowpass()}, {'N1d':3, 'border':128, 'perturbation':2, 'custom_subpixel_psf': make_anisocado_model()}, {'N1d':3, 'border':128, 'perturbation':2, 'custom_subpixel_psf': make_anisocado_model(lowpass=5)} ]) def test_grid(printer, generator_args): with work_in(Config.instance().scopesim_working_dir): img, table = scopesim_grid(**generator_args) xref, yref = table[INPUT_TABLE_NAMES[X]], table[INPUT_TABLE_NAMES[Y]] x, y = centroid_sources(img, xref, yref, box_size=7, centroid_func=centroid_quadratic) xdev = np.abs(x-xref) ydev = np.abs(y-yref) printer(f'{xdev=}\n{ydev=}') #TODO this is pretty shit accuracy sometimes...
def psf_effect_even(request): # This may not make sense σ = request.param if σ: return scopesim_helper.make_psf(N=512, transform=lowpass(σ)) else: return scopesim_helper.make_psf(N=512)
def psf_effect_odd(request): σ = request.param if σ: return scopesim_helper.make_psf(N=511, transform=lowpass(σ)) else: return scopesim_helper.make_psf(N=511)