def test_returns_currsys_edge_waves_for_no_input(self, ncpa_kwargs, fov_Ks): ncpa = NonCommonPathAberration(**ncpa_kwargs) waves = ncpa.fov_grid() wave_min = rc.__currsys__["!SIM.spectral.wave_min"] wave_max = rc.__currsys__["!SIM.spectral.wave_max"] assert waves[0].to(u.um).value == approx(wave_min) assert waves[-1].to(u.um).value == approx(wave_max)
def test_convolves_kernel_with_fov_image(self, ncpa_kwargs, fov_Ks): ncpa = NonCommonPathAberration(**ncpa_kwargs) pre_max_flux = np.max(fov_Ks.data) fov_Ks = ncpa.apply_to(fov_Ks) post_max_flux = np.max(fov_Ks.data) assert post_max_flux/pre_max_flux == approx(0.954, rel=0.002) if PLOTS: plt.imshow(fov_Ks.image[40:60, 40:60], norm=LogNorm()) plt.show()
def test_ignores_classes_other_than_fov(self, ncpa_kwargs): implane = ImagePlane(_implane_header()) implane.hdu.data[1, 1] = 1 ncpa = NonCommonPathAberration(**ncpa_kwargs) new_implane = ncpa.apply_to(implane) assert np.all(new_implane.data == implane.data) if PLOTS: plt.imshow(new_implane.image[:5,:5]) plt.show()
def test_returns_kernel_with_expected_central_peak_value( self, fov_Ks, ncpa_kwargs, waves, strehl): ncpa = NonCommonPathAberration(**ncpa_kwargs) fov_Ks.meta["wave_min"] = waves[0] fov_Ks.meta["wave_max"] = waves[1] kernel = ncpa.get_kernel(fov_Ks) assert np.abs(np.max(kernel) / strehl - 1) < 0.01 assert kernel.shape == (3, 3) assert np.sum(kernel) == approx(1) if PLOTS: plt.imshow(kernel, norm=LogNorm(), vmax=1, vmin=1e-4) plt.colorbar() plt.show()
def test_returns_total_wfe_in_units_of_table(self, ncpa_kwargs, fov_Ks): ncpa = NonCommonPathAberration(**ncpa_kwargs) assert ncpa.total_wfe.value == approx(76.158, rel=1e-5)
def test_initialises_with_file(self): kwargs = {"filename": "test_NCPAs_table.dat", "pixel_scale": 0.004} ncpa = NonCommonPathAberration(**kwargs) assert ncpa.table["wfe_rms"][0] == 20
def test_initialises_with_arrays(self, ncpa_kwargs): ncpa = NonCommonPathAberration(**ncpa_kwargs) assert ncpa.table["wfe_rms"][0] == 20
def test_initialises_with_nothing_but_pixel_scale(self): ncpa = NonCommonPathAberration(pixel_scale=0.004) assert isinstance(ncpa, NonCommonPathAberration)