The lensing pipeline of the future: GPU-accelerated, automatically-differentiable, highly modular. Currently under heavy development: expect interface changes and some imprecise/untested calculations.
Project description
caustics
The lensing pipeline of the future: GPU-accelerated, automatically-differentiable, highly modular. Currently under heavy development: expect interface changes and some imprecise/untested calculations.
Installation
Simply install caustics from PyPI:
pip install caustics
Minimal Example
import matplotlib.pyplot as plt
import caustics
import torch
cosmology = caustics.FlatLambdaCDM()
sie = caustics.SIE(cosmology=cosmology, name="lens")
src = caustics.Sersic(name="source")
lnslt = caustics.Sersic(name="lenslight")
x = torch.tensor([
# z_s z_l x0 y0 q phi b x0 y0 q phi n Re
1.5, 0.5, -0.2, 0.0, 0.4, 1.5708, 1.7, 0.0, 0.0, 0.5, -0.985, 1.3, 1.0,
# Ie x0 y0 q phi n Re Ie
5.0, -0.2, 0.0, 0.8, 0.0, 1., 1.0, 10.0
]) # fmt: skip
sim = caustics.LensSource(
lens=sie, source=src, lens_light=lnslt, pixelscale=0.05, pixels_x=100
)
plt.imshow(sim(x), origin="lower")
plt.axis("off")
plt.show()
Batched simulator
newx = x.repeat(20, 1)
newx += torch.normal(mean=0, std=0.1 * torch.ones_like(newx))
images = torch.vmap(sim)(newx)
fig, axarr = plt.subplots(4, 5, figsize=(20, 16))
for ax, im in zip(axarr.flatten(), images):
ax.imshow(im, origin="lower")
plt.show()
Automatic Differentiation
J = torch.func.jacfwd(sim)(x)
# Plot the new images
fig, axarr = plt.subplots(3, 7, figsize=(20, 9))
for i, ax in enumerate(axarr.flatten()):
ax.imshow(J[..., i], origin="lower")
plt.show()
Documentation
Please see our documentation page for more detailed information.
Contribution
We welcome contributions from collaborators and researchers interested in our work. If you have improvements, suggestions, or new findings to share, please submit an issue or pull request. Your contributions help advance our research and analysis efforts.
To get started with your development (or fork), click the "Open with GitHub Codespaces" button below to launch a fully configured development environment with all the necessary tools and extensions.
Instruction on how to contribute to this project can be found in the CONTRIBUTION.md
Some guidelines:
- Please use
isort
andblack
to format your code. - Use
CamelCase
for class names andsnake_case
for variable and method names. - Open up issues for bugs/missing features.
- Use pull requests for additions to the code.
- Write tests that can be run by
pytest
.
Thanks to our contributors so far!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file caustics-0.12.0.tar.gz
.
File metadata
- Download URL: caustics-0.12.0.tar.gz
- Upload date:
- Size: 6.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d31e3d0b49d2cb0ec9ac4182ddc7aaec761eb5604fa416b95968badc8c9e091 |
|
MD5 | 9de492f748dae6cd8b21bed7c3ff6c59 |
|
BLAKE2b-256 | 863eae9ab6578492f544d92b97571827a257fb74c90cfba5651789160150ee65 |
Provenance
The following attestation bundles were made for caustics-0.12.0.tar.gz
:
- Repository: Ciela-Institute/caustics
- Workflow: cd.yml
-
Statement type: https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
caustics-0.12.0.tar.gz
- Subject digest:
7d31e3d0b49d2cb0ec9ac4182ddc7aaec761eb5604fa416b95968badc8c9e091
- Transparency log index: 147428990
- Transparency log integration time:
- Predicate type:
File details
Details for the file caustics-0.12.0-py3-none-any.whl
.
File metadata
- Download URL: caustics-0.12.0-py3-none-any.whl
- Upload date:
- Size: 110.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64cc303cbf0d74ffad46381fb1d11b00a043296ee22e6d75eabf63fd265642fb |
|
MD5 | de1d369bf333dd8a46125446d4d5e2ef |
|
BLAKE2b-256 | 2b151b14801b146e00e922f1d1b3a67a777ef8d351db8f17f6658cbf1b1fa46c |
Provenance
The following attestation bundles were made for caustics-0.12.0-py3-none-any.whl
:
- Repository: Ciela-Institute/caustics
- Workflow: cd.yml
-
Statement type: https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
caustics-0.12.0-py3-none-any.whl
- Subject digest:
64cc303cbf0d74ffad46381fb1d11b00a043296ee22e6d75eabf63fd265642fb
- Transparency log index: 147428993
- Transparency log integration time:
- Predicate type: