Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2a91230
Add PHOENIX backend module (initial)
ytsapras Mar 6, 2026
2f70048
Add PHOENIX template backend and smoke test
ytsapras Mar 6, 2026
e558c5c
Ignore build and bytecode artifacts
ytsapras Mar 6, 2026
57c5832
Test PHOENIX cache with tolerance; store/load flux_grid
ytsapras Mar 6, 2026
96be868
Add SpectrumSegment and PEPSI .nor reader
ytsapras Mar 6, 2026
7dd0ea6
Improve PHOENIX fitter: optional RV init, scaling, subgrid selection
ytsapras Mar 10, 2026
4beaa56
feat: add PHOENIX native-grid fitting and X-SHOOTER validation
ytsapras Mar 20, 2026
ad72c86
refactor: centralize fit helpers and improve smoketest UX
ytsapras Mar 20, 2026
a10c9ae
feat: add XDG config support for PHOENIX path
ytsapras Apr 8, 2026
1245be9
Add PHOENIX workflow recipes, instrument readers, smoke tests, and ex…
ytsapras Apr 10, 2026
5db3e3e
Add top-level project README
ytsapras Apr 10, 2026
e12ddad
Add top-level project README
ytsapras Apr 10, 2026
62245b2
Refactor PHOENIX fitting core and add SpectrumCollection support
ytsapras May 11, 2026
04e4319
Add X-SHOOTER VIS/NIR example data and update notebook
ytsapras May 11, 2026
6857081
Stabilize PHOENIX native fitting and Balmer recipes
ytsapras May 17, 2026
e055534
Update simple PHOENIX classification example
ytsapras May 17, 2026
5b5ec7b
Add X-SHOOTER multi-arm PHOENIX example
ytsapras May 17, 2026
ea66695
Use shared speed-of-light constant
ytsapras May 17, 2026
68f9266
Use shared speed-of-light constant
ytsapras May 17, 2026
e4607e7
Document PHOENIX workflow architecture
ytsapras May 17, 2026
3821361
Share native PHOENIX wavelength grid builder
ytsapras May 18, 2026
ba9af1f
Use shared velocity broadening implementation
ytsapras May 18, 2026
b6f69f8
Document PHOENIX wavelength grid state
ytsapras May 18, 2026
05638fa
Preserve shape in velocity broadening helper
ytsapras May 18, 2026
01a34e0
Move PEPSI legacy window helpers into recipes
ytsapras May 19, 2026
770f860
Move PEPSI legacy window helpers into recipes
ytsapras May 19, 2026
fe77eb6
Add PEPSI example spectra and shared grid helper
ytsapras May 19, 2026
d2a5197
Move observed-grid RV resampling into waveutils
ytsapras May 19, 2026
6d78556
Add PEPSI fitting presets
ytsapras May 19, 2026
24dd40b
Move PEPSI legacy likelihood helpers into recipes
ytsapras May 19, 2026
9f77248
Use SpectrumCollection for PEPSI legacy windows
ytsapras May 19, 2026
647995b
Polish PEPSI smoke-test command-line interface
ytsapras May 19, 2026
4176c0f
Polish PEPSI smoke-test command-line interface
ytsapras May 19, 2026
1f06184
Add PEPSI legacy line-window validation notebook
ytsapras May 19, 2026
77644fa
Merge upstream master into feature/phoenix-backend
ytsapras Jul 2, 2026
b19e8e6
Require Python 3.12
ytsapras Jul 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
.idea/inspectionProfiles/
.idea/modules.xml
Spyctres/__pycache__/
# Python bytecode
__pycache__/
*.py[cod]

# Packaging / build artifacts
*.egg-info/
build/
dist/

# IDE files
.idea/

# Notebooks
.ipynb_checkpoints/

# Local development scripts
scripts/phoenix_backend_compare.py
127 changes: 101 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,117 @@
# Spyctres

Spyctres is a tool for analysing stellar spectra. It can compare a measured spectrum with publicly-available
libraries of spectral templates in order to find the closest match.
Spyctres is a Python package for stellar spectral fitting and spectral typing from reduced spectra. It can compare a measured spectrum with publicly available spectral-template libraries to find the closest match.

Developer: Etienne Bachelet

Please note that Spyctres is still under development.
Spyctres is still under active development. It includes core fitting utilities, instrument I/O helpers, plotting tools, and example workflows. Recent additions include PHOENIX template-based fitting and a clearer separation between generic fitting code, workflow recipes, examples, and smoke tests.

## Features

