caustics


Namecaustics JSON
Version 0.12.0 PyPI version JSON
download
home_pageNone
SummaryThe lensing pipeline of the future: GPU-accelerated, automatically-differentiable, highly modular. Currently under heavy development: expect interface changes and some imprecise/untested calculations.
upload_time2024-11-07 21:58:20
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) [2023] [caustics authors] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords astronomy astrophysics caustics differentiable programming gravitational lensing lensing pytorch strong lensing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://github.com/Ciela-Institute/caustics/blob/main/media/caustics_logo.png?raw=true">
  <source media="(prefers-color-scheme: light)" srcset="https://github.com/Ciela-Institute/caustics/blob/main/media/caustics_logo_white.png?raw=true">
  <img alt="caustics logo" src="media/caustics_logo.png" width="70%">
</picture>

[![ssec](https://img.shields.io/badge/SSEC-Project-purple?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAOCAQAAABedl5ZAAAACXBIWXMAAAHKAAABygHMtnUxAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAMNJREFUGBltwcEqwwEcAOAfc1F2sNsOTqSlNUopSv5jW1YzHHYY/6YtLa1Jy4mbl3Bz8QIeyKM4fMaUxr4vZnEpjWnmLMSYCysxTcddhF25+EvJia5hhCudULAePyRalvUteXIfBgYxJufRuaKuprKsbDjVUrUj40FNQ11PTzEmrCmrevPhRcVQai8m1PRVvOPZgX2JttWYsGhD3atbHWcyUqX4oqDtJkJiJHUYv+R1JbaNHJmP/+Q1HLu2GbNoSm3Ft0+Y1YMdPSTSwQAAAABJRU5ErkJggg==&style=plastic)](https://escience.washington.edu/software-engineering/ssec/)
[![CI](https://github.com/Ciela-Institute/caustics/actions/workflows/ci.yml/badge.svg)](https://github.com/Ciela-Institute/caustics/actions/workflows/ci.yml)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Ciela-Institute/caustics/main.svg)](https://results.pre-commit.ci/latest/github/Ciela-Institute/caustics/main)
[![Documentation Status](https://readthedocs.org/projects/caustics/badge/?version=latest)](https://caustics.readthedocs.io/en/latest/?badge=latest)
[![PyPI version](https://badge.fury.io/py/caustics.svg)](https://pypi.org/project/caustics/)
[![coverage](https://img.shields.io/codecov/c/github/Ciela-Institute/caustics)](https://app.codecov.io/gh/Ciela-Institute/caustics)
[![status](https://joss.theoj.org/papers/995fa98462eb534a32952549ef2244f8/status.svg)](https://joss.theoj.org/papers/995fa98462eb534a32952549ef2244f8)
[![Zenodo](https://zenodo.org/badge/521722463.svg)](https://zenodo.org/doi/10.5281/zenodo.10806382)
[![arXiv](https://img.shields.io/badge/arXiv-2406.15542-b31b1b.svg)](https://arxiv.org/abs/2406.15542)

# 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:

```bash
pip install caustics
```

## Minimal Example

```python
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()
```

![Caustics lensed image](./media/minimal_example.png)

### Batched simulator

```python
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()
```

![Batched Caustics lensed images](./media/minisim_vmap.png)

### Automatic Differentiation

```python
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()
```

![Jacobian Caustics lensed image](./media/minisim_jacobian.png)

## Documentation

Please see our [documentation page](https://caustics.readthedocs.io/en/latest/)
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.

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/uw-ssec/caustics?quickstart=1)

Instruction on how to contribute to this project can be found in the
CONTRIBUTION.md

Some guidelines:

- Please use `isort` and `black` to format your code.
- Use `CamelCase` for class names and `snake_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`](https://docs.pytest.org/).

Thanks to our contributors so far!

[![Contributors](https://contrib.rocks/image?repo=Ciela-Institute/caustics)](https://github.com/Ciela-Institute/caustics/graphs/contributors)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "caustics",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "astronomy, astrophysics, caustics, differentiable programming, gravitational lensing, lensing, pytorch, strong lensing",
    "author": null,
    "author_email": "Connor Stone <connor.stone@mila.quebec>, Alexandre Adam <alexandre.adam@mila.quebec>, UW SSEC <ssec@uw.edu>",
    "download_url": "https://files.pythonhosted.org/packages/86/3e/ae9ab6578492f544d92b97571827a257fb74c90cfba5651789160150ee65/caustics-0.12.0.tar.gz",
    "platform": null,
    "description": "<picture>\n  <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/Ciela-Institute/caustics/blob/main/media/caustics_logo.png?raw=true\">\n  <source media=\"(prefers-color-scheme: light)\" srcset=\"https://github.com/Ciela-Institute/caustics/blob/main/media/caustics_logo_white.png?raw=true\">\n  <img alt=\"caustics logo\" src=\"media/caustics_logo.png\" width=\"70%\">\n</picture>\n\n[![ssec](https://img.shields.io/badge/SSEC-Project-purple?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAOCAQAAABedl5ZAAAACXBIWXMAAAHKAAABygHMtnUxAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAMNJREFUGBltwcEqwwEcAOAfc1F2sNsOTqSlNUopSv5jW1YzHHYY/6YtLa1Jy4mbl3Bz8QIeyKM4fMaUxr4vZnEpjWnmLMSYCysxTcddhF25+EvJia5hhCudULAePyRalvUteXIfBgYxJufRuaKuprKsbDjVUrUj40FNQ11PTzEmrCmrevPhRcVQai8m1PRVvOPZgX2JttWYsGhD3atbHWcyUqX4oqDtJkJiJHUYv+R1JbaNHJmP/+Q1HLu2GbNoSm3Ft0+Y1YMdPSTSwQAAAABJRU5ErkJggg==&style=plastic)](https://escience.washington.edu/software-engineering/ssec/)\n[![CI](https://github.com/Ciela-Institute/caustics/actions/workflows/ci.yml/badge.svg)](https://github.com/Ciela-Institute/caustics/actions/workflows/ci.yml)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Ciela-Institute/caustics/main.svg)](https://results.pre-commit.ci/latest/github/Ciela-Institute/caustics/main)\n[![Documentation Status](https://readthedocs.org/projects/caustics/badge/?version=latest)](https://caustics.readthedocs.io/en/latest/?badge=latest)\n[![PyPI version](https://badge.fury.io/py/caustics.svg)](https://pypi.org/project/caustics/)\n[![coverage](https://img.shields.io/codecov/c/github/Ciela-Institute/caustics)](https://app.codecov.io/gh/Ciela-Institute/caustics)\n[![status](https://joss.theoj.org/papers/995fa98462eb534a32952549ef2244f8/status.svg)](https://joss.theoj.org/papers/995fa98462eb534a32952549ef2244f8)\n[![Zenodo](https://zenodo.org/badge/521722463.svg)](https://zenodo.org/doi/10.5281/zenodo.10806382)\n[![arXiv](https://img.shields.io/badge/arXiv-2406.15542-b31b1b.svg)](https://arxiv.org/abs/2406.15542)\n\n# caustics\n\nThe lensing pipeline of the future: GPU-accelerated,\nautomatically-differentiable, highly modular. Currently under heavy development:\nexpect interface changes and some imprecise/untested calculations.\n\n## Installation\n\nSimply install caustics from PyPI:\n\n```bash\npip install caustics\n```\n\n## Minimal Example\n\n```python\nimport matplotlib.pyplot as plt\nimport caustics\nimport torch\n\ncosmology = caustics.FlatLambdaCDM()\nsie = caustics.SIE(cosmology=cosmology, name=\"lens\")\nsrc = caustics.Sersic(name=\"source\")\nlnslt = caustics.Sersic(name=\"lenslight\")\n\nx = torch.tensor([\n#   z_s  z_l   x0   y0   q    phi     b    x0   y0   q     phi    n    Re\n    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,\n#   Ie    x0   y0   q    phi  n   Re   Ie\n    5.0, -0.2, 0.0, 0.8, 0.0, 1., 1.0, 10.0\n])  # fmt: skip\n\nsim = caustics.LensSource(\n    lens=sie, source=src, lens_light=lnslt, pixelscale=0.05, pixels_x=100\n)\nplt.imshow(sim(x), origin=\"lower\")\nplt.axis(\"off\")\nplt.show()\n```\n\n![Caustics lensed image](./media/minimal_example.png)\n\n### Batched simulator\n\n```python\nnewx = x.repeat(20, 1)\nnewx += torch.normal(mean=0, std=0.1 * torch.ones_like(newx))\n\nimages = torch.vmap(sim)(newx)\n\nfig, axarr = plt.subplots(4, 5, figsize=(20, 16))\nfor ax, im in zip(axarr.flatten(), images):\n    ax.imshow(im, origin=\"lower\")\nplt.show()\n```\n\n![Batched Caustics lensed images](./media/minisim_vmap.png)\n\n### Automatic Differentiation\n\n```python\nJ = torch.func.jacfwd(sim)(x)\n\n# Plot the new images\nfig, axarr = plt.subplots(3, 7, figsize=(20, 9))\nfor i, ax in enumerate(axarr.flatten()):\n    ax.imshow(J[..., i], origin=\"lower\")\nplt.show()\n```\n\n![Jacobian Caustics lensed image](./media/minisim_jacobian.png)\n\n## Documentation\n\nPlease see our [documentation page](https://caustics.readthedocs.io/en/latest/)\nfor more detailed information.\n\n## Contribution\n\nWe welcome contributions from collaborators and researchers interested in our\nwork. If you have improvements, suggestions, or new findings to share, please\nsubmit an issue or pull request. Your contributions help advance our research\nand analysis efforts.\n\nTo get started with your development (or fork), click the \"Open with GitHub\nCodespaces\" button below to launch a fully configured development environment\nwith all the necessary tools and extensions.\n\n[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/uw-ssec/caustics?quickstart=1)\n\nInstruction on how to contribute to this project can be found in the\nCONTRIBUTION.md\n\nSome guidelines:\n\n- Please use `isort` and `black` to format your code.\n- Use `CamelCase` for class names and `snake_case` for variable and method\n  names.\n- Open up issues for bugs/missing features.\n- Use pull requests for additions to the code.\n- Write tests that can be run by [`pytest`](https://docs.pytest.org/).\n\nThanks to our contributors so far!\n\n[![Contributors](https://contrib.rocks/image?repo=Ciela-Institute/caustics)](https://github.com/Ciela-Institute/caustics/graphs/contributors)\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) [2023] [caustics authors]  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "The lensing pipeline of the future: GPU-accelerated, automatically-differentiable, highly modular. Currently under heavy development: expect interface changes and some imprecise/untested calculations.",
    "version": "0.12.0",
    "project_urls": {
        "Documentation": "https://caustics.readthedocs.io/en/latest/",
        "Homepage": "https://mila.quebec/en/",
        "Issues": "https://github.com/Ciela-Institute/caustics/issues",
        "Repository": "https://github.com/Ciela-Institute/caustics"
    },
    "split_keywords": [
        "astronomy",
        " astrophysics",
        " caustics",
        " differentiable programming",
        " gravitational lensing",
        " lensing",
        " pytorch",
        " strong lensing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2b151b14801b146e00e922f1d1b3a67a777ef8d351db8f17f6658cbf1b1fa46c",
                "md5": "de1d369bf333dd8a46125446d4d5e2ef",
                "sha256": "64cc303cbf0d74ffad46381fb1d11b00a043296ee22e6d75eabf63fd265642fb"
            },
            "downloads": -1,
            "filename": "caustics-0.12.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "de1d369bf333dd8a46125446d4d5e2ef",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 110245,
            "upload_time": "2024-11-07T21:58:18",
            "upload_time_iso_8601": "2024-11-07T21:58:18.121994Z",
            "url": "https://files.pythonhosted.org/packages/2b/15/1b14801b146e00e922f1d1b3a67a777ef8d351db8f17f6658cbf1b1fa46c/caustics-0.12.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "863eae9ab6578492f544d92b97571827a257fb74c90cfba5651789160150ee65",
                "md5": "9de492f748dae6cd8b21bed7c3ff6c59",
                "sha256": "7d31e3d0b49d2cb0ec9ac4182ddc7aaec761eb5604fa416b95968badc8c9e091"
            },
            "downloads": -1,
            "filename": "caustics-0.12.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9de492f748dae6cd8b21bed7c3ff6c59",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 6582183,
            "upload_time": "2024-11-07T21:58:20",
            "upload_time_iso_8601": "2024-11-07T21:58:20.214156Z",
            "url": "https://files.pythonhosted.org/packages/86/3e/ae9ab6578492f544d92b97571827a257fb74c90cfba5651789160150ee65/caustics-0.12.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-07 21:58:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Ciela-Institute",
    "github_project": "caustics",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "caustics"
}
        
Elapsed time: 0.44824s