{ "cells": [ { "cell_type": "markdown", "id": "1309f725-3a4b-4d20-bc09-ac44328c4c8e", "metadata": {}, "source": [ "# Cluster Lens Simulation Interface" ] }, { "cell_type": "markdown", "id": "d8d41f63", "metadata": {}, "source": [ "This notebook shows the current progress in the group and cluster scale simulations.\n", "\n", "Implemented:\n", "* NFWCluster deflector class: a NFW halo and subhalos that can be any deflector, accesible through the Deflector interface\n", "* Integration with Lens interface to simulate lens related quanities.\n", "\n", "Not (yet) implemented:\n", "* Draw halo and subhalo population\n", "* Catalog of cluster halos and cluster members\n", "* Integration with LensPop" ] }, { "cell_type": "markdown", "id": "a4e168e0-af2c-4777-b63a-589281ddecb7", "metadata": {}, "source": [ "## Setup" ] }, { "cell_type": "code", "execution_count": 1, "id": "db69cd01-ebfc-452a-ad70-3b152e7c79e6", "metadata": {}, "outputs": [], "source": [ "from slsim.Deflectors.deflector import Deflector\n", "from slsim.lens import Lens\n", "from slsim.lens_pop import LensPop\n", "from slsim.image_simulation import simulate_image, rgb_image_from_image_list\n", "\n", "from astropy.cosmology import FlatLambdaCDM\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from astropy.table import Table, vstack, hstack\n", "from astropy import units as u\n", "from lenstronomy.Util import param_util\n", "from scipy.spatial.distance import cdist\n", "\n", "from matplotlib.patches import Ellipse" ] }, { "cell_type": "markdown", "id": "f63d103f-15b7-460d-97d7-beeb116e6421", "metadata": {}, "source": [ "Generate a population of sources and elliptical deflectors" ] }, { "cell_type": "code", "execution_count": 2, "id": "c988a829-d091-4e3b-93fb-93ebb1a7a0ad", "metadata": {}, "outputs": [], "source": [ "np.random.seed(0)" ] }, { "cell_type": "code", "execution_count": 3, "id": "1a749fac-e1d6-43ee-99aa-2368373955a6", "metadata": {}, "outputs": [], "source": [ "# define a cosmology\n", "cosmo = FlatLambdaCDM(H0=70, Om0=0.3)\n", "\n", "# define a sky area\n", "sky_area = u.Quantity(value=0.1, unit=\"deg2\")\n", "\n", "\n", "# define limits in the intrinsic deflector and source population (in addition to the skypy config\n", "# file)\n", "kwargs_deflector_cut = {\"band\": \"g\", \"band_max\": 26, \"z_min\": 0.01, \"z_max\": 2.5}\n", "kwargs_source_cut = {\"band\": \"g\", \"band_max\": 26, \"z_min\": 0.1, \"z_max\": 5.0}\n", "\n", "# run skypy pipeline and make galaxy-galaxy population class using LensPop\n", "gg_lens_pop = LensPop(\n", " deflector_type=\"elliptical\",\n", " source_type=\"galaxies\",\n", " kwargs_deflector_cut=kwargs_deflector_cut,\n", " kwargs_source_cut=kwargs_source_cut,\n", " kwargs_mass2light=None,\n", " skypy_config=None,\n", " sky_area=sky_area,\n", " cosmo=cosmo,\n", ")" ] }, { "cell_type": "markdown", "id": "ac4fa562-827c-4a90-b639-a3fbda39a9f2", "metadata": {}, "source": [ "## Basic Example\n", "\n", "This example shows the implemented features. It generates a lens from an slsim sampled source, and a halo + subhalos with manually set parameters. It is not intended to be a realistic cluster." ] }, { "cell_type": "markdown", "id": "0d77e9dc-e507-45bb-9e41-b0a5d1080128", "metadata": {}, "source": [ "Set seed for reproduction" ] }, { "cell_type": "code", "execution_count": 4, "id": "227e8442-d713-45a8-a6db-be4c1381cdf6", "metadata": {}, "outputs": [], "source": [ "np.random.seed(3)" ] }, { "cell_type": "markdown", "id": "758f43f6-5929-44ff-8f6b-35786ba10ebf", "metadata": {}, "source": [ "Halo parameters:" ] }, { "cell_type": "code", "execution_count": 5, "id": "b552db1b-5996-4d97-8cf1-e2eecf383f94", "metadata": {}, "outputs": [], "source": [ "halo_dict = {\n", " \"halo_mass\": 1e14,\n", " \"concentration\": 5,\n", " \"e1_mass\": 0.1,\n", " \"e2_mass\": -0.1,\n", " \"z\": 0.42,\n", "}" ] }, { "cell_type": "markdown", "id": "a19e5249-ca68-450f-9492-5da5d7f68b5f", "metadata": {}, "source": [ "A random sample of deflectors as subhalos:" ] }, { "cell_type": "code", "execution_count": 8, "id": "24d168d4-d64d-4473-8189-b44cc9307572", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| z | M | coeff | ellipticity | physical_size | stellar_mass | angular_size | mag_g | mag_r | mag_i | mag_z | mag_Y | vel_disp | e1_light | e2_light | e1_mass | e2_mass | n_sersic | center_x | center_y |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| kpc | rad | ||||||||||||||||||
| float64 | float64 | float64[5] | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 |
| 0.40961161750606623 | -17.74659351948313 | 0.014461312431650886 .. 0.0017553671438891554 | 0.2910638099896307 | 0.6126468465532885 | 6134707325.985248 | 5.449207115062017e-07 | 24.980052525073667 | 23.595940832611404 | 23.07059085953089 | 22.76766104854414 | 22.57663477819682 | 238.6881226614444 | -0.04528497553751 | 0.1416914374289071 | -0.0019891604503226743 | 0.026829555556416532 | 4.0 | 2.1991997927160987 | 3.919514530899428 |
| 0.4116468964498543 | -21.33484897934431 | 0.23285635798664925 .. 0.0006941668698218637 | 0.15174652869004476 | 3.7017292439367973 | 240837649679.1357 | 3.282729405263374e-06 | 21.567499195041215 | 20.026445329337342 | 19.363187222380752 | 18.981620021271375 | 18.75254269621525 | 275.0041773084429 | -0.05236187054892784 | 0.05551789525462122 | -0.06511420472541432 | 0.08282581103144096 | 4.0 | 0.8693181053414824 | 0.8279203242106586 |
| 0.357742197708797 | -17.70016474314204 | 0.11749415182192821 .. 0.0009963705918894985 | 0.09247542465242468 | 0.22517235412009645 | 8172885735.947244 | 2.1789243925349325e-07 | 24.558320753535146 | 23.174654552345824 | 22.60350168788489 | 22.273007291380058 | 22.085215345311457 | 239.48534781261813 | 0.023416486644143208 | 0.03998480716073247 | 0.08818194961203064 | 0.2393539252201014 | 4.0 | -1.4313058824457068 | -1.2971386999655654 |
| 0.43321408312382476 | -21.624890597703676 | 0.08464660764530811 .. 0.0009006445161237372 | 0.21060142972690385 | 2.3919434702572593 | 260035388352.9656 | 2.058095711291011e-06 | 21.000557844900243 | 19.926803223244768 | 19.33049856621807 | 19.010991686213686 | 18.79413875740036 | 276.91021844529143 | 0.10590581383265181 | 0.011186271676403 | 0.01235901177287892 | 0.0008661401605979852 | 4.0 | 0.5913335287465081 | 9.373582206571212 |
| 0.40664485199633355 | -20.323923719919286 | 0.04239681022192635 .. 0.000642978918452646 | 0.3224955343138368 | 1.4049504867155502 | 82384629856.09811 | 1.2551227098076372e-06 | 22.470274300452132 | 20.990325400071697 | 20.39528372488079 | 20.065144547510236 | 19.87646729406098 | 256.2982137470725 | -0.029037278604714677 | 0.1631091572224996 | -0.01927975004064865 | 0.10069437796471338 | 4.0 | 7.369516112011384 | 5.00295994058848 |
| 0.4376178752381092 | -18.7936006252479 | 0.14206729280250247 .. 0.0016625409960951707 | 0.1647023203467217 | 0.4254001095167009 | 20230857612.75885 | 3.6388064941698217e-07 | 24.21872306092851 | 22.799104546193014 | 22.146352378632578 | 21.79395982665163 | 21.565756843217763 | 243.85574045984882 | -0.0754136386484834 | 0.03446838704341557 | -0.018110945492180335 | 0.008948504939325357 | 4.0 | -5.005510169566389 | -2.681860992222449 |
| 0.4099796727538578 | -16.512141575263364 | 0.030875540197497997 .. 0.0002203614733351139 | 0.08513893600336805 | 0.11686325540198512 | 2792649800.8751807 | 1.038882899755727e-07 | 26.39549320727873 | 24.83029836517223 | 24.182210285777888 | 23.840503093758993 | 23.65161860291757 | 236.99130742917959 | -0.0424965956722835 | 0.003577249480990931 | 0.09694801706010811 | -0.017100807340409214 | 4.0 | 7.644046541105355 | 9.268773948886318 |
| 0.4127768279274331 | -15.721344032029277 | 0.07559942601411682 .. 0.00027449606564557876 | 0.26668668280998875 | 0.2985039673322858 | 1283273119.2410483 | 2.642817163990263e-07 | 27.04262960934578 | 25.65013657080857 | 25.022279241903632 | 24.68099549945051 | 24.48110194359954 | 235.93973169995965 | -0.0382039211203908 | 0.1303179954461028 | -0.016311796145999414 | 0.07570778350877454 | 4.0 | 16.833942804162128 | -6.2521801083342154 |
| 0.43371538809999644 | -19.906496833927086 | 0.1330919972384299 .. 0.0009832574915758423 | 0.08163712829655634 | 0.6388918586183057 | 46629527232.0393 | 5.493502154531822e-07 | 22.80636123567772 | 21.645474543240972 | 21.083604730434686 | 20.773945108716994 | 20.535144539362967 | 249.68829440839266 | 0.02535741704846566 | 0.032073851673849366 | 0.11267280486614065 | 0.16064388545998565 | 4.0 | -3.0834953283783717 | -6.801424536872165 |
| 0.4470202859737583 | -21.25808349208964 | 0.03378577389732713 .. 0.000507403732677016 | 0.34214100047044205 | 2.381466544421677 | 219084869701.21854 | 2.012277977759689e-06 | 21.859885721418987 | 20.425021381344155 | 19.707747157772868 | 19.35273673247956 | 19.15103583581944 | 273.01372375012085 | 0.1640864088616454 | 0.06473208537573834 | 0.10843336276188861 | 0.052678427823703515 | 4.0 | -4.136205681886929 | 3.5504779276895233 |