{ "cells": [ { "cell_type": "markdown", "id": "573d587c", "metadata": {}, "source": [ "# Fitting quasi-normal modes in GW150914" ] }, { "cell_type": "markdown", "id": "67711d92", "metadata": {}, "source": [ "We demonstrate how to use `ringdown` to fit damped sinusoids in data from the first LIGO detection, GW150914. We will make a number of pedagogical plots along the way, the actual fit should take under 2 minutes in a modern desktop computer." ] }, { "cell_type": "markdown", "id": "34124c7b", "metadata": {}, "source": [ "_NOTE:_ this example is inteneded to demonstrate the functionality of the `ringdown` package using GW150914 as an example; it is not meant to reproduce the result from [Isi, et al. (2019)](https://ui.adsabs.harvard.edu/abs/2019PhRvL.123k1102I/abstract): we use a more general polarization model, assume different priors, and apply slightly different data conditioning; therefore, the results should not be expected to be identical Isi et al (2019)." ] }, { "cell_type": "markdown", "id": "f4da0873", "metadata": {}, "source": [ "We begin with some standard imports and global settings." ] }, { "cell_type": "markdown", "id": "d1468161", "metadata": {}, "source": [ "## Preliminaries" ] }, { "cell_type": "code", "execution_count": 1, "id": "d5888e7e", "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "%config InlineBackend.figure_format = 'retina'" ] }, { "cell_type": "code", "execution_count": 2, "id": "3d500eef", "metadata": {}, "outputs": [], "source": [ "# disable numpy multithreading to avoid conflicts\n", "# with jax multiprocessing in numpyro\n", "import os\n", "os.environ[\"OMP_NUM_THREADS\"] = \"1\"\n", "import numpy as np\n", "\n", "# import jax and set it up to use double precision\n", "from jax import config\n", "config.update(\"jax_enable_x64\", False)\n", "\n", "# import numpyro and set it up to use 4 CPU devices\n", "import numpyro\n", "numpyro.set_host_device_count(4)\n", "numpyro.set_platform('cpu')\n", "\n", "# we will use matplotlib, arviz and seaborn for some of the plotting\n", "import matplotlib.pyplot as plt\n", "import arviz as az\n", "import seaborn as sns\n", "\n", "# disable some warning shown by importing LALSuite from a notebook\n", "import warnings\n", "warnings.filterwarnings(\"ignore\", \"Wswiglal-redir-stdio\")\n", "\n", "# import ringdown package\n", "import ringdown as rd\n", "\n", "# set plotting context\n", "sns.set_context('notebook')\n", "sns.set_palette('colorblind')" ] }, { "cell_type": "markdown", "id": "c8b094a6", "metadata": {}, "source": [ "
<xarray.Dataset> Size: 27MB\n",
"Dimensions: (chain: 4, draw: 1000, mode: 2, ifo: 2, time_index: 410)\n",
"Coordinates:\n",
" * chain (chain) int64 32B 0 1 2 3\n",
" * draw (draw) int64 8kB 0 1 2 3 4 5 6 7 ... 993 994 995 996 997 998 999\n",
" * mode (mode) |S10 20B b'1,-2,2,2,0' b'1,-2,2,2,1'\n",
" * ifo (ifo) <U2 16B 'H1' 'L1'\n",
" * time_index (time_index) int64 3kB 0 1 2 3 4 5 6 ... 404 405 406 407 408 409\n",
"Data variables:\n",
" a_scale (chain, draw, mode) float32 32kB 3.477e-21 ... 3.297e-21\n",
" chi (chain, draw) float32 16kB 0.1735 0.8477 ... 0.5773 0.6874\n",
" f (chain, draw, mode) float32 32kB 236.9 222.7 ... 237.6 232.4\n",
" g (chain, draw, mode) float32 32kB 330.5 1.009e+03 ... 229.9 699.0\n",
" m (chain, draw) float32 16kB 54.34 78.9 59.82 ... 64.21 71.66\n",
" a (chain, draw, mode) float32 32kB 2.994e-21 ... 1.976e-21\n",
" ax_unit (chain, draw, mode) float32 32kB 0.4851 -2.144 ... 0.7748 1.316\n",
" ay_unit (chain, draw, mode) float32 32kB 0.0456 0.6439 ... -0.04075\n",
" ellip (chain, draw, mode) float32 32kB -1.0 -1.0 -1.0 ... -1.0 -1.0\n",
" h_det_mode (chain, draw, ifo, mode, time_index) float32 26MB 1.26e-21 .....\n",
" phi (chain, draw, mode) float32 32kB 0.5805 -2.326 ... 0.9118 -1.535\n",
"Attributes:\n",
" created_at: 2024-10-09T19:14:10.419458+00:00\n",
" arviz_version: 0.18.0\n",
" inference_library: numpyro\n",
" inference_library_version: 0.14.0<xarray.Dataset> Size: 40kB\n",
"Dimensions: (chain: 4, draw: 1000)\n",
"Coordinates:\n",
" * chain (chain) int64 32B 0 1 2 3\n",
" * draw (draw) int64 8kB 0 1 2 3 4 5 6 7 ... 993 994 995 996 997 998 999\n",
"Data variables:\n",
" logl_0 (chain, draw) float32 16kB 1.494e+03 1.499e+03 ... 1.493e+03\n",
" logl_1 (chain, draw) float32 16kB 1.441e+03 1.44e+03 ... 1.442e+03\n",
"Attributes:\n",
" created_at: 2024-10-09T19:14:17.538225+00:00\n",
" arviz_version: 0.18.0\n",
" inference_library: numpyro\n",
" inference_library_version: 0.14.0<xarray.Dataset> Size: 12kB\n",
"Dimensions: (chain: 4, draw: 1000)\n",
"Coordinates:\n",
" * chain (chain) int64 32B 0 1 2 3\n",
" * draw (draw) int64 8kB 0 1 2 3 4 5 6 7 ... 993 994 995 996 997 998 999\n",
"Data variables:\n",
" diverging (chain, draw) bool 4kB False False False ... False False False\n",
"Attributes:\n",
" created_at: 2024-10-09T19:14:10.449647+00:00\n",
" arviz_version: 0.18.0\n",
" inference_library: numpyro\n",
" inference_library_version: 0.14.0<xarray.Dataset> Size: 13kB\n",
"Dimensions: (logl_0_dim_0: 0, logl_1_dim_0: 0, ifo: 2, mode: 2,\n",
" time_index: 410, time_index_1: 410)\n",
"Coordinates:\n",
" * logl_0_dim_0 (logl_0_dim_0) int64 0B \n",
" * logl_1_dim_0 (logl_1_dim_0) int64 0B \n",
" * ifo (ifo) <U2 16B 'H1' 'L1'\n",
" * mode (mode) |S10 20B b'1,-2,2,2,0' b'1,-2,2,2,1'\n",
" * time_index (time_index) int64 3kB 0 1 2 3 4 5 ... 404 405 406 407 408 409\n",
" * time_index_1 (time_index_1) int64 3kB 0 1 2 3 4 5 ... 405 406 407 408 409\n",
"Data variables:\n",
" logl_0 (logl_0_dim_0) float32 0B \n",
" logl_1 (logl_1_dim_0) float32 0B \n",
" strain (ifo, time_index) float64 7kB 1.768e-20 ... -3.06e-20\n",
"Attributes:\n",
" created_at: 2024-10-09T19:14:17.542262+00:00\n",
" arviz_version: 0.18.0\n",
" inference_library: numpyro\n",
" inference_library_version: 0.14.0<xarray.Dataset> Size: 3MB\n",
"Dimensions: (ifo: 2, time_index: 410, time_index_1: 410, scale_dim_0: 1)\n",
"Coordinates:\n",
" * ifo (ifo) <U2 16B 'H1' 'L1'\n",
" * time_index (time_index) int64 3kB 0 1 2 3 4 5 ... 405 406 407 408 409\n",
" * time_index_1 (time_index_1) int64 3kB 0 1 2 3 4 ... 405 406 407 408 409\n",
" * scale_dim_0 (scale_dim_0) int64 8B 0\n",
"Data variables:\n",
" cholesky_factor (ifo, time_index, time_index_1) float64 3MB 1.702e-20 .....\n",
" epoch (ifo) float64 16B 1.126e+09 1.126e+09\n",
" fc (ifo) float64 16B -0.4509 0.2052\n",
" fp (ifo) float64 16B 0.5787 -0.5274\n",
" scale (scale_dim_0) float64 8B 1.0\n",
" time (ifo, time_index) float64 7kB -2.646e-05 ... 0.1997\n",
"Attributes:\n",
" created_at: 2024-10-09T19:14:17.548972+00:00\n",
" arviz_version: 0.18.0\n",
" inference_library: numpyro\n",
" inference_library_version: 0.14.0| \n", " | mean | \n", "sd | \n", "hdi_3% | \n", "hdi_97% | \n", "mcse_mean | \n", "mcse_sd | \n", "ess_bulk | \n", "ess_tail | \n", "r_hat | \n", "
|---|---|---|---|---|---|---|---|---|---|
| a[b'1,-2,2,2,0'] | \n", "0.000 | \n", "0.000 | \n", "0.000 | \n", "0.000 | \n", "0.000 | \n", "0.000 | \n", "2590.0 | \n", "2327.0 | \n", "1.0 | \n", "
| a[b'1,-2,2,2,1'] | \n", "0.000 | \n", "0.000 | \n", "0.000 | \n", "0.000 | \n", "0.000 | \n", "0.000 | \n", "2751.0 | \n", "2486.0 | \n", "1.0 | \n", "
| m | \n", "72.383 | \n", "8.122 | \n", "56.953 | \n", "86.946 | \n", "0.185 | \n", "0.131 | \n", "1855.0 | \n", "1101.0 | \n", "1.0 | \n", "
| chi | \n", "0.683 | \n", "0.164 | \n", "0.367 | \n", "0.910 | \n", "0.005 | \n", "0.003 | \n", "1762.0 | \n", "929.0 | \n", "1.0 | \n", "
| f[b'1,-2,2,2,0'] | \n", "241.321 | \n", "8.398 | \n", "226.042 | \n", "257.261 | \n", "0.165 | \n", "0.117 | \n", "2730.0 | \n", "2114.0 | \n", "1.0 | \n", "
| f[b'1,-2,2,2,1'] | \n", "235.969 | \n", "9.784 | \n", "218.280 | \n", "254.070 | \n", "0.215 | \n", "0.152 | \n", "2333.0 | \n", "1157.0 | \n", "1.0 | \n", "
| g[b'1,-2,2,2,0'] | \n", "226.454 | \n", "41.814 | \n", "149.710 | \n", "304.645 | \n", "0.996 | \n", "0.753 | \n", "1863.0 | \n", "1026.0 | \n", "1.0 | \n", "
| g[b'1,-2,2,2,1'] | \n", "687.530 | \n", "130.421 | \n", "448.097 | \n", "931.308 | \n", "3.093 | \n", "2.339 | \n", "1866.0 | \n", "1026.0 | \n", "1.0 | \n", "
| \n", " | $M / M_\\odot$ | \n", "$\\chi$ | \n", "$f_{220} / \\mathrm{Hz}$ | \n", "$f_{221} / \\mathrm{Hz}$ | \n", "$\\gamma_{220} / \\mathrm{Hz}$ | \n", "$\\gamma_{221} / \\mathrm{Hz}$ | \n", "$A_{220}$ | \n", "$A_{221}$ | \n", "$\\phi_{220}$ | \n", "$\\phi_{221}$ | \n", "$\\epsilon_{220}$ | \n", "$\\epsilon_{221}$ | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1975 | \n", "63.744255 | \n", "0.540083 | \n", "240.402634 | \n", "232.453522 | \n", "271.023010 | \n", "827.261841 | \n", "2.028834e-21 | \n", "1.978116e-21 | \n", "0.798366 | \n", "-1.844549 | \n", "-1.0 | \n", "-1.0 | \n", "
| 3331 | \n", "53.371269 | \n", "0.003806 | \n", "228.270950 | \n", "211.972427 | \n", "337.275848 | \n", "1027.417725 | \n", "2.578548e-21 | \n", "2.752907e-21 | \n", "0.477533 | \n", "-2.331038 | \n", "-1.0 | \n", "-1.0 | \n", "
| 3241 | \n", "73.982391 | \n", "0.701359 | \n", "232.859207 | \n", "227.951736 | \n", "221.233810 | \n", "672.114441 | \n", "1.674814e-21 | \n", "1.410554e-21 | \n", "0.476132 | \n", "-2.101680 | \n", "-1.0 | \n", "-1.0 | \n", "
| 1453 | \n", "63.589539 | \n", "0.471834 | \n", "231.500549 | \n", "222.680450 | \n", "275.225342 | \n", "840.881165 | \n", "1.630561e-21 | \n", "1.525404e-21 | \n", "0.492855 | \n", "-1.945385 | \n", "-1.0 | \n", "-1.0 | \n", "
| 1212 | \n", "69.349838 | \n", "0.704752 | \n", "249.137009 | \n", "243.949631 | \n", "235.612534 | \n", "715.690735 | \n", "1.714517e-21 | \n", "2.247939e-21 | \n", "1.348513 | \n", "-0.894499 | \n", "-1.0 | \n", "-1.0 | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 782 | \n", "67.635185 | \n", "0.553754 | \n", "228.531662 | \n", "221.206268 | \n", "254.636353 | \n", "777.048218 | \n", "1.895225e-21 | \n", "1.964108e-21 | \n", "0.629840 | \n", "-1.903309 | \n", "-1.0 | \n", "-1.0 | \n", "
| 229 | \n", "63.197891 | \n", "0.504437 | \n", "237.314835 | \n", "228.843048 | \n", "275.359772 | \n", "840.965393 | \n", "1.794975e-21 | \n", "1.633226e-21 | \n", "0.822161 | \n", "-1.845080 | \n", "-1.0 | \n", "-1.0 | \n", "
| 2854 | \n", "84.826508 | \n", "0.839987 | \n", "234.419861 | \n", "231.915436 | \n", "172.660767 | \n", "519.961731 | \n", "1.472406e-21 | \n", "1.449929e-21 | \n", "0.786228 | \n", "-1.568629 | \n", "-1.0 | \n", "-1.0 | \n", "
| 2540 | \n", "65.534164 | \n", "0.606795 | \n", "244.368256 | \n", "237.496628 | \n", "259.099792 | \n", "789.716858 | \n", "1.888778e-21 | \n", "2.443565e-21 | \n", "1.024894 | \n", "-1.650668 | \n", "-1.0 | \n", "-1.0 | \n", "
| 1686 | \n", "79.150085 | \n", "0.791397 | \n", "237.265060 | \n", "233.864227 | \n", "194.870026 | \n", "589.087463 | \n", "1.303603e-21 | \n", "7.788810e-22 | \n", "0.690618 | \n", "-1.612360 | \n", "-1.0 | \n", "-1.0 | \n", "
500 rows × 12 columns
\n", "