exocat 0.1.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.
- exocat/__init__.py +4 -0
- exocat/bulk_density.py +69 -0
- exocat/plots.py +48 -0
- exocat/read_tepcat.py +22 -0
- exocat/temperature.py +76 -0
- exocat-0.1.0.dist-info/METADATA +31 -0
- exocat-0.1.0.dist-info/RECORD +10 -0
- exocat-0.1.0.dist-info/WHEEL +5 -0
- exocat-0.1.0.dist-info/licenses/LICENSE +21 -0
- exocat-0.1.0.dist-info/top_level.txt +1 -0
exocat/__init__.py
ADDED
exocat/bulk_density.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#%%
|
|
2
|
+
import numpy as np
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
import pandas as pd
|
|
5
|
+
|
|
6
|
+
class BulkDensity:
|
|
7
|
+
"""A class to represent and classify bulk density values."""
|
|
8
|
+
|
|
9
|
+
def __init__(self, df: pd.DataFrame|np.ndarray|list) -> None:
|
|
10
|
+
|
|
11
|
+
if isinstance(df, pd.DataFrame):
|
|
12
|
+
self.df = df
|
|
13
|
+
self.density = np.atleast_1d(np.asarray(df["rho_b"]))
|
|
14
|
+
else:
|
|
15
|
+
self.df = None
|
|
16
|
+
self.density = np.atleast_1d(np.asarray(df))
|
|
17
|
+
|
|
18
|
+
self.classifications = None
|
|
19
|
+
|
|
20
|
+
def classify(self) -> np.ndarray|str:
|
|
21
|
+
|
|
22
|
+
density_jup = 1.326
|
|
23
|
+
density_gcm3 = self.density * density_jup
|
|
24
|
+
|
|
25
|
+
output = np.empty_like(density_gcm3, dtype=object)
|
|
26
|
+
output[density_gcm3 < 0.5] = "gaseous"
|
|
27
|
+
output[(density_gcm3 >= 0.5) & (density_gcm3 < 2)] = "gaseous/water-rich"
|
|
28
|
+
output[(density_gcm3 >= 2) & (density_gcm3 < 7)] = "rocky"
|
|
29
|
+
output[(density_gcm3 >= 7) & (density_gcm3 < 13)] = "metallic"
|
|
30
|
+
output[density_gcm3 >= 13] = "super dense"
|
|
31
|
+
self.classifications = output
|
|
32
|
+
|
|
33
|
+
return self.classifications
|
|
34
|
+
|
|
35
|
+
def plot(self, bins:int=50) -> None:
|
|
36
|
+
|
|
37
|
+
plt.figure(figsize=(10, 6))
|
|
38
|
+
ax = plt.gca()
|
|
39
|
+
|
|
40
|
+
ax.axvspan(xmin=-999, xmax=0.5, color='green', linestyle='--', label='gaseous', alpha=0.2)
|
|
41
|
+
ax.axvspan(xmin=0.5, xmax=2, color='blue', linestyle='--', label='gaseous/water-rich', alpha=0.2)
|
|
42
|
+
ax.axvspan(xmin=2, xmax=7, color='orange', linestyle='--', label='rocky', alpha=0.2)
|
|
43
|
+
ax.axvspan(xmin=7, xmax=13, color='red', linestyle='--', label='metallic', alpha=0.2)
|
|
44
|
+
ax.axvspan(xmin=13, xmax=999, color='purple', linestyle='--', label='super dense', alpha=0.2)
|
|
45
|
+
|
|
46
|
+
ax.hist(self.density, bins=bins, color='skyblue', edgecolor='black', align="mid", alpha=0.7)
|
|
47
|
+
|
|
48
|
+
xmin = np.min(self.density) - 1
|
|
49
|
+
xmax = np.max(self.density) + 1
|
|
50
|
+
|
|
51
|
+
gas_mid = (xmin + 0.5) / 2
|
|
52
|
+
water_mid = (0.5 + 2) / 2
|
|
53
|
+
rocky_mid = (2 + 7) / 2
|
|
54
|
+
metallic_mid = (7 + 13) / 2
|
|
55
|
+
super_dense_mid = (13 + xmax) / 2
|
|
56
|
+
y_coord1 = ax.get_ylim()[1] * 0.9
|
|
57
|
+
y_coord2 = ax.get_ylim()[1] * 0.95
|
|
58
|
+
ax.text(gas_mid, y_coord1, 'Gaseous', color='green', fontsize=12, ha='center')
|
|
59
|
+
ax.text(water_mid, y_coord2, 'Gaseous/Water-Rich', color='blue', fontsize=12, ha='center')
|
|
60
|
+
ax.text(rocky_mid, y_coord1, 'Rocky', color='orange', fontsize=12, ha='center')
|
|
61
|
+
ax.text(metallic_mid, y_coord2, 'Metallic', color='red', fontsize=12, ha='center')
|
|
62
|
+
ax.text(super_dense_mid, y_coord1, 'Super Dense', color='purple', fontsize=12, ha='center')
|
|
63
|
+
|
|
64
|
+
ax.set_xlim(xmin, xmax)
|
|
65
|
+
ax.set_title('Bulk Density Distribution')
|
|
66
|
+
ax.set_xlabel('Bulk Density (kg/m³)')
|
|
67
|
+
ax.set_ylabel('Frequency')
|
|
68
|
+
ax.grid(axis='y', alpha=0.5)
|
|
69
|
+
plt.show()
|
exocat/plots.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import matplotlib.pyplot as plt
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
class Plot:
|
|
5
|
+
"""A class to create scatter plots with color mapping based on a DataFrame."""
|
|
6
|
+
|
|
7
|
+
def __init__(self, df: np.ndarray) -> None:
|
|
8
|
+
"""
|
|
9
|
+
Initialize the Plot class with a DataFrame.
|
|
10
|
+
|
|
11
|
+
Parameters
|
|
12
|
+
----------
|
|
13
|
+
df : np.ndarray
|
|
14
|
+
A DataFrame containing the data to be plotted.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
self.df = df
|
|
18
|
+
|
|
19
|
+
def plot_cmap(self, x:str, y:str, c:str, cmap:str='viridis', title:str=None) -> None:
|
|
20
|
+
"""
|
|
21
|
+
Create a scatter plot with color mapping based on a DataFrame.
|
|
22
|
+
|
|
23
|
+
Parameters
|
|
24
|
+
----------
|
|
25
|
+
x : str
|
|
26
|
+
The column name for the x-axis values.
|
|
27
|
+
y : str
|
|
28
|
+
The column name for the y-axis values.
|
|
29
|
+
c : str
|
|
30
|
+
The column name for the color mapping values.
|
|
31
|
+
cmap : str, optional
|
|
32
|
+
The colormap to use for the scatter plot (default is 'viridis').
|
|
33
|
+
title : str, optional
|
|
34
|
+
The title of the plot (default is None).
|
|
35
|
+
|
|
36
|
+
Returns
|
|
37
|
+
-------
|
|
38
|
+
None
|
|
39
|
+
"""
|
|
40
|
+
plt.figure(figsize=(10, 6))
|
|
41
|
+
scatter = plt.scatter(self.df[x], self.df[y], c=self.df[c], cmap=cmap)
|
|
42
|
+
plt.colorbar(scatter, label=c)
|
|
43
|
+
plt.xlabel(x)
|
|
44
|
+
plt.ylabel(y)
|
|
45
|
+
if title:
|
|
46
|
+
plt.title(title)
|
|
47
|
+
plt.grid()
|
|
48
|
+
plt.show()
|
exocat/read_tepcat.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#%%
|
|
2
|
+
import requests
|
|
3
|
+
from astropy.io import ascii
|
|
4
|
+
|
|
5
|
+
link = "https://www.astro.keele.ac.uk/jkt/tepcat/allinfo-ascii.txt"
|
|
6
|
+
|
|
7
|
+
txt = requests.get(link).text
|
|
8
|
+
|
|
9
|
+
lines = txt.splitlines()
|
|
10
|
+
# Strip the leading comment marker from the header line
|
|
11
|
+
lines[0] = lines[0].removeprefix("#").strip()
|
|
12
|
+
|
|
13
|
+
ascii_dat = ascii.read(
|
|
14
|
+
lines,
|
|
15
|
+
format="fixed_width",
|
|
16
|
+
delimiter=" ",
|
|
17
|
+
comment=None,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
dat = ascii_dat.to_pandas()
|
|
21
|
+
# Strip leading and trailing hyphens from column names
|
|
22
|
+
dat.columns = dat.columns.str.strip("-")
|
exocat/temperature.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
class Temperature:
|
|
6
|
+
"""A class to represent and classify temperature values."""
|
|
7
|
+
|
|
8
|
+
def __init__(self, df: pd.DataFrame|np.ndarray|list) -> None:
|
|
9
|
+
"""
|
|
10
|
+
Initialize the Temperature class with a DataFrame or an array of temperature values.
|
|
11
|
+
|
|
12
|
+
Parameters
|
|
13
|
+
----------
|
|
14
|
+
df : pd.DataFrame, np.ndarray, or list
|
|
15
|
+
A DataFrame containing a column named 'Teq' or an array/list of temperature values
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
if isinstance(df, pd.DataFrame):
|
|
19
|
+
self.df = df
|
|
20
|
+
self.temperature = np.atleast_1d(np.asarray(df["Teq"]))
|
|
21
|
+
else:
|
|
22
|
+
self.df = None
|
|
23
|
+
self.temperature = np.atleast_1d(np.asarray(df))
|
|
24
|
+
|
|
25
|
+
self.classifications = None
|
|
26
|
+
|
|
27
|
+
def classify(self) -> np.ndarray|str:
|
|
28
|
+
"""
|
|
29
|
+
Classify the temperature values into categories: 'cold', 'warm', or 'hot'.
|
|
30
|
+
|
|
31
|
+
Returns
|
|
32
|
+
-------
|
|
33
|
+
np.ndarray or str
|
|
34
|
+
An array of classifications corresponding to the temperature values.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
output = np.empty_like(self.temperature, dtype=object)
|
|
38
|
+
output[self.temperature > 373] = "hot"
|
|
39
|
+
output[(self.temperature <= 373) & (self.temperature > 273)] = "warm"
|
|
40
|
+
output[self.temperature <= 273] = "cold"
|
|
41
|
+
|
|
42
|
+
self.classifications = output
|
|
43
|
+
return self.classifications
|
|
44
|
+
|
|
45
|
+
def plot(self, bins:int=50) -> None:
|
|
46
|
+
"""
|
|
47
|
+
Plot the distribution of temperature values with color-coded regions for 'cold', 'warm', and 'hot' categories.
|
|
48
|
+
|
|
49
|
+
Parameters
|
|
50
|
+
----------
|
|
51
|
+
bins : int, optional
|
|
52
|
+
The number of bins to use for the histogram (default is 50).
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
plt.figure(figsize=(10, 6))
|
|
56
|
+
ax = plt.gca()
|
|
57
|
+
|
|
58
|
+
ax.axvspan(xmin=self.temperature.min(), xmax=273, color='blue', linestyle='--', label='cold', alpha=0.2)
|
|
59
|
+
ax.axvspan(xmin=273, xmax=373, color='orange', linestyle='--', label='warm', alpha=0.2)
|
|
60
|
+
ax.axvspan(xmin=373, xmax=self.temperature.max(), color='red', linestyle='--', label='hot', alpha=0.2)
|
|
61
|
+
|
|
62
|
+
ax.hist(self.temperature, bins=bins, color='skyblue', edgecolor='black', align="mid", alpha=0.7)
|
|
63
|
+
|
|
64
|
+
cold_mid = (self.temperature.min() + 273) / 2
|
|
65
|
+
warm_mid = (273 + 373) / 2
|
|
66
|
+
hot_mid = (373 + self.temperature.max()) / 2
|
|
67
|
+
y_coord = ax.get_ylim()[1] * 0.9
|
|
68
|
+
ax.text(cold_mid, y_coord, 'Cold', color='blue', fontsize=12, ha='center')
|
|
69
|
+
ax.text(warm_mid, y_coord, 'Warm', color='orange', fontsize=12, ha='center')
|
|
70
|
+
ax.text(hot_mid, y_coord, 'Hot', color='red', fontsize=12, ha='center')
|
|
71
|
+
|
|
72
|
+
ax.set_title('Temperature Distribution')
|
|
73
|
+
ax.set_xlabel('Temperature (K)')
|
|
74
|
+
ax.set_ylabel('Frequency')
|
|
75
|
+
ax.grid(axis='y', alpha=0.5)
|
|
76
|
+
plt.show()
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: exocat
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Classifies exoplanet parameters using the TEPCat catalogue
|
|
5
|
+
Author: Ben Cadell, Mélissa Azombo, Khang Nguyen
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Benjamin-Cadell/exocat
|
|
8
|
+
Keywords: tepcat,classification
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: POSIX
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: matplotlib
|
|
16
|
+
Requires-Dist: astropy
|
|
17
|
+
Requires-Dist: requests
|
|
18
|
+
Requires-Dist: pandas
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# ExoCat
|
|
22
|
+
|
|
23
|
+
This is a project created and developed during the 2026 Code/Astro course at the Manchester local hub.
|
|
24
|
+
|
|
25
|
+
The authors are:
|
|
26
|
+
|
|
27
|
+
Benjamin Cadell
|
|
28
|
+
Mélissa Azombo
|
|
29
|
+
Khang Nguyen
|
|
30
|
+
|
|
31
|
+
The code will classify known transiting exoplanets using the Transiting ExoPlanets Catalogue (TEPCat) using their studied parameters. As of 23/06/2026 the code is still in active development.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
exocat/__init__.py,sha256=Jck2am-Kc7yY3vua1BUYPvdKyFvEdm-MaoImtqSekZI,97
|
|
2
|
+
exocat/bulk_density.py,sha256=VINkKl8XqRxvAzcpNqVPDBeJucYp7240iGlXBUJJk3Y,2809
|
|
3
|
+
exocat/plots.py,sha256=GffLLLyTtH10tjc3QgMcbk9CSbHva3fOeShM3dTUt6M,1378
|
|
4
|
+
exocat/read_tepcat.py,sha256=pPMJTvn-VLyX8ZT5yk6-MCdcygUIulVhoXMFnNH0PUE,503
|
|
5
|
+
exocat/temperature.py,sha256=-BIh6nE5GWUnJuflyZ1U2ocAsPn8dmqa8WUdqV_bXhQ,2852
|
|
6
|
+
exocat-0.1.0.dist-info/licenses/LICENSE,sha256=iMzcYTs_w1MWoT1K6CsTTsNdjxf5oVscJfhl6sj9mA4,1072
|
|
7
|
+
exocat-0.1.0.dist-info/METADATA,sha256=Vg9lYF3euvDd4ytRdLPvHlAi34e_R0Ef5SkFKxT57gI,981
|
|
8
|
+
exocat-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
9
|
+
exocat-0.1.0.dist-info/top_level.txt,sha256=7UiqTDhRL1RQyIf-PvrQdwLuTYSisGQhKGWLbi1gknU,7
|
|
10
|
+
exocat-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Benjamin-Cadell
|
|
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 @@
|
|
|
1
|
+
exocat
|