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
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:
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:
# 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$:
fast_kepler.calc_rv1(x, per, A, tp, ecc, w)
Metadata
Release files for fast-kepler 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fast_kepler-0.5.1.tar.gz | 154.7 kB | Without provenance | Details for fast_kepler-0.5.1.tar.gz |
Release files / fast_kepler-0.5.1.tar.gz
| Download URL | fast_kepler-0.5.1.tar.gz |
|---|---|
| Size | 154.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8462086925b65413472d8fa9784c36a5fc04dabe2d9ff6aa39a575beccf51499
|
|
BLAKE2b-256 checksum How to use checksums |
8de795627ea58987f9e4522562e28e5e038507b14999ebbeaed7bf55ab643961
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.12
|
Security for fast-kepler 0.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.