A Python Wrapper for running the Brussels Automatic Code for Characterizing High accUracy Spectra (BACCHUS (https://ui.adsabs.harvard.edu/abs/2016ascl.soft05004M/abstract)).
- Features
- Installation
- Quick Start
- Usage
- Parameters
- Examples
- Contributing
- Citation
- License
- Acknowledgments
The purpose of this code is to allow interfacing with the native BACCHUS enivroment using Python. This is NOT a version of BACCHUS written in Python, it requires an existing BACCHUS installation to function.
There are three primary modules for this package: BACCHUS, Star, and Result.
The BACCHUS class is instantiated by giving it the location of an existing BACCHUS installation. Once a BACCHUS object is created, it will be populated with the existing state of all the primary bacchus modules:
for a BACCHUS object bacchus
bacchus = BACCHUS('your path here!')
- bsyn.com --> bacchus.bsyn
- babsma.com --> bacchus.babsma
- stellar_parameters.tab --> bacchus.stellar_parameters
- init.com --> bacchus.init
- elements.wln --> bacchus.elements_wln
- eqwidt.com --> bacchus.eqwidt
as well as a linelists object that contains the paths to all available linelists. Each of these modules is accessible in a BACCHUS object as an attribute (e.g. init.com can be accessed by bacchus.init). This allows for editing each module in python, both through direct line-by-line editing, and a suite of preloaded methods (e.g. set_ncpu, set_linelist). MORE DOCUMENTATION COMING.
Once the configuration of BACCHUS is set up to your liking, you can write it out to the native BACCHUS.
A Star object is the container for the stars being run in BACCHUS. At a minimum it requires a name to be instantiated, but to load into stellar_parameters.tab it will require the six necessary parameters (spectra path, teff, logg, etc...). This object will also have access to all the parameter and model information from a BACCHUS analysis, as well as the elemental abundance results (stored in a Results object).
A Results object holds all the data for a single element within a Star. It automatically scrapes the star's directory after a .abund, .eqw, or .param analysis load in the .abu, .plt, and .eqw results as Astropy Tables.
After you've configured your BACCHUS setup to your liking and written the setup to native BACCHUS, you can follow the same procedure normally used in native BACCHUS
for a BACCHUS object bacchus, and a Star object
import PyBACCHUS
from PyBACCHUS import *
from PyBACCHUS.bacchus import BACCHUS
from PyBACCHUS.star import Star
bacchus = BACCHUS('your path here!')
1) bacchus.load_parameters(Star)
2) bacchus.abund(Star)
3) bacchus.eqw(Star)
4) bacchus.param(Star)
import PyBACCHUS
from PyBACCHUS import *
from PyBACCHUS.bacchus import BACCHUS
from PyBACCHUS.star import Star
bacchus = BACCHUS('your path here!')
star = Star(starname)
#let's say we only want to use one CPU and the metal-poor line selenction
bacchus.init.set_ncpu(1)
bacchus.init.set_wavereffile('elements_MP.wln')
#check to see your configuration is good
bacchus.init.show()
bacchus.bsyn.show()
#now we can write out our changes to the init.com file
bacchus.init.write()
#now lets get our star ready. to set its initial guesses, we need a spectra path (str),
#and teff/logg/mh/vmicro/conv all as tuples of the form (guess, uncertainty).
star.set_initial_values(spectra_path, (5000,100), (4.5, 0.1), (0,0.1),(1.5,0.2), (-15,5))
bacchus.stellar_parameters.add_star(star)
bacchus.stellar_parameters.write()
#check to see your stellar_parameters.tab is good
bacchus.stellar_parameters.show()
#now run your abundance analysis!
bacchus.load_parameters(star)
bacchus.param(star)
bacchus.eqw(star, 'C')
bacchus.abund(star, 'Zr')
pip install PyBACCHUS
# Latest development version
pip install git+https://github.com/rocketxturtle/PyBACCHUS
# Or clone and install locally
git clone https://github.com/rocketxturtle/PyBACCHUS.git
cd PyBACCHUS
pip install -e .
The package requires the following Python libraries:
numpy- Numerical computationspandas- Data manipulationastropy- Astronomical utilitiesmatplotlib- Plotting functionality
These will be automatically installed with the package.
PyBACCHUS/
├── __init__.py # Package initialization and version info
├── bacchus.py # The core BACCHUS object that mimics the file structure of BACCHUS
├── star.py # Contains the Star class, which is used to run objects in BACCHUS
├── results.py # A class that contains all the result data for a star
|_ other # Individual classes that mimic the functionality of each BACCHUS module
(e.g. bsyn.com, babsma.com, stellar_parameters.tab, ....)
We welcome contributions! Please feel free to:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Adding better plotting functionality
- Interfacing with Korg
- Documentation & debugging
If you use PyBACCHUS in your research, please cite this code as well as the original citation for BACCHUS:
@misc{PyBACCHUS,
author = {{Sinha}, Amaya},
title = {PyBACCHUS: Interactive Stellar Spectra Plotting Tool},
year = {2025},
publisher = {Zenodo},
doi = {10.5281/zenodo.17070806},
url = {https://github.com/rocketxturtle/PyBACCHUS}
}
@software{2016ascl.soft05004M,
author = {{Masseron}, Thomas and {Merle}, Thibault and {Hawkins}, Keith},
title = "{BACCHUS: Brussels Automatic Code for Characterizing High accUracy Spectra}",
howpublished = {Astrophysics Source Code Library, record ascl:1605.004},
year = 2016,
month = may,
eid = {ascl:1605.004},
adsurl = {https://ui.adsabs.harvard.edu/abs/2016ascl.soft05004M},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}
This project is licensed under the MIT License - see the LICENSE file for details.
- Developed partially at Code/Astro workshop
- Special thanks to the astronomy community for feedback and testing
Found a bug or have a question? Please open an issue on our GitHub Issues page.
- Add in the code for creating multiple parallelized BACCHI
- Add in better plotting (e.g. with lines) & reading in the SuperMongo plots
- Add in functionality for editing linelists
Happy stellar spectroscopy! 🔭✨
Remember: The universe is under no obligation to make sense to you, but these spectra might help!