AnisoCADO 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of AnisoCADO might be problematic. Click here for more details.

@@ -0,0 +1,62 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Various tests to see if things run, no assertions."""
3
+
4
+ import numpy as np
5
+
6
+ from matplotlib import pyplot as plt
7
+
8
+ from anisocado import AnalyticalScaoPsf
9
+ from anisocado.misc import on_axis_strehl_for_kernel_size
10
+
11
+ PLOTS = False
12
+
13
+
14
+ class TestMakeStrehlMap:
15
+ def test_make_a_strehl_map_over_a_grid_on_the_focal_plane(self):
16
+ psf = AnalyticalScaoPsf(N=128, wavelength=2.15)
17
+ x, y = np.mgrid[-50:51:20, -50:51:20]
18
+
19
+ sr = np.zeros(x.shape)
20
+ for i in range(len(x)):
21
+ for j in range(len(y)):
22
+ psf.shift_off_axis(x[i, j], y[i, j])
23
+ sr[i, j] = psf.strehl_ratio
24
+ print(np.max(sr))
25
+
26
+ if PLOTS:
27
+ plt.imshow(sr)
28
+ plt.contourf(x, y, sr, np.arange(0, 1, 0.05))
29
+ plt.colorbar()
30
+ plt.show()
31
+
32
+
33
+ class TestStrehlRatiosForDifferentSizedKernels:
34
+ def test_how_much_does_the_SR_change_for_kernel_size_increase(self):
35
+ side_length = [64, 128, 256, 512, 1024]
36
+ sr = on_axis_strehl_for_kernel_size(side_length, wavelength=2.15)
37
+ if PLOTS:
38
+ plt.plot(side_length, sr)
39
+ plt.show()
40
+
41
+
42
+ class TestPsfsAlongXaxis:
43
+ def test_strehl_ratio_along_x_axis(self):
44
+ for wave in [0.8, 0.9, 1.1, 1.6, 2.15]:
45
+ psf = AnalyticalScaoPsf(N=128, wavelength=wave)
46
+ x, y = np.mgrid[0:41:1, 0:1:1]
47
+
48
+ sr = np.zeros(x.shape)
49
+ for i in range(x.shape[0]):
50
+ for j in range(x.shape[1]):
51
+ psf.shift_off_axis(x[i, j], y[i, j])
52
+ sr[i, j] = psf.strehl_ratio
53
+
54
+ if PLOTS:
55
+ print(wave, np.sum(psf._kernel_sum))
56
+ plt.plot(x.flatten(), sr, label=f"{wave} um")
57
+
58
+ if PLOTS:
59
+ plt.legend()
60
+ plt.xlabel("Distance from NGS [arcsec]")
61
+ plt.ylabel("Strehl Ratio")
62
+ plt.show()
@@ -0,0 +1,100 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Unit tests for misc functions."""
3
+
4
+ import pytest
5
+
6
+ import numpy as np
7
+ import matplotlib.pyplot as plt
8
+ from astropy.io import fits
9
+
10
+ from anisocado import misc
11
+
12
+
13
+ @pytest.fixture(scope="class")
14
+ def basic_fv_psf():
15
+ n = 30
16
+ coords = [(-n, n), (0, n), (n, n),
17
+ (-n, 0), (0, 0), (n, 0),
18
+ (-n, -n), (0, -n), (n, -n)]
19
+ waves = [0.9, 1.1, 1.6, 2.15]
20
+ hdu = misc.make_simcado_psf_file(coords=coords, wavelengths=waves, N=128)
21
+ return hdu
22
+
23
+
24
+ class TestSimcadoPsfFile:
25
+ def test_throws_error_with_no_input(self):
26
+ with pytest.raises(TypeError):
27
+ misc.make_simcado_psf_file()
28
+
29
+ def test_returns_hdulist_for_basic_input(self):
30
+ hdu = misc.make_simcado_psf_file(
31
+ coords=[(0, 0)],
32
+ wavelengths=[2.15],
33
+ N=128,
34
+ )
35
+ assert isinstance(hdu, fits.HDUList)
36
+ assert isinstance(hdu[1], fits.BinTableHDU)
37
+ assert len(hdu) == 3
38
+ assert hdu[2].data.shape == (1, 128, 128)
39
+
40
+ def test_returns_full_hdulist_for_full_input(self):
41
+ n = 30
42
+ coords = [(0, 0), (-n, -n), (n, -n), (n, n), (-n, n)]
43
+ waves = [0.9, 1.1, 1.6, 2.15]
44
+ hdu = misc.make_simcado_psf_file(coords=coords, wavelengths=waves,
45
+ N=128)
46
+ assert len(hdu) == len(waves) + 2
47
+ assert hdu[2].data.shape == (len(coords), 128, 128)
48
+ assert hdu[2].header["CDELT1"] == 0.004 / 3600.
49
+
50
+
51
+ @pytest.mark.usefixtures("basic_fv_psf")
52
+ class TestFvpsfFileConsistencyChecks:
53
+ def test_has_correct_keywords_in_ext0(self, basic_fv_psf):
54
+ for key in ["AUTHOR", "DATE_CRE", "DATE_MOD", "SOURCE", "STATUS",
55
+ "ETYPE", "ECAT", "EDATA"]:
56
+ assert key in basic_fv_psf[0].header
57
+
58
+ def test_has_catalogue_psf(self, basic_fv_psf):
59
+ ecat = basic_fv_psf[0].header["ECAT"]
60
+ cat_hdu = basic_fv_psf[ecat]
61
+ for key in ["NUMPSFS", "CATTYPE", "CUNIT1"]:
62
+ assert key in cat_hdu.header
63
+
64
+ if cat_hdu.header["CATTYPE"] == "table":
65
+ assert isinstance(cat_hdu.data, (fits.BinTableHDU, fits.FITS_rec))
66
+
67
+ elif basic_fv_psf[ecat].header["CATTYPE"] == "image":
68
+ assert isinstance(cat_hdu.data, fits.ImageHDU)
69
+ for key in ["CRVAL1", "CRPIX1", "CDELT1"]:
70
+ assert key in cat_hdu.header
71
+
72
+ def test_has_the_right_number_of_layers_per_psf_hdu(self, basic_fv_psf):
73
+ ecat = basic_fv_psf[0].header["ECAT"]
74
+ cat_hdu = basic_fv_psf[ecat]
75
+ n_layers = len(set(cat_hdu.data["layer"]))
76
+
77
+ edata = basic_fv_psf[0].header["EDATA"]
78
+ data_indexes = range(edata, len(basic_fv_psf))
79
+ for ii in data_indexes:
80
+ assert basic_fv_psf[ii].data.shape[0] == n_layers
81
+ for key in ["CRVAL1", "CRPIX1", "CDELT1", "WAVE0"]:
82
+ assert key in basic_fv_psf[ii].header
83
+
84
+ def plot_psfs(self, basic_fv_psf):
85
+ for psf_hdu in basic_fv_psf[2:]:
86
+ for i in range(len(psf_hdu.data)):
87
+ plt.subplot(3, 3, i + 1)
88
+ plt.imshow(psf_hdu.data[i, :, :].T, origin="l", norm="log")
89
+
90
+ plt.show()
91
+
92
+ def print_coords(self):
93
+ # coords = psf.field_positions_for_simcado_psf()
94
+ # waves = [0.8, 0.9, 1.05, 1.2, 1.5, 1.7, 2.0, 2.2]
95
+ # hdu = psf.make_simcado_psf_file()
96
+
97
+ map = misc.make_strehl_map_from_table([(0, 0)])
98
+ plt.imshow(map)
99
+ plt.show()
100
+ print(np.unique(map))
@@ -0,0 +1,89 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Unit tests for AnalyticalScaoPsf."""
3
+
4
+ import pytest
5
+
6
+ import numpy as np
7
+ from matplotlib import pyplot as plt
8
+ from astropy.io import fits
9
+
10
+ from anisocado.psf import AnalyticalScaoPsf
11
+
12
+
13
+ PLOTS = False
14
+
15
+
16
+ class TestInit:
17
+ def test_initialises_with_nothing(self):
18
+ assert isinstance(AnalyticalScaoPsf(), AnalyticalScaoPsf)
19
+
20
+ def test_initialises_with_bunch_of_keywords(self):
21
+ psf = AnalyticalScaoPsf(N=256, wavelengthIR=1.2e-6)
22
+ assert isinstance(psf, AnalyticalScaoPsf)
23
+
24
+ def test_throws_warning_if_keyword_not_spelt_correctly(self):
25
+ psf = AnalyticalScaoPsf(N=256, wavelengthIR=1.2e-6, hello="world")
26
+ assert isinstance(psf, AnalyticalScaoPsf)
27
+
28
+ def test_on_axis_psf_is_made(self):
29
+ psf = AnalyticalScaoPsf(N=512)
30
+ assert isinstance(psf.psf_on_axis, np.ndarray)
31
+
32
+ if PLOTS:
33
+ plt.imshow(psf.psf_on_axis.T,
34
+ origin="lower", norm="log", vmin=1e-7)
35
+ plt.show()
36
+
37
+ def test_kernel_sums_to_one(self):
38
+ psf = AnalyticalScaoPsf(N=256)
39
+ assert psf.psf_latest.sum() == pytest.approx(1)
40
+
41
+
42
+ class TestShiftPSF:
43
+ def test_psf_blurs_when_shifted(self):
44
+ psf = AnalyticalScaoPsf(N=1024)
45
+ sr_orig = psf.strehl_ratio
46
+
47
+ psf.shift_off_axis(0, 10)
48
+ sr_last = psf.strehl_ratio
49
+
50
+ assert sr_last < sr_orig
51
+
52
+ if PLOTS:
53
+ plt.subplot(121)
54
+ plt.imshow(psf.psf_on_axis.T,
55
+ origin="lower", norm="log", vmin=3e-6)
56
+ plt.colorbar()
57
+
58
+ plt.subplot(122)
59
+ plt.imshow(psf.psf_latest.T,
60
+ origin="lower", norm="log", vmin=3e-6)
61
+ plt.colorbar()
62
+ plt.show()
63
+
64
+ def test_kernel_sums_to_one(self):
65
+ psf = AnalyticalScaoPsf(N=512)
66
+ psf.shift_off_axis(0, 0)
67
+ assert psf.psf_latest.sum() == pytest.approx(1)
68
+
69
+
70
+ class TestHDUProperty:
71
+ def test_returns_fits_imagehdu(self):
72
+ psf = AnalyticalScaoPsf(N=512)
73
+ psf.shift_off_axis(10, 10)
74
+ hdu = psf.hdu
75
+ assert isinstance(hdu, fits.ImageHDU)
76
+ assert hdu.header["CDELT1"] == 4 / (3600 * 1000.)
77
+ assert hdu.header["CRVAL1"] == 10 / 3600.
78
+
79
+ if PLOTS:
80
+ plt.imshow(hdu.data.T, origin="l", norm="log")
81
+ plt.show()
82
+
83
+
84
+ class TestRNG:
85
+ def test_predictable(self):
86
+ psf_a = AnalyticalScaoPsf(N=512, seed=9999999)
87
+ psf_b = AnalyticalScaoPsf(N=512, seed=9999999)
88
+
89
+ np.testing.assert_array_equal(psf_a.psf_on_axis, psf_b.psf_on_axis)
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.3
2
+ Name: AnisoCADO
3
+ Version: 0.4.0
4
+ Summary: Generate off-axis SCAO PSFs for the ELT
5
+ License: GPL-3.0-or-later
6
+ Keywords: astronomy
7
+ Author: Kieran Leschinski
8
+ Author-email: kieran.leschinski@unive.ac.at
9
+ Maintainer: Kieran Leschinski
10
+ Maintainer-email: kieran.leschinski@unive.ac.at
11
+ Requires-Python: >=3.10,<3.14
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
21
+ Requires-Dist: astropy (>=6.1.7,<8.0.0)
22
+ Requires-Dist: matplotlib (>=3.10.1,<4.0.0)
23
+ Requires-Dist: numpy (>=1.26.4,<2.3.0) ; python_version >= "3.10" and python_version < "3.13"
24
+ Requires-Dist: numpy (>=2.2.6,<3.0.0) ; python_version >= "3.13"
25
+ Project-URL: Bug Tracker, https://github.com/AstarVienna/AnisoCADO/issues
26
+ Project-URL: Changelog, https://github.com/AstarVienna/AnisoCADO/releases
27
+ Project-URL: Documentation, https://anisocado.readthedocs.io/en/latest/
28
+ Project-URL: Repository, https://github.com/AstarVienna/AnisoCADO/
29
+ Description-Content-Type: text/markdown
30
+
31
+ # AnisoCADO
32
+
33
+ [![Tests](https://github.com/AstarVienna/AnisoCADO/actions/workflows/tests.yml/badge.svg)](https://github.com/AstarVienna/AnisoCADO/actions/workflows/tests.yml)
34
+ [![Documentation Status](https://readthedocs.org/projects/anisocado/badge/?version=latest)](https://anisocado.readthedocs.io/en/latest/?badge=latest)
35
+ [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
36
+ ![dev version](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FAstarVienna%2FAnisoCADO%2Fmain%2Fpyproject.toml&query=%24.project.version&label=dev%20version&color=teal)
37
+
38
+ [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
39
+ ![GitHub Release Date](https://img.shields.io/github/release-date/AstarVienna/AnisoCADO)
40
+ [![PyPI - Version](https://img.shields.io/pypi/v/AnisoCADO)](https://pypi.org/project/AnisoCADO/)
41
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/AnisoCADO)
42
+
43
+
44
+ A python package to generate off-axis PSFs for the SCAO mode for the ELT
45
+
46
+ Please note: this package is not yet finished yet! The code is fine, but the
47
+ documentation is lacking.
48
+
49
+ ## Documentation
50
+
51
+ Apropos documentation. It can be found here:
52
+ [https://anisocado.readthedocs.io/en/latest/index.html](https://anisocado.readthedocs.io/en/latest/index.html)
53
+
@@ -0,0 +1,14 @@
1
+ anisocado/__init__.py,sha256=J-25dIVp8MNV4Wvzg_RX9373kccqDVhnuAW6FeYSZGs,309
2
+ anisocado/_anisocado.py,sha256=-SbAZ9jATckuKtDC8qko0gJl9YM0PXmf7e6xuXdcDRM,9668
3
+ anisocado/misc.py,sha256=4HRkwr1JavEcsvMB3Q7zJmwTwZs324uikdu3bAgfags,6243
4
+ anisocado/psf.py,sha256=flXK2EvTYGhwQsd3nUZX2JvhghBK9FDjBIxAyeeOsu4,17410
5
+ anisocado/psf_utils.py,sha256=D4fbm8w60LtJiDT5-OZzpwBnTSGoiRngimYMg-kKl6M,23178
6
+ anisocado/pupil_utils.py,sha256=c-uRxucVtJMbKSgHcnev52aumpmprkOLko224bqKPjc,37172
7
+ anisocado/tests/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
8
+ anisocado/tests/test_playing_around.py,sha256=cppxriCdCnQUjtkJ8DZmdyaZ-0csw1UFpofK3ldDhpI,1899
9
+ anisocado/tests/test_psf_functions.py,sha256=i_Ke0NjapEgiRIAVVKPRpQrUrJaSDjJj1ebnf0FZAhY,3480
10
+ anisocado/tests/test_scao_psf.py,sha256=6BvAjqAkh1hRg9AtW8Mf001zmET-6uDUUjcOf0jeIls,2556
11
+ anisocado-0.4.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
12
+ anisocado-0.4.0.dist-info/METADATA,sha256=SMee_1eUTNhfKPCv73dEcpnxqudVc-PpmWtOjw8Qtms,2770
13
+ anisocado-0.4.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
14
+ anisocado-0.4.0.dist-info/RECORD,,
@@ -1,5 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: poetry-core 2.1.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
-
@@ -1,52 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: AnisoCADO
3
- Version: 0.3.0
4
- Summary: Generate off-axis SCAO PSFs for the ELT
5
- Author: Eric Gendron
6
- Author-email: Kieran Leschinski <kieran.leschinski@unive.ac.at>
7
- Maintainer-email: Kieran Leschinski <kieran.leschinski@unive.ac.at>, Hugo Buddelmeijer <hugo@buddelmeijer.nl>
8
- License: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
9
- Project-URL: Homepage, https://anisocado.readthedocs.io/en/latest/
10
- Project-URL: Source, https://github.com/AstarVienna/AnisoCADO/
11
- Project-URL: Bug Reports, https://github.com/AstarVienna/AnisoCADO/issues
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
14
- Classifier: Operating System :: OS Independent
15
- Classifier: Intended Audience :: Science/Research
16
- Classifier: Topic :: Scientific/Engineering :: Astronomy
17
- Requires-Python: >=3.8
18
- Description-Content-Type: text/markdown
19
- License-File: LICENSE
20
- Requires-Dist: numpy (>=1.18.0)
21
- Requires-Dist: astropy (>=4.0)
22
- Requires-Dist: matplotlib (>=3.2.0)
23
- Provides-Extra: dev
24
- Requires-Dist: scipy ; extra == 'dev'
25
- Provides-Extra: docs
26
- Requires-Dist: sphinx (>=4.3.0) ; extra == 'docs'
27
- Requires-Dist: sphinx-rtd-theme (>=0.5.1) ; extra == 'docs'
28
- Requires-Dist: sphinxcontrib-apidoc ; extra == 'docs'
29
- Requires-Dist: numpydoc ; extra == 'docs'
30
- Provides-Extra: test
31
- Requires-Dist: pytest (>=5.0.0) ; extra == 'test'
32
- Requires-Dist: pytest-cov ; extra == 'test'
33
-
34
- # AnisoCADO
35
-
36
- [![Tests](https://github.com/AstarVienna/AnisoCADO/actions/workflows/tests.yml/badge.svg)](https://github.com/AstarVienna/AnisoCADO/actions/workflows/tests.yml)
37
- [![Documentation Status](https://readthedocs.org/projects/anisocado/badge/?version=latest)](https://anisocado.readthedocs.io/en/latest/?badge=latest)
38
-
39
- [![Build Status](http://github-actions.40ants.com/AstarVienna/AnisoCADO/matrix.svg)](https://github.com/AstarVienna/AnisoCADO)
40
-
41
- [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
42
-
43
-
44
- A python package to generate off-axis PSFs for the SCAO mode for the ELT
45
-
46
- Please note: this package is not yet finished yet! The code is fine, but the
47
- documentation is lacking.
48
-
49
- ## Documentation
50
-
51
- Apropos documentation. It can be found here:
52
- [https://anisocado.readthedocs.io/en/latest/index.html](https://anisocado.readthedocs.io/en/latest/index.html)
@@ -1,12 +0,0 @@
1
- anisocado/__init__.py,sha256=k9knIPJ4-n-Ec52GePTgttwEmpQPSxaA_AI77Ky17aA,107
2
- anisocado/_anisocado.py,sha256=bc5pffn7-yHVy3iZUrHQugb40kcqw0i8dMLNR60Q--U,10116
3
- anisocado/misc.py,sha256=2CH1dOxUmdOZDUMFDbjRVSMLfQkMbmWphcdugYy5Q5o,6101
4
- anisocado/psf.py,sha256=F_4prXDKP_eI8C9B-vDnIcHkQ1srXt9j5UJahs9YBz0,16782
5
- anisocado/psf_utils.py,sha256=kX-RGhGLDBRc31CyOUMdZoLJXI6lcRbwsWHMuQ-P36Q,23379
6
- anisocado/pupil_utils.py,sha256=Qao9jv_c2smOrcdqmyxBme5V00NYkIVX1VGLK-Is8oc,36858
7
- anisocado/version.py,sha256=ta0Fge42PF4lOHwxmBa6ij23TVXjpCQBB46tB5SE020,104
8
- AnisoCADO-0.3.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
9
- AnisoCADO-0.3.0.dist-info/METADATA,sha256=jO9kpegkZDIWi1n6g4qUsJgv5AlPBgCNRBuw5hhAvg0,2359
10
- AnisoCADO-0.3.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
11
- AnisoCADO-0.3.0.dist-info/top_level.txt,sha256=PEq0LVCCihooKMxK5ZCHLIl_7gTMnUgPXZsxNzW417Q,10
12
- AnisoCADO-0.3.0.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- anisocado
anisocado/version.py DELETED
@@ -1,3 +0,0 @@
1
- from importlib import metadata
2
- version = metadata.version(__package__)
3
- date = '2023-07-10 10:00:00 GMT'