跳转到主要内容

未来的透镜管道:基于GPU加速、自动微分、高度模块化。目前处于紧张的开发中:预计将出现界面更改和一些不精确/未经测试的计算。

项目描述

caustics logo

ssec CI pre-commit.ci status Documentation Status PyPI version coverage status Zenodo arXiv

caustics

未来的透镜管道:基于GPU加速、自动微分、高度模块化。目前处于紧张的开发中:预计将出现界面更改和一些不精确/未经测试的计算。

安装

简单地从PyPI安装caustics

pip install caustics

最小示例

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

批量模拟器

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

自动微分

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

文档

请参阅我们的文档页面获取更详细的信息。

贡献

我们欢迎有兴趣与我们一起工作的合作者和研究人员做出贡献。如果您有改进、建议或新的发现要分享,请提交问题或拉取请求。您的贡献有助于推动我们的研究和分析工作。

要开始开发(或分支),请点击下面的“使用GitHub Codespaces打开”按钮,以启动一个配备所有必需工具和扩展的完整配置的开发环境。

Open in GitHub Codespaces

有关如何为此项目做出贡献的说明,请参阅CONTRIBUTION.md。

一些指南

  • 请使用isortblack来格式化您的代码。
  • 使用CamelCase为类名,使用snake_case为变量和方法名。
  • 为错误/缺失功能打开问题。
  • 使用拉取请求向代码添加内容。
  • 编写可以通过pytest运行的测试。

感谢迄今为止的贡献者!

Contributors

项目详情


下载文件

下载适用于您平台的应用程序。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

caustics-0.11.2.tar.gz (6.6 MB 查看哈希值)

上传时间

构建分布

caustics-0.11.2-py3-none-any.whl (104.4 kB 查看哈希值)

上传时间 Python 3

由以下支持:

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面