spock


Namespock JSON
Version 1.6.0 PyPI version JSON
download
home_pagehttps://github.com/dtamayo/spock
SummaryStability of Planetary Orbital Configurations Klassifier
upload_time2024-02-14 19:14:52
maintainer
docs_urlNone
authorDaniel Tamayo
requires_python
licenseGPL
keywords astronomy astrophysics exoplanets stability
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # SPOCK 🖖

**Stability of Planetary Orbital Configurations Klassifier**

[![image](https://badge.fury.io/py/spock.svg)](https://badge.fury.io/py/spock)
[![image](https://travis-ci.com/dtamayo/spock.svg?branch=master)](https://travis-ci.com/dtamayo/spock)
[![image](http://img.shields.io/badge/license-GPL-green.svg?style=flat)](https://github.com/dtamayo/spock/blob/master/LICENSE)
[![image](https://img.shields.io/badge/launch-binder-ff69b4.svg?style=flat)](http://mybinder.org/repo/dtamayo/spock)
[![image](http://img.shields.io/badge/arXiv-2007.06521-green.svg?style=flat)](http://arxiv.org/abs/2007.06521)
[![image](http://img.shields.io/badge/arXiv-2101.04117-green.svg?style=flat)](https://arxiv.org/abs/2101.04117)
[![image](http://img.shields.io/badge/arXiv-2106.14863-green.svg?style=flat)](https://arxiv.org/abs/2106.14863)
![image](https://raw.githubusercontent.com/dtamayo/spock/master/paper_plots/spockpr.jpg)

[Documentation](https://spock-instability.readthedocs.io/en/latest/)

The SPOCK package incorporates several machine learning and analytical tools for estimating the stability of compact planetary configurations.
All estimators use a common API to facilitate comparisons between them and with N-body integrations.

# Quickstart

Let's predict the probability that a given 3-planet system is stable
past 1 billion orbits with the XGBoost-based classifier of [Tamayo et al., 2020](http://arxiv.org/abs/2007.06521).

```python
import rebound
from spock import FeatureClassifier
feature_model = FeatureClassifier()

sim = rebound.Simulation()
sim.add(m=1.)
sim.add(m=1.e-5, P=1., e=0.03, pomega=2., l=0.5)
sim.add(m=1.e-5, P=1.2, e=0.03, pomega=3., l=3.)
sim.add(m=1.e-5, P=1.5, e=0.03, pomega=1.5, l=2.)
sim.move_to_com()

print(feature_model.predict_stable(sim))
# >>> 0.06591137
```

That model provides a simple scalar probability of stability over a billion orbits. 
We can instead estimate its median expected instability time using the deep regressor from [Cranmer et al., 2021](https://arxiv.org/abs/2101.04117).

```python
from spock import DeepRegressor
deep_model = DeepRegressor()

median, lower, upper = deep_model.predict_instability_time(sim, samples=10000)
print(int(median))
# >>> 242570.1378387966
```

The returned time is expressed in the time units used in setting up the REBOUND Simulation above.
Since we set the innermost planet orbit to unity, this corresponds to 242570 innermost planet orbits.

Finally, we can compare these results to the semi-analytic criterion of [Tamayo et al., 2021](https://arxiv.org/abs/2106.14863) for how likely the configuration is to be dynamically chaotic. .
This is not a one-to-one comparison, but configurations that are chaotic through two-body MMR overlap are generally unstable on long timescales (see paper and examples).

```python
from spock import AnalyticalClassifier
analytical_model = AnalyticalClassifier()

print(analytical_model.predict_stable(sim))
# >>> 0.0
```

To match up with the above classifiers, the analytical classifier returns the probability the configuration is *regular*, i.e., not chaotic.
A probability of zero therefore corresponds to confidently chaotic.
See [this example](https://github.com/dtamayo/spock/blob/master/jupyter_examples/QuickStart.ipynb) for more information about the analytical model.

# Examples

[Colab tutorial](https://colab.research.google.com/drive/1R3NrPmtI5DZFq_VZtv8gowINBrXM85Zv?usp=sharing)
for the deep regressor.

The example notebooks contain many additional examples:
[jupyter\_examples/](https://github.com/dtamayo/spock/tree/master/jupyter_examples).

# Installation

SPOCK is compatible with both Linux and Mac. SPOCK relies on XGBoost, which has installation issues with OpenMP on
Mac OSX. If you have problems (<https://github.com/dmlc/xgboost/issues/4477>), the easiest way is
probably to install [homebrew](brew.sh), and:

```
brew install libomp
```

The most straightforward way to avoid any version conflicts is to download the Anaconda Python distribution and make a separate conda environment.

Here we create we create a new conda environment called `spock` and install all the required dependencies
```
conda create -q --name spock -c pytorch -c conda-forge python=3.7 numpy scipy pandas scikit-learn matplotlib torchvision pytorch xgboost rebound einops jupyter pytorch-lightning ipython h5py
conda activate spock
pip install spock
```

Each time you want to use spock you will first have to activate this `spock` conda environment (google conda environments).



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dtamayo/spock",
    "name": "spock",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "astronomy astrophysics exoplanets stability",
    "author": "Daniel Tamayo",
    "author_email": "tamayo.daniel@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c0/81/11bedc37c924cd27248d9440a78cb7b124efdf125a410f8214e9bce2d7e0/spock-1.6.0.tar.gz",
    "platform": null,
    "description": "# SPOCK \ud83d\udd96\n\n**Stability of Planetary Orbital Configurations Klassifier**\n\n[![image](https://badge.fury.io/py/spock.svg)](https://badge.fury.io/py/spock)\n[![image](https://travis-ci.com/dtamayo/spock.svg?branch=master)](https://travis-ci.com/dtamayo/spock)\n[![image](http://img.shields.io/badge/license-GPL-green.svg?style=flat)](https://github.com/dtamayo/spock/blob/master/LICENSE)\n[![image](https://img.shields.io/badge/launch-binder-ff69b4.svg?style=flat)](http://mybinder.org/repo/dtamayo/spock)\n[![image](http://img.shields.io/badge/arXiv-2007.06521-green.svg?style=flat)](http://arxiv.org/abs/2007.06521)\n[![image](http://img.shields.io/badge/arXiv-2101.04117-green.svg?style=flat)](https://arxiv.org/abs/2101.04117)\n[![image](http://img.shields.io/badge/arXiv-2106.14863-green.svg?style=flat)](https://arxiv.org/abs/2106.14863)\n![image](https://raw.githubusercontent.com/dtamayo/spock/master/paper_plots/spockpr.jpg)\n\n[Documentation](https://spock-instability.readthedocs.io/en/latest/)\n\nThe SPOCK package incorporates several machine learning and analytical tools for estimating the stability of compact planetary configurations.\nAll estimators use a common API to facilitate comparisons between them and with N-body integrations.\n\n# Quickstart\n\nLet's predict the probability that a given 3-planet system is stable\npast 1 billion orbits with the XGBoost-based classifier of [Tamayo et al., 2020](http://arxiv.org/abs/2007.06521).\n\n```python\nimport rebound\nfrom spock import FeatureClassifier\nfeature_model = FeatureClassifier()\n\nsim = rebound.Simulation()\nsim.add(m=1.)\nsim.add(m=1.e-5, P=1., e=0.03, pomega=2., l=0.5)\nsim.add(m=1.e-5, P=1.2, e=0.03, pomega=3., l=3.)\nsim.add(m=1.e-5, P=1.5, e=0.03, pomega=1.5, l=2.)\nsim.move_to_com()\n\nprint(feature_model.predict_stable(sim))\n# >>> 0.06591137\n```\n\nThat model provides a simple scalar probability of stability over a billion orbits. \nWe can instead estimate its median expected instability time using the deep regressor from [Cranmer et al., 2021](https://arxiv.org/abs/2101.04117).\n\n```python\nfrom spock import DeepRegressor\ndeep_model = DeepRegressor()\n\nmedian, lower, upper = deep_model.predict_instability_time(sim, samples=10000)\nprint(int(median))\n# >>> 242570.1378387966\n```\n\nThe returned time is expressed in the time units used in setting up the REBOUND Simulation above.\nSince we set the innermost planet orbit to unity, this corresponds to 242570 innermost planet orbits.\n\nFinally, we can compare these results to the semi-analytic criterion of [Tamayo et al., 2021](https://arxiv.org/abs/2106.14863) for how likely the configuration is to be dynamically chaotic. .\nThis is not a one-to-one comparison, but configurations that are chaotic through two-body MMR overlap are generally unstable on long timescales (see paper and examples).\n\n```python\nfrom spock import AnalyticalClassifier\nanalytical_model = AnalyticalClassifier()\n\nprint(analytical_model.predict_stable(sim))\n# >>> 0.0\n```\n\nTo match up with the above classifiers, the analytical classifier returns the probability the configuration is *regular*, i.e., not chaotic.\nA probability of zero therefore corresponds to confidently chaotic.\nSee [this example](https://github.com/dtamayo/spock/blob/master/jupyter_examples/QuickStart.ipynb) for more information about the analytical model.\n\n# Examples\n\n[Colab tutorial](https://colab.research.google.com/drive/1R3NrPmtI5DZFq_VZtv8gowINBrXM85Zv?usp=sharing)\nfor the deep regressor.\n\nThe example notebooks contain many additional examples:\n[jupyter\\_examples/](https://github.com/dtamayo/spock/tree/master/jupyter_examples).\n\n# Installation\n\nSPOCK is compatible with both Linux and Mac. SPOCK relies on XGBoost, which has installation issues with OpenMP on\nMac OSX. If you have problems (<https://github.com/dmlc/xgboost/issues/4477>), the easiest way is\nprobably to install [homebrew](brew.sh), and:\n\n```\nbrew install libomp\n```\n\nThe most straightforward way to avoid any version conflicts is to download the Anaconda Python distribution and make a separate conda environment.\n\nHere we create we create a new conda environment called `spock` and install all the required dependencies\n```\nconda create -q --name spock -c pytorch -c conda-forge python=3.7 numpy scipy pandas scikit-learn matplotlib torchvision pytorch xgboost rebound einops jupyter pytorch-lightning ipython h5py\nconda activate spock\npip install spock\n```\n\nEach time you want to use spock you will first have to activate this `spock` conda environment (google conda environments).\n\n\n",
    "bugtrack_url": null,
    "license": "GPL",
    "summary": "Stability of Planetary Orbital Configurations Klassifier",
    "version": "1.6.0",
    "project_urls": {
        "Homepage": "https://github.com/dtamayo/spock"
    },
    "split_keywords": [
        "astronomy",
        "astrophysics",
        "exoplanets",
        "stability"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c08111bedc37c924cd27248d9440a78cb7b124efdf125a410f8214e9bce2d7e0",
                "md5": "0b2a5850ed5308a64fef26d271a53404",
                "sha256": "c174cd7d07f58c5ec7c93695c7d7b63cc8f8e90bb3d62614da60ce5f23f10472"
            },
            "downloads": -1,
            "filename": "spock-1.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0b2a5850ed5308a64fef26d271a53404",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 29930566,
            "upload_time": "2024-02-14T19:14:52",
            "upload_time_iso_8601": "2024-02-14T19:14:52.802258Z",
            "url": "https://files.pythonhosted.org/packages/c0/81/11bedc37c924cd27248d9440a78cb7b124efdf125a410f8214e9bce2d7e0/spock-1.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-14 19:14:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dtamayo",
    "github_project": "spock",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "spock"
}
        
Elapsed time: 0.18233s