fast-kepler


Namefast-kepler JSON
Version 0.5.1 PyPI version JSON
download
home_pageNone
Summarykepler equation solver in c for python
upload_time2024-08-24 02:10:26
maintainerNone
docs_urlNone
authorReddTea
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # fast_kepler

A c implementation for solving kepler's equation in c. Made for astroemperor, put in a different library for public use.

## Dependencies

This code makes use of:
  - numpy
  - cython

## Installation

In the console type in your work folder
```sh
pip install fast_kepler
```

## Usage

Solution to Kepler's equation. Given mean anomaly, M, and eccentricity, e,
solve for E, the eccentric anomaly, which must satisfy:

$$E - e sin(E) - M = 0$$

For a given eccentricity, and an M array, we use:

```python
import fast_kepler
M = np.sort(np.random.uniform(0, 100, size=100))
ecc = 0.11
E = fast_kepler.kepler_array(M, ecc)
```


## More on usage
We can calculate RVs:

```python
# time array of our observations
x = np.sort(np.random.uniform(0, 100, size=100))
# keplerian parameters
period = 4.1  # in days
semi_amplitude = 55  # in m/s
M0 = np.pi/3  # in rad
ecc = 0.23  # from 0 to 1
om = 3*np.pi/5  # in rad

theta = [period, semi_amplitude, M0, ecc, om]

def calc_RV(theta):
  per, K, M0, ecc, om = theta

  freq = 2. * np.pi / per
  M = freq * x + M0
  E = fast_kepler.kepler_array(M, ecc)

  f = np.arctan(((1. + ecc)/(1. - ecc)) ** 0.5 * np.tan(E / 2.)) * 2.
  
  return K * (np.cos(f + om) + ecc * np.cos(om))

# or simply:

def get_RV(theta):
  per, K, M0, ecc, om = theta
  return fast_kepler.calc_rv0(x, per, K, M0, ecc, om)
```

## Additional Options

You can also use a different parameterization to retrieve RVs, with time of periastron passage $T_p$ instead of the mean anomaly $M_0$:

```python
fast_kepler.calc_rv1(x, per, A, tp, ecc, w)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fast-kepler",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "ReddTea",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/8d/e7/95627ea58987f9e4522562e28e5e038507b14999ebbeaed7bf55ab643961/fast_kepler-0.5.1.tar.gz",
    "platform": null,
    "description": "# fast_kepler\n\nA c implementation for solving kepler's equation in c. Made for astroemperor, put in a different library for public use.\n\n## Dependencies\n\nThis code makes use of:\n  - numpy\n  - cython\n\n## Installation\n\nIn the console type in your work folder\n```sh\npip install fast_kepler\n```\n\n## Usage\n\nSolution to Kepler's equation. Given mean anomaly, M, and eccentricity, e,\nsolve for E, the eccentric anomaly, which must satisfy:\n\n$$E - e sin(E) - M = 0$$\n\nFor a given eccentricity, and an M array, we use:\n\n```python\nimport fast_kepler\nM = np.sort(np.random.uniform(0, 100, size=100))\necc = 0.11\nE = fast_kepler.kepler_array(M, ecc)\n```\n\n\n## More on usage\nWe can calculate RVs:\n\n```python\n# time array of our observations\nx = np.sort(np.random.uniform(0, 100, size=100))\n# keplerian parameters\nperiod = 4.1  # in days\nsemi_amplitude = 55  # in m/s\nM0 = np.pi/3  # in rad\necc = 0.23  # from 0 to 1\nom = 3*np.pi/5  # in rad\n\ntheta = [period, semi_amplitude, M0, ecc, om]\n\ndef calc_RV(theta):\n  per, K, M0, ecc, om = theta\n\n  freq = 2. * np.pi / per\n  M = freq * x + M0\n  E = fast_kepler.kepler_array(M, ecc)\n\n  f = np.arctan(((1. + ecc)/(1. - ecc)) ** 0.5 * np.tan(E / 2.)) * 2.\n  \n  return K * (np.cos(f + om) + ecc * np.cos(om))\n\n# or simply:\n\ndef get_RV(theta):\n  per, K, M0, ecc, om = theta\n  return fast_kepler.calc_rv0(x, per, K, M0, ecc, om)\n```\n\n## Additional Options\n\nYou can also use a different parameterization to retrieve RVs, with time of periastron passage $T_p$ instead of the mean anomaly $M_0$:\n\n```python\nfast_kepler.calc_rv1(x, per, A, tp, ecc, w)\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "kepler equation solver in c for python",
    "version": "0.5.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8de795627ea58987f9e4522562e28e5e038507b14999ebbeaed7bf55ab643961",
                "md5": "d14cb3361dc9cbcbdf91676dc6c433d7",
                "sha256": "8462086925b65413472d8fa9784c36a5fc04dabe2d9ff6aa39a575beccf51499"
            },
            "downloads": -1,
            "filename": "fast_kepler-0.5.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d14cb3361dc9cbcbdf91676dc6c433d7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 154728,
            "upload_time": "2024-08-24T02:10:26",
            "upload_time_iso_8601": "2024-08-24T02:10:26.113596Z",
            "url": "https://files.pythonhosted.org/packages/8d/e7/95627ea58987f9e4522562e28e5e038507b14999ebbeaed7bf55ab643961/fast_kepler-0.5.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-24 02:10:26",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "fast-kepler"
}
        
Elapsed time: 0.63525s