coronagraphoto 1.0.0__tar.gz

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.
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "monthly"
@@ -0,0 +1,50 @@
1
+ name: Publish to PyPI
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ build:
7
+ name: Build distribution
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - name: Set up Python
13
+ uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.x"
16
+ - name: Install pypa/build
17
+ run: >-
18
+ python3 -m
19
+ pip install
20
+ build
21
+ --user
22
+ - name: Build a binary wheel and a source tarball
23
+ run: python3 -m build
24
+ - name: Store the distribution packages
25
+ uses: actions/upload-artifact@v4
26
+ with:
27
+ name: python-package-distributions
28
+ path: dist/
29
+
30
+ publish-to-pypi:
31
+ name: >-
32
+ Publish Python distribution to PyPI
33
+ if: startsWith(github.ref, 'refs/tags/')
34
+ needs:
35
+ - build
36
+ runs-on: ubuntu-latest
37
+ environment:
38
+ name: pypi
39
+ url: https://pypi.org/p/coronagraphoto
40
+ permissions:
41
+ id-token: write
42
+
43
+ steps:
44
+ - name: Download all the dists
45
+ uses: actions/download-artifact@v4
46
+ with:
47
+ name: python-package-distributions
48
+ path: dist/
49
+ - name: Publish distribution to PyPI
50
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,24 @@
1
+ on:
2
+ push:
3
+ branches:
4
+ - main
5
+
6
+ permissions:
7
+ contents: write
8
+ pull-requests: write
9
+
10
+ name: release-please
11
+
12
+ jobs:
13
+ release-please:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: google-github-actions/release-please-action@v4
17
+ with:
18
+ # this assumes that you have created a personal access token
19
+ # (PAT) and configured it as a GitHub action secret named
20
+ # `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important).
21
+ token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
22
+ # this is a built-in strategy in release-please, see "Action Inputs"
23
+ # for more options
24
+ release-type: simple
@@ -0,0 +1,163 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ #.idea/
161
+
162
+ input/
163
+ !input/settings/example.toml
@@ -0,0 +1,22 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: "v4.5.0"
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ - id: name-tests-test
7
+ - id: end-of-file-fixer
8
+ - id: no-commit-to-branch
9
+ - repo: https://github.com/astral-sh/ruff-pre-commit
10
+ rev: v0.3.4
11
+ hooks:
12
+ # Run the linter.
13
+ - id: ruff
14
+ args: [ --fix ]
15
+ # Run the formatter.
16
+ - id: ruff-format
17
+ - repo: https://github.com/compilerla/conventional-pre-commit
18
+ rev: v3.1.0
19
+ hooks:
20
+ - id: conventional-pre-commit
21
+ stages: [commit-msg]
22
+ args: []
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 (2024-03-22)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * adding dependabot ([5a7fe8e](https://github.com/CoreySpohn/coronagraphoto/commit/5a7fe8e613a436155293495a44fb121d98819f16))
9
+ * Adding workflow ([4f020b2](https://github.com/CoreySpohn/coronagraphoto/commit/4f020b26ce70578127a3560af6947c1d43b1dfaf))
10
+ * Commenting out not implemented code ([49d9b0a](https://github.com/CoreySpohn/coronagraphoto/commit/49d9b0a40beb106a432fe501d4f5d01459162e41))
11
+ * fixing more ruff linting things ([1dbb5e9](https://github.com/CoreySpohn/coronagraphoto/commit/1dbb5e90553949a5d9d186df91868a4f48c3ea0a))
12
+ * hatch version control ([a1f342c](https://github.com/CoreySpohn/coronagraphoto/commit/a1f342ce8b883076205bb832bbdd9f964bede3fa))
13
+ * Linting ([bca15f0](https://github.com/CoreySpohn/coronagraphoto/commit/bca15f0e096ce67466117c92d0cc6487ea11010e))
14
+ * removing the problem files for ruff ([41911c1](https://github.com/CoreySpohn/coronagraphoto/commit/41911c1f86c455dd560d054ff65ceeb843c76619))
15
+ * Still more annoying linting ([7022c05](https://github.com/CoreySpohn/coronagraphoto/commit/7022c05ec4c1ecf7f0859803a0fc47198a11939c))
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Corey Spohn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.3
2
+ Name: coronagraphoto
3
+ Version: 1.0.0
4
+ Summary: A python library to simulate coronagraphic observations of exoplanets.
5
+ Project-URL: Homepage, https://github.com/CoreySpohn/coronagraphoto
6
+ Project-URL: Issues, https://github.com/CoreySpohn/coronagraphoto/issues
7
+ Author-email: Corey Spohn <corey.a.spohn@nasa.gov>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2023 Corey Spohn
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ License-File: LICENSE
30
+ Classifier: Development Status :: 3 - Alpha
31
+ Classifier: Intended Audience :: Science/Research
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
35
+ Requires-Python: >=3.9
36
+ Requires-Dist: astropy
37
+ Requires-Dist: exoverses
38
+ Requires-Dist: lod-unit
39
+ Requires-Dist: matplotlib
40
+ Requires-Dist: numba
41
+ Requires-Dist: numpy
42
+ Requires-Dist: pandas
43
+ Requires-Dist: photutils
44
+ Requires-Dist: synphot
45
+ Requires-Dist: tqdm
46
+ Requires-Dist: xarray
47
+ Description-Content-Type: text/markdown
48
+
49
+ # coronagraphoto
50
+ A library to simulate observations based on
51
+ 1. An astrophysical scene (from [ExoVista](https://github.com/alexrhowe/ExoVista))
52
+ 2. A coronagraph (from a [yield input package](https://starkspace.com/yield_standards.pdf))
53
+ 3. An observation scenario
@@ -0,0 +1,5 @@
1
+ # coronagraphoto
2
+ A library to simulate observations based on
3
+ 1. An astrophysical scene (from [ExoVista](https://github.com/alexrhowe/ExoVista))
4
+ 2. A coronagraph (from a [yield input package](https://starkspace.com/yield_standards.pdf))
5
+ 3. An observation scenario
@@ -0,0 +1,58 @@
1
+ #####################
2
+ # ObservingScenario #
3
+ #####################
4
+ [general]
5
+ diameter = { value = 8.4, unit = 'm' }
6
+ exposure_time = { value = 5, unit = 'hr' }
7
+ frame_time = { value = 30, unit = 'min' }
8
+
9
+ # Annoying astropy.time uses "val" and astropy.unit uses "value"
10
+ start_time = { val = 2000, format = 'decimalyear' }
11
+
12
+ [spectral_information]
13
+ central_wavelength = { value = 500, unit = 'nm' }
14
+ spectral_resolution = 100
15
+ # bandpass
16
+
17
+ [detector]
18
+ # The size of the detector in pixels
19
+ shape = [300, 300]
20
+ # The pixel scale of the detector pixels
21
+ pixel_scale = { value = 0.1, unit = 'arcsec' }
22
+
23
+ ############
24
+ # Settings #
25
+ ############
26
+
27
+ [sources]
28
+ # When true, the code will include the source in the simulation
29
+ star = false
30
+ planets = true
31
+ disk = false
32
+
33
+ [output]
34
+ # If true, the code returns all the frames individually (keyed as "time"). If
35
+ # false, the code sums all the frames together.
36
+ frames = true
37
+ # If true, the observation separates out the counted photons by
38
+ # "spectral_wavelength(nm)". If false, the observation returns the total
39
+ spectrum = false
40
+ # If true, the output includes the counted photons for each source. If false,
41
+ # the output includes the total counted photons.
42
+ sources = false
43
+
44
+ [precision]
45
+ [precision.wavelength]
46
+ # When true, the code will recalculate the flux of each source for each
47
+ # wavelength in the bandpass
48
+ flux = false
49
+ # When true, the code will recalculate the transmission of the bandpass for
50
+ # each wavelength
51
+ transmission = false
52
+
53
+ [precision.time_invariance]
54
+ # When true, the code will reuse the count rate from the initial exposure for
55
+ # all subsequent exposures (frames)
56
+ planets = false
57
+ star = true
58
+ disk = true
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ['hatchling', "hatch-fancy-pypi-readme", "hatch-vcs"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "coronagraphoto"
7
+ description = "A python library to simulate coronagraphic observations of exoplanets."
8
+ authors = [{ name = "Corey Spohn", email = "corey.a.spohn@nasa.gov" }]
9
+ dynamic = ['readme', 'version']
10
+ requires-python = ">=3.9"
11
+ license = { file = "LICENSE" }
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Science/Research",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python :: 3",
17
+ "Topic :: Scientific/Engineering :: Astronomy",
18
+ ]
19
+ dependencies = [
20
+ "astropy",
21
+ "exoverses",
22
+ "lod_unit",
23
+ "matplotlib",
24
+ "numpy",
25
+ "numba",
26
+ "pandas",
27
+ "photutils",
28
+ "synphot",
29
+ "tqdm",
30
+ "xarray",
31
+ ]
32
+
33
+ [tool.hatch.version]
34
+ source = "vcs"
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/CoreySpohn/coronagraphoto"
38
+ Issues = "https://github.com/CoreySpohn/coronagraphoto/issues"
39
+
40
+ [tool.hatch.metadata.hooks.fancy-pypi-readme]
41
+ content-type = "text/markdown"
42
+
43
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
44
+ path = "README.md"
@@ -0,0 +1,116 @@
1
+ from pathlib import Path
2
+
3
+ import astropy.units as u
4
+ import matplotlib.colors as colors
5
+ import matplotlib.pyplot as plt
6
+ import numpy as np
7
+ from astropy.time import Time
8
+ from exoverses.exovista.system import ExovistaSystem
9
+ from synphot import SpectralElement
10
+ from synphot.models import Gaussian1D
11
+
12
+ from coronagraphoto import Coronagraph, Observation, ObservingScenario, Settings
13
+
14
+ # Input files
15
+ scene = Path("input/scenes/999-HIP_-TYC_SUN-mv_4.83-L_1.00-d_10.00-Teff_5778.00.fits")
16
+ time = Time(2000, format="decimalyear")
17
+ wavelength = 500 * u.nm
18
+ frac_bandwidth = 0.15
19
+ bandpass = SpectralElement(
20
+ Gaussian1D,
21
+ mean=wavelength,
22
+ stddev=frac_bandwidth * wavelength / np.sqrt(2 * np.pi),
23
+ )
24
+
25
+ # high_fid = {"bandpass": bandpass}
26
+ base = "input/observing_scenarios/example.toml"
27
+ med_fid = {
28
+ "diameter": 8 * u.m,
29
+ "central_wavelength": wavelength,
30
+ "start_time": time,
31
+ "exposure_time": 48 * u.hr,
32
+ "frame_time": 1 * u.hr,
33
+ "bandpass": bandpass,
34
+ "spectral_resolution": 100,
35
+ }
36
+ # low_fid = {
37
+ # "diameter": 8 * u.m,
38
+ # "wavelength": wavelength,
39
+ # "time": time,
40
+ # "exposure_time": 48 * u.hr,
41
+ # "include_star": True,
42
+ # "include_planets": True,
43
+ # "include_disk": True,
44
+ # "bandpass": bandpass,
45
+ # "return_spectrum": False,
46
+ # "return_frames": False,
47
+ # "return_sources": False,
48
+ # "wavelength_resolved_flux": False,
49
+ # "wavelength_resolved_transmission": False,
50
+ # }
51
+ # high_fid_scen = ObservingScenario(base, overwrite=high_fid)
52
+ # med_fid_scen = ObservingScenario(med_fid)
53
+ # low_fid_scen = ObservingScenario(low_fid)
54
+
55
+ # Initialize coronagraph object.
56
+ # Load ExoVista scene
57
+ settings = Settings(base)
58
+ observing_scenario = ObservingScenario(base, custom_scenario=med_fid)
59
+ system = ExovistaSystem(scene)
60
+
61
+ coronagraph_dir1 = Path("input/coronagraphs/LUVOIR-B-VC6_timeseries/")
62
+ # coronagraph_dir2 = Path(
63
+ # "input/coronagraphs/LUVOIR-A_APLC_18bw_medFPM_2021-05-07_Dyn10pm-nostaticabb/"
64
+ # )
65
+ cdirs = [coronagraph_dir1]
66
+
67
+ # Loop over coronagraphs and simulate observations
68
+ for cdir in cdirs:
69
+ coro = Coronagraph(cdir)
70
+ obs = Observation(coro, system, observing_scenario, settings)
71
+ # obs = observation.Observation(coro, system, med_fid_scen)
72
+ obs.create_count_rates()
73
+ image = obs.count_photons()
74
+ fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 6))
75
+ ax1.imshow(
76
+ obs.planet_count_rate.squeeze().value, norm=colors.LogNorm(), origin="lower"
77
+ )
78
+ ax2.imshow(
79
+ obs.planet_count_rate.squeeze().value, norm=colors.LogNorm(), origin="lower"
80
+ )
81
+ plt.show()
82
+ # fig, ax = plt.subplots(1, 1, figsize=(6, 6))
83
+ # ax.imshow(
84
+ # obs.planet_count_rate[1].value - obs.planet_count_rate[0].value,
85
+ # norm=colors.LogNorm(),
86
+ # origin="lower",
87
+ # )
88
+
89
+ # start = datetime.datetime.now()
90
+ # obs.create_count_rates()
91
+ # obs.count_photons()
92
+ # print(f"High fidelity: {datetime.datetime.now() - start}")
93
+
94
+ # obs.load_observing_scenario(med_fid_scen)
95
+ # start = datetime.datetime.now()
96
+ # obs.create_count_rates()
97
+ # obs.count_photons()
98
+ # print(f"Medium fidelity: {datetime.datetime.now() - start}")
99
+ #
100
+ # obs.load_observing_scenario(low_fid_scen)
101
+ # start = datetime.datetime.now()
102
+ # obs.create_count_rates()
103
+ # obs.count_photons()
104
+ # print(f"Low fidelity: {datetime.datetime.now() - start}")
105
+ #
106
+ # plt.imshow(obs.data["total"], norm=colors.LogNorm(), origin="lower")
107
+ # x_loc = obs.system.planets[4]._x_pix[0] - obs.system.star._x_pix[0]
108
+ # y_loc = obs.system.planets[4]._y_pix[0] - obs.system.star._y_pix[0]
109
+ # plt.scatter(y_loc.value, x_loc.value, marker="x", color="r")
110
+ # plt.scatter(120, 120, marker="x", color="g")
111
+ # plt.show()
112
+ #
113
+ # obs.snr_check(np.arange(1, 100, 1) * u.hr)
114
+ #
115
+ # # re.render(system, coro, observing_scenario, obs)
116
+ # plt.close("all")
@@ -0,0 +1,17 @@
1
+ __all__ = [
2
+ "Coronagraph",
3
+ "logger",
4
+ "Observation",
5
+ "Observations",
6
+ "ObservingScenario",
7
+ "Settings",
8
+ "util",
9
+ ]
10
+
11
+ from .coronagraph import Coronagraph
12
+ from .logger import logger
13
+ from .observation import Observation
14
+ from .observations import Observations
15
+ from .observing_scenario import ObservingScenario
16
+ from .settings import Settings
17
+ from . import util