{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Example of generating a Gaussian beam in spherical harmonics space" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Generate $b_{lm}$ representation of a Gaussian beam" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import healpy as hp\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from astropy import units as u" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Configure parameters of the transformation" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "lmax = 32\n", "pol = True\n", "nside = 64\n", "beam_width = 10 * u.degree" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Generate the $b_{lm}$\n", "\n", "The shape is $(1, \\ell_{max})$ for temperature only, $(3, \\ell_{max})$ for a polarized beam." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "blm=hp.blm_gauss(beam_width.to_value(u.radian), lmax=lmax, pol=pol)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "blm.shape" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot\n", "\n", "Plot the beam, rotate inside `mollview` for better visualization" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m = hp.alm2map(blm, lmax=lmax, mmax=2 if pol else 0, nside=nside, pol=pol)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for each_m, label in zip(m, \"IQU\"):\n", " hp.mollview(each_m, rot=[0, 90], title=f\"Beam map, {label}\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "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.8.3" } }, "nbformat": 4, "nbformat_minor": 4 }