自动强引力透镜模型

autolens的Python项目详细描述


pyautolens

当两个或两个以上的星系完全沿着我们的视线排列时,背景星系就会出现多次。这被称为强引力透镜,&;pyautolens使模拟强引力透镜变得简单,就像这个:

alt text

pyautolens基于以下论文:

强引力透镜成像的自适应半线性反演

自动镜头:强光、质量和光源的自动建模

python示例

使用pyautolens,您可以在几分钟内开始为镜头建模。下面的例子演示了一个简单的分析,它适合前景镜头星系的质量和背景光源星系的光线。

importautofitasafimportautolensasalimportos# In this example, we'll fit a simple lens galaxy + source galaxy system.data_path='{}/../data/'.format(os.path.dirname(os.path.realpath(__file__)))lens_name='example_lens'# Get the relative path to the data in our workspace & load the ccd imaging data.ccd_data=al.load_ccd_data_from_fits(image_path=data_path+lens_name+'/image.fits',psf_path=data_path+lens_name+'/psf.fits',noise_map_path=data_path+lens_name+'/noise_map.fits',pixel_scale=0.1)# Create a mask for the data, which we setup as a 3.0" circle.mask=al.Mask.circular(shape=ccd_data.shape,pixel_scale=ccd_data.pixel_scale,radius_arcsec=3.0)# We model our lens galaxy using a mass profile (a singular isothermal ellipsoid) & our source galaxy # a light profile (an elliptical Sersic).lens_mass_profile=al.mass_profiles.EllipticalIsothermalsource_light_profile=al.light_profiles.EllipticalSersic# To setup our model galaxies, we use the GalaxyModel class, which represents a galaxy whose parameters # are variable & fitted for by PyAutoLens. The galaxies are also assigned redshifts.lens_galaxy_model=al.GalaxyModel(redshift=0.5,mass=lens_mass_profile)source_galaxy_model=al.GalaxyModel(redshift=1.0,light=source_light_profile)# To perform the analysis we set up a phase, which takes our galaxy models & fits their parameters using a non-linear# search (in this case, MultiNest).phase=al.PhaseImaging(galaxies=dict(lens=lens_galaxy_model,source=source_galaxy_model),phase_name='example/phase_example',optimizer_class=af.MultiNest)# We pass the ccd data and mask to the phase, thereby fitting it with the lens model above & plot the resulting fit.result=phase.run(data=ccd_data,mask=mask)al.lens_fit_plotters.plot_fit_subplot(fit=result.most_likely_fit)

松弛度

我们正在slack上建立一个pyautolens社区,因此在开始之前,您应该通过我们的slack频道与我们联系。在这里,我将为您提供有关软件的最新更新,并讨论如何在您的科学案例中最好地使用pyautolens。

不幸的是,slack只是邀请,所以首先给我发送一封请求邀请的电子邮件。

功能

pyautolens的高级建模功能包括:

如何操作

pyautolens附带的是Howtolens系列讲座,介绍了使用pyautolens进行强引力透镜建模。它可以在工作区中找到,由4章组成:

工作空间

pyautolens附带一个工作区,可以在这里找到其中包括:

如果使用conda或pip安装pyautolens,则需要从autolens工作区存储库下载工作区,如下面的安装说明所述。

依赖性

pyautolens需要pymultinest&;numba

使用conda安装

我们建议使用conda环境进行安装,因为这样可以在安装pymultinest时避免许多兼容性问题。

首先,安装conda

创建conda环境:

conda create -n autolens python=3.7 anaconda

激活conda环境:

conda activate autolens

安装多嵌套:

conda install -c conda-forge multinest

安装自动镜头:

pip install autolens

克隆autolens workspace&set workspace环境变量:

cd /path/where/you/want/autolens_workspace
git clone https://github.com/Jammy2211/autolens_workspace
export WORKSPACE=/path/to/autolens_workspace/

将pythonpath设置为包含autolens_工作区目录:

export PYTHONPATH=/path/to/autolens_workspace/

您可以通过在autolens_工作区中运行示例pipeline runner来测试所有工作是否正常

python3 /path/to/autolens_workspace/runners/simple/runner__lens_sie__source_inversion.py

使用PIP安装

也可以通过PIP进行安装,但是在安装pymultinest时会遇到一些报告的问题,这些问题会使安装变得困难,请参阅文件install.notes

$ pip install autolens

克隆autolens workspace&set workspace环境变量:

cd /path/where/you/want/autolens_workspace
git clone https://github.com/Jammy2211/autolens_workspace
export WORKSPACE=/path/to/autolens_workspace/

将pythonpath设置为包含autolens_工作区目录:

