{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Event Rates with 3G detectors" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from ler.rates import LeR" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "ler = LeR(batch_size=50000, ifos=['CE', 'ET'], verbose=False)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "unlensed params will be store in unlensed_3G_1M.json\n", "chosen batch size = 50000 with total size = 1000000\n", "There will be 20 batche(s)\n", "resuming from ./ler_data/unlensed_3G_1M.json\n", "saving all unlensed_params in ./ler_data/unlensed_3G_1M.json...\n" ] } ], "source": [ "ler.unlensed_cbc_statistics(size=1000000, save_batch=False, resume=True, output_jsonfile='unlensed_3G_1M.json');" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "getting unlensed_params from json file unlensed_3G_1M.json...\n", "total unlensed rate (yr^-1) (with step function): 91843.65042655931\n", "number of simulated unlensed detectable events: 887182\n", "number of all simulated unlensed events: 1000000\n", "storing detectable unlensed params in unlensed_param_detectable.json\n" ] } ], "source": [ "ler.unlensed_rate();" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "getting unlensed_params from json file unlensed_3G_1M.json...\n", "total unlensed rate (yr^-1) (with step function): 94258.63255779142\n", "number of simulated unlensed detectable events: 910510\n", "number of all simulated unlensed events: 1000000\n", "storing detectable unlensed params in unlensed_param_detectable.json\n" ] } ], "source": [ "ler.unlensed_rate(snr_threshold=6);" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "lensed params will be store in lensed_3G_1M.json\n", "chosen batch size = 50000 with total size = 1000000\n", "There will be 20 batche(s)\n", "resuming from ./ler_data/lensed_3G_1M.json\n", "saving all lensed_params in ./ler_data/lensed_3G_1M.json...\n" ] } ], "source": [ "ler.lensed_cbc_statistics(size=1000000, save_batch=False, resume=True, output_jsonfile='lensed_3G_1M.json');" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "getting lensed_params from json file lensed_3G_1M.json...\n", "total lensed rate (yr^-1) (with step function): 152.3718678085319\n", "number of simulated lensed detectable events: 613339\n", "number of simulated all lensed events: 1000000\n", "storing detectable lensed params in lensed_param_detectable.json\n" ] } ], "source": [ "ler.lensed_rate();" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "getting lensed_params from json file lensed_3G_1M.json...\n", "total lensed rate (yr^-1) (with step function): 167.8888117226168\n", "number of simulated lensed detectable events: 675799\n", "number of simulated all lensed events: 1000000\n", "storing detectable lensed params in lensed_param_detectable.json\n" ] } ], "source": [ "ler.lensed_rate(snr_threshold=[6,6], num_img=[1,1]);" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'ler_param': './ler_params.json',\n", " 'unlensed_param': 'unlensed_3G_1M.json',\n", " 'unlensed_param_detectable': './unlensed_param_detectable.json',\n", " 'lensed_param': 'lensed_3G_1M.json',\n", " 'lensed_param_detectable': './lensed_param_detectable.json'}" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ler.json_file_names" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "unlensed_rate: 91843.65042655931\n", "lensed_rate: 152.3718678085319\n", "ratio: 602.7598909660187\n" ] } ], "source": [ "ler.rate_ratio();" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## With ANN snr (IMRphenomXPHM)\n", "* (under development)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "from ler.rates import LeR\n", "ler = LeR(\n", " batch_size=50000, \n", " verbose=False, \n", " spin_zero=False, \n", " spin_precession=True, \n", " # ifos=['CE', 'ET'], # This will be implemented in the next version\n", " snr_type='ann', \n", " waveform_approximant='IMRPhenomXPHM'\n", " )" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "lensed params will be store in ./lensed_param.json\n", "chosen batch size = 50000 with total size = 100000\n", "There will be 2 batche(s)\n", "Batch no. 1\n", "sampling lensed params...\n", "solving lens equations...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "100%|███████████████████████████████████████████████████████| 50000/50000 [00:14<00:00, 3389.90it/s]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "calculating snrs...\n", "Batch no. 2\n", "sampling lensed params...\n", "solving lens equations...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "100%|███████████████████████████████████████████████████████| 50000/50000 [00:14<00:00, 3358.70it/s]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "calculating snrs...\n" ] } ], "source": [ "ler.lensed_cbc_statistics(size=100000, save_batch=False);" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "getting lensed_params from json file ./lensed_param.json...\n", "total lensed rate (yr^-1) (with step function): 1.488096286349158\n", "number of simulated lensed detectable events: 599\n", "number of simulated all lensed events: 100000\n", "storing detectable lensed params in ./lensed_param_detectable.json\n" ] } ], "source": [ "ler.lensed_rate();" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "getting lensed_params from json file ./lensed_param.json...\n", "calculating snrs...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "100%|████████████████████████████████████████████████████████████| 840/840 [00:04<00:00, 177.26it/s]\n", "100%|████████████████████████████████████████████████████████████| 840/840 [00:04<00:00, 201.31it/s]\n", "100%|████████████████████████████████████████████████████████████| 729/729 [00:03<00:00, 193.07it/s]\n", "100%|████████████████████████████████████████████████████████████| 570/570 [00:03<00:00, 160.27it/s]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "total lensed rate (yr^-1) (with step function): 1.1800429649680302\n", "number of simulated lensed detectable events: 475\n", "number of simulated all lensed events: 100000\n", "storing detectable lensed params in ./lensed_param_detectable.json\n" ] } ], "source": [ "ler.lensed_rate(snr_recalculation=True,);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [] } ], "metadata": { "kernelspec": { "display_name": "ler", "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.10.12" } }, "nbformat": 4, "nbformat_minor": 2 }