multirex


Namemultirex JSON
Version 0.2.3 PyPI version JSON
download
home_pagehttps://pypi.org/project/multirex
SummaryMassive planetary spectra generator
upload_time2024-07-26 21:45:34
maintainerNone
docs_urlNone
authorDavid Duque-Castaño and Jorge I. Zuluaga
requires_pythonNone
licenseMIT
keywords exoplanets astrobiology astronomy spectroscopy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MultiREx
## Planetary transmission spectra generator

<!-- This are visual tags that you may add to your package at the beginning with useful information on your package --> 
[![version](https://img.shields.io/pypi/v/multirex?color=blue)](https://pypi.org/project/multirex/)
[![downloads](https://img.shields.io/pypi/dw/multirex)](https://pypi.org/project/multirex/)
[![license](https://img.shields.io/pypi/l/multirex)](https://pypi.org/project/multirex/)
[![implementation](https://img.shields.io/pypi/implementation/multirex)](https://pypi.org/project/multirex/)
[![pythonver](https://img.shields.io/pypi/pyversions/multirex)](https://pypi.org/project/multirex/)
<!-- 
[![arXiv](http://img.shields.io/badge/arXiv-2207.08636-orange.svg?style=flat)](http://arxiv.org/abs/2207.08636)
[![ascl](https://img.shields.io/badge/ascl-2205.016-blue.svg?colorB=262255)](https://ascl.net/2205.016)
-->

MultiREx is a Python library designed for generating synthetic exoplanet transmission spectra. This tool extends the functionalities of the `Taurex` library (see below), reorganizing and enabling the massive generation of spectra and observations with added noise. The package was originally devised for training large machine learning models at identifying the presence of biosignatures in noisy spectra. However, it should also be used for other purposes.

For the science behind the model please refer to the following paper:

> David S. Duque-Castaño, Jorge I. Zuluaga, and Lauren Flor-Torres (2024), **Machine-assisted classification of potential biosignatures in earth-like exoplanets using low signal-to-noise ratio transmission spectra**, submitted to MNRAS.
<!--
[Astronomy and Computing 40 (2022) 100623](https://www.sciencedirect.com/science/article/pii/S2213133722000476), [arXiv:2207.08636](https://arxiv.org/abs/2207.08636).
-->

## Downloading and Installing `MultiREx` 

`MultiREx` is available at the `Python` package index and can be installed in Linux using:

```bash
$ sudo pip install multirex
```
as usual this command will install all dependencies and download some useful data, scripts and constants.

> **NOTE**: If you don't have access to `sudo`, you can install `MultiREx` in your local environmen (usually at `~/.local/`). In that case you need to add to your `PATH` environmental variable the location of the local python installation. For that purpose add to the configuration files `~/.bashrc` or `~/.bash_profile`, the line `export PATH=$HOME/.local/bin:$PATH`

If you are a developer or want to work directly with the package sources, clone `MultiREx` from the `GitHub` repository:

```bash
$ git clone https://github.com/D4san/MultiREx-public
```

To install the package from the sources use:

```bash
$ cd MultiREx-public
$ python3 setup.py install
```

## Running `MultiREx` in `GoogleColab`

To run MultiREx in Google Colab you should execute:
```python
!pip install -Uq multirex
```

After installing you should reset session before importing the package. This is to avoid the unintended behavior of the package `pybtex`. After reset you should not reinstall the package, just import it:

```python
import multirex as mrex
```

## Quickstart

To start using `MultiREx` you must import the package:

```python
import multirex as mrex
```

To start with, we need to provide to `MultiREx` the properties of the three components of any transmission model: A star, a planet and a planetary atmosphere.


```python
star=mrex.Star(temperature=5777,radius=1,mass=1)
```

Radius and mass are in solar units.

Now let's create the planet:
```python
planet=mrex.Planet(radius=1,mass=1)
```
Radius and mass are in units of Earth properties. 

Now it's time to give the planet an atmosphere. This is a basic example of an N2 atmosphere having 100 ppm of CO2 and 1 ppm of CH4:

```python
atmosphere=mrex.Atmosphere(
    temperature=288, # in K
    base_pressure=1e5, # in Pa
    top_pressure=1, # in Pa
    fill_gas="N2", # the gas that fills the atmosphere
    composition=dict(
        CO2=-4, # This is the log10(mix-ratio)
        CH4=-6,
    )
)
planet.set_atmosphere(atmosphere)
```

Now we can ensamble the system:

```python
system=mrex.System(star=star,planet=planet,sma=1)
```

Semimajor axis of the planeta (`sma`) is given in au (astronomical units).

We are ready to see some spectrum. For this purpose we need to create a transmission model:

```python
system.make_tm()
```

Once initialized, let's plot the transmission spectrum over a given grid of wavenumbers or wavelengths:

```python
wns = mrex.Physics.wavenumber_grid(wl_min=0.6,wl_max=10,resolution=1000)
fig, ax = system.plot_contributions(wns,xscale='log')
```

<p align="center"><img src="https://github.com/D4san/MultiREx-public/blob/main/examples/resources/contributions-transmission-spectrum.png?raw=true" alt="Contributions in transmission spectra"/></p>

All of these functionalities are also available in `Taurex`. However, the interface to `MultiREx` is much more intuitive and, more importantly, it is also best suited for the real superpower of the package: the capaciy to create large ensamble of random planetary systems. 

For creating a random planetary system starting with a range of the relevant parameters (ranges given between parenthesis), we use the command:

```python
system=mrex.System(
    star=mrex.Star(
        temperature=(4000,6000),
        radius=(0.5,1.5),
        mass=(0.8,1.2),
    ),
    planet=mrex.Planet(
        radius=(0.5,1.5),
        mass=(0.8,1.2),
        atmosphere=mrex.Atmosphere(
            temperature=(290,310), # in K
            base_pressure=(1e5,10e5), # in Pa
            top_pressure=(1,10), # in Pa
            fill_gas="N2", # the gas that fills the atmosphere
            composition=dict(
                CO2=(-5,-4), # This is the log10(mix-ratio)
                CH4=(-6,-5),
            )
        )
    ),
    sma=(0.5,1)
)
```

In this simple example, we assume that all key parameters (stellar mass and radius, planetary mass and radius, surface planetary temperature, semimajor axis, etc.) are physically and statistically independent. This is not true, but it works for testing the basic features of the package.

Using this system as a template we may generate thousands of spectra that can be used, for instance, for training machine learning algorithms. For an in depth explanation of how to use those advanced functionalities of `MultiREx` please check the  [quick start guide](https://github.com/D4san/MultiREx-public/blob/main/examples/multirex-quickstart.ipynb).

In the figure below we show some of the resulting synthetic spectra, along with the corresponding theoretical spectrum corresponding to a particular set of random values for the key system parameters.

<p align="center"><img src="https://github.com/D4san/MultiREx-public/blob/main/examples/resources/synthetic-transmission-spectra.png?raw=true" alt="Synthetic transmission spectra"/></p>

## Further examples

In order to illustrate the basic and advanced functionalities of `MultiREx` we provided with the package repository several example `Jupyter` notebooks (see directory `examples/`). Additionally, all the notebooks used to generate the results and create the figures for our papers are also available in the `GitHub` repo (see directory `examples/papers`). 

## Key features of `MultiREx`

- **Planetary System Assembly**: Facilitates the combination of different planets, stars, and atmospheres to explore various stellar system configurations.

- **Customizable Atmospheres**: Allows the addition and configuration of varied atmospheric compositions for the planets.

- **Synthetic Spectrum Generation**: Produces realistic spectra based on the attributes and conditions of planetary systems.

- **Astronomical Observation Simulation**: Includes `randinstrument` to simulate spectral observations with noise levels determined by the signal-to-noise ratio (SNR).

- **Multiverse analysis**: Automates the generation of multiple spectra that randomly vary in specific parameters, providing a wide range of results for analysis.

### A note about `Taurex`

MultiREx is built on the spectral calculation capabilities and the basic structure of [Taurex](https://taurex3-public.readthedocs.io/en/latest/index.html). If you use `MultiREx` in your research or publications, please also cite Taurex as follows:

> A. F. Al-Refaie, Q. Changeat, I.P. Waldmann, and G. Tinetti **TauREx III: A fast, dynamic, and extendable framework for retrievals**,  arXiv preprint [arXiv:1912.07759 (2019)](https://arxiv.org/abs/1912.07759).

It is necessary to load the opacities or cross-sections of the molecules used in the formats that Taurex utilizes, which can be obtained from:
- [ExoMol](https://www.exomol.com/data/search/)
- [ExoTransmit](https://github.com/elizakempton/Exo_Transmit/tree/master/Opac)

We have pre-downloaded some of these molecules, and others can be downloaded using the command `multirex.Util.get_gases()`

## What's new

For a detailed list of the newest characteristics of the code see the file [What's new](https://github.com/D4san/MultiREx-public/blob/master/WHATSNEW.md).

------------

This package has been designed and written by David Duque-Castaño and Jorge I. Zuluaga (C) 2024

            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/multirex",
    "name": "multirex",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "exoplanets astrobiology astronomy spectroscopy",
    "author": "David Duque-Casta\u00f1o and Jorge I. Zuluaga",
    "author_email": "dsantiago.duque@udea.edu.co",
    "download_url": "https://files.pythonhosted.org/packages/6b/85/70d50f263e23a21886c3125185795425979d05daa2cf90c3ea8dea138514/multirex-0.2.3.tar.gz",
    "platform": null,
    "description": "# MultiREx\n## Planetary transmission spectra generator\n\n<!-- This are visual tags that you may add to your package at the beginning with useful information on your package --> \n[![version](https://img.shields.io/pypi/v/multirex?color=blue)](https://pypi.org/project/multirex/)\n[![downloads](https://img.shields.io/pypi/dw/multirex)](https://pypi.org/project/multirex/)\n[![license](https://img.shields.io/pypi/l/multirex)](https://pypi.org/project/multirex/)\n[![implementation](https://img.shields.io/pypi/implementation/multirex)](https://pypi.org/project/multirex/)\n[![pythonver](https://img.shields.io/pypi/pyversions/multirex)](https://pypi.org/project/multirex/)\n<!-- \n[![arXiv](http://img.shields.io/badge/arXiv-2207.08636-orange.svg?style=flat)](http://arxiv.org/abs/2207.08636)\n[![ascl](https://img.shields.io/badge/ascl-2205.016-blue.svg?colorB=262255)](https://ascl.net/2205.016)\n-->\n\nMultiREx is a Python library designed for generating synthetic exoplanet transmission spectra. This tool extends the functionalities of the `Taurex` library (see below), reorganizing and enabling the massive generation of spectra and observations with added noise. The package was originally devised for training large machine learning models at identifying the presence of biosignatures in noisy spectra. However, it should also be used for other purposes.\n\nFor the science behind the model please refer to the following paper:\n\n> David S. Duque-Casta\u00f1o, Jorge I. Zuluaga, and Lauren Flor-Torres (2024), **Machine-assisted classification of potential biosignatures in earth-like exoplanets using low signal-to-noise ratio transmission spectra**, submitted to MNRAS.\n<!--\n[Astronomy and Computing 40 (2022) 100623](https://www.sciencedirect.com/science/article/pii/S2213133722000476), [arXiv:2207.08636](https://arxiv.org/abs/2207.08636).\n-->\n\n## Downloading and Installing `MultiREx` \n\n`MultiREx` is available at the `Python` package index and can be installed in Linux using:\n\n```bash\n$ sudo pip install multirex\n```\nas usual this command will install all dependencies and download some useful data, scripts and constants.\n\n> **NOTE**: If you don't have access to `sudo`, you can install `MultiREx` in your local environmen (usually at `~/.local/`). In that case you need to add to your `PATH` environmental variable the location of the local python installation. For that purpose add to the configuration files `~/.bashrc` or `~/.bash_profile`, the line `export PATH=$HOME/.local/bin:$PATH`\n\nIf you are a developer or want to work directly with the package sources, clone `MultiREx` from the `GitHub` repository:\n\n```bash\n$ git clone https://github.com/D4san/MultiREx-public\n```\n\nTo install the package from the sources use:\n\n```bash\n$ cd MultiREx-public\n$ python3 setup.py install\n```\n\n## Running `MultiREx` in `GoogleColab`\n\nTo run MultiREx in Google Colab you should execute:\n```python\n!pip install -Uq multirex\n```\n\nAfter installing you should reset session before importing the package. This is to avoid the unintended behavior of the package `pybtex`. After reset you should not reinstall the package, just import it:\n\n```python\nimport multirex as mrex\n```\n\n## Quickstart\n\nTo start using `MultiREx` you must import the package:\n\n```python\nimport multirex as mrex\n```\n\nTo start with, we need to provide to `MultiREx` the properties of the three components of any transmission model: A star, a planet and a planetary atmosphere.\n\n\n```python\nstar=mrex.Star(temperature=5777,radius=1,mass=1)\n```\n\nRadius and mass are in solar units.\n\nNow let's create the planet:\n```python\nplanet=mrex.Planet(radius=1,mass=1)\n```\nRadius and mass are in units of Earth properties. \n\nNow it's time to give the planet an atmosphere. This is a basic example of an N2 atmosphere having 100 ppm of CO2 and 1 ppm of CH4:\n\n```python\natmosphere=mrex.Atmosphere(\n    temperature=288, # in K\n    base_pressure=1e5, # in Pa\n    top_pressure=1, # in Pa\n    fill_gas=\"N2\", # the gas that fills the atmosphere\n    composition=dict(\n        CO2=-4, # This is the log10(mix-ratio)\n        CH4=-6,\n    )\n)\nplanet.set_atmosphere(atmosphere)\n```\n\nNow we can ensamble the system:\n\n```python\nsystem=mrex.System(star=star,planet=planet,sma=1)\n```\n\nSemimajor axis of the planeta (`sma`) is given in au (astronomical units).\n\nWe are ready to see some spectrum. For this purpose we need to create a transmission model:\n\n```python\nsystem.make_tm()\n```\n\nOnce initialized, let's plot the transmission spectrum over a given grid of wavenumbers or wavelengths:\n\n```python\nwns = mrex.Physics.wavenumber_grid(wl_min=0.6,wl_max=10,resolution=1000)\nfig, ax = system.plot_contributions(wns,xscale='log')\n```\n\n<p align=\"center\"><img src=\"https://github.com/D4san/MultiREx-public/blob/main/examples/resources/contributions-transmission-spectrum.png?raw=true\" alt=\"Contributions in transmission spectra\"/></p>\n\nAll of these functionalities are also available in `Taurex`. However, the interface to `MultiREx` is much more intuitive and, more importantly, it is also best suited for the real superpower of the package: the capaciy to create large ensamble of random planetary systems. \n\nFor creating a random planetary system starting with a range of the relevant parameters (ranges given between parenthesis), we use the command:\n\n```python\nsystem=mrex.System(\n    star=mrex.Star(\n        temperature=(4000,6000),\n        radius=(0.5,1.5),\n        mass=(0.8,1.2),\n    ),\n    planet=mrex.Planet(\n        radius=(0.5,1.5),\n        mass=(0.8,1.2),\n        atmosphere=mrex.Atmosphere(\n            temperature=(290,310), # in K\n            base_pressure=(1e5,10e5), # in Pa\n            top_pressure=(1,10), # in Pa\n            fill_gas=\"N2\", # the gas that fills the atmosphere\n            composition=dict(\n                CO2=(-5,-4), # This is the log10(mix-ratio)\n                CH4=(-6,-5),\n            )\n        )\n    ),\n    sma=(0.5,1)\n)\n```\n\nIn this simple example, we assume that all key parameters (stellar mass and radius, planetary mass and radius, surface planetary temperature, semimajor axis, etc.) are physically and statistically independent. This is not true, but it works for testing the basic features of the package.\n\nUsing this system as a template we may generate thousands of spectra that can be used, for instance, for training machine learning algorithms. For an in depth explanation of how to use those advanced functionalities of `MultiREx` please check the  [quick start guide](https://github.com/D4san/MultiREx-public/blob/main/examples/multirex-quickstart.ipynb).\n\nIn the figure below we show some of the resulting synthetic spectra, along with the corresponding theoretical spectrum corresponding to a particular set of random values for the key system parameters.\n\n<p align=\"center\"><img src=\"https://github.com/D4san/MultiREx-public/blob/main/examples/resources/synthetic-transmission-spectra.png?raw=true\" alt=\"Synthetic transmission spectra\"/></p>\n\n## Further examples\n\nIn order to illustrate the basic and advanced functionalities of `MultiREx` we provided with the package repository several example `Jupyter` notebooks (see directory `examples/`). Additionally, all the notebooks used to generate the results and create the figures for our papers are also available in the `GitHub` repo (see directory `examples/papers`). \n\n## Key features of `MultiREx`\n\n- **Planetary System Assembly**: Facilitates the combination of different planets, stars, and atmospheres to explore various stellar system configurations.\n\n- **Customizable Atmospheres**: Allows the addition and configuration of varied atmospheric compositions for the planets.\n\n- **Synthetic Spectrum Generation**: Produces realistic spectra based on the attributes and conditions of planetary systems.\n\n- **Astronomical Observation Simulation**: Includes `randinstrument` to simulate spectral observations with noise levels determined by the signal-to-noise ratio (SNR).\n\n- **Multiverse analysis**: Automates the generation of multiple spectra that randomly vary in specific parameters, providing a wide range of results for analysis.\n\n### A note about `Taurex`\n\nMultiREx is built on the spectral calculation capabilities and the basic structure of [Taurex](https://taurex3-public.readthedocs.io/en/latest/index.html). If you use `MultiREx` in your research or publications, please also cite Taurex as follows:\n\n> A. F. Al-Refaie, Q. Changeat, I.P. Waldmann, and G. Tinetti **TauREx III: A fast, dynamic, and extendable framework for retrievals**,  arXiv preprint [arXiv:1912.07759 (2019)](https://arxiv.org/abs/1912.07759).\n\nIt is necessary to load the opacities or cross-sections of the molecules used in the formats that Taurex utilizes, which can be obtained from:\n- [ExoMol](https://www.exomol.com/data/search/)\n- [ExoTransmit](https://github.com/elizakempton/Exo_Transmit/tree/master/Opac)\n\nWe have pre-downloaded some of these molecules, and others can be downloaded using the command `multirex.Util.get_gases()`\n\n## What's new\n\nFor a detailed list of the newest characteristics of the code see the file [What's new](https://github.com/D4san/MultiREx-public/blob/master/WHATSNEW.md).\n\n------------\n\nThis package has been designed and written by David Duque-Casta\u00f1o and Jorge I. Zuluaga (C) 2024\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Massive planetary spectra generator",
    "version": "0.2.3",
    "project_urls": {
        "Homepage": "https://pypi.org/project/multirex"
    },
    "split_keywords": [
        "exoplanets",
        "astrobiology",
        "astronomy",
        "spectroscopy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2dd9bc111dd7825f119a56576012df936309e0afd5856e1bf0c55e02658ccc9c",
                "md5": "206638143be914bfa0c2fd63c8723960",
                "sha256": "d46fb94a26ac592afdf8c72d96f11c6980dacc733d7f39f32332ba63c656ce4e"
            },
            "downloads": -1,
            "filename": "multirex-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "206638143be914bfa0c2fd63c8723960",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 23770926,
            "upload_time": "2024-07-26T21:45:22",
            "upload_time_iso_8601": "2024-07-26T21:45:22.840994Z",
            "url": "https://files.pythonhosted.org/packages/2d/d9/bc111dd7825f119a56576012df936309e0afd5856e1bf0c55e02658ccc9c/multirex-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6b8570d50f263e23a21886c3125185795425979d05daa2cf90c3ea8dea138514",
                "md5": "54730c4923076d4a2ff6d4a2d8722299",
                "sha256": "40bdab84580e2ea4a9b112110d35fdffed4d37a28098b6329682905cf9c507da"
            },
            "downloads": -1,
            "filename": "multirex-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "54730c4923076d4a2ff6d4a2d8722299",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 23234628,
            "upload_time": "2024-07-26T21:45:34",
            "upload_time_iso_8601": "2024-07-26T21:45:34.789486Z",
            "url": "https://files.pythonhosted.org/packages/6b/85/70d50f263e23a21886c3125185795425979d05daa2cf90c3ea8dea138514/multirex-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-26 21:45:34",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "multirex"
}
        
Elapsed time: 3.95040s