kosmos-craftroom 0.0.5__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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Zach Berta-Thompson
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,52 @@
1
+ Metadata-Version: 2.4
2
+ Name: kosmos-craftroom
3
+ Version: 0.0.5
4
+ Summary: Tools for working with spectroscopic light curves (of transiting exoplanets).
5
+ Home-page: https://github.com/zkbt/kosmos-craftroom/
6
+ Author: Zach Berta-Thompson
7
+ Author-email: zach.bertathompson@colorado.edu
8
+ License: MIT
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
13
+ Requires-Python: >=3.7
14
+ License-File: LICENSE
15
+ Requires-Dist: numpy
16
+ Requires-Dist: scipy
17
+ Requires-Dist: matplotlib
18
+ Requires-Dist: astropy
19
+ Requires-Dist: jupyter
20
+ Requires-Dist: ipympl
21
+ Requires-Dist: ipywidgets
22
+ Requires-Dist: tqdm
23
+ Requires-Dist: pyperclip
24
+ Requires-Dist: thefriendlystars>=0.1.2
25
+ Requires-Dist: illumination>=0.1.0
26
+ Provides-Extra: develop
27
+ Requires-Dist: pytest; extra == "develop"
28
+ Requires-Dist: black; extra == "develop"
29
+ Requires-Dist: jupyter; extra == "develop"
30
+ Requires-Dist: ipython; extra == "develop"
31
+ Requires-Dist: mkdocs; extra == "develop"
32
+ Requires-Dist: mkdocs-material; extra == "develop"
33
+ Requires-Dist: mkdocstrings; extra == "develop"
34
+ Requires-Dist: mkdocstrings-python; extra == "develop"
35
+ Requires-Dist: pytkdocs[numpy-style]; extra == "develop"
36
+ Requires-Dist: mkdocs-jupyter; extra == "develop"
37
+ Requires-Dist: mkdocs-exclude; extra == "develop"
38
+ Requires-Dist: twine; extra == "develop"
39
+ Requires-Dist: pre-commit; extra == "develop"
40
+ Dynamic: author
41
+ Dynamic: author-email
42
+ Dynamic: classifier
43
+ Dynamic: description
44
+ Dynamic: home-page
45
+ Dynamic: license
46
+ Dynamic: license-file
47
+ Dynamic: provides-extra
48
+ Dynamic: requires-dist
49
+ Dynamic: requires-python
50
+ Dynamic: summary
51
+
52
+ Read the complete documentation at https://zkbt.github.io/kosmos-craftroom/
@@ -0,0 +1,40 @@
1
+ # kosmos-craftroom
2
+ A cheerful mess of tools for working with the KOSMOS spectrograph at APO.
3
+
4
+ # Documentation
5
+ Read (draft!) [documentation](https://zkbt.github.io/kosmos-craftroom).
6
+
7
+ # Installation
8
+
9
+ For installing this code we assume you have a Python environment set up, into which you can install packages via `pip`. If so, please continue to one of the installation options below.
10
+
11
+ If this isn't the case, we recommend installing the [Anaconda Python distribution](https://www.anaconda.com/products/distribution), and using `conda` to manage the `python` environment(s) you have installed on your computer. One tutorial (of many) about how to get started with Python and creating `conda` environments is available [here](https://github.com/ers-transit/hackathon-2021-day0).
12
+
13
+ ## Basic Installation
14
+
15
+ If you want to install into your current environment, the basic installation should be pretty simple. From the Terminal or Anaconda Prompt, please run
16
+ ```
17
+ pip install https://github.com/zkbt/kosmos-craftroom
18
+ ```
19
+ and it should install everything, along with all the necessary dependencies.
20
+
21
+ If you previously installed this package and need to grab a newer version, run
22
+ ```
23
+ pip install --upgrade https://github.com/zkbt/kosmos-craftroom
24
+ ```
25
+ to download any officially released updates.
26
+
27
+ ## Developer Installation
28
+
29
+ If you want to install this code while being able to edit and develop it, you can clone its [GitHub repository](https://github.com/zkbt/thefriendlystars.git) onto your own computer. This allows you to edit it for your own sake and/or to draft changes that can be contributed to the public package (after being added as a collaborator to the project on GitHub).
30
+
31
+ To install directly as an editable package on your local computer, run
32
+ ```
33
+ git clone git+https://github.com/zkbt/kosmos-craftroom
34
+ cd kosmos-craftroom
35
+ pip install -e '.[develop]'
36
+ ```
37
+ The `-e .` will point your environment's `kosmoscraftroom` package to your local folder, meaning that any changes you make in the repository will be reflected in what Python sees when it tries to `import kosmoscraftroom`. Including the `[develop]` after the `.` will install both the dependencies for the package itself and the extra dependencies required for development (= testing and documentation).
38
+
39
+ ## Did it work?
40
+ You can quickly test whether your installation worked, and what version you have, by running the Python code
@@ -0,0 +1,52 @@
1
+ Metadata-Version: 2.4
2
+ Name: kosmos-craftroom
3
+ Version: 0.0.5
4
+ Summary: Tools for working with spectroscopic light curves (of transiting exoplanets).
5
+ Home-page: https://github.com/zkbt/kosmos-craftroom/
6
+ Author: Zach Berta-Thompson
7
+ Author-email: zach.bertathompson@colorado.edu
8
+ License: MIT
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
13
+ Requires-Python: >=3.7
14
+ License-File: LICENSE
15
+ Requires-Dist: numpy
16
+ Requires-Dist: scipy
17
+ Requires-Dist: matplotlib
18
+ Requires-Dist: astropy
19
+ Requires-Dist: jupyter
20
+ Requires-Dist: ipympl
21
+ Requires-Dist: ipywidgets
22
+ Requires-Dist: tqdm
23
+ Requires-Dist: pyperclip
24
+ Requires-Dist: thefriendlystars>=0.1.2
25
+ Requires-Dist: illumination>=0.1.0
26
+ Provides-Extra: develop
27
+ Requires-Dist: pytest; extra == "develop"
28
+ Requires-Dist: black; extra == "develop"
29
+ Requires-Dist: jupyter; extra == "develop"
30
+ Requires-Dist: ipython; extra == "develop"
31
+ Requires-Dist: mkdocs; extra == "develop"
32
+ Requires-Dist: mkdocs-material; extra == "develop"
33
+ Requires-Dist: mkdocstrings; extra == "develop"
34
+ Requires-Dist: mkdocstrings-python; extra == "develop"
35
+ Requires-Dist: pytkdocs[numpy-style]; extra == "develop"
36
+ Requires-Dist: mkdocs-jupyter; extra == "develop"
37
+ Requires-Dist: mkdocs-exclude; extra == "develop"
38
+ Requires-Dist: twine; extra == "develop"
39
+ Requires-Dist: pre-commit; extra == "develop"
40
+ Dynamic: author
41
+ Dynamic: author-email
42
+ Dynamic: classifier
43
+ Dynamic: description
44
+ Dynamic: home-page
45
+ Dynamic: license
46
+ Dynamic: license-file
47
+ Dynamic: provides-extra
48
+ Dynamic: requires-dist
49
+ Dynamic: requires-python
50
+ Dynamic: summary
51
+
52
+ Read the complete documentation at https://zkbt.github.io/kosmos-craftroom/
@@ -0,0 +1,18 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ kosmos_craftroom.egg-info/PKG-INFO
5
+ kosmos_craftroom.egg-info/SOURCES.txt
6
+ kosmos_craftroom.egg-info/dependency_links.txt
7
+ kosmos_craftroom.egg-info/not-zip-safe
8
+ kosmos_craftroom.egg-info/requires.txt
9
+ kosmos_craftroom.egg-info/top_level.txt
10
+ kosmoscraftroom/__init__.py
11
+ kosmoscraftroom/catalogs.py
12
+ kosmoscraftroom/detector.py
13
+ kosmoscraftroom/finder.py
14
+ kosmoscraftroom/iplot.py
15
+ kosmoscraftroom/loupe.py
16
+ kosmoscraftroom/scripts.py
17
+ kosmoscraftroom/slit.py
18
+ kosmoscraftroom/version.py
@@ -0,0 +1,26 @@
1
+ numpy
2
+ scipy
3
+ matplotlib
4
+ astropy
5
+ jupyter
6
+ ipympl
7
+ ipywidgets
8
+ tqdm
9
+ pyperclip
10
+ thefriendlystars>=0.1.2
11
+ illumination>=0.1.0
12
+
13
+ [develop]
14
+ pytest
15
+ black
16
+ jupyter
17
+ ipython
18
+ mkdocs
19
+ mkdocs-material
20
+ mkdocstrings
21
+ mkdocstrings-python
22
+ pytkdocs[numpy-style]
23
+ mkdocs-jupyter
24
+ mkdocs-exclude
25
+ twine
26
+ pre-commit
@@ -0,0 +1 @@
1
+ kosmoscraftroom
@@ -0,0 +1 @@
1
+ from .version import *
@@ -0,0 +1,162 @@
1
+ from astropy.table import Table, vstack, unique
2
+ from astropy.coordinates import SkyCoord
3
+ from astropy.io.ascii import read
4
+ import astropy.units as u
5
+
6
+ import numpy as np
7
+
8
+
9
+ class TUICatalog:
10
+ """
11
+ Tool to make a TUI catalog, as outlined in this documentation:
12
+ https://www.apo.nmsu.edu/35m_operations/TUI/Telescope/UserCatalogs.html
13
+
14
+ """
15
+
16
+ def __init__(self, name="?"):
17
+ """
18
+ Initialize a catalog
19
+ """
20
+ self.name = name
21
+ self.table = []
22
+
23
+ def __repr__(self):
24
+ return f"<'{self.name}' TUICatalog ({len(self.table)} targets)>"
25
+
26
+ def from_table(self, table, remove_duplicates=True, sort=True):
27
+ """
28
+ Initialize from a table.
29
+ """
30
+ self.table = table
31
+ if remove_duplicates:
32
+ self.remove_duplicates()
33
+ if sort:
34
+ self.sort()
35
+
36
+ def from_TUI(self, filename, names=["name", "ra", "dec"]):
37
+ t = read(filename, names=names)
38
+ table = Table(
39
+ dict(
40
+ names=t["name"],
41
+ sky_coordinates=SkyCoord(
42
+ ra=t["ra"],
43
+ dec=t["dec"],
44
+ unit=(u.hourangle, u.deg), # TO-DO make sure this is more general!!
45
+ ),
46
+ category=[self.name for i in range(len(t))],
47
+ )
48
+ )
49
+ self.from_table(table)
50
+
51
+ def from_exoatlas(self, pop):
52
+ """
53
+ Initialize from an exoplanet-atlas population.
54
+ """
55
+ self._exoatlas_pop = pop
56
+ table = Table(
57
+ dict(
58
+ names=pop.standard["hostname"],
59
+ sky_coordinates=SkyCoord(pop.standard["ra"], pop.standard["dec"]),
60
+ G=pop.standard["gaiamag"],
61
+ distance=pop.standard["distance"],
62
+ category=[self.name for i in range(len(pop.standard))],
63
+ )
64
+ )
65
+ self.from_table(table)
66
+
67
+ def remove_duplicates(self):
68
+ self.table = unique(self.table, keys=["names"])
69
+
70
+ def sort(self):
71
+ self.table = self.table[np.argsort(self.table["sky_coordinates"].ra)]
72
+
73
+ def make_three_columns(self, row):
74
+ return f"""{row['names'].replace(' ', ''):<20} {row['sky_coordinates'].to_string('hmsdms', sep=':', precision=1)}"""
75
+
76
+ def make_tui_columns(self, row):
77
+ keywords = []
78
+ return "; ".join(keywords)
79
+
80
+ def make_human_columns(self, row):
81
+ keywords = [
82
+ f"{row['category']}",
83
+ f"d={row['distance']:.1f}pc",
84
+ f"G={row['G']:.2f}",
85
+ ]
86
+ return ", ".join(keywords)
87
+
88
+ def to_TUI(self, parallactic=True, output=False, color="Black"):
89
+ """
90
+ Write this catalog out to a TUI-friendly format.
91
+
92
+ The catalog will be written out to a file set by the catalogs 'name' attribute,
93
+ in a format that can be loaded into TUI via the Slew > Catalogs button.
94
+
95
+ Parameters
96
+ ----------
97
+ parallactic : bool
98
+ Should we rotate the slit to be along the parallactic angle?
99
+ Doing so will minimize the effects of differental refraction
100
+ through Earth's atmosphere on the amount light that enters
101
+ the slit.
102
+ output : bool
103
+ Should we print the catalog to the screen?
104
+ """
105
+ filename = f"{self.name}.tui"
106
+ if parallactic:
107
+ preamble = f"CSys=ICRS; RotType=Horizon; RotAng=90; DispColor={color}"
108
+ else:
109
+ preamble = f"CSys=ICRS; RotType=Object; RotAng=0; DispColor={color}"
110
+
111
+ lines = [
112
+ f"""{self.make_three_columns(row)} {self.make_tui_columns(row)}\n"""
113
+ for row in self.table
114
+ ]
115
+
116
+ with open(filename, "w") as f:
117
+ f.write(preamble)
118
+ f.write("\n" * 3)
119
+ f.writelines(lines)
120
+
121
+ if output:
122
+ with open(filename, "r") as f:
123
+ print(f.read())
124
+
125
+ print(f"{self} has been saved to {filename}")
126
+
127
+ def to_human_friendly(self, output=False):
128
+ """
129
+ Write this catalog out to a human-friendly format.
130
+
131
+ The catalog will be written with the same initial columns as a TUI catalog,
132
+ but with additional information that might help in observation planning,
133
+ such as the category of observing program, the distance, the magnitude.
134
+ """
135
+ filename = f"{self.name}.txt"
136
+ lines = [
137
+ f"""{self.make_three_columns(row)} {self.make_human_columns(row)}\n"""
138
+ for row in self.table
139
+ ]
140
+
141
+ with open(filename, "w") as f:
142
+ f.writelines(lines)
143
+
144
+ if output:
145
+ with open(filename, "r") as f:
146
+ print(f.read())
147
+
148
+ print(
149
+ f"Human-friendly catalog ({len(self.table)} targets) has been saved to {filename}"
150
+ )
151
+
152
+ def __add__(self, other):
153
+ """
154
+ Merge two catalogs together.
155
+ """
156
+ new = TUICatalog(f"{self.name}+{other.name}")
157
+ new.table = vstack([self.table, other.table])
158
+ new.sort()
159
+ return new
160
+
161
+
162
+ # def to_human(self)G={row['G']:>5.2f}