Skip to main content

Apply Placco et al. (2014) carbon abundance evolutionary corrections.

Project description

carbcor

PyPI Python License: MIT

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 1k stars.
df = pd.DataFrame({
    "logg": [1.4,  1.5,  3.7],
    "feh":  [-2.7, -3.1, -5.4],
    "cfe":  [0.2,  1.0,  3.0],
})
df_cor = apply_carbon_corrections(df)
print(df_cor[["cfe", "cfe_corrected", "correction"]])

Command line

# Query a single star
carbcor query 1.0 -3.0 1.5

# 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

  1. The package carbcor fetches the website HTML and auto-discovers the form structure (action URL, HTTP method, field names).
  2. For each star, it submits the parameters and parses the correction delta from the HTML response.
  3. Corrected [C/Fe] = input [C/Fe] + correction delta.
  4. Missing / NaN inputs produce NaN outputs (standard float('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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

carbcor-1.0.0.tar.gz (482.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

carbcor-1.0.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file carbcor-1.0.0.tar.gz.

File metadata

  • Download URL: carbcor-1.0.0.tar.gz
  • Upload date:
  • Size: 482.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.14

File hashes

Hashes for carbcor-1.0.0.tar.gz
Algorithm Hash digest
SHA256 28b257f0bbc620d8b593b3a7c5ad6d97ed363bb6dde5bb5ae97c600ab3646638
MD5 380dde744c84ba9367f96e51528a4771
BLAKE2b-256 7f18cbfc3d8b6433385583a38f93f60b0bd477c65d10c50f3b99ec9ffe1ac243

See more details on using hashes here.

File details

Details for the file carbcor-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: carbcor-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.14

File hashes

Hashes for carbcor-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46fe4d5e49f1521814bdfd44b4f7cf1c9cedd231f2891beab992caed054330b1
MD5 6930d01eb0c3dc583d5688d62b7e3924
BLAKE2b-256 080ef662450bf741f562e9a7b7bd5833e754caaaa60d843b2dec2ff340badbe2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page