Apply Placco et al. (2014) carbon abundance evolutionary corrections.
Project description
carbcor
Python package to calculate Placco et al. (2014) carbon abundance evolutionary corrections with online tool at vplacco.pythonanywhere.com.
Corrects observed [C/Fe] abundances for the depletion of carbon due to CN processing on the upper red giant branch. Inputs are observed [C/Fe], logg, and [Fe/H].
Installation
pip install carbcor
Quick start
Python API
from carbcor import get_carbon_correction, apply_carbon_corrections
import pandas as pd
# Single star
res = get_carbon_correction(logg=0.88, feh=-4.82, cfe=0.50) # these are the parameters for star GDR3_526285 [Limberg, Placco et al. (2025)](https://ui.adsabs.harvard.edu/abs/2025ApJ...989L..18L/abstract)
print(res["cfe_corrected"]) # corrected [C/Fe]
print(res["correction"]) # correction delta
# Batch from a DataFrame
# You can test for the whole JINAbase [Abohalima & Frebel 2018](https://ui.adsabs.harvard.edu/abs/2018ApJS..238...36A/abstract) following the tests folder.
# Since it parses 1 star at a time, it takes ~10min for each 2.5k stars.
df = pd.DataFrame({
"logg": [0.88, -4.82, 0.50], # GDR3_526285 [Limberg, Placco et al. (2025)](https://ui.adsabs.harvard.edu/abs/2025ApJ...989L..18L/abstract)
"feh": [1.89, -4.11, 2.20], # HE 0144-4657 [Placco, Limberg et al. (2026)](https://ui.adsabs.harvard.edu/abs/2026ApJ..1000L..34P/abstract)
"cfe": [2.02, -4.06, 1.53], # GDR3 47959 [Limberg, Placco et al. (2026)] --> submitted
})
df_cor = apply_carbon_corrections(df)
print(df_cor[["cfe", "cfe_corrected", "correction"]])
Command line
# Query a single star
carbcor query 0.88 -4.82 0.50
# Process a CSV file
carbcor batch stars.csv -o corrected.csv
# Inspect the web form structure
carbcor discover
Parameter space
The underlying correction grid covers:
| Parameter | Range | Step |
|---|---|---|
| log(g) | 0.0 to 5.0 | 0.1 |
| [Fe/H] | −5.5 to 0.0 | 0.1 |
| [C/Fe] | −1.0 to 3.0 | 0.1 |
Values outside these ranges are clipped to the nearest grid point.
Custom column names
apply_carbon_corrections(df, logg_col="logg", feh_col="Fe/H", cfe_col="CFe") # example for the JINAbase_2021.csv table
How it works
- The package
carbcorfetches the website HTML and auto-discovers the form structure (action URL, HTTP method, field names). - For each star, it submits the parameters and parses the correction delta from the HTML response.
- Corrected [C/Fe] = input [C/Fe] + correction delta.
- Missing / NaN inputs produce
NaNoutputs (standardfloat('nan'), which is to be compatible with pandas, i.e., you can just plot it afterwards).
Development
git clone https://github.com/guilimberg/carbcor.git
cd carbcor
pip install -e ".[dev]"
pytest
Reference
If you use this tool, you SHOULD cite:
Placco, V.M., Frebel, A., Beers, T.C., & Stancliffe, R.J. 2014, ApJ, 797, 21 (ADS | arXiv:1410.2223)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file carbcor-1.0.1.tar.gz.
File metadata
- Download URL: carbcor-1.0.1.tar.gz
- Upload date:
- Size: 582.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4b3dd0a1cd321207e956c14b452321fc561873f9a5876f4f88789f16c194f93
|
|
| MD5 |
8a50238cd13913e5c33acd84dd83f68a
|
|
| BLAKE2b-256 |
39bfda0dcaa2538bed146657520ee10ecfa6eafdc581b345713f119e90e44781
|
File details
Details for the file carbcor-1.0.1-py3-none-any.whl.
File metadata
- Download URL: carbcor-1.0.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77711a45129a686f556d1cfda4a5b50c2139e355ed69ac832ea47d1a09862c3e
|
|
| MD5 |
33d7520072c57ff90b07bc0500397471
|
|
| BLAKE2b-256 |
2d6afd16a842abb3a23ab56c25cc0a48605a5dd05dccc9c279b1baa5da863432
|