-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Notebook demonstrating bulge+disk inference (#74)
* notebook demonstration * notebook updates * move notebooks * demonstrate inference with bulge + disk notebook * trying to fix efficiency, need to explore more options * comment
- Loading branch information
1 parent
c72f59e
commit 070f885
Showing
4 changed files
with
1,339 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,306 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "bc3945e8-3e07-416d-88d3-c3b35421afad", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0\"\n", | ||
"os.environ[\"JAX_ENABLE_X64\"] = \"True\"\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 45, | ||
"id": "d7831e80-3e63-4f59-b180-3d984e45fa85", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from functools import partial\n", | ||
"\n", | ||
"import jax\n", | ||
"import jax.numpy as jnp\n", | ||
"import jax_galsim as xgalsim\n", | ||
"import matplotlib.pyplot as plt \n", | ||
"\n", | ||
"from jax import random\n", | ||
"from jax import vmap, grad, jit\n", | ||
"\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"import galsim\n", | ||
"\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "6e850712-6982-410d-a35d-ce77cfa93e5a", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"@jax.jit\n", | ||
"def render_bd(\n", | ||
" lf, scale_radius, q, beta, x, y, *, psf_hlr=0.7, slen=53, fft_size=256, pixel_scale=0.2\n", | ||
"):\n", | ||
" gsparams = xgalsim.GSParams(minimum_fft_size=fft_size, maximum_fft_size=fft_size)\n", | ||
"\n", | ||
" bulge = xgalsim.Spergel(nu=-0.6, flux=10**lf, scale_radius=scale_radius).shear(\n", | ||
" q=q,\n", | ||
" beta=beta * xgalsim.radians,\n", | ||
" )\n", | ||
"\n", | ||
" psf = xgalsim.Gaussian(flux=1.0, half_light_radius=0.7)\n", | ||
" gal_conv = xgalsim.Convolve([bulge, psf]).withGSParams(gsparams)\n", | ||
" galaxy_image = gal_conv.drawImage(nx=slen, ny=slen, scale=pixel_scale, offset=(x,y)).array\n", | ||
" return galaxy_image" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 39, | ||
"id": "6c228ea9-e513-4aa9-a318-f4d852fbc46d", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"def render_bd_galsim(\n", | ||
" lf, scale_radius, q, beta, x, y, *, psf_hlr=0.7, slen=53, fft_size=256, pixel_scale=0.2\n", | ||
"):\n", | ||
"\n", | ||
" bulge = galsim.Spergel(nu=-0.6, flux=10**lf, scale_radius=scale_radius).shear(\n", | ||
" q=q,\n", | ||
" beta=beta * galsim.radians,\n", | ||
" )\n", | ||
"\n", | ||
" psf = galsim.Gaussian(flux=1.0, half_light_radius=0.7)\n", | ||
" gal_conv = galsim.Convolve([bulge, psf])\n", | ||
" galaxy_image = gal_conv.drawImage(nx=slen, ny=slen, scale=pixel_scale, offset=(x,y)).array\n", | ||
" return galaxy_image" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 35, | ||
"id": "e54f7103-90fe-467d-87da-13dcbec17b7c", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"66" | ||
] | ||
}, | ||
"execution_count": 35, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# image size? \n", | ||
"bulge = galsim.Spergel(nu=-0.6, flux=10**5, scale_radius=0.7).shear(\n", | ||
" q=0.2,\n", | ||
" beta=np.pi/2 * galsim.radians,\n", | ||
")\n", | ||
"\n", | ||
"psf = galsim.Gaussian(flux=1.0, half_light_radius=0.7)\n", | ||
"gal_conv = galsim.Convolve([bulge, psf])\n", | ||
"gal_conv.getGoodImageSize(0.2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 36, | ||
"id": "b7bf387e-86d4-426b-875c-87aa95706215", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"image = render_bd(5.0, 0.7, 0.2, jnp.pi / 2, 0.0, 0.0) # compile" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 37, | ||
"id": "83a10db6-cdeb-4645-82b9-05bf04249c30", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"<matplotlib.image.AxesImage at 0x7fa48c5e8320>" | ||
] | ||
}, | ||
"execution_count": 37, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
}, | ||
{ | ||
"data": { | ||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaAAAAGfCAYAAAAZGgYhAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjAsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvlHJYcgAAAAlwSFlzAAAPYQAAD2EBqD+naQAAJAVJREFUeJzt3X9sleX9//HXfdqeUwR6Kr9aOijD+AN/BIyVH/2qm4N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NmEw2Hzuc99zixbtsycPHkyPT5Ya8KfYwAAeJGX14AAAMMfAQQA8IIAAgB4QQABALwggAAAXhBAAAAvCCAAgBcEEADACwIIAOAFAQQA8IIAAgB4QQABALz4/8TXk4rDmIZ2AAAAAElFTkSuQmCC", | ||
"text/plain": [ | ||
"<Figure size 640x480 with 1 Axes>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"plt.imshow(image)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 17, | ||
"id": "10c8f524-dd45-4114-a756-93c6e5991eb6", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"210 μs ± 2.42 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# timing\n", | ||
"%timeit _ = render_bd(5.0, 1.0, 0.2, jnp.pi / 2, 0.0, 0.0)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 41, | ||
"id": "b3b3ca3c-dd74-4325-ab2c-48868cd44329", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"413 μs ± 18.3 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"%timeit _ = render_bd_galsim(5.0, 1.0, 0.2, jnp.pi / 2, 0.0, 0.0)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 49, | ||
"id": "b6d75ca1-6c98-47a5-a206-10cfb15eb574", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from bpd.draw import draw_gaussian\n", | ||
"\n", | ||
"\n", | ||
"draw_gaussian_jitted = jax.jit(partial(draw_gaussian, slen=53, fft_size=252))\n", | ||
"_ = draw_gaussian_jitted(f=1e6, hlr=1.0, e1=0.2, e2=0.2, g1=0.02, g2=0.0,x=0,y=0)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 51, | ||
"id": "938e232a-c52a-48d6-8c76-ab62f58a041c", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"241 μs ± 1.38 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# compare with Gaussian\n", | ||
"%timeit _ = draw_gaussian_jitted(f=1e6, hlr=1.0, e1=0.2, e2=0.2, g1=0.02, g2=0.0,x=0,y=0)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 53, | ||
"id": "cc054d34-5ef1-4b17-bdb1-d0c69b6bdded", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"106" | ||
] | ||
}, | ||
"execution_count": 53, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# check good size of Gaussian to see how much it matters\n", | ||
"gal = galsim.Gaussian(flux=1e5, half_light_radius=2.0)\n", | ||
"psf = galsim.Gaussian(flux=1.0, half_light_radius=0.7)\n", | ||
"gal_conv = galsim.Convolve([gal, psf])\n", | ||
"gal_conv.getGoodImageSize(0.2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "32b9d712-c53b-42a1-aa2e-ad8f059ad1ef", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "bpd_gpu3", | ||
"language": "python", | ||
"name": "bpd_gpu3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.8" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |