Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_slopecovmat_init():
threads = 1
n_wfs = 3
telescope_diameter = 8.
nx_subaps = 10
n_layers = 3
layer_altitudes = numpy.linspace(0, 20000, n_layers)
layer_r0s = [1] * n_layers
layer_L0s = [25.] * n_layers
asterism_radius = 10
subap_diameters = [telescope_diameter / nx_subaps] * n_wfs
pupil_masks = [aotools.circle(nx_subaps / 2., nx_subaps)] * n_wfs
gs_altitudes = [90000] * n_wfs
gs_positions = [
[asterism_radius, 0],
[numpy.sin(numpy.pi / 3.) * asterism_radius, numpy.cos(numpy.pi / 3.) * asterism_radius],
[numpy.sin(numpy.pi / 3.) * asterism_radius, -numpy.cos(numpy.pi / 3.) * asterism_radius],
[-numpy.sin(numpy.pi / 3.) * asterism_radius, numpy.cos(numpy.pi / 3.) * asterism_radius],
[-numpy.sin(numpy.pi / 3.) * asterism_radius, -numpy.cos(numpy.pi / 3.) * asterism_radius],
[-asterism_radius, 0]]
wfs_magnifications = [1.] * n_wfs
pupil_offsets = [[0, 0]] * n_wfs
wfs_rotations = [0] * n_wfs
wfs_wavelengths = [550e-9] * n_wfs
cov_mat = aotools.CovarianceMatrix(n_wfs, pupil_masks, telescope_diameter, subap_diameters, gs_altitudes, gs_positions,
wfs_wavelengths,
n_layers, layer_altitudes, layer_r0s, layer_L0s, threads)
def test_slopecovmat_makecovmat_multithreaded():
threads = 2
n_wfs = 3
telescope_diameter = 8.
nx_subaps = 10
n_layers = 3
layer_altitudes = numpy.linspace(0, 20000, n_layers)
layer_r0s = [1] * n_layers
layer_L0s = [25.] * n_layers
asterism_radius = 10
subap_diameters = [telescope_diameter / nx_subaps] * n_wfs
pupil_masks = [aotools.circle(nx_subaps / 2., nx_subaps)] * n_wfs
gs_altitudes = [90000] * n_wfs
gs_positions = [
[asterism_radius, 0],
[numpy.sin(numpy.pi / 3.) * asterism_radius, numpy.cos(numpy.pi / 3.) * asterism_radius],
[numpy.sin(numpy.pi / 3.) * asterism_radius, -numpy.cos(numpy.pi / 3.) * asterism_radius],
[-numpy.sin(numpy.pi / 3.) * asterism_radius, numpy.cos(numpy.pi / 3.) * asterism_radius],
[-numpy.sin(numpy.pi / 3.) * asterism_radius, -numpy.cos(numpy.pi / 3.) * asterism_radius],
[-asterism_radius, 0]]
wfs_magnifications = [1.] * n_wfs
pupil_offsets = [[0, 0]] * n_wfs
wfs_rotations = [0] * n_wfs
wfs_wavelengths = [550e-9] * n_wfs
cov_mat = aotools.CovarianceMatrix(n_wfs, pupil_masks, telescope_diameter, subap_diameters, gs_altitudes, gs_positions,
wfs_wavelengths,
n_layers, layer_altitudes, layer_r0s, layer_L0s, threads)
def test_photons_per_mag():
mask = circle(2, 5)
photons = astronomy.photons_per_mag(5.56, mask, 0.5, 0.3, 10)
assert type(photons) == float
def test_slopecovmat_makecovmat():
threads = 1
n_wfs = 3
telescope_diameter = 8.
nx_subaps = 10
n_layers = 3
layer_altitudes = numpy.linspace(0, 20000, n_layers)
layer_r0s = [1] * n_layers
layer_L0s = [25.] * n_layers
asterism_radius = 10
subap_diameters = [telescope_diameter / nx_subaps] * n_wfs
pupil_masks = [aotools.circle(nx_subaps / 2., nx_subaps)] * n_wfs
gs_altitudes = [90000] * n_wfs
gs_positions = [
[asterism_radius, 0],
[numpy.sin(numpy.pi / 3.) * asterism_radius, numpy.cos(numpy.pi / 3.) * asterism_radius],
[numpy.sin(numpy.pi / 3.) * asterism_radius, -numpy.cos(numpy.pi / 3.) * asterism_radius],
[-numpy.sin(numpy.pi / 3.) * asterism_radius, numpy.cos(numpy.pi / 3.) * asterism_radius],
[-numpy.sin(numpy.pi / 3.) * asterism_radius, -numpy.cos(numpy.pi / 3.) * asterism_radius],
[-asterism_radius, 0]]
wfs_magnifications = [1.] * n_wfs
pupil_offsets = [[0, 0]] * n_wfs
wfs_rotations = [0] * n_wfs
wfs_wavelengths = [550e-9] * n_wfs
cov_mat = aotools.CovarianceMatrix(n_wfs, pupil_masks, telescope_diameter, subap_diameters, gs_altitudes, gs_positions,
wfs_wavelengths,
n_layers, layer_altitudes, layer_r0s, layer_L0s, threads)
def test_findActiveSubaps_with_returnFill():
subapertures = 10
mask = circle(4, 10)
threshold = .6
active_subapertures, fill_factors = wfs.findActiveSubaps(subapertures, mask, threshold, returnFill=True)
assert active_subapertures.shape == (52, 2)
assert len(fill_factors) == 52
def test_findActiveSubaps():
subapertures = 10
mask = circle(4, 10)
threshold = .6
active_subapertures = wfs.findActiveSubaps(subapertures, mask, threshold)
assert active_subapertures.shape == (52, 2)
def test_covtomorecon():
threads = 1
n_wfs = 3
telescope_diameter = 8.
nx_subaps = 10
n_layers = 3
layer_altitudes = numpy.linspace(0, 20000, n_layers)
layer_r0s = [1] * n_layers
layer_L0s = [25.] * n_layers
asterism_radius = 10
subap_diameters = [telescope_diameter / nx_subaps] * n_wfs
pupil_masks = [aotools.circle(nx_subaps / 2., nx_subaps)] * n_wfs
gs_altitudes = [90000] * n_wfs
gs_positions = [
[asterism_radius, 0],
[numpy.sin(numpy.pi / 3.) * asterism_radius, numpy.cos(numpy.pi / 3.) * asterism_radius],
[numpy.sin(numpy.pi / 3.) * asterism_radius, -numpy.cos(numpy.pi / 3.) * asterism_radius],
[-numpy.sin(numpy.pi / 3.) * asterism_radius, numpy.cos(numpy.pi / 3.) * asterism_radius],
[-numpy.sin(numpy.pi / 3.) * asterism_radius, -numpy.cos(numpy.pi / 3.) * asterism_radius],
[-asterism_radius, 0]]
wfs_magnifications = [1.] * n_wfs
pupil_offsets = [[0, 0]] * n_wfs
wfs_rotations = [0] * n_wfs
wfs_wavelengths = [550e-9] * n_wfs
cov_mat = aotools.CovarianceMatrix(n_wfs, pupil_masks, telescope_diameter, subap_diameters, gs_altitudes, gs_positions,
wfs_wavelengths,
n_layers, layer_altitudes, layer_r0s, layer_L0s, threads)
def test_make_subaps_2d():
data = numpy.random.random((10, 2, 52))
mask = circle(4, 10)
sub_apertures_2d = wfs.make_subaps_2d(data, mask)
assert sub_apertures_2d.shape == (10, 2, 10, 10)
def test_computeFillFactor():
mask = circle(49, 100)
sub_aperture_positions = numpy.array(([[10, 10], [10, 0]]))
sub_aperture_spacing = 10
fill_factor = wfs.computeFillFactor(mask, sub_aperture_positions, sub_aperture_spacing)
assert len(fill_factor) == 2
def test_propagation_conserves_intensity():
screen = phasescreen.ft_phase_screen(0.16, 512, 4.2 / 512, 100, 0.01)
# Input E Field
E = numpy.exp(1j * screen)
Em = E * circle(150, 512)
sum1 = (abs(Em) ** 2).sum()
prop1 = opticalpropagation.angularSpectrum(Em, 500e-9, 4.2 / 512, 4.2 / 512, 10000.)
sum2 = (abs(prop1) ** 2).sum()
assert numpy.allclose(sum1, sum2)