From 7e22daff55c2c4ae02b4e9586f1bfd069e3d6486 Mon Sep 17 00:00:00 2001 From: emilyhunt Date: Tue, 23 Sep 2025 14:00:39 +0200 Subject: [PATCH] Initial setup of basic skeleton & skeleton methods --- .python-version | 1 + pyproject.toml | 14 +++++++ src/hr_selection_function/__init__.py | 3 ++ src/hr_selection_function/config.py | 60 +++++++++++++++++++++++++++ src/hr_selection_function/data.py | 6 +++ src/hr_selection_function/gaia.py | 16 +++++++ src/hr_selection_function/models.py | 6 +++ 7 files changed, 106 insertions(+) create mode 100644 .python-version create mode 100644 pyproject.toml create mode 100644 src/hr_selection_function/__init__.py create mode 100644 src/hr_selection_function/config.py create mode 100644 src/hr_selection_function/data.py create mode 100644 src/hr_selection_function/gaia.py create mode 100644 src/hr_selection_function/models.py diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..e4fba21 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7c54607 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,14 @@ +[project] +name = "hr-selection-function" +version = "0.1.0" +description = "Selection function for the Hunt & Reffert 2024 open cluster catalogue." +readme = "README.md" +authors = [ + { name = "emilyhunt", email = "emily.hunt.physics@gmail.com" } +] +requires-python = ">=3.12" +dependencies = [] + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" diff --git a/src/hr_selection_function/__init__.py b/src/hr_selection_function/__init__.py new file mode 100644 index 0000000..2bd26f7 --- /dev/null +++ b/src/hr_selection_function/__init__.py @@ -0,0 +1,3 @@ +from .config import set_data_directory +from .models import HR24SelectionFunction, NStarsPredictor +from .gaia import estimate_gaia_data_density, estimate_m10, estimate_m_rybizki \ No newline at end of file diff --git a/src/hr_selection_function/config.py b/src/hr_selection_function/config.py new file mode 100644 index 0000000..e0331b9 --- /dev/null +++ b/src/hr_selection_function/config.py @@ -0,0 +1,60 @@ +"""File specifying various configuration options for the package.""" + +import os +from pathlib import Path + + +# Internal config storage dict (user access not supported!) +_CONFIG = dict() + + +# Some helpers for config things +def set_data_directory(directory: Path | str): + """User-facing function for the + + Parameters + ---------- + directory : Path | str + Directory to set. Must be a pathlib.Path or a string that can be cast to a Path. + The specified directory will be checked for validity + """ + directory, first_time = _setup_data_directory(directory) + _CONFIG['data_dir'], _CONFIG['first_run'] = directory, first_time + + + +def _setup_data_directory(directory: Path | str) -> tuple[Path, bool]: + """Performs setup of the data directory to be used in the package, checking user + arguments & creating it.""" + # Initial checks + if isinstance(directory, str): + try: + directory = Path(directory) + except Exception as e: + raise ValueError( + f"Unable to cast user-specified directory '{directory}' into a path. " + "Are you sure it is a valid path on your operating system?" + ) + + if not isinstance(directory, Path): + raise ValueError("Data directory path must be a pathlib.Path or string.") + + # Make the directory + first_time = False + if not directory.exists(): + print( + "This looks like your first time running the hr_selection_function package " + "/ with this data directory. Trying to create data directory at " + f"{directory}..." + ) + directory.mkdir(parents=True) + first_time = False + + return directory, first_time + + +# Setup default directory +directory = os.getenv("HRSF_DATA", None) +if directory is None: + directory = Path.home() / ".hr_selection_function" +directory, first_time = _setup_data_directory(directory) diff --git a/src/hr_selection_function/data.py b/src/hr_selection_function/data.py new file mode 100644 index 0000000..a985217 --- /dev/null +++ b/src/hr_selection_function/data.py @@ -0,0 +1,6 @@ +def _check_data_exists(): + pass + + +def _download_data(): + pass diff --git a/src/hr_selection_function/gaia.py b/src/hr_selection_function/gaia.py new file mode 100644 index 0000000..12fa314 --- /dev/null +++ b/src/hr_selection_function/gaia.py @@ -0,0 +1,16 @@ +from hr_selection_function.config import _CONFIG + + +_MAPS = dict() + + +def estimate_gaia_data_density(): + pass + + +def estimate_m10(): + pass + + +def estimate_m_rybizki(): + pass diff --git a/src/hr_selection_function/models.py b/src/hr_selection_function/models.py new file mode 100644 index 0000000..874daa1 --- /dev/null +++ b/src/hr_selection_function/models.py @@ -0,0 +1,6 @@ +class HR24SelectionFunction: + pass + + +class NStarsPredictor: + pass -- 2.51.2