Metadata-Version: 2.4
Name: compytools
Version: 0.1.0
Summary: Read and write CompOSE equation-of-state tables.
Author-email: "Philip J. Davis" <davis@lpccaen.in2p3.fr>
License-Expression: MIT
Project-URL: Documentation, https://compytools.in2p3.fr/
Project-URL: Repository, https://gitlab.in2p3.fr/lpc-caen/compytools
Project-URL: Issues, https://gitlab.in2p3.fr/lpc-caen/compytools/-/issues
Keywords: astrophysics,CompOSE,equations of state,neutron stars,nuclear physics
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Astronomy
Classifier: Programming Language :: Fortran
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: astropy>=7.1.0
Requires-Dist: matplotlib>=3.10.3
Requires-Dist: pandas>=2.3.2
Requires-Dist: scipy>=1.15.2
Requires-Dist: rich>=14.1.0
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: jupyter-sphinx; extra == "dev"
Requires-Dist: nbsphinx; extra == "dev"
Requires-Dist: pytest>=8.4.1; extra == "dev"
Requires-Dist: sphinx-copybutton; extra == "dev"
Requires-Dist: sphinx-rtd-theme; extra == "dev"
Requires-Dist: sphinxemoji; extra == "dev"
Requires-Dist: twine; extra == "dev"
Provides-Extra: jupyter
Requires-Dist: jupyterlab>=4.4.3; extra == "jupyter"
Dynamic: license-file

![compytools](https://gitlab.in2p3.fr/lpc-caen/compytools/-/raw/main/docs/source/logo/ComPyTools_logo_rescaled.png)

[![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://opensource.org/license/mit)
[![astropy](http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat-square)](http://www.astropy.org/)
![coverage](https://img.shields.io/badge/coverage-92%25-orange)

**ComPyTools** is an open source (MIT) Python package for working with equation of state (EoS) tables in the [**CompOSE** ("CompStar Online Supernova Equations of State")](https://compose.obspm.fr/home/) format. It provides tools to read, write and analyse **CompOSE** tables within Python workflows, leveraging **astropy** for data tables, units and metadata.

**ComPyTools** allows the user to:

* Read in **CompOSE** cold or general purpose EoS tables,
* Create interpolated tables from cold or general purpose EoSs via a Python interface to the **CompOSE** code,
* Produce cold EoS tables in the **CompOSE** format for those who wish to contribute their own EoS to the **CompOSE** database.

# Quick Example

```python
import tempfile
import matplotlib.pyplot as plt

from compytools import EoS
from compytools.download import CompOSEDownloader

# Download sample data into temporary directory
# for purposes of this example
tmpdir = tempfile.TemporaryDirectory()
downloader = CompOSEDownloader.from_eosname('PCP(BSk22)', tmpdir.name)
downloader.get()

bsk22 = EoS.from_compose(tmpdir.name)

# View the data in tabular form
bsk22.thermo.pprint(max_width=-1)

# View column descriptions
print(bsk22.thermo.info)

nb = bsk22.params.nb.grid_points
pressure = bsk22.thermo['Q1'] * nb
plt.loglog(nb, pressure)
plt.grid()

plt.xlabel(r'$n_{B}$ [fm$^{-3}$]')
plt.ylabel(r'$p$ [MeV fm$^{-3}$]')
plt.show()
```
![PCP(BSk22) example](https://gitlab.in2p3.fr/lpc-caen/compytools/-/raw/main/docs/source/figs/BSk22_pressure_versus_nb_example.png)

# Documentation

Full documentation, including installation instructions, a tutorial and an API reference can be found on the [ComPyTools web page](https://compytools.in2p3.fr/).

# Requirements

**ComPyTools** requires Python 3.12 along with the following Python packages:

- **Astropy**: for displaying data in tabular form and to attach metadata and units to the data. We also use physical constants defined within **astropy**,
- **Matplotlib**: for plotting EoS data,
- **Pandas**: for writing out tabulated data into text files,
- **Rich**: for log output and tabulating metadata information,
- **Scipy**: for performing numerical integration.

Additional packages are also needed to install and build **ComPyTools**:

- [**CompOSE**](https://compose.obspm.fr/software/): a set of Fortran routines for computing the interpolated tables. This is included as part of the **ComPyTools** package,
- **cmake** and **make**: for compiling the **CompOSE** Fortran routines,
- **gfortran**: compiler for the Fortran routines,
- **micromamba**: for creating the software environment within which to install ComPyTools.

# Installation

For Linux and MacOS, install **micromamba** (a more optimized, drop-in replacement of **conda**) with
```
"${SHELL}" <(curl -L micro.mamba.pm/install.sh)
```

and create the **micromamba** environment in order to install the build and compilation tools:
```
micromamba create -n compytools-env -c conda-forge python=3.12 cmake make gfortran
```
Activate the environment with
```
micromamba activate compytools-env
```
Then, install **ComPyTools** with **pip**:
```
pip install compytools
```

Further details can be found on the [installation instructions](https://compytools.in2p3.fr/installation.html).

# License

[![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://opensource.org/license/mit)

**ComPyTools** is released under the MIT license.

# Acknowledgements

The development of **ComPyTools** has been partially supported by the French Centre National de la Recherche Scientifique (CNRS) International Research Project (IRP) "Origine des éléments lourds dans l'univers: Astres Compacts et Nucléosynthèse (ACNu)".

We also acknowledge contributions from the **CompOSE** core development team and members of the LuTH-Caen group within the Virgo collaboration.

# Contributing and contact

**ComPyTools** is a community project. We therefore welcome and appreciate any comments that you may have to improve the tool. Suggestions or bug reports can be communicated to Philip Davis at the following email address: davis@lpccaen.in2p3.fr
