Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
cov_mat.make_covariance_matrix()
tomo_recon = cov_mat.make_tomographic_reconstructor()
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)
covariance_matrix_multithread = cov_mat.make_covariance_matrix()
# Check consistant with single thread implementation
cov_mat.threads = 1
covariance_matrix = cov_mat.make_covariance_matrix()
assert numpy.array_equal(covariance_matrix, covariance_matrix_multithread)
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)
covariance_matrix = cov_mat.make_covariance_matrix()
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
t1 = time.time()
for i in range(N):
print("\nIteration {}".format(i))
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)
cov_mat.make_covariance_matrix()
t2 = time.time()
time_taken = (t2 - t1) / N
covmat_per_sec = 1. / time_taken
print("Time for 1 Covariance Matrix: {}s".format(time_taken))
print("Covariance Matrics per second: {} cps".format(covmat_per_sec))
from matplotlib import pyplot
pyplot.imshow(cov_mat.covariance_matrix)
pyplot.show()
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)