export PYTHONPATH=/path/to/autolens_workspace/

您可以通过在autolens_工作区中运行示例pipeline runner来测试所有工作是否正常

importautofitasafimportautolensasalimportos# In this example, we'll fit a simple lens galaxy + source galaxy system.data_path='{}/../data/'.format(os.path.dirname(os.path.realpath(__file__)))lens_name='example_lens'# Get the relative path to the data in our workspace & load the ccd imaging data.ccd_data=al.load_ccd_data_from_fits(image_path=data_path+lens_name+'/image.fits',psf_path=data_path+lens_name+'/psf.fits',noise_map_path=data_path+lens_name+'/noise_map.fits',pixel_scale=0.1)# Create a mask for the data, which we setup as a 3.0" circle.mask=al.Mask.circular(shape=ccd_data.shape,pixel_scale=ccd_data.pixel_scale,radius_arcsec=3.0)# We model our lens galaxy using a mass profile (a singular isothermal ellipsoid) & our source galaxy # a light profile (an elliptical Sersic).lens_mass_profile=al.mass_profiles.EllipticalIsothermalsource_light_profile=al.light_profiles.EllipticalSersic# To setup our model galaxies, we use the GalaxyModel class, which represents a galaxy whose parameters # are variable & fitted for by PyAutoLens. The galaxies are also assigned redshifts.lens_galaxy_model=al.GalaxyModel(redshift=0.5,mass=lens_mass_profile)source_galaxy_model=al.GalaxyModel(redshift=1.0,light=source_light_profile)# To perform the analysis we set up a phase, which takes our galaxy models & fits their parameters using a non-linear# search (in this case, MultiNest).phase=al.PhaseImaging(galaxies=dict(lens=lens_galaxy_model,source=source_galaxy_model),phase_name='example/phase_example',optimizer_class=af.MultiNest)# We pass the ccd data and mask to the phase, thereby fitting it with the lens model above & plot the resulting fit.result=phase.run(data=ccd_data,mask=mask)al.lens_fit_plotters.plot_fit_subplot(fit=result.most_likely_fit)
2

支持和讨论

如果您在安装、镜头建模方面遇到困难,或者只是想聊天,请随时在我们的松弛频道上给我们留言。

贡献

如果您有任何建议或想贡献,请与我们联系。

出版物

下面的文章使用pyautolens

引力透镜合并hatlas j142935.3-002836中的分子气体性质

具有强引力透镜的星系结构:分解大质量椭圆星系的内部质量分布

新型子结构和超流体暗物质

CO、H2O、H2O+A z=3.63中的线和尘埃排放在低于千帕尺度的强透镜星暴合并中

学分

开发商

詹姆斯·南丁格尔-首席开发人员和pyautolens大师。

Richard Hayes-首席开发人员&;pyautofit大师。

ashley kelly-用于快速偏转计算的pyquad开发人员。

amy etherington-放大率、临界曲线和焦散计算。

ef="https://github.com/cao xiaoyue" rel="nofollow">cao xiaoyue-解析椭圆幂律偏转角计算。

nan li-Docker集成与支持。

代码捐赠者

andrew robertson-临界曲线和腐蚀性计算。

Mattia Negrello-通过直接傅里叶变换在紫外平面上建立可见性模型。

andrea enia-voronoi源平面绘图工具。

Aristeidis Amvrosiadis-ALMA图像数据加载。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java中不同http客户端超时时间单位的重要性   java数据[i++]=data[i++]*2结果令我惊讶   java Quartz在使用spring的hibernate中执行事务时发生异常   java如何将我的对象传递给另一个类   java嵌套布局奇怪的问题   当使用javax时,有一种方法可以通过策略定义自定义订单。坚持不懈OrderBy注释?   xml Java DOM getElementByID   java使用intent将视图列表传递给另一个片段   带构造函数的Java枚举。通过构造函数参数获取值的最佳方法   java为什么不在单线程中执行此通量?   如何将JavaScript字符串传递给Nashorn引擎而不是Java字符串?   java二进制XML文件行#17:膨胀类片段时出错   java如何使用Seekbar值作为int变量?   java我想从数据存储中进行选择,但它不起作用   java如何处理幻灯片中的多分辨率图像?   java这意味着什么?类型不匹配:无法从列表<对象和可比<?>&可序列化>以列出<对象>“   java我如何让这个猜谜游戏发挥作用?   java将ZipInputStream传递给DocumentBuilder。parse()   java后添加maven依赖项,org。阿帕奇。卡塔琳娜。过滤器。当前错误消息   java有没有一种方法可以使用安卓通过按下便利键触发方法?