- spectral fitting utilities in `Spyctres/Spyctres.py`
- generic spectrum containers and reader dispatch in `Spyctres/io.py`
- PHOENIX template support in `Spyctres/phoenix.py`
- PHOENIX forward modelling in `Spyctres/phoenix_forward.py`
- fitting helpers in `Spyctres/fitting.py`
- workflow recipes in `Spyctres/recipes.py`
- plotting helpers in `Spyctres/plotting.py`

## Installation
For the time being, the best way to install Spyctres is to clone its [Github repository](https://github.com/ebachelet/Spyctres),
and run the setup.py. It is recommended that you create and activate a virtual environment before proceeding with this
installation.

```commandline
venv> git clone https://github.com/ebachelet/Spyctres.git
venv> cd Spyctres/
venv> python setpy.py install

Spyctres is currently intended for local editable installs during development. Creating and activating a virtual environment first is recommended.

Spyctres requires Python 3.12 or later.

```bash
git clone https://github.com/ebachelet/Spyctres.git
cd Spyctres
pip install -e .
```

Some legacy workflows use `pysynphot` and its successor package `stsynphot`:

```bash
pip install pysynphot stsynphot
```

Spyctres makes use of ```pysynphot``` and its successor package ```stsynphot``` as dependencies.
These can both be installed via pip:
Those workflows also require the stellar template libraries linked from the [pysynphot installation documentation](https://pysynphot.readthedocs.io/en/latest/index.html#pysynphot-installation-setup). After downloading and unpacking them, set `PYSYN_CDBS` to their local root directory:

```bash
export PYSYN_CDBS=/path/to/cdbs
```

PHOENIX workflows require additional scientific Python dependencies and a local PHOENIX template directory.

The PHOENIX templates may be downloaded from the Goettingen Spectral Library:

- PHOENIX archive: `https://phoenix.astro.physik.uni-goettingen.de/`
- PHOENIX v2 HiResFITS directory: `https://phoenix.astro.physik.uni-goettingen.de/data/v2.0/HiResFITS/PHOENIX-ACES-AGSS-COND-2011/`
- PHOENIX v2 wavelength file: `https://phoenix.astro.physik.uni-goettingen.de/data/v2.0/HiResFITS/WAVE_PHOENIX-ACES-AGSS-COND-2011.fits`

The wavelength file must be placed in the root directory of the PHOENIX v2 models.

## PHOENIX template path

The local PHOENIX path is resolved in this order:

```commandline
venv> pip install pysynphot
venv> pip install stsynphot
1. explicit command-line value
2. environment variable `SPYCTRES_PHOENIX_DIR`
3. config file `~/.config/spyctres/config.toml`

Example config:

```toml
[paths]
phoenix_dir = "/path/to/PHOENIXv2"
```

Lastly, you will need to download the stellar spectrum library used as templates in Spyctres fitting
process. Tarballs of these libraries are linked from the [```pysynphot``` ReadTheDocs page](https://pysynphot.readthedocs.io/en/latest/index.html#pysynphot-installation-setup)
in the second table.
## Quick start

Useful entry points in the repository include:

- `quick_example.py` for the legacy fitting workflow
- `examples/full_spectrum_classification.ipynb` for PHOENIX classification
- smoke tests under `scripts/`

Download and unpack these files into a local directory. In order to tell Spyctres where to find this library,
the path to it should be declared as an environment variable in any script or shell where the software is
run, e.g.
To open the PHOENIX example notebook:

```python
os.environ['PYSYN_CDBS'] = '/my/path/cdbs/'
```bash
jupyter lab examples/full_spectrum_classification.ipynb
```

## Running Spyctres
The ```quick_example.py``` script in this repository provides a worked demonstration of the fitting process.
## Supported readers

Current reader coverage includes:

- X-SHOOTER 1D products
- PEPSI `.dxt.nor`
- FLOYDS ASCII/CSV exports
- Gemini/GMOS ASCII exports

Readers return a generic `SpectrumSegment` object so that fitting code can remain instrument-agnostic.

## Project structure

Spyctres is organized around four layers:

- generic fitting core
- workflow recipes
- user-facing examples
- developer smoke tests

Notable files:

- `Spyctres/recipes.py`
- `examples/full_spectrum_classification.ipynb`
- `scripts/xshooter_fit_smoketest.py`

## Current limitations

PHOENIX support should still be treated as alpha.

In particular:

- the example notebook is a first-pass classification workflow, not a final precision analysis
- some workflows still require user judgment for wavelength windows, masking, resolving power, and continuum treatment
- instrument-specific metadata quality varies across input formats
- packaging and documentation are still minimal
3 changes: 2 additions & 1 deletion Spyctres.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.6,<4
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.12,<4
License-File: LICENSE
Requires-Dist: scipy
Requires-Dist: numpy
Expand Down
Loading