{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Simulating catalogs\n", "\n", "This tutorial shows how to generate mock catalogs of Galactic binaries" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os\n", "import torch\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "plt.rcParams['font.size'] = 14\n", "plt.rcParams['text.usetex'] = True\n", "plt.rcParams['font.family'] = 'serif'\n", "\n", "from corner import corner\n", "from fast_lisa_subtraction.utils import latexify\n", "\n", "# Specify the device to use for computations\n", "device = 'cuda' if torch.cuda.is_available() else 'cpu'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Simulate a DWD Population\n", "\n", "We will make use of the `GalacticBinaryPopulation` class to draw samples of a DWD Population.\n", "\n", "This class uses enables the sampling of the parameters describing a catalog of GBs\n", "\n", "In particular:\n", "- `Frequency`\n", "- `FrequencyDerivative`\n", "- `Amplitude`\n", "- `InitialPhase`\n", "- `Inclination`\n", "- `Polarization`\n", "- `EclipticLatitude`\n", "- `EclipticLongitude`\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "the the parametrization explained in [De Santi F. et al (2026)](https://arxiv.org/abs/2602.18560) and is by default initialized to reproduce the best fit to the catalog of [Lamberts A. et al. (2019)](https://academic.oup.com/mnras/article/490/4/5888/5585418)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Priors" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`FastLisaSubtraction` supports multiple analytical priors, like `Uniform`, `Gaussian`, `Gamma`, `LogNormal` as described in [De Santi F. et al (2026)](https://arxiv.org/abs/2602.18560)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['Uniform', 'LogNormal', 'Gamma', 'PowerLaw', 'BrokenPowerLaw', 'UniformCosine', 'UniformSine', 'Gaussian', 'Cauchy', 'GalacticBinaryPopulation']\n" ] } ], "source": [ "import fast_lisa_subtraction.priors as priors\n", "\n", "print(priors.__all__)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In order to generate a mock catalog we need to instanciate the `GalacticBinaryPopulation` class.\n", "\n", "We first need to define a dictionary with the prior for each set of parameters, as an example:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from fast_lisa_subtraction.priors import *\n", "\n", "prior_dict = dict(\n", " Frequency = PowerLaw(alpha=-2, minimum=1e-4, maximum=1e-1, name='Frequency', device=device),\n", " FrequencyDerivative = Gamma(alpha=2, beta=3, offset=-20.0, name='FrequencyDerivative', device=device),\n", " Amplitude = LogNormal(mu=-21.5, sigma=0.2, minimum=-24.5, maximum=-20.5, name='Amplitude', device=device),\n", " InitialPhase = Uniform(0, 2*np.pi, name='InitialPhase', device=device),\n", " Inclination = UniformCosine(0, np.pi, name='Inclination', device=device),\n", " Polarization = Uniform(0, 2*np.pi, name='Polarization', device=device),\n", " EclipticLatitude = UniformSine(-np.pi/2, np.pi/2, name='EclipticLatitude', device=device),\n", " EclipticLongitude = Uniform(0, 2*np.pi, name='EclipticLongitude', device=device)\n", " )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then we use the class to sample the marginal and introduce a copula correlation in $f$-$\\dot{f}$ as described in [De Santi F. et al (2026)](https://arxiv.org/abs/2602.18560)\n", "\n", "Other available copulas are the `Clayton`, `Frank` and `Student-T`, refer to the documentation page for details" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | Frequency | \n", "FrequencyDerivative | \n", "Amplitude | \n", "InitialPhase | \n", "Inclination | \n", "Polarization | \n", "EclipticLatitude | \n", "EclipticLongitude | \n", "
|---|---|---|---|---|---|---|---|---|
| 0 | \n", "0.000102 | \n", "9.838469e-21 | \n", "1.047984e-23 | \n", "5.581181 | \n", "2.062936 | \n", "2.949006 | \n", "-0.684814 | \n", "6.278080 | \n", "
| 1 | \n", "0.001257 | \n", "2.889604e-20 | \n", "2.848996e-22 | \n", "5.217888 | \n", "2.465560 | \n", "4.257358 | \n", "-0.258646 | \n", "4.241662 | \n", "
| 2 | \n", "0.000104 | \n", "5.488845e-21 | \n", "4.679115e-24 | \n", "3.888970 | \n", "0.441004 | \n", "5.520145 | \n", "-0.408062 | \n", "5.351471 | \n", "
| 3 | \n", "0.000134 | \n", "7.041943e-21 | \n", "4.371890e-24 | \n", "2.507201 | \n", "1.304868 | \n", "4.035791 | \n", "-0.428621 | \n", "1.592792 | \n", "
| 4 | \n", "0.000255 | \n", "8.474385e-21 | \n", "2.026280e-23 | \n", "1.373542 | \n", "2.880041 | \n", "2.436864 | \n", "0.307664 | \n", "2.670212 | \n", "