PyLightcurve-torch
An exoplanet transit modelling package for deep learning applications in Pytorch.
See this open publication in the Publications of the Astronomical Society of the Pacific for more details and official citation and jupyter notebook tutorials here.
The code for orbit and flux drop computation is adapted from Pylightcurve.
The module pylightcurve_torch.functional.py contains the functions implemented in Pytorch and computing the orbital positions,
transit durations and flux drops. (see PyLightcurve repository
for more information about the numerical models used).
A TransitModule class is implemented in pylightcurve_torch.nn.py with the following features:
- Computes time series of planetary positions and primary/secondary flux drops
- it inherits
torch.nn.Moduleclass to benefit from its parameters optimisation and management capabilities and facilitated combination with neural networks - native GPU compatibility
Installation
$ pip install pylightcurve-torch
Basic use
from pylightcurve_torch import TransitModule
tm = TransitModule(time, **transit_params)
flux_drop = tm()
If needs be, the returned torch.Tensor can be converted to a numpy.ndarrray using flux_drop.numpy() torch method or
flux.cpu().numpy() if the computation took place on a gpu.
Transit parameters
Below is a summary table of the planetary orbital and transit parameters use in PyLightcurve-torch:
| Name | Pylightcurve alias | Description | Python type | Unit | Transit type |
|---|---|---|---|---|---|
a |
sma_over_rs |
ratio of semi-major axis by the stellar radius | float | unitless | primary/secondary |
P |
period |
orbital period | float | days | primary/secondary |
e |
eccentricity |
orbital eccentricity | float | unitless | primary/secondary |
i |
inclination |
orbital inclination | float | degrees | primary/secondary |
p |
periastron |
orbital argument of periastron | float | degrees | primary/secondary |
t0 |
mid_time |
transit mid-time epoch | float | days | primary/secondary |
rp |
rp_over_rs |
ratio of planetary by stellar radii | float | unitless | primary/secondary |
method |
method |
limb-darkening law | str | primary | |
ldc |
limb_darkening_coefficients |
limb-darkening coefficients | list | unitless | primary |
fp |
fp_over_fs |
ratio of planetary by stellar fluxes | float | unitless | secondary |
A short version of each parameter has been introduced, while maintaining a compatibility with origin PyLightcurve
parameter names. All the parameters except method are converted to torch.Parameters when passed to
a ``TransitModule```, with double dtype.
Differentiation
One of the main benefits of having a pytorch implementation for modelling transits is offered by its automatic differentiation feature with torch.autograd, stemming from autograd library.
Here is an example of basic usage:
...
tm.fit_param('rp') # activates the gradient computation for parameter 'rp'
err = loss(flux, **data) # loss computation in pytorch
err.backward() # gradients computation
tm.rp.grad # access to computed gradient for parameter 'rp'
More Pytorch support
Several utility methods inherited from PyTorch modules are listed below, simplifying operations on all module's defined tensor parameters.
tm = TransitModule()
# Parameters access (iterators)
tm.parameters()
tm.named_parameters()
# dtype conversions
tm.float()
tm.double()
# Gradient local deactivation
with torch.no_grad():
flux_no_grad = tm()
# device conversion
tm.cpu()
tm.cuda()
Running performance tests
In addition to traditional unit tests, computation performance tests can be executed this way:
python tests/performance.py --plot
This will measure the computation time for computing forward transits as a function of transit duration, time vector length or batch size. If data have been savec previously, these will be plotted to with the name of the corresponding tag.
Metadata
Release files for pylightcurve-torch 1.1.0
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 |
|---|---|---|---|---|
| pylightcurve-torch-1.1.0.tar.gz | 109.2 kB | Without provenance | Details for pylightcurve-torch-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pylightcurve_torch-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for pylightcurve_torch-1.1.0-py3-none-any.whl |
Total release size: 139.0 kB
Release files / pylightcurve-torch-1.1.0.tar.gz
| Download URL | pylightcurve-torch-1.1.0.tar.gz |
|---|---|
| Size | 109.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75e4f57a6d36e143acd239cd8ab1a282b5a48a05c0a7468d7765672a8ceffab8
|
|
BLAKE2b-256 checksum How to use checksums |
302a61e80d7a98b38dfc4b4c095b4ae8af4af24c8696b3b7face05fbdbced225
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / pylightcurve_torch-1.1.0-py3-none-any.whl
| Download URL | pylightcurve_torch-1.1.0-py3-none-any.whl |
|---|---|
| Size | 29.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d09120723ded11c4aef6312dad102b37ec09012465769a7b4d7a029b727cc24e
|
|
BLAKE2b-256 checksum How to use checksums |
e151e2d00e5d92953f791cc12c4dd00ddb2ddbbe3c15917133084ef1edd3491a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Security for pylightcurve-torch 1.1.0
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.