-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
224 changed files
with
24,493 additions
and
100,864 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
# ignore everything in root | ||
/* | ||
# except for this file | ||
!asteca.py | ||
# except for these files | ||
!README.md | ||
!CHANGELOG.rst | ||
!LICENSE.txt | ||
# and this folder | ||
!/packages | ||
# But do ignore these files | ||
!poetry.lock | ||
!pyproject.toml | ||
!.readthedocs.yaml | ||
|
||
# and these folderers | ||
!/asteca | ||
!/docs | ||
|
||
# But ignore these files | ||
*.pyc | ||
*.pickle | ||
|
||
# and ignore these folders | ||
/docs/build/* | ||
/docs/autoapi/* | ||
# Jupyter Notebook | ||
.ipynb_checkpoints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Read the Docs configuration file for Sphinx projects | ||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details | ||
|
||
# Required | ||
version: 2 | ||
|
||
# Set the OS, Python version and other tools you might need | ||
build: | ||
os: ubuntu-22.04 | ||
tools: | ||
python: "3.12" | ||
# You can also specify other tool versions: | ||
# nodejs: "20" | ||
# rust: "1.70" | ||
# golang: "1.20" | ||
|
||
# Build documentation in the "docs/" directory with Sphinx | ||
sphinx: | ||
configuration: docs/conf.py | ||
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs | ||
# builder: "dirhtml" | ||
# Fail on all warnings to avoid broken references | ||
# fail_on_warning: true | ||
|
||
# Optionally build your docs in additional formats such as PDF and ePub | ||
# formats: | ||
# - epub | ||
|
||
# Optional but recommended, declare the Python requirements required | ||
# to build your documentation | ||
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html | ||
python: | ||
install: | ||
- requirements: docs/requirements.txt |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from .isochrones import isochrones | ||
from .synthetic import synthetic | ||
from .cluster import cluster | ||
from .likelihood import likelihood | ||
|
||
from contextlib import suppress | ||
import importlib.metadata | ||
from pathlib import Path | ||
|
||
|
||
def extract_version() -> str: | ||
"""Returns either the version of the installed package or the one | ||
found in nearby pyproject.toml | ||
https://stackoverflow.com/a/76206192/1391441 | ||
""" | ||
with suppress(FileNotFoundError, StopIteration): | ||
pp_file = Path(__file__).parent.parent / "pyproject.toml" | ||
with open(pp_file, encoding="utf-8") as pyproject_toml: | ||
version = ( | ||
next(line for line in pyproject_toml if line.startswith("version")) | ||
.split("=")[1] | ||
.strip("'\"\n ") | ||
) | ||
return f"{version}" | ||
# return importlib.metadata.version(__package__ | ||
# or __name__.split(".", maxsplit=1)[0]) | ||
return importlib.metadata.version(__package__ or __name__) | ||
|
||
|
||
__version__ = extract_version() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
from dataclasses import dataclass | ||
from typing import Optional | ||
import numpy as np | ||
import pandas as pd | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
@dataclass | ||
class cluster: | ||
r"""Define a ``cluster`` object. | ||
Parameters | ||
---------- | ||
cluster_df : pd.DataFrame | ||
pandas DataFrame with the cluster's loaded data | ||
magnitude : str | ||
Name of the DataFrame column that contains the magnitude | ||
e_mag : str | ||
Name of the DataFrame column that contains the magnitude's uncertainty | ||
color : str | ||
Name of the DataFrame column that contains the color | ||
e_color : str | ||
Name of the DataFrame column that contains the color's uncertainty | ||
ra: str, optional, default=None | ||
Name of the DataFrame column that contains the right ascension (RA) | ||
dec: str, optional, default=None | ||
Name of the DataFrame column that contains the declination (DEC) | ||
plx: str, optional, default=None | ||
Name of the DataFrame column that contains the parallax | ||
pmra: str, optional, default=None | ||
Name of the DataFrame column that contains the RA proper motion | ||
pmde: str, optional, default=None | ||
Name of the DataFrame column that contains the DEC proper motion | ||
color2: str, optional, default=None | ||
Name of the DataFrame column that contains the second color | ||
e_color2: str, optional, default=None | ||
Name of the DataFrame column that contains the second color's uncertainty | ||
""" | ||
cluster_df: pd.DataFrame | ||
magnitude: str | ||
e_mag: str | ||
color: str | ||
e_color: str | ||
ra: Optional[str] = None | ||
dec: Optional[str] = None | ||
plx: Optional[str] = None | ||
pmra: Optional[str] = None | ||
pmde: Optional[str] = None | ||
color2: Optional[str] = None | ||
e_color2: Optional[str] = None | ||
|
||
def __post_init__(self): | ||
# Load photometry | ||
self._load() | ||
|
||
def _load(self): | ||
""" | ||
The photometry is store with a '_p' to differentiate from the self.magnitude, | ||
self.color, etc that are defined with the class is called. | ||
""" | ||
print("Reading and processing cluster data") | ||
|
||
self.mag_p = np.array(self.cluster_df[self.magnitude]) | ||
self.e_mag_p = np.array(self.cluster_df[self.e_mag]) | ||
|
||
self.colors_p = [np.array(self.cluster_df[self.color])] | ||
if self.color2 is not None: | ||
self.colors_p.append(np.array(self.cluster_df[self.color2])) | ||
self.e_colors_p = [np.array(self.cluster_df[self.e_color])] | ||
if self.e_color2 is not None: | ||
self.e_colors_p.append(np.array(self.cluster_df[self.e_color2])) | ||
|
||
if self.ra is not None: | ||
self.ra_v = self.cluster_df[self.ra] | ||
self.dec_v = self.cluster_df[self.dec] | ||
|
||
print("Cluster object generated\n") | ||
|
||
def radecplot(self): | ||
r"""Generate a (RA, DEC) plot. | ||
Returns | ||
------- | ||
matplotlib.axis | ||
Matplotlib axis object | ||
""" | ||
ra = self.ra_v # cluster_df[self.ra].values | ||
dec = self.dec_v # cluster_df[self.dec].values | ||
mag = self.mag_p # self.cluster_df[self.magnitude].values | ||
|
||
msk = ~np.isnan(mag) | ||
ra = ra[msk] | ||
dec = dec[msk] | ||
mag = mag[msk] | ||
|
||
# Mag to flux | ||
sizes = 10 ** (mag / -2.5) | ||
# Normalize to 1 | ||
sizes /= sizes.max() | ||
# Set min, max | ||
sizes = 1 + 75 * sizes | ||
|
||
f, ax = plt.subplots() | ||
plt.scatter(ra, dec, s=sizes, c="k", alpha=0.7) | ||
plt.xlabel("RA") | ||
plt.ylabel("DEC") | ||
plt.gca().invert_xaxis() | ||
|
||
return ax | ||
|
||
def clustplot(self, ax=None, binar_prob=None): | ||
r"""Generate a color-magnitude plot. | ||
Parameters | ||
---------- | ||
ax : matplotlib.axis, optional, default=None | ||
Matplotlib axis where to draw the plot | ||
binar_prob : numpy.array, optional, default=None | ||
Array with probabilities of being a binary system for each observed star | ||
Returns | ||
------- | ||
matplotlib.axis | ||
Matplotlib axis object | ||
""" | ||
if ax is None: | ||
f, ax = plt.subplots() | ||
|
||
if binar_prob is not None: | ||
msk_binar = binar_prob > 0.5 | ||
|
||
mag_col = self.magnitude | ||
col_col = self.color | ||
|
||
if binar_prob is None: | ||
ax.scatter( | ||
self.colors_p[0], | ||
self.mag_p, | ||
c="green", | ||
alpha=0.5, | ||
label=f"Observed, N={len(self.mag_p)}", | ||
) | ||
else: | ||
ax.scatter( | ||
self.colors_p[0][~msk_binar], | ||
self.mag_p[~msk_binar], | ||
c="green", | ||
alpha=0.5, | ||
label=f"Observed (single), N={len(self.mag_p[~msk_binar])}", | ||
) | ||
ax.scatter( | ||
self.colors_p[0][msk_binar], | ||
self.mag_p[msk_binar], | ||
c="red", | ||
alpha=0.5, | ||
label=f"Observed (binary), N={len(self.mag_p[msk_binar])}", | ||
) | ||
|
||
ax.set_ylim(max(self.mag_p) + .5, min(self.mag_p) - .5) | ||
ax.set_xlabel(col_col) | ||
ax.set_ylabel(mag_col) | ||
ax.legend() | ||
|
||
return ax |
Oops, something went wrong.