astro-notebooks 0.1.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,162 @@
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/latest/usage/project/#working-with-version-control
110
+ .pdm.toml
111
+ .pdm-python
112
+ .pdm-build/
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ #.idea/
@@ -0,0 +1,17 @@
1
+ # Notebook in the "Stellarphot setup" section of the launcher
2
+
3
+ - title: Image viewers
4
+ description: Widgets for viewing a folder of images or a single image
5
+ source: ../astro_notebooks/image-viewers.ipynb
6
+ icon: ../astro-notebooks/stellarphot-logo.svg
7
+ cwd: not_used
8
+ type: notebook
9
+ catalog: Astro tools
10
+
11
+ - title: Reproject images
12
+ description: Widgets for viewing a folder of images or a single image
13
+ source: ../astro_notebooks/reproject-images.ipynb
14
+ icon: ../astro-notebooks/stellarphot-logo.svg
15
+ cwd: not_used
16
+ type: notebook
17
+ catalog: Astro tools
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024, Paul P. Feder Observatory at Minnesota State University Moorhead
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.3
2
+ Name: astro-notebooks
3
+ Version: 0.1.0
4
+ Project-URL: Documentation, https://github.com/feder-observatory/astro-notebooks#readme
5
+ Project-URL: Issues, https://github.com/feder-observatory/astro-notebooks/issues
6
+ Project-URL: Source, https://github.com/feder-observatory/astro-notebooks
7
+ Author-email: Matt Craig <mattwcraig@gmail.com>
8
+ License-Expression: BSD-3-Clause
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: Implementation :: CPython
18
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
19
+ Requires-Python: >=3.11
20
+ Requires-Dist: jupyter-app-launcher
21
+ Requires-Dist: stellarphot
22
+ Description-Content-Type: text/markdown
23
+
24
+ # astro-notebooks
25
+
26
+ [![PyPI - Version](https://img.shields.io/pypi/v/astro-notebooks.svg)](https://pypi.org/project/astro-notebooks)
27
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/astro-notebooks.svg)](https://pypi.org/project/astro-notebooks)
28
+
29
+ -----
30
+
31
+ ## Table of Contents
32
+
33
+ - [Installation](#installation)
34
+ - [License](#license)
35
+
36
+ ## Installation
37
+
38
+ ```console
39
+ pip install astro-notebooks
40
+ ```
41
+
42
+ ## License
43
+
44
+ `astro-notebooks` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,21 @@
1
+ # astro-notebooks
2
+
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/astro-notebooks.svg)](https://pypi.org/project/astro-notebooks)
4
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/astro-notebooks.svg)](https://pypi.org/project/astro-notebooks)
5
+
6
+ -----
7
+
8
+ ## Table of Contents
9
+
10
+ - [Installation](#installation)
11
+ - [License](#license)
12
+
13
+ ## Installation
14
+
15
+ ```console
16
+ pip install astro-notebooks
17
+ ```
18
+
19
+ ## License
20
+
21
+ `astro-notebooks` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,80 @@
1
+ [build-system]
2
+ requires = ["hatchling", "hatch-vcs"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "astro-notebooks"
7
+ dynamic = ["version"]
8
+ description = ''
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "BSD-3-Clause"
12
+ keywords = []
13
+ authors = [
14
+ { name = "Matt Craig", email = "mattwcraig@gmail.com" },
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Programming Language :: Python",
19
+ "Programming Language :: Python :: 3.8",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: Implementation :: CPython",
25
+ "Programming Language :: Python :: Implementation :: PyPy",
26
+ ]
27
+ dependencies = [
28
+ "jupyter-app-launcher",
29
+ "stellarphot",
30
+ ]
31
+
32
+ [project.urls]
33
+ Documentation = "https://github.com/feder-observatory/astro-notebooks#readme"
34
+ Issues = "https://github.com/feder-observatory/astro-notebooks/issues"
35
+ Source = "https://github.com/feder-observatory/astro-notebooks"
36
+
37
+ [tool.hatch.version]
38
+ source = "vcs"
39
+
40
+ [tool.hatch.build.hooks.vcs]
41
+ version-file = "src/astro_notebooks/_version.py"
42
+
43
+ [tool.hatch.build.targets.sdist]
44
+ include = [
45
+ ".jp_app_launcher_astro-notebooks.yaml",
46
+ "src/astro_notebooks/",
47
+ ]
48
+
49
+ [tool.hatch.build.targets.wheel.shared-data]
50
+ # This section determines what data files are included in the wheel
51
+ # and where they should eventually be installed in the user's environment.
52
+ # This includes the notebooks used in the launcher
53
+ "src/astro_notebooks" = "share/jupyter/astro_notebooks"
54
+ ".jp_app_launcher_astro-notebooks.yaml" = "share/jupyter/jupyter_app_launcher/jp_app_launcher_astro-notebooks.yaml"
55
+
56
+ [tool.hatch.envs.types]
57
+ extra-dependencies = [
58
+ "mypy>=1.0.0",
59
+ ]
60
+ [tool.hatch.envs.types.scripts]
61
+ check = "mypy --install-types --non-interactive {args:src/astro_notebooks tests}"
62
+
63
+ [tool.coverage.run]
64
+ source_pkgs = ["astro_notebooks", "tests"]
65
+ branch = true
66
+ parallel = true
67
+ omit = [
68
+ "src/astro_notebooks/__about__.py",
69
+ ]
70
+
71
+ [tool.coverage.paths]
72
+ astro_notebooks = ["src/astro_notebooks", "*/astro-notebooks/src/astro_notebooks"]
73
+ tests = ["tests", "*/astro-notebooks/tests"]
74
+
75
+ [tool.coverage.report]
76
+ exclude_lines = [
77
+ "no cov",
78
+ "if __name__ == .__main__.:",
79
+ "if TYPE_CHECKING:",
80
+ ]
@@ -0,0 +1,4 @@
1
+ # SPDX-FileCopyrightText: 2024-present Matt Craig <mattwcraig@gmail.com>
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ __version__ = "0.0.1"
@@ -0,0 +1,3 @@
1
+ # SPDX-FileCopyrightText: 2024-present Matt Craig <mattwcraig@gmail.com>
2
+ #
3
+ # SPDX-License-Identifier: MIT
@@ -0,0 +1,16 @@
1
+ # file generated by setuptools_scm
2
+ # don't change, don't track in version control
3
+ TYPE_CHECKING = False
4
+ if TYPE_CHECKING:
5
+ from typing import Tuple, Union
6
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
7
+ else:
8
+ VERSION_TUPLE = object
9
+
10
+ version: str
11
+ __version__: str
12
+ __version_tuple__: VERSION_TUPLE
13
+ version_tuple: VERSION_TUPLE
14
+
15
+ __version__ = version = '0.1.0'
16
+ __version_tuple__ = version_tuple = (0, 1, 0)
@@ -0,0 +1,111 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# Image viewing notebook"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": 14,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "import ipywidgets as widgets\n",
17
+ "\n",
18
+ "from astropy.table import Table\n",
19
+ "from astrowidgets import ImageWidget\n",
20
+ "from ccdproc import ImageFileCollection\n",
21
+ "from reducer.image_browser import ImageBrowser\n",
22
+ "from stellarphot.settings.fits_opener import FitsOpener"
23
+ ]
24
+ },
25
+ {
26
+ "cell_type": "markdown",
27
+ "metadata": {},
28
+ "source": [
29
+ "## View all images in the current folder"
30
+ ]
31
+ },
32
+ {
33
+ "cell_type": "code",
34
+ "execution_count": null,
35
+ "metadata": {},
36
+ "outputs": [],
37
+ "source": [
38
+ "ifc = ImageFileCollection('.')\n",
39
+ "ib = ImageBrowser(ifc, keys=['imagetyp', 'object'])\n",
40
+ "ib"
41
+ ]
42
+ },
43
+ {
44
+ "cell_type": "markdown",
45
+ "metadata": {},
46
+ "source": [
47
+ "## Interactive view of a single image"
48
+ ]
49
+ },
50
+ {
51
+ "cell_type": "markdown",
52
+ "metadata": {},
53
+ "source": [
54
+ "### Make the viewer"
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "code",
59
+ "execution_count": null,
60
+ "metadata": {},
61
+ "outputs": [],
62
+ "source": [
63
+ "iw = ImageWidget()\n",
64
+ "fo = FitsOpener()\n",
65
+ "\n",
66
+ "def load_it(change):\n",
67
+ " fo.load_in_image_widget(iw)\n",
68
+ "\n",
69
+ "fo.file_chooser.observe(load_it, names='_value')\n",
70
+ "\n",
71
+ "hb = widgets.HBox([iw, fo.file_chooser])\n",
72
+ "hb"
73
+ ]
74
+ },
75
+ {
76
+ "cell_type": "markdown",
77
+ "metadata": {},
78
+ "source": [
79
+ "### Choose an image to view"
80
+ ]
81
+ },
82
+ {
83
+ "cell_type": "code",
84
+ "execution_count": null,
85
+ "metadata": {},
86
+ "outputs": [],
87
+ "source": []
88
+ }
89
+ ],
90
+ "metadata": {
91
+ "kernelspec": {
92
+ "display_name": "Python 3",
93
+ "language": "python",
94
+ "name": "python3"
95
+ },
96
+ "language_info": {
97
+ "codemirror_mode": {
98
+ "name": "ipython",
99
+ "version": 3
100
+ },
101
+ "file_extension": ".py",
102
+ "mimetype": "text/x-python",
103
+ "name": "python",
104
+ "nbconvert_exporter": "python",
105
+ "pygments_lexer": "ipython3",
106
+ "version": "3.11.9"
107
+ }
108
+ },
109
+ "nbformat": 4,
110
+ "nbformat_minor": 4
111
+ }
@@ -0,0 +1,171 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# Reprojection template\n",
8
+ "\n",
9
+ "Use this when you want to change a series of images so that they are aligned with one of the imags."
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": 3,
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "from pathlib import Path\n",
19
+ "\n",
20
+ "import numpy as np\n",
21
+ "\n",
22
+ "from astropy.nddata import CCDData\n",
23
+ "from ccdproc import ImageFileCollection\n",
24
+ "from reproject import reproject_interp\n",
25
+ "from stellarphot.settings.fits_opener import FitsOpener"
26
+ ]
27
+ },
28
+ {
29
+ "cell_type": "markdown",
30
+ "metadata": {},
31
+ "source": [
32
+ "## Change the values here"
33
+ ]
34
+ },
35
+ {
36
+ "cell_type": "code",
37
+ "execution_count": 8,
38
+ "metadata": {},
39
+ "outputs": [],
40
+ "source": [
41
+ "image_folder = '.' # '.' means the same folder as the notebook.\n",
42
+ "\n",
43
+ "ipath = Path(image_folder)\n",
44
+ "\n",
45
+ "# You can call this anything you want.\n",
46
+ "folder_for_shifted_images = 'shifted'\n",
47
+ "\n",
48
+ "# Subract median background value?\n",
49
+ "subtract_median = True"
50
+ ]
51
+ },
52
+ {
53
+ "cell_type": "markdown",
54
+ "metadata": {},
55
+ "source": [
56
+ "### Choose your \"reference\" image"
57
+ ]
58
+ },
59
+ {
60
+ "cell_type": "code",
61
+ "execution_count": null,
62
+ "metadata": {},
63
+ "outputs": [],
64
+ "source": [
65
+ "fo = FitsOpener()\n",
66
+ "fo.file_chooser"
67
+ ]
68
+ },
69
+ {
70
+ "cell_type": "code",
71
+ "execution_count": null,
72
+ "metadata": {},
73
+ "outputs": [],
74
+ "source": [
75
+ "# This can be any one of the images. If one image is offset from all\n",
76
+ "# of the others do not choose that image.\n",
77
+ "reference_image = fo.file_chooser.value #'kelt-16-b-S001-R001-C004-r.fit'\n",
78
+ "print(reference_image)"
79
+ ]
80
+ },
81
+ {
82
+ "cell_type": "markdown",
83
+ "metadata": {},
84
+ "source": [
85
+ "### Run the rest but you should not need to modify anything"
86
+ ]
87
+ },
88
+ {
89
+ "cell_type": "code",
90
+ "execution_count": null,
91
+ "metadata": {},
92
+ "outputs": [],
93
+ "source": [
94
+ "p = Path(folder_for_shifted_images)\n",
95
+ "p.mkdir(exist_ok=True)\n",
96
+ "ccd_ref = CCDData.read(ipath / Path(reference_image).name)\n",
97
+ "wcs_ref = ccd_ref.wcs"
98
+ ]
99
+ },
100
+ {
101
+ "cell_type": "markdown",
102
+ "metadata": {},
103
+ "source": [
104
+ "### This cell does this shifting. It will update as it completes images."
105
+ ]
106
+ },
107
+ {
108
+ "cell_type": "code",
109
+ "execution_count": null,
110
+ "metadata": {},
111
+ "outputs": [],
112
+ "source": [
113
+ "ifc = ImageFileCollection(image_folder)\n",
114
+ "\n",
115
+ "n_images = len(ifc.summary) + 1\n",
116
+ "i = 0\n",
117
+ "\n",
118
+ "for ccd, fname in ifc.ccds(return_fname=True):\n",
119
+ " print(f'\\n{i} done šŸŽ‰, {n_images - i - 1} left\\n')\n",
120
+ " i = i + 1\n",
121
+ " print(f'\\tStarting to shift image {fname}...')\n",
122
+ " outfile = p / fname\n",
123
+ " if outfile.exists():\n",
124
+ " print(f'\\t\\t...skipping because it is already shifted')\n",
125
+ " continue\n",
126
+ "\n",
127
+ " if subtract_median:\n",
128
+ " median = np.nanmedian(ccd.data)\n",
129
+ " else:\n",
130
+ " median = 0\n",
131
+ "\n",
132
+ " new_data, footprint = reproject_interp(ccd, wcs_ref,\n",
133
+ " shape_out=ccd_ref.shape, order=1)\n",
134
+ " ccd.data = new_data - median\n",
135
+ " ccd.wcs = wcs_ref\n",
136
+ " ccd.write(p / fname)\n",
137
+ " print(f'\\t\\t...Finished shifting image')\n",
138
+ "\n",
139
+ "print('\\nšŸŽ‰ All done ✨')"
140
+ ]
141
+ },
142
+ {
143
+ "cell_type": "code",
144
+ "execution_count": null,
145
+ "metadata": {},
146
+ "outputs": [],
147
+ "source": []
148
+ }
149
+ ],
150
+ "metadata": {
151
+ "kernelspec": {
152
+ "display_name": "Python 3 (ipykernel)",
153
+ "language": "python",
154
+ "name": "python3"
155
+ },
156
+ "language_info": {
157
+ "codemirror_mode": {
158
+ "name": "ipython",
159
+ "version": 3
160
+ },
161
+ "file_extension": ".py",
162
+ "mimetype": "text/x-python",
163
+ "name": "python",
164
+ "nbconvert_exporter": "python",
165
+ "pygments_lexer": "ipython3",
166
+ "version": "3.11.9"
167
+ }
168
+ },
169
+ "nbformat": 4,
170
+ "nbformat_minor": 4
171
+